From c1c82316e2d8e34077b108e8f581b9671a4079ea Mon Sep 17 00:00:00 2001 From: Zsolt Parragi Date: Tue, 18 Aug 2026 07:44:29 +0000 Subject: [PATCH 1/2] Stabilize the FORCE drop test for online data checksums Commit 51f55b13a4d added a test where DROP DATABASE ... WITH (FORCE) terminates a session holding a temporary table in the target database. While exiting, the terminated session drops its temporary table and commits, and the commit waits for a WAL flush behind the backlog generated by the checksum workers. On machines with slow storage this can exceed the five seconds DROP DATABASE waits for terminated backends to exit, making the test fail with "database "dropmeforce" is being accessed by other users", as observed on buildfarm member turaco. To fix, use asynchronous commit in the terminated session, so that its exit does not wait for a WAL flush, and checkpoint before the drop so that the exit-time WAL records do not queue up behind the backlog. Reported-by: Alexander Lakhin Discussion: https://postgr.es/m/361531e2-52b5-499c-a126-815f277bbef2@gmail.com --- src/test/modules/test_checksums/t/001_basic.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/test/modules/test_checksums/t/001_basic.pl b/src/test/modules/test_checksums/t/001_basic.pl index 72e0d0df46f..53fe8d70dc9 100644 --- a/src/test/modules/test_checksums/t/001_basic.pl +++ b/src/test/modules/test_checksums/t/001_basic.pl @@ -145,8 +145,13 @@ $node->safe_psql('dropmeforce', "CREATE TABLE dropme_t AS SELECT generate_series(1,10000) AS a;"); # Hold the worker inside "dropmeforce" by keeping a temporary table around -# there. +# there. The session is later terminated by DROP DATABASE ... WITH (FORCE) +# and drops the temp table while exiting; commit that drop asynchronously, +# otherwise the exit has to flush WAL behind the traffic generated by the +# checksum workers, which on slow machines can exceed the time DROP DATABASE +# waits for the session to exit. $bg = $node->background_psql('dropmeforce'); +$bg->query_safe('SET synchronous_commit = off;'); $bg->query_safe('CREATE TEMP TABLE holdme (a int);'); enable_data_checksums($node); @@ -158,6 +163,11 @@ $node->poll_query_until( AND query LIKE 'Waiting for % temp tables to be removed'] ) or die "timed out waiting for worker to wait for temporary tables"; +# Write out the WAL backlog from the checksum processing so far, so that the +# sessions terminated below do not get stuck behind it when writing their +# final WAL records on slow machines. +$node->safe_psql('postgres', "CHECKPOINT;"); + # Terminates both the session holding the temp table and the checksums # worker connected to the database. $node->safe_psql('postgres', "DROP DATABASE dropmeforce WITH (FORCE);"); -- 2.54.0