Re: [HACKERS] make async slave to wait for lsn to be replayed
Peter Eisentraut <peter.eisentraut@enterprisedb.com>
On 28.02.23 11:10, Kartyshov Ivan wrote: > 3) Procedure style: Tom Lane and Kyotaro (wait_proc_v1.patch) > https://www.postgresql.org/message-id/27171.1586439221%40sss.pgh.pa.us > https://www.postgresql.org/message-id/20210121.173009.235021120161403875.horikyota.ntt%40gmail.com > ========== > advantages: no new words in grammar,like it made in > pg_last_wal_replay_lsn, no snapshots need > disadvantages: a little harder to remember names > SELECT pg_waitlsn(‘LSN’, timeout); > SELECT pg_waitlsn_infinite(‘LSN’); > SELECT pg_waitlsn_no_wait(‘LSN’); Of the presented options, I prefer this one. (Maybe with a "_" between "wait" and "lsn".) But I wonder how a client is going to get the LSN. How would all of this be used by a client? I can think of a scenarios where you have an application that issues a bunch of SQL commands and you have some kind of pooler in the middle that redirects those commands to different hosts, and what you really want is to have it transparently behave as if it's just a single host. Do we want to inject a bunch of "SELECT pg_get_lsn()", "SELECT pg_wait_lsn()" calls into that? 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. That said, exposing this functionality using functions could be a valid step in that direction, so that you can at least build out the actual internals of the functionality and test it out.
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