From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
---|---|
To: | Alexander Korotkov <akorotkov(at)postgresql(dot)org>, pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | Re: pgsql: Implement pg_wal_replay_wait() stored procedure |
Date: | 2024-08-30 19:42:20 |
Message-ID: | 18c0fa64-0475-415e-a1bd-665d922c5201@eisentraut.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers pgsql-hackers |
On 02.08.24 20:22, Alexander Korotkov wrote:
> Implement pg_wal_replay_wait() stored procedure
Why is this under src/backend/command/? Wouldn't it belong under
src/backend/utils/adt/?
> 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
>
> Branch
> ------
> master
>
> Details
> -------
> https://git.postgresql.org/pg/commitdiff/3c5db1d6b01642bcd8dbf5e34b68f034365747bb
>
> Modified Files
> --------------
> doc/src/sgml/func.sgml | 117 ++++++++
> src/backend/access/transam/xact.c | 6 +
> src/backend/access/transam/xlog.c | 7 +
> src/backend/access/transam/xlogrecovery.c | 11 +
> src/backend/catalog/system_functions.sql | 3 +
> src/backend/commands/Makefile | 3 +-
> src/backend/commands/meson.build | 1 +
> src/backend/commands/waitlsn.c | 363 ++++++++++++++++++++++++
> src/backend/lib/pairingheap.c | 18 +-
> src/backend/storage/ipc/ipci.c | 3 +
> src/backend/storage/lmgr/proc.c | 6 +
> src/backend/tcop/pquery.c | 9 +-
> src/backend/utils/activity/wait_event_names.txt | 2 +
> src/include/catalog/catversion.h | 2 +-
> src/include/catalog/pg_proc.dat | 6 +
> src/include/commands/waitlsn.h | 80 ++++++
> src/include/lib/pairingheap.h | 3 +
> src/include/storage/lwlocklist.h | 1 +
> src/test/recovery/meson.build | 1 +
> src/test/recovery/t/043_wal_replay_wait.pl | 150 ++++++++++
> src/tools/pgindent/typedefs.list | 2 +
> 21 files changed, 786 insertions(+), 8 deletions(-)
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-08-30 20:47:46 | pgsql: Make postgres_fdw's query_cancel test less flaky. |
Previous Message | Tom Lane | 2024-08-30 16:42:23 | pgsql: Avoid inserting PlaceHolderVars in cases where pre-v16 PG did no |
From | Date | Subject | |
---|---|---|---|
Next Message | Matthias van de Meent | 2024-08-30 19:43:22 | Re: Avoiding superfluous buffer locking during nbtree backwards scans |
Previous Message | Tom Lane | 2024-08-30 19:21:25 | Re: [EXTERNAL] Re: Add non-blocking version of PQcancel |