From 772faafca1b288c4dd66b7150a7831c27b768003 Mon Sep 17 00:00:00 2001 From: Alexander Korotkov Date: Thu, 11 Apr 2024 16:30:32 +0300 Subject: Revert: Implement pg_wal_replay_wait() stored procedure This commit reverts 06c418e163, e37662f221, bf1e650806, 25f42429e2, ee79928441, and 74eaf66f98 per review by Heikki Linnakangas. Discussion: https://postgr.es/m/b155606b-e744-4218-bda5-29379779da1a%40iki.fi --- doc/src/sgml/func.sgml | 113 ------------------------------------------------- 1 file changed, 113 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index f017c2ef047..b432914dc88 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -28770,119 +28770,6 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset the pause, the rate of WAL generation and available disk space. - - There are also procedures to control the progress of recovery. - They are shown in . - These procedures may be executed only during recovery. - - - - Recovery Control Procedures - - - - - Procedure - - - Description - - - - - - - - - pg_wal_replay_wait - - pg_wal_replay_wait ( - target_lsn pg_lsn, - timeout bigint DEFAULT 0) - void - - - If timeout is not specified or zero, this - procedure returns once WAL is replayed upto - target_lsn. - If the timeout is specified (in - milliseconds) and greater than zero, the procedure waits until the - server actually replays the WAL upto target_lsn or - until the given time has passed. On timeout, an error is emitted. - - - - -
- - - pg_wal_replay_wait waits till - target_lsn to be replayed on standby. - That is, after this function execution, the value returned by - pg_last_wal_replay_lsn should be greater or equal - to the target_lsn value. This is useful to achieve - read-your-writes-consistency, while using async replica for reads and - primary for writes. In that case lsn of the last - modification should be stored on the client application side or the - connection pooler side. - - - - You can use pg_wal_replay_wait to wait for - the pg_lsn value. For example, an application could update - the movie table and get the lsn after - changes just made. This example uses pg_current_wal_insert_lsn - on primary server to get the lsn given that - synchronous_commit could be set to - off. - - -postgres=# UPDATE movie SET genre = 'Dramatic' WHERE genre = 'Drama'; -UPDATE 100 -postgres=# SELECT pg_current_wal_insert_lsn(); -pg_current_wal_insert_lsn --------------------- -0/306EE20 -(1 row) - - - Then an application could run pg_wal_replay_wait - with the lsn obtained from primary. After that the - changes made of primary should be guaranteed to be visible on replica. - - -postgres=# CALL pg_wal_replay_wait('0/306EE20'); -CALL -postgres=# SELECT * FROM movie WHERE genre = 'Drama'; - genre -------- -(0 rows) - - - It may also happen that target lsn is not achieved - within the timeout. In that case the error is thrown. - - -postgres=# CALL pg_wal_replay_wait('0/306EE20', 100); -ERROR: timed out while waiting for target LSN 0/306EE20 to be replayed; current replay LSN 0/306EA60 - - - - - - pg_wal_replay_wait can't be used within - the transaction, another procedure or function. Any of them holds a - snapshot, which could prevent the replay of WAL records. - - -postgres=# BEGIN; -BEGIN -postgres=*# CALL pg_wal_replay_wait('0/306EE20'); -ERROR: pg_wal_replay_wait() must be only called in non-atomic context -DETAIL: Make sure pg_wal_replay_wait() isn't called within a transaction, another procedure, or a function. - - - -- cgit v1.2.3