postgres.git / summary / log / commit / refs

commit    cacba321c2ef9dfd1c1b6924b6c7291a1182d2d6
Author:   Fujii Masao <fujii@postgresql.org>
Date:     Fri Aug 07 03:28:44 2026 +0000

    Make 030_pg_recvlogical robust against PID reuse
    
    The reconnection test assumed that a restarted walsender would always
    have a different PID from the previous one. On some platforms, however,
    PIDs can be reused quickly, causing the test to time out even though
    pg_recvlogical has successfully reconnected.
    
    This issue was reported by buildfarm member fairywren:
    https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=fairywren&dt=2026-07-30%2009%3A58%3A12
    
    Fix this by waiting for the server log message indicating that the
    logical replication slot has been acquired again, rather than relying on
    a PID change.
    
    Backpatch to v19, where the affected reconnection test was introduced by
    commit d89b1d817513.
    
    Author: Hayato Kuroda <kuroda.hayato@fujitsu.com>
    Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
    Discussion: https://postgr.es/m/OS9PR01MB121497CF10DFF54F745E37204F5C92@OS9PR01MB12149.jpnprd01.prod.outlook.com
    Backpatch-through: 19


src/bin/pg_basebackup/t/030_pg_recvlogical.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bin/pg_basebackup/t/030_pg_recvlogical.pl b/src/bin/pg_basebackup/t/030_pg_recvlogical.pl index 945a242bdad..35c77358f11 100644 --- a/src/bin/pg_basebackup/t/030_pg_recvlogical.pl +++ b/src/bin/pg_basebackup/t/030_pg_recvlogical.pl @@ -198,6 +198,8 @@ my $recv = IPC::Run::start( # Wait for pg_recvlogical to receive and write the first INSERT my $first_ins = wait_for_file($outfile, qr/INSERT/); +my $log_offset = -s $node->logfile; + # Terminate the walsender to force pg_recvlogical to reconnect my $backend_pid = $node->safe_psql('postgres', "SELECT active_pid FROM pg_replication_slots WHERE slot_name = 'reconnect_test'" @@ -205,9 +207,8 @@ my $backend_pid = $node->safe_psql('postgres', $node->safe_psql('postgres', "SELECT pg_terminate_backend($backend_pid)"); # Wait for pg_recvlogical to reconnect -$node->poll_query_until('postgres', - "SELECT active_pid IS NOT NULL AND active_pid != $backend_pid FROM pg_replication_slots WHERE slot_name = 'reconnect_test'" -) or die "Timed out while waiting for pg_recvlogical to reconnect"; +$node->wait_for_log(qr/acquired logical replication slot \"reconnect_test\"/, + $log_offset); # Insert the second record for this test $node->safe_psql('postgres', 'INSERT INTO test_table VALUES (2)'); [parent: fd90c3221850]