]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Make data checksum tests more resilient for slow machines
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Fri, 3 Apr 2026 22:25:07 +0000 (00:25 +0200)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Fri, 3 Apr 2026 22:25:07 +0000 (00:25 +0200)
The test for re-running checksum enabling was only checking for the
data checksum state to transition to 'on', but didn't account for
the launcher process having had time to exit, thus getting an error
instead of the expected no-op.  Adding a pg_stat_activity check for
the launcher exiting resolves the error, verified by inducing delay
in the launcher.

Also wrap a variable only used in injection point tests within the
correct USE macros to avoid warning for an unused variable.

All per the buildfarm.

Author: Daniel Gustafsson <daniel@yesql.se>
Reported-by: Buildfarm
Discussion: https://postgr.es/m/1CB288C9-564B-4664-B096-C2F4377D17AB@yesql.se

src/test/modules/test_checksums/t/001_basic.pl
src/test/modules/test_checksums/test_checksums.c

index c008e95fbff322d25cb935c963d2acec907cb6ca..5933c730da1697ef8cc1d06f48a50e30340baa78 100644 (file)
@@ -35,7 +35,11 @@ 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
+# 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';"
+);
 enable_data_checksums($node);
 test_checksum_state($node, 'on');
 # ..and make sure we can still read/write data
index b087a3b4664e63b50fa2b97b26ce72da65c7a5f6..e2b91f9c78c13a68d01bb474f8858074b003edd8 100644 (file)
@@ -108,7 +108,9 @@ dcw_inject_startup_delay(PG_FUNCTION_ARGS)
        PG_RETURN_VOID();
 }
 
+#ifdef USE_INJECTION_POINTS
 static uint32 db_fail = DATACHECKSUMSWORKER_FAILED;
+#endif
 
 void
 dc_modify_db_result(const char *name, const void *private_data, void *arg)