@@ -6320,6 +6320,10 @@ StartupXLOG(void)
63206320/* No need to hold ControlFileLock yet, we aren't up far enough */
63216321UpdateControlFile ();
63226322
6323+ /* initialize shared-memory copy of latest checkpoint XID/epoch */
6324+ XLogCtl -> ckptXidEpoch = ControlFile -> checkPointCopy .nextXidEpoch ;
6325+ XLogCtl -> ckptXid = ControlFile -> checkPointCopy .nextXid ;
6326+
63236327/* initialize our local copy of minRecoveryPoint */
63246328minRecoveryPoint = ControlFile -> minRecoveryPoint ;
63256329
@@ -6915,10 +6919,6 @@ StartupXLOG(void)
69156919/* start the archive_timeout timer running */
69166920XLogCtl -> Write .lastSegSwitchTime = (pg_time_t )time (NULL );
69176921
6918- /* initialize shared-memory copy of latest checkpoint XID/epoch */
6919- XLogCtl -> ckptXidEpoch = ControlFile -> checkPointCopy .nextXidEpoch ;
6920- XLogCtl -> ckptXid = ControlFile -> checkPointCopy .nextXid ;
6921-
69226922/* also initialize latestCompletedXid, to nextXid - 1 */
69236923LWLockAcquire (ProcArrayLock ,LW_EXCLUSIVE );
69246924ShmemVariableCache -> latestCompletedXid = ShmemVariableCache -> nextXid ;
@@ -8601,6 +8601,17 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
86018601ControlFile -> checkPointCopy .nextXidEpoch = checkPoint .nextXidEpoch ;
86028602ControlFile -> checkPointCopy .nextXid = checkPoint .nextXid ;
86038603
8604+ /* Update shared-memory copy of checkpoint XID/epoch */
8605+ {
8606+ /* use volatile pointer to prevent code rearrangement */
8607+ volatile XLogCtlData * xlogctl = XLogCtl ;
8608+
8609+ SpinLockAcquire (& xlogctl -> info_lck );
8610+ xlogctl -> ckptXidEpoch = checkPoint .nextXidEpoch ;
8611+ xlogctl -> ckptXid = checkPoint .nextXid ;
8612+ SpinLockRelease (& xlogctl -> info_lck );
8613+ }
8614+
86048615/*
86058616 * TLI may change in a shutdown checkpoint, but it shouldn't decrease
86068617 */
@@ -8645,6 +8656,17 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
86458656ControlFile -> checkPointCopy .nextXidEpoch = checkPoint .nextXidEpoch ;
86468657ControlFile -> checkPointCopy .nextXid = checkPoint .nextXid ;
86478658
8659+ /* Update shared-memory copy of checkpoint XID/epoch */
8660+ {
8661+ /* use volatile pointer to prevent code rearrangement */
8662+ volatile XLogCtlData * xlogctl = XLogCtl ;
8663+
8664+ SpinLockAcquire (& xlogctl -> info_lck );
8665+ xlogctl -> ckptXidEpoch = checkPoint .nextXidEpoch ;
8666+ xlogctl -> ckptXid = checkPoint .nextXid ;
8667+ SpinLockRelease (& xlogctl -> info_lck );
8668+ }
8669+
86488670/* TLI should not change in an on-line checkpoint */
86498671if (checkPoint .ThisTimeLineID != ThisTimeLineID )
86508672ereport (PANIC ,