pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedDoes pg_ctl promote wait for pending WAL?
4+ messages / 3 participants
[nested] [flat]
* Does pg_ctl promote wait for pending WAL?
@ 2021-01-29 02:51 Tatsuo Ishii <ishii@sraoss.co.jp>
0 siblings, 1 reply; 4+ messages in thread
From: Tatsuo Ishii @ 2021-01-29 02:51 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Does anybody know whether a standby server waits for pending WAL
records/files while promotion is requested? I assume that no data
update is performed on the primary server while promotion.
I imagine that a standby server stops to replay WAL and promotes as
soon as SIGUSR1 signal is received.
The motivation of this question behind is I want to have a complete
copy of the primary server using promote command.
Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Does pg_ctl promote wait for pending WAL?
@ 2021-01-29 06:59 Paul Förster <paul.foerster@gmail.com>
parent: Tatsuo Ishii <ishii@sraoss.co.jp>
0 siblings, 1 reply; 4+ messages in thread
From: Paul Förster @ 2021-01-29 06:59 UTC (permalink / raw)
To: Tatsuo Ishii <ishii@sraoss.co.jp>; +Cc: pgsql-general@lists.postgresql.org
Hi Tatsuo,
> On 29. Jan, 2021, at 03:51, Tatsuo Ishii <ishii@sraoss.co.jp> wrote:
>
> Does anybody know whether a standby server waits for pending WAL
> records/files while promotion is requested? I assume that no data
> update is performed on the primary server while promotion.
>
> I imagine that a standby server stops to replay WAL and promotes as
> soon as SIGUSR1 signal is received.
>
> The motivation of this question behind is I want to have a complete
> copy of the primary server using promote command.
do I understand you correctly that you wait until there is no activity on the primary and want to promote the replica only then?
If this is the case, you should be able to safely shutdown the primary anyway at any time to be assured that the replica doesn't receive any more WAL files and is complete. Then promote the replica and restart the primary.
From then on, the replica is no replica anymore but has a life on its own with its own timeline.
Cheers,
Paul
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Does pg_ctl promote wait for pending WAL?
@ 2021-01-29 07:24 Michael Paquier <michael@paquier.xyz>
parent: Paul Förster <paul.foerster@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Michael Paquier @ 2021-01-29 07:24 UTC (permalink / raw)
To: Paul Förster <paul.foerster@gmail.com>; +Cc: Tatsuo Ishii <ishii@sraoss.co.jp>; pgsql-general@lists.postgresql.org
Hi Ishii-san,
On Fri, Jan 29, 2021 at 07:59:26AM +0100, Paul Förster wrote:
> On 29. Jan, 2021, at 03:51, Tatsuo Ishii <ishii@sraoss.co.jp> wrote:
>>
>> Does anybody know whether a standby server waits for pending WAL
>> records/files while promotion is requested? I assume that no data
>> update is performed on the primary server while promotion.
>>
>> I imagine that a standby server stops to replay WAL and promotes as
>> soon as SIGUSR1 signal is received.
To answer to your question based on the code, you can check for the
code paths calling CheckForStandbyTrigger() in xlog.c when it comes to
promotion detection in the WAL replay. In short,
WaitForWALToBecomeAvailable() tells that after the promotion is
detected in the startup process, then recovery would still try to
replay as much WAL as possible from the archives or pg_wal before a
failover.
Equally, from the docs:
"Before failover, any WAL immediately available in the archive or in
pg_wal will be restored, but no attempt is made to connect to the
primary."
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Does pg_ctl promote wait for pending WAL?
@ 2021-01-29 07:47 Tatsuo Ishii <ishii@sraoss.co.jp>
parent: Michael Paquier <michael@paquier.xyz>
0 siblings, 0 replies; 4+ messages in thread
From: Tatsuo Ishii @ 2021-01-29 07:47 UTC (permalink / raw)
To: michael@paquier.xyz; +Cc: paul.foerster@gmail.com; ishii@sraoss.co.jp; pgsql-general@lists.postgresql.org
Hi Michael,
> To answer to your question based on the code, you can check for the
> code paths calling CheckForStandbyTrigger() in xlog.c when it comes to
> promotion detection in the WAL replay. In short,
> WaitForWALToBecomeAvailable() tells that after the promotion is
> detected in the startup process, then recovery would still try to
> replay as much WAL as possible from the archives or pg_wal before a
> failover.
Great. That should make my life a lot easier. I will look into the
code to confirm it.
Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2021-01-29 07:47 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-01-29 02:51 Does pg_ctl promote wait for pending WAL? Tatsuo Ishii <ishii@sraoss.co.jp>
2021-01-29 06:59 ` Paul Förster <paul.foerster@gmail.com>
2021-01-29 07:24 ` Michael Paquier <michael@paquier.xyz>
2021-01-29 07:47 ` Tatsuo Ishii <ishii@sraoss.co.jp>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox