From 7cb7d2c913aa43b24c3224dc8f51166144c98b05 Mon Sep 17 00:00:00 2001 From: Hayato Kuroda Date: Fri, 20 Nov 2026 20:42:12 +0900 Subject: [PATCH 3/3] Wait for backend exit by default in BackgroundPsql::quit --- .../test_misc/t/010_index_concurrently_upsert.pl | 2 +- .../modules/test_misc/t/013_temp_obj_multisession.pl | 2 +- src/test/perl/PostgreSQL/Test/BackgroundPsql.pm | 6 ++++-- src/test/recovery/t/051_effective_wal_level.pl | 12 ++++++------ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/test/modules/test_misc/t/010_index_concurrently_upsert.pl b/src/test/modules/test_misc/t/010_index_concurrently_upsert.pl index db3d6d8d19a..50a0e7db8f7 100644 --- a/src/test/modules/test_misc/t/010_index_concurrently_upsert.pl +++ b/src/test/modules/test_misc/t/010_index_concurrently_upsert.pl @@ -944,7 +944,7 @@ sub safe_quit $stderr =~ s/$banner_match//; # Close the session - $session->quit(1); + $session->quit; return $stderr; } diff --git a/src/test/modules/test_misc/t/013_temp_obj_multisession.pl b/src/test/modules/test_misc/t/013_temp_obj_multisession.pl index ff6f23ef3b1..c389ad12138 100644 --- a/src/test/modules/test_misc/t/013_temp_obj_multisession.pl +++ b/src/test/modules/test_misc/t/013_temp_obj_multisession.pl @@ -249,7 +249,7 @@ $psql2->query_safe( # owner will try to acquire deletion lock all its temp objects via # findDependentObjects. my $log_offset = -s $node->logfile; -$psql1->quit; +$psql1->quit(0); # Check whether session-exit cleanup is blocked. $node->wait_for_log(qr/waiting for AccessExclusiveLock on relation $foo2_oid/, diff --git a/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm b/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm index e5ea9481253..18a1cea5c33 100644 --- a/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm +++ b/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm @@ -189,7 +189,8 @@ sub wait_connect =item $session->quit() Close the session and clean up resources. Each test run must be closed with -C. Also wait for the saved backend PID to exit if C<$wait> is true. +C. By default, also wait for the backend process to exit. Set C<$wait> +to 0 to skip it. =cut @@ -200,8 +201,9 @@ sub quit $self->{stdin} .= "\\q\n"; my $ret = $self->{run}->finish; + $wait = 1 unless defined($wait); - if ($wait && defined($self->{backend_pid})) + if ($wait) { my $pid = $self->{backend_pid}; my $max_attempts = 10 * $PostgreSQL::Test::Utils::timeout_default; diff --git a/src/test/recovery/t/051_effective_wal_level.pl b/src/test/recovery/t/051_effective_wal_level.pl index ffb817b5b1e..4aa26ec786b 100644 --- a/src/test/recovery/t/051_effective_wal_level.pl +++ b/src/test/recovery/t/051_effective_wal_level.pl @@ -443,7 +443,7 @@ select pg_create_logical_replication_slot('slot_1', 'test_decoding'); qq[select injection_points_wakeup('logical-decoding-activation')]); # Let the released backend finish creating its slot. - $psql_create_slot->quit(1); + $psql_create_slot->quit; # Decode from slot_2, whose start point precedes where a redundant # status-change record would have been written; this fails in xlog_decode() @@ -497,7 +497,7 @@ select pg_cancel_backend(pid) from pg_stat_activity where query ~ 'slot_canceled wait_for_logical_decoding_disabled($primary); pass("the activation process aborted"); - $psql_create_slot->quit(1); + $psql_create_slot->quit; # Test concurrent activation processes run and one is interrupted. $psql_create_slot = @@ -540,7 +540,7 @@ select pg_cancel_backend(pid) from pg_stat_activity where query ~ 'slot_canceled "effective_wal_level remains 'logical' even after the concurrent activation is interrupted" ); - $psql_create_slot->quit(1); + $psql_create_slot->quit; # Test races between the deactivation of logical decoding and slot # creation during recovery. Logical decoding can be deactivated while a @@ -622,7 +622,7 @@ select pg_sync_replication_slots(); qq[select injection_points_wakeup('replication-slot-create-begin')]); $standby5->wait_for_log( qr/could not synchronize replication slot "sync_slot"/, $log_offset); - $psql_sync_slot->quit(1); + $psql_sync_slot->quit; is( $standby5->safe_psql( 'postgres', qq[select count(*) from pg_replication_slots]), '0', @@ -696,7 +696,7 @@ select pg_create_logical_replication_slot('test_slot4', 'test_decoding'); select pg_drop_replication_slot('sync_slot'); ]); $primary->wait_for_replay_catchup($standby5); - $psql_sync_slot->quit(1); + $psql_sync_slot->quit; # The slot created on retry may or may not have been persisted by the # time the remote slot was dropped. One more synchronization cycle @@ -761,7 +761,7 @@ select pg_create_logical_replication_slot('standby5_slot', 'test_decoding'); $standby5->wait_for_log( qr/ERROR: .* logical decoding on standby requires "effective_wal_level" >= "logical" on the primary/, $log_offset); - $psql_create_slot->quit(1); + $psql_create_slot->quit; is( $standby5->safe_psql( 'postgres', qq[select count(*) from pg_replication_slots]), '0', -- 2.52.0