1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

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 d89b1d8175.

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
This commit is contained in:
Fujii Masao
2026-08-07 12:28:44 +09:00
parent fd90c32218
commit cacba321c2

View File

@@ -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)');