Re: [HACKERS] make async slave to wait for lsn to be replayed
Ivan Kartyshov <i.kartyshov@postgrespro.ru>
Attachments
- wait_proc_v2.patch (text/x-diff) patch v2
Here I made new patch of feature, discussed above.
WAIT FOR procedure - waits for certain lsn on pause
==========
Synopsis
==========
SELECT pg_wait_lsn(‘LSN’, timeout) returns boolean
Where timeout = 0, will wait infinite without timeout
And if timeout = 1, then just check if lsn was replayed
How to use it
==========
Greg Stark wrote:
> That said, I'm not a fan of the specific function names. Remember that
> we have polymorphic functions so you could probably just have an
> option argument:
If you have any example, I will be glade to see them. Ьy searches have
not been fruitful.
Michael Paquier wrote:
> While looking at all the patches proposed, I have noticed that all the
> approaches proposed force a wakeup of the waiters in the redo loop of
> the startup process for each record, before reading the next record.
> It strikes me that there is some interaction with custom resource
> managers here, where it is possible to poke at the waiters not for
> each record, but after reading some specific records. Something
> out-of-core would not be as responsive as the per-record approach,
> still responsive enough that the waiters wait on input for an
> acceptable amount of time, depending on the frequency of the records
> generated by a primary to wake them up. Just something that popped
> into my mind while looking a bit at the threads.
I`ll work on this idea to have less impact on the redo system.
On 2023-03-02 13:33, Peter Eisentraut wrote:
> But I wonder how a client is going to get the LSN. How would all of
> this be used by a client?
As I wrote earlier main purpose of the feature is to achieve
read-your-writes-consistency, while using async replica for reads and
primary for writes. In that case lsn of last modification is stored
inside application.
> I'm tempted to think this could be a protocol-layer facility. Every
> query automatically returns the current LSN, and every query can also
> send along an LSN to wait for, and the client library would just keep
> track of the LSN for (what it thinks of as) the connection. So you
> get some automatic serialization without having to modify your client
> code.
Yes it sounds very tempted. But I think community will be against it.
--
Ivan Kartyshov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Commits
-
Ensure standby promotion point in 043_wal_replay_wait.pl
- 2520226c953c 18.0 landed
-
Minor cleanup related to pg_wal_replay_wait() procedure
- 85b98b8d5a48 18.0 landed
-
Adjust pg_wal_replay_wait() procedure behavior on promoted standby
- 867d396ccd2a 18.0 landed
-
pg_wal_replay_wait(): Fix typo in the doc
- 8036d73ae3d4 18.0 landed
-
Implement pg_wal_replay_wait() stored procedure
- 3c5db1d6b016 18.0 landed
- 06c418e163e9 17.0 landed
-
Revert: Implement pg_wal_replay_wait() stored procedure
- 772faafca1b2 17.0 landed
-
Call WaitLSNCleanup() in AbortTransaction()
- 74eaf66f988c 17.0 landed
-
Clarify what is protected by WaitLSNLock
- ee79928441e7 17.0 landed
-
Use an LWLock instead of a spinlock in waitlsn.c
- 25f42429e2ff 17.0 landed
-
Use the pairing heap instead of a flat array for LSN replay waiters
- bf1e65080629 17.0 landed
-
Minor improvements for waitlsn.c
- e37662f22158 17.0 landed
-
Make the order of the header file includes consistent
- 97d85be36544 17.0 cited