|From:||Kartyshov Ivan <i(dot)kartyshov(at)postgrespro(dot)ru>|
|To:||Simon Riggs <simon(at)2ndquadrant(dot)com>|
|Subject:||Re: [HACKERS] make async slave to wait for lsn to be replayed|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
On 2018-03-06 14:50, Simon Riggs wrote:
> On 6 March 2018 at 11:24, Dmitry Ivanov <d(dot)ivanov(at)postgrespro(dot)ru>
>>> In PG11, I propose the following command, sticking mostly to Ants'
>>> syntax, and allowing to wait for multiple events before it returns.
>>> doesn't hold snapshot and will not get cancelled by Hot Standby.
>>> WAIT FOR event [, event ...] options
>>> event is
>>> LSN value
>>> TIMESTAMP value
>>> TIMEOUT delay
>>> UNTIL TIMESTAMP timestamp
>>> (we have both, so people don't need to do math, they can use
>>> they have)
>> I have a (possibly) dumb question: if we have specified several
>> should WAIT finish if only one of them triggered? It's not immediately
>> obvious if we're waiting for ALL of them to trigger, or just one will
>> suffice (ANY). IMO the syntax could be extended to something like:
>> WAIT FOR [ANY | ALL] event [, event ...] options,
>> with ANY being the default variant.
Here I made new patch of feature, discussed above.
WAIT FOR - wait statement to pause beneath statements
WAIT FOR [ANY | SOME | ALL] event [, event ...] options
and event is:
and options is:
UNTIL TIMESTAMP timestamp
WAIT FOR - make to wait statements (that are beneath) on sleep until
event happens (Don’t process new queries until an event happens).
How to use it
WAIT FOR LSN ‘LSN’ [, timeout in ms];
#Wait until LSN 0/303EC60 will be replayed, or 10 second passed.
WAIT FOR ANY LSN ‘0/303EC60’, TIMEOUT 10000;
#Or same without timeout.
WAIT FOR LSN ‘0/303EC60’;
#Or wait for some timestamp.
WAIT FOR TIMESTAMP '2020-01-02 17:20:19.028161+03';
#Wait until ALL events occur: LSN to be replayed and timestamp
WAIT FOR ALL LSN ‘0/303EC60’, TIMESTAMP '2020-01-28 11:10:39.021341+03';
Notice: WAIT FOR will release on PostmasterDeath or Interruption events
if they come earlier then LSN or timeout.
Testing the implementation
The implementation was tested with src/test/recovery/t/018_waitfor.pl
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
|Next Message||Sebastian Kemper||2020-03-05 21:38:29||[PATCH] Make pkg-config files cross-compile friendly|
|Previous Message||Aleksei Ivanov||2020-03-05 21:23:21||Re: Proposal: PqSendBuffer removal|