diff options
author | Thomas Munro <tmunro@postgresql.org> | 2021-08-02 17:32:20 +1200 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2021-08-02 17:32:44 +1200 |
commit | 7ff23c6d277d1d90478a51f0dd81414d343f3850 (patch) | |
tree | 94979ca9b71d373c4f93b669bfe78517ed5a6d48 /src/backend/access/transam/xlog.c | |
parent | 8b1de88b7ce9fe0458d3950121a797fd3d988f6c (diff) | |
download | postgresql-7ff23c6d277d1d90478a51f0dd81414d343f3850.tar.gz postgresql-7ff23c6d277d1d90478a51f0dd81414d343f3850.zip |
Run checkpointer and bgwriter in crash recovery.
Start up the checkpointer and bgwriter during crash recovery (except in
--single mode), as we do for replication. This wasn't done back in
commit cdd46c76 out of caution. Now it seems like a better idea to make
the environment as similar as possible in both cases. There may also be
some performance advantages.
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Tested-by: Jakub Wartak <Jakub.Wartak@tomtom.com>
Discussion: https://postgr.es/m/CA%2BhUKGJ8NRsqgkZEnsnRc2MFROBV-jCnacbYvtpptK2A9YYp9Q%40mail.gmail.com
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r-- | src/backend/access/transam/xlog.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index efb3ca273ed..f84c0bb01eb 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -869,9 +869,6 @@ bool reachedConsistency = false; static bool InRedo = false; -/* Have we launched bgwriter during recovery? */ -static bool bgwriterLaunched = false; - /* For WALInsertLockAcquire/Release functions */ static int MyLockNo = 0; static bool holdingAllLocks = false; @@ -7311,25 +7308,15 @@ StartupXLOG(void) /* Also ensure XLogReceiptTime has a sane value */ XLogReceiptTime = GetCurrentTimestamp(); + /* Allow ProcSendSignal() to find us, for buffer pin wakeups. */ + PublishStartupProcessInformation(); + /* * Let postmaster know we've started redo now, so that it can launch - * checkpointer to perform restartpoints. We don't bother during - * crash recovery as restartpoints can only be performed during - * archive recovery. And we'd like to keep crash recovery simple, to - * avoid introducing bugs that could affect you when recovering after - * crash. - * - * After this point, we can no longer assume that we're the only - * process in addition to postmaster! Also, fsync requests are - * subsequently to be handled by the checkpointer, not locally. + * the archiver if necessary. */ - if (ArchiveRecoveryRequested && IsUnderPostmaster) - { - PublishStartupProcessInformation(); - EnableSyncRequestForwarding(); + if (IsUnderPostmaster) SendPostmasterSignal(PMSIGNAL_RECOVERY_STARTED); - bgwriterLaunched = true; - } /* * Allow read-only connections immediately if we're consistent @@ -7903,7 +7890,7 @@ StartupXLOG(void) * after we're fully out of recovery mode and already accepting * queries. */ - if (bgwriterLaunched) + if (ArchiveRecoveryRequested && IsUnderPostmaster) { if (LocalPromoteIsTriggered) { @@ -7927,7 +7914,11 @@ StartupXLOG(void) CHECKPOINT_WAIT); } else - CreateCheckPoint(CHECKPOINT_END_OF_RECOVERY | CHECKPOINT_IMMEDIATE); + { + RequestCheckpoint(CHECKPOINT_END_OF_RECOVERY | + CHECKPOINT_IMMEDIATE | + CHECKPOINT_WAIT); + } } if (ArchiveRecoveryRequested) @@ -12182,7 +12173,7 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen, * Request a restartpoint if we've replayed too much xlog since the * last one. */ - if (bgwriterLaunched) + if (ArchiveRecoveryRequested && IsUnderPostmaster) { if (XLogCheckpointNeeded(readSegNo)) { |