TimeLineID prevTLI);
static void VerifyOverwriteContrecord(xl_overwrite_contrecord *xlrec,
XLogReaderState *state);
-static void LocalSetXLogInsertAllowed(void);
+static int LocalSetXLogInsertAllowed(void);
static void CreateEndOfRecoveryRecord(void);
static XLogRecPtr CreateOverwriteContrecordRecord(XLogRecPtr aborted_lsn);
static void CheckPointGuts(XLogRecPtr checkPointRedo, int flags);
}
XLogReaderFree(xlogreader);
+ /* Enable WAL writes for this backend only. */
LocalSetXLogInsertAllowed();
/* If necessary, write overwrite-contrecord before doing anything else */
*/
Insert->fullPageWrites = lastFullPageWrites;
UpdateFullPageWrites();
- LocalXLogInsertAllowed = -1;
/*
* Emit checkpoint or end-of-recovery record in XLOG, if required.
* If any of the critical GUCs have changed, log them before we allow
* backends to write WAL.
*/
- LocalSetXLogInsertAllowed();
XLogReportParameters();
/* If this is archive recovery, perform post-recovery cleanup actions. */
*
* Note: it is allowed to switch LocalXLogInsertAllowed back to -1 later,
* and even call LocalSetXLogInsertAllowed() again after that.
+ *
+ * Returns the previous value of LocalXLogInsertAllowed.
*/
-static void
+static int
LocalSetXLogInsertAllowed(void)
{
- Assert(LocalXLogInsertAllowed == -1);
+ int oldXLogAllowed = LocalXLogInsertAllowed;
+
LocalXLogInsertAllowed = 1;
/* Initialize as RecoveryInProgress() would do when switching state */
InitXLOGAccess();
+
+ return oldXLogAllowed;
}
/*
XLogRecPtr last_important_lsn;
VirtualTransactionId *vxids;
int nvxids;
+ int oldXLogAllowed;
/*
* An end-of-recovery checkpoint is really a shutdown checkpoint, just
* initialized, which we need here and in AdvanceXLInsertBuffer.)
*/
if (flags & CHECKPOINT_END_OF_RECOVERY)
- LocalSetXLogInsertAllowed();
+ oldXLogAllowed = LocalSetXLogInsertAllowed();
checkPoint.ThisTimeLineID = ThisTimeLineID;
if (flags & CHECKPOINT_END_OF_RECOVERY)
if (shutdown)
{
if (flags & CHECKPOINT_END_OF_RECOVERY)
- LocalXLogInsertAllowed = -1; /* return to "check" state */
+ LocalXLogInsertAllowed = oldXLogAllowed;
else
LocalXLogInsertAllowed = 0; /* never again write WAL */
}
xlrec.PrevTimeLineID = XLogCtl->PrevTimeLineID;
WALInsertLockRelease();
- LocalSetXLogInsertAllowed();
-
START_CRIT_SECTION();
XLogBeginInsert();
LWLockRelease(ControlFileLock);
END_CRIT_SECTION();
-
- LocalXLogInsertAllowed = -1; /* return to "check" state */
}
/*