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