postgres.git / summary / log / commit / refs

commit    1d28812160d4e7ec06ebb2223d2c67b0dec74720
Author:   Daniel Gustafsson <dgustafsson@postgresql.org>
Date:     Tue Aug 18 20:25:58 2026 +0000

    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.
    
    Author: Zsolt Parragi <zsolt.parragi@percona.com>
    Reported-by: Alexander Lakhin <exclusion@gmail.com>
    Discussion: https://postgr.es/m/361531e2-52b5-499c-a126-815f277bbef2@gmail.com
    Backpatch-through: 19


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 4cfa35b6885..4cfd532500d 100644 --- a/src/test/modules/test_checksums/t/001_basic.pl +++ b/src/test/modules/test_checksums/t/001_basic.pl @@ -172,8 +172,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); @@ -185,6 +190,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);"); [parent: c61c3ec40cb8]