Ensure standby promotion point in 043_wal_replay_wait.pl
authorAlexander Korotkov <akorotkov@postgresql.org>
Tue, 17 Sep 2024 19:51:06 +0000 (22:51 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Tue, 17 Sep 2024 19:51:06 +0000 (22:51 +0300)
This commit ensures standby will be promoted at least at the primary insert
LSN we have just observed.  We use pg_switch_wal() to force the insert LSN
to be written then wait for standby to catchup.

Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/1d7b08f2-64a2-77fb-c666-c9a74c68eeda%40gmail.com

src/test/recovery/t/043_wal_replay_wait.pl

index b24033ff36e4d8306f9b9d9189fab9d2944a46dd..024f1fe6488a6237a0ed3ed30ab7ffd17ef2a048 100644 (file)
@@ -177,6 +177,12 @@ $psql_session->query_until(
    CALL pg_wal_replay_wait('${lsn4}');
 ]);
 
+# Make sure standby will be promoted at least at the primary insert LSN we
+# have just observed.  Use pg_switch_wal() to force the insert LSN to be
+# written then wait for standby to catchup.
+$node_primary->safe_psql('postgres', 'SELECT pg_switch_wal();');
+$node_primary->wait_for_catchup($node_standby);
+
 $log_offset = -s $node_standby->logfile;
 $node_standby->promote;
 $node_standby->wait_for_log('recovery is not in progress', $log_offset);