]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix background psql session cleanup in 051_effective_wal_level.pl.
authorMasahiko Sawada <msawada@postgresql.org>
Thu, 30 Jul 2026 23:17:10 +0000 (16:17 -0700)
committerMasahiko Sawada <msawada@postgresql.org>
Thu, 30 Jul 2026 23:17:10 +0000 (16:17 -0700)
Commit 6aba42c660c added quit() calls for two background psql sessions
whose slot creation is canceled by pg_cancel_backend(). Both sessions
ran with the default ON_ERROR_STOP=1 and ended their script with \q,
so psql exited as soon as the cancellation error arrived. quit() then
wrote another \q to the already-closed pipe, making the test die with
"ack Broken pipe".

Run both sessions with on_error_stop => 0 and drop the trailing \q, so
that psql stays at the prompt after reporting the error and quit() can
shut it down cleanly.

Discussion: https://postgr.es/m/CAD21AoCZY1fKYgfkvHGWGiXpatUKd23FSLnDCL4m9bWFjdXNZw@mail.gmail.com
Backpatch-through: 19

src/test/recovery/t/051_effective_wal_level.pl

index 02f750097bd6ad5664c6841c083d365394f97d5d..11bf4cb613451ade81357f45838da07db7596659 100644 (file)
@@ -438,7 +438,8 @@ select pg_drop_replication_slot('slot_2');
 
        # Start a psql session to test the case where the activation process is
        # interrupted.
-       $psql_create_slot = $primary->background_psql('postgres');
+       $psql_create_slot =
+         $primary->background_psql('postgres', on_error_stop => 0);
 
        # Start the logical decoding activation process upon creating the logical
        # slot, but it will wait due to the injection point.
@@ -448,7 +449,6 @@ select pg_drop_replication_slot('slot_2');
 select injection_points_set_local();
 select injection_points_attach('logical-decoding-activation', 'wait');
 select pg_create_logical_replication_slot('slot_canceled', 'pgoutput');
-\q
 ));
 
        $primary->wait_for_event('client backend', 'logical-decoding-activation');
@@ -470,7 +470,8 @@ select pg_cancel_backend(pid) from pg_stat_activity where query ~ 'slot_canceled
        $psql_create_slot->quit;
 
        # Test concurrent activation processes run and one is interrupted.
-       $psql_create_slot = $primary->background_psql('postgres');
+       $psql_create_slot =
+         $primary->background_psql('postgres', on_error_stop => 0);
 
        # Start a psql session and stops in the middle of the activation
        # process.
@@ -480,7 +481,6 @@ select pg_cancel_backend(pid) from pg_stat_activity where query ~ 'slot_canceled
 select injection_points_set_local();
 select injection_points_attach('logical-decoding-activation', 'wait');
 select pg_create_logical_replication_slot('slot_canceled2', 'pgoutput');
-\q
 ));
        $primary->wait_for_event('client backend', 'logical-decoding-activation');
        note("injection_point 'logical-decoding-activation' is reached");