]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix recovery target test waiting on unavailable WAL
authorFujii Masao <fujii@postgresql.org>
Mon, 20 Jul 2026 18:24:58 +0000 (03:24 +0900)
committerFujii Masao <fujii@postgresql.org>
Mon, 20 Jul 2026 18:24:58 +0000 (03:24 +0900)
Buildfarm member skink reported a failure in
recovery/003_recovery_targets after commit d5751c33cc3. The newly
added recovery_target_xid set-then-cleared test could time out while
waiting for pg_last_wal_replay_lsn() to reach the expected LSN.

The test recorded lsn6 after calling pg_switch_wal(). As a result,
lsn6 pointed into the next WAL segment, but pg_switch_wal() only
archived the previous one. Since the standby in this test restores WAL
from the archive only, it could not obtain the segment containing
lsn6 and waited indefinitely.

Fix this by recording lsn6 before calling pg_switch_wal(), so the
archived WAL contains the LSN that the standby is waiting for.

Per buildfarm member skink.

Reported-by: Álvaro Herrera <alvherre@kurilemu.de>
Author: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/al5Y2mWffRs1NP34@alvherre.pgsql

src/test/recovery/t/003_recovery_targets.pl

index 0469afb5bde5459d7cd3c920238d12e07e201102..db4a0ea74b24b3f02b721c580d6e48fdfed77bdc 100644 (file)
@@ -111,12 +111,12 @@ my $lsn5 = my $recovery_lsn =
 $node_primary->safe_psql('postgres',
        "INSERT INTO tab_int VALUES (generate_series(5001,6000))");
 
-# Force archiving of WAL file
-$node_primary->safe_psql('postgres', "SELECT pg_switch_wal()");
-
 my $lsn6 =
   $node_primary->safe_psql('postgres', "SELECT pg_current_wal_lsn()");
 
+# Force archiving of WAL file containing $lsn6
+$node_primary->safe_psql('postgres', "SELECT pg_switch_wal()");
+
 # Test recovery targets
 my @recovery_params = ("recovery_target = 'immediate'");
 test_recovery_standby('immediate target',