8000 Ensure the cluster process is dead in tests · percona/postgres@3553dde · GitHub
[go: up one dir, main page]

Skip to content

Commit 3553dde

Browse files
committed
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.
1 parent 2d944d5 commit 3553dde

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

contrib/pg_tde/t/011_unlogged_tables.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
PGTDE::psql($node, 'postgres', "CHECKPOINT;");
3131

3232
PGTDE::append_to_result_file("-- kill -9");
33-
$node->kill9();
33+
PGTDE::kill9_until_dead($node);
3434

3535
PGTDE::append_to_result_file("-- server start");
3636
$node->start;

contrib/pg_tde/t/012_replication.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474

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

7979
PGTDE::append_to_result_file("-- primary start");
8080
$primary->start;

contrib/pg_tde/t/013_crash_recovery.pl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
PGTDE::psql($node, 'postgres', "ALTER SYSTEM SET pg_tde.wal_encrypt = 'on';");
4747

4848
PGTDE::append_to_result_file("-- kill -9");
49-
$node->kill9;
49+
PGTDE::kill9_until_dead($node);
5050

5151
PGTDE::append_to_result_file("-- server start");
5252
$node->start;
@@ -60,7 +60,7 @@
6060
);
6161
PGTDE::psql($node, 'postgres', "INSERT INTO test_enc (x) VALUES (3), (4);");
6262
PGTDE::append_to_result_file("-- kill -9");
63-
$node->kill9;
63+
PGTDE::kill9_until_dead($node);
6464
PGTDE::append_to_result_file("-- server start");
6565
PGTDE::append_to_result_file(
6666
"-- check that pg_tde_save_principal_key_redo hasn't destroyed a WAL key created during the server start"
@@ -76,7 +76,7 @@
7676
);
7777
PGTDE::psql($node, 'postgres', "INSERT INTO test_enc (x) VALUES (5), (6);");
7878
PGTDE::append_to_result_file("-- kill -9");
79-
$node->kill9;
79+
PGTDE::kill9_until_dead($node);
8080
PGTDE::append_to_result_file("-- server start");
8181
PGTDE::append_to_result_file(
8282
"-- check that the key rotation hasn't destroyed a WAL key created during the server start"
@@ -88,7 +88,7 @@
8888
PGTDE::psql($node, 'postgres',
8989
"CREATE TABLE test_enc2 (x int PRIMARY KEY) USING tde_heap;");
9090
PGTDE::append_to_result_file("-- kill -9");
91-
$node->kill9;
91+
PGTDE::kill9_until_dead($node);
9292
PGTDE::append_to_result_file("-- server start");
9393
PGTDE::append_to_result_file(
9494
"-- check redo of the smgr internal key creation when the key is on disk"

contrib/pg_tde/t/pgtde.pm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@ sub psql
3737
}
3838
}
3939

40+
sub kill9_until_dead
41+
{
42+
my ($node) = @_;
43+
44+
return unless defined $node->{_pid}; # Cluster already stopped
45+
46+
my $pid = $node->{_pid};
47+
$node->kill9;
48+
49+
# Wait for process to actually die.
50+
while (kill(0, $pid) != 0)
51+
{
52+
sleep(0.1);
53+
}
54+
}
55+
56+
4057
sub append_to_result_file
4158
{
4259
my ($str) = @_;

0 commit comments

Comments
 (0)
0