pgsql: Wake standby_write/standby_flush waiters from the WAL replay loo
pgsql: Wake standby_write/standby_flush waiters from the WAL replay loo
От:
Alexander Korotkov <akorotkov@postgresql.org>
Дата:
Wake standby_write/standby_flush waiters from the WAL replay loop The startup process only woke STANDBY_REPLAY waiters after replaying each WAL record. STANDBY_WRITE and STANDBY_FLUSH waiters depended only on walreceiver write/flush callbacks. As a result, replay progress alone did not wake those waiters, and in pure archive recovery (where no walreceiver exists) they could sleep until timeout. Fix by also calling WaitLSNWakeup() for STANDBY_WRITE and STANDBY_FLUSH after each replay. For the replay-floor semantics used by GetCurrentLSNForWaitType(), replay progress is a valid lower bound for both modes: WAL cannot be replayed unless it has already been written and flushed locally. This works together with the replay-position floor in GetCurrentLSNForWaitType(). The getter ensures that a waiter woken by replay can recheck successfully; the replay-side wakeups ensure that a waiter already asleep is notified when replay reaches its target. Reported-by: Tom Lane Discussion: https://postgr.es/m/1957514.1775526774%40sss.pgh.pa.us Author: Xuneng Zhou Reviewed-by: Andres Freund Reviewed-by: Alexander Korotkov Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/e7cd592174d94f9aea197edc5f0c6f708df27271 Modified Files -------------- src/backend/access/transam/xlogrecovery.c | 10 ++++- src/test/recovery/t/049_wait_for_lsn.pl | 64 +++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-)