From: | Kartyshov Ivan <i(dot)kartyshov(at)postgrespro(dot)ru> |
---|---|
To: | Simon Riggs <simon(at)2ndquadrant(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [HACKERS] make async slave to wait for lsn to be replayed |
Date: | 2020-03-05 21:24:01 |
Message-ID: | 80f267591b373db5588d580fdfb432f0@postgrespro.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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>
> wrote:
>>> In PG11, I propose the following command, sticking mostly to Ants'
>>> syntax, and allowing to wait for multiple events before it returns.
>>> It
>>> doesn't hold snapshot and will not get cancelled by Hot Standby.
>>>
>>> WAIT FOR event [, event ...] options
>>>
>>> event is
>>> LSN value
>>> TIMESTAMP value
>>>
>>> options
>>> TIMEOUT delay
>>> UNTIL TIMESTAMP timestamp
>>> (we have both, so people don't need to do math, they can use
>>> whichever
>>> they have)
>>
>>
>> I have a (possibly) dumb question: if we have specified several
>> events,
>> 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.
>
> +1
Here I made new patch of feature, discussed above.
WAIT FOR - wait statement to pause beneath statements
==========
Synopsis
==========
WAIT FOR [ANY | SOME | ALL] event [, event ...] options
and event is:
LSN value
TIMESTAMP value
and options is:
TIMEOUT delay
UNTIL TIMESTAMP timestamp
Description
==========
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
passed.
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
--
Ivan Kartyshov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachment | Content-Type | Size |
---|---|---|
wait_for_v1.patch | text/x-diff | 28.3 KB |
From | Date | Subject | |
---|---|---|---|
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 |