Adjust pg_wal_replay_wait() procedure behavior on promoted standby
authorAlexander Korotkov <akorotkov@postgresql.org>
Sat, 10 Aug 2024 18:43:02 +0000 (21:43 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Sat, 10 Aug 2024 18:43:02 +0000 (21:43 +0300)
commit867d396ccd2a7f0ce55e1fa7ebda00bc8c81147b
tree2af07b058abba4f384d06781a952203e1c250842
parentbbf668d66fbf61d45f1c187b08a5f51537bfb7c7
Adjust pg_wal_replay_wait() procedure behavior on promoted standby

pg_wal_replay_wait() is intended to be called on standby.  However, standby
can be promoted to primary at any moment, even concurrently with the
pg_wal_replay_wait() call.  If recovery is not currently in progress
that doesn't mean the wait was unsuccessful.  Thus, we always need to recheck
if the target LSN is replayed.

Reported-by: Kevin Hale Boyes
Discussion: https://postgr.es/m/CAPpHfdu5QN%2BZGACS%2B7foxmr8_nekgA2PA%2B-G3BuOUrdBLBFb6Q%40mail.gmail.com
Author: Alexander Korotkov
doc/src/sgml/func.sgml
src/backend/commands/waitlsn.c
src/test/recovery/t/043_wal_replay_wait.pl