From fd90e1739e17a0b62efe3aa1e4a20fb34befb183 Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Sat, 4 Apr 2026 02:12:49 +0200 Subject: [PATCH] Wait for launcher exit in enable/disable checksum tests When enabling or disabling data checksums in a test with waiting for an end state (on or off), the test typically want to perform more test against the cluster immediately. Make sure to wait for the launcher to exit in these cases before returning in order to know it can immediately be acted on. This is a more generic implementation of 0036232ba8f since more buildfarm animals are showing timing related failures. --- .../modules/test_checksums/t/001_basic.pl | 6 +---- .../test_checksums/t/DataChecksums/Utils.pm | 24 ++++++++++++++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/test/modules/test_checksums/t/001_basic.pl b/src/test/modules/test_checksums/t/001_basic.pl index 5933c730da1..a78118320d5 100644 --- a/src/test/modules/test_checksums/t/001_basic.pl +++ b/src/test/modules/test_checksums/t/001_basic.pl @@ -35,11 +35,7 @@ my $result = is($result, '9999', 'ensure checksummed pages can be read back'); # Enable data checksums again which should be a no-op so we explicitly don't -# wait for any state transition as none should happen here. Make sure to let -# any running launcher finish in case it's still wrapping up. -$result = $node->poll_query_until('postgres', - "SELECT count(*) = 0 FROM pg_catalog.pg_stat_activity WHERE backend_type = 'datachecksum launcher';" -); +# wait for any state transition as none should happen here. enable_data_checksums($node); test_checksum_state($node, 'on'); # ..and make sure we can still read/write data diff --git a/src/test/modules/test_checksums/t/DataChecksums/Utils.pm b/src/test/modules/test_checksums/t/DataChecksums/Utils.pm index 9a2269e8a92..6ee3169c737 100644 --- a/src/test/modules/test_checksums/t/DataChecksums/Utils.pm +++ b/src/test/modules/test_checksums/t/DataChecksums/Utils.pm @@ -175,8 +175,19 @@ EOQ $postgresnode->safe_psql('postgres', sprintf($query, $params{cost_delay}, $params{cost_limit})); - wait_for_checksum_state($postgresnode, $params{wait}) - if (defined($params{wait})); + if (defined($params{wait})) + { + wait_for_checksum_state($postgresnode, $params{wait}); + # If we are tasked with waiting for an end state, also wait for the + # launcher to exit. + if ($params{wait} eq 'on' || $params{wait} eq 'off') + { + $postgresnode->poll_query_until('postgres', + "SELECT count(*) = 0 ". + "FROM pg_catalog.pg_stat_activity " . + "WHERE backend_type = 'datachecksum launcher';"); + } + } } =item disable_data_checksums($node, %params) @@ -204,7 +215,14 @@ sub disable_data_checksums $postgresnode->safe_psql('postgres', 'SELECT pg_disable_data_checksums();'); - wait_for_checksum_state($postgresnode, 'off') if (defined($params{wait})); + if (defined($params{wait})) + { + wait_for_checksum_state($postgresnode, 'off'); + $postgresnode->poll_query_until('postgres', + "SELECT count(*) = 0 ". + "FROM pg_catalog.pg_stat_activity " . + "WHERE backend_type = 'datachecksum launcher';"); + } } =item cointoss -- 2.39.3 (Apple Git-146)