From bcea68c1925a018967e2a8ea42c54552d623234c Mon Sep 17 00:00:00 2001 From: Amul Sul Date: Fri, 15 Oct 2021 08:44:09 -0400 Subject: [PATCH] POC rearrange code to remove frequent need of LocalSetXLogInsertAllowed() --- src/backend/access/transam/xlog.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 62862255fca..ae561ed7e30 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -8080,7 +8080,6 @@ StartupXLOG(void) */ Insert->fullPageWrites = lastFullPageWrites; UpdateFullPageWrites(); - LocalXLogInsertAllowed = -1; /* * Emit checkpoint or end-of-recovery record in XLOG, if required. @@ -8094,17 +8093,18 @@ StartupXLOG(void) if (!XLogRecPtrIsInvalid(XLogCtl->lastReplayedEndRecPtr)) promoted = PerformRecoveryXLogAction(); - /* If this is archive recovery, perform post-recovery cleanup actions. */ - if (ArchiveRecoveryRequested) - CleanupAfterArchiveRecovery(EndOfLogTLI, EndOfLog); - /* * If any of the critical GUCs have changed, log them before we allow * backends to write WAL. */ - LocalSetXLogInsertAllowed(); XLogReportParameters(); + LocalXLogInsertAllowed = -1; + + /* If this is archive recovery, perform post-recovery cleanup actions. */ + if (ArchiveRecoveryRequested) + CleanupAfterArchiveRecovery(EndOfLogTLI, EndOfLog); + /* * Local WAL inserts enabled, so it's time to finish initialization of * commit timestamp. @@ -9126,7 +9126,7 @@ CreateCheckPoint(int flags) * enable XLogInsertAllowed. (This also ensures ThisTimeLineID is * initialized, which we need here and in AdvanceXLInsertBuffer.) */ - if (flags & CHECKPOINT_END_OF_RECOVERY) + if ((flags & CHECKPOINT_END_OF_RECOVERY) && IsPostmasterEnvironment) LocalSetXLogInsertAllowed(); checkPoint.ThisTimeLineID = ThisTimeLineID; @@ -9304,7 +9304,7 @@ CreateCheckPoint(int flags) * to just temporarily disable writing until the system has exited * recovery. */ - if (shutdown) + if (shutdown && IsPostmasterEnvironment) { if (flags & CHECKPOINT_END_OF_RECOVERY) LocalXLogInsertAllowed = -1; /* return to "check" state */ @@ -9447,8 +9447,6 @@ CreateEndOfRecoveryRecord(void) xlrec.PrevTimeLineID = XLogCtl->PrevTimeLineID; WALInsertLockRelease(); - LocalSetXLogInsertAllowed(); - START_CRIT_SECTION(); XLogBeginInsert(); @@ -9469,8 +9467,6 @@ CreateEndOfRecoveryRecord(void) LWLockRelease(ControlFileLock); END_CRIT_SECTION(); - - LocalXLogInsertAllowed = -1; /* return to "check" state */ } /* -- 2.18.0