You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
ERROR: timed out while waiting for target LSN 0/306EE20 to be replayed; current replay LSN 0/306EA60
29010
+
</programlisting>
29011
+
29012
+
</para>
29013
+
29014
+
<para>
29015
+
<function>pg_wal_replay_wait</function> can't be used within
29016
+
a transaction with an isolation level higher than
29017
+
<literal>READ COMMITTED</literal>, another procedure, or a function.
29018
+
All the cases above imply holding a snapshot, which could prevent
29019
+
WAL records from replaying (see <xref linkend="hot-standby-conflict"/>)
29020
+
and cause an indirect deadlock.
29021
+
29022
+
<programlisting>
29023
+
postgres=# BEGIN;
29024
+
BEGIN
29025
+
postgres=*# CALL pg_wal_replay_wait('0/306EE20');
29026
+
ERROR: pg_wal_replay_wait() must be only called without an active or registered snapshot
29027
+
DETAIL: Make sure pg_wal_replay_wait() isn't called within a transaction with an isolation level higher than READ COMMITTED, another procedure, or a function.
0 commit comments