8000 Ensure the cluster process is dead in tests by AndersAstrand · Pull Request #350 · percona/postgres · GitHub
[go: up one dir, main page]

Skip to content

Ensure the cluster process is dead in tests #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Ensure the cluster process is dead in tests
Sometimes kill -9 might take a bit longer than what it takes for us to
restart the server. Wait for the process to actually die before
continuing.

This is to fix the CI failures these tests often had.
  • Loading branch information
AndersAstrand committed May 20, 2025
commit 3553dde252ea9a72a88bff573dd29efae8abc7e3
2 changes: 1 addition & 1 deletion contrib/pg_tde/t/011_unlogged_tables.pl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
PGTDE::psql($node, 'postgres', "CHECKPOINT;");

PGTDE::append_to_result_file("-- kill -9");
$node->kill9();
PGTDE::kill9_until_dead($node);

PGTDE::append_to_result_file("-- server start");
$node->start;
Expand Down
2 changes: 1 addition & 1 deletion contrib/pg_tde/t/012_replication.pl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

PGTDE::psql($primary, 'postgres',
"ALTER SYSTEM SET pg_tde.wal_encrypt = 'on';");
$primary->kill9;
PGTDE::kill9_until_dead($primary);

PGTDE::append_to_result_file("-- primary start");
$primary->start;
Expand Down
8 changes: 4 additions & 4 deletions contrib/pg_tde/t/013_crash_recovery.pl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
PGTDE::psql($node, 'postgres', "ALTER SYSTEM SET pg_tde.wal_encrypt = 'on';");

PGTDE::append_to_result_file("-- kill -9");
$node->kill9;
PGTDE::kill9_until_dead($node);

PGTDE::append_to_result_file("-- server start");
$node->start;
Expand All @@ -60,7 +60,7 @@
);
PGTDE::psql($node, 'postgres', "INSERT INTO test_enc (x) VALUES (3), (4);");
PGTDE::append_to_result_file("-- kill -9");
$node->kill9;
PGTDE::kill9_until_dead($node);
PGTDE::append_to_result_file("-- server start");
PGTDE::append_to_result_file(
"-- check that pg_tde_save_principal_key_redo hasn't destroyed a WAL key created during the server start"
Expand All @@ -76,7 +76,7 @@
);
PGTDE::psql($node, 'postgres', "INSERT INTO test_enc (x) VALUES (5), (6);");
PGTDE::append_to_result_file("-- kill -9");
$node->kill9;
PGTDE::kill9_until_dead($node);
PGTDE::append_to_result_file("-- server start");
PGTDE::append_to_result_file(
"-- check that the key rotation hasn't destroyed a WAL key created during the server start"
Expand All @@ -88,7 +88,7 @@
PGTDE::psql($node, 'postgres',
"CREATE TABLE test_enc2 (x int PRIMARY KEY) USING tde_heap;");
PGTDE::append_to_result_file("-- kill -9");
$node->kill9;
PGTDE::kill9_until_dead($node);
PGTDE::append_to_result_file("-- server start");
PGTDE::append_to_result_file(
"-- check redo of the smgr internal key creation when the key is on disk"
Expand Down
17 changes: 17 additions & 0 deletions contrib/pg_tde/t/pgtde.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ sub psql
}
}

sub kill9_until_dead
{
my ($node) = @_;

return unless defined $node->{_pid}; # Cluster already stopped

my $pid = $node->{_pid};
$node->kill9;

# Wait for process to actually die.
while (kill(0, $pid) != 0)
{
sleep(0.1);
}
}


sub append_to_result_file
{
my ($str) = @_;
Expand Down
0