Thread: Does pg_ctl promote wait for pending WAL?
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
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 onlythen? If this is the case, you should be able to safely shutdown the primary anyway at any time to be assured that the replicadoesn'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
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
Attachment
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