git.postgresql.org Git - postgresql.git/commit

git projects / postgresql.git / commit
? search:
summary | shortlog | log | commit | commitdiff | tree
(parent: a83f308) | patch
Implement pg_wal_replay_wait() stored procedure
Fri, 2 Aug 2024 18:13:05 +0000 (21:13 +0300)
Fri, 2 Aug 2024 18:16:56 +0000 (21:16 +0300)
commit 3c5db1d6b01642bcd8dbf5e34b68f034365747bb
Implement pg_wal_replay_wait() stored procedure

pg_wal_replay_wait() is to be used on standby and specifies waiting for
the specific WAL location to be replayed. This option is useful when
the user makes some data changes on primary and needs a guarantee to see
these changes are on standby.

The queue of waiters is stored in the shared memory as an LSN-ordered pairing
heap, where the waiter with the nearest LSN stays on the top. During
the replay of WAL, waiters whose LSNs have already been replayed are deleted
from the shared memory pairing heap and woken up by setting their latches.

pg_wal_replay_wait() needs to wait without any snapshot held. Otherwise,
the snapshot could prevent the replay of WAL records, implying a kind of
self-deadlock. This is why it is only possible to implement
pg_wal_replay_wait() as a procedure working without an active snapshot,
not a function.

Catversion is bumped.

Discussion: https://postgr.es/m/eb12f9b03851bb2583adab5df9579b4b%40postgrespro.ru
Author: Kartyshov Ivan, Alexander Korotkov
Reviewed-by: Michael Paquier, Peter Eisentraut, Dilip Kumar, Amit Kapila
Reviewed-by: Alexander Lakhin, Bharath Rupireddy, Euler Taveira
Reviewed-by: Heikki Linnakangas, Kyotaro Horiguchi
21 files changed:
doc/src/sgml/func.sgml diff | blob | blame | history
src/backend/access/transam/xact.c diff | blob | blame | history
src/backend/access/transam/xlog.c diff | blob | blame | history
src/backend/access/transam/xlogrecovery.c diff | blob | blame | history
src/backend/catalog/system_functions.sql diff | blob | blame | history
src/backend/commands/Makefile diff | blob | blame | history
src/backend/commands/meson.build diff | blob | blame | history
src/backend/commands/waitlsn.c [new file with mode: 0644] blob
src/backend/lib/pairingheap.c diff | blob | blame | history
src/backend/storage/ipc/ipci.c diff | blob | blame | history
src/backend/storage/lmgr/proc.c diff | blob | blame | history
src/backend/tcop/pquery.c diff | blob | blame | history
src/backend/utils/activity/wait_event_names.txt diff | blob | blame | history
src/include/catalog/catversion.h diff | blob | blame | history
src/include/catalog/pg_proc.dat diff | blob | blame | history
src/include/commands/waitlsn.h [new file with mode: 0644] blob
src/include/lib/pairingheap.h diff | blob | blame | history
src/include/storage/lwlocklist.h diff | blob | blame | history
src/test/recovery/meson.build diff | blob | blame | history
src/test/recovery/t/043_wal_replay_wait.pl [new file with mode: 0644] blob
src/tools/pgindent/typedefs.list diff | blob | blame | history
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /