@@ -6331,6 +6331,10 @@ StartupXLOG(void)
63316331/* No need to hold ControlFileLock yet, we aren't up far enough */
63326332UpdateControlFile ();
63336333
6334+ /* initialize shared-memory copy of latest checkpoint XID/epoch */
6335+ XLogCtl -> ckptXidEpoch = ControlFile -> checkPointCopy .nextXidEpoch ;
6336+ XLogCtl -> ckptXid = ControlFile -> checkPointCopy .nextXid ;
6337+
63346338/* initialize our local copy of minRecoveryPoint */
63356339minRecoveryPoint = ControlFile -> minRecoveryPoint ;
63366340
@@ -6875,10 +6879,6 @@ StartupXLOG(void)
68756879/* start the archive_timeout timer running */
68766880XLogCtl -> Write .lastSegSwitchTime = (pg_time_t )time (NULL );
68776881
6878- /* initialize shared-memory copy of latest checkpoint XID/epoch */
6879- XLogCtl -> ckptXidEpoch = ControlFile -> checkPointCopy .nextXidEpoch ;
6880- XLogCtl -> ckptXid = ControlFile -> checkPointCopy .nextXid ;
6881-
68826882/* also initialize latestCompletedXid, to nextXid - 1 */
68836883ShmemVariableCache -> latestCompletedXid = ShmemVariableCache -> nextXid ;
68846884TransactionIdRetreat (ShmemVariableCache -> latestCompletedXid );
@@ -8461,6 +8461,17 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
84618461ControlFile -> checkPointCopy .nextXidEpoch = checkPoint .nextXidEpoch ;
84628462ControlFile -> checkPointCopy .nextXid = checkPoint .nextXid ;
84638463
8464+ /* Update shared-memory copy of checkpoint XID/epoch */
8465+ {
8466+ /* use volatile pointer to prevent code rearrangement */
8467+ volatile XLogCtlData * xlogctl = XLogCtl ;
8468+
8469+ SpinLockAcquire (& xlogctl -> info_lck );
8470+ xlogctl -> ckptXidEpoch = checkPoint .nextXidEpoch ;
8471+ xlogctl -> ckptXid = checkPoint .nextXid ;
8472+ SpinLockRelease (& xlogctl -> info_lck );
8473+ }
8474+
84648475/*
84658476 * TLI may change in a shutdown checkpoint, but it shouldn't decrease
84668477 */
@@ -8501,6 +8512,17 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
85018512ControlFile -> checkPointCopy .nextXidEpoch = checkPoint .nextXidEpoch ;
85028513ControlFile -> checkPointCopy .nextXid = checkPoint .nextXid ;
85038514
8515+ /* Update shared-memory copy of checkpoint XID/epoch */
8516+ {
8517+ /* use volatile pointer to prevent code rearrangement */
8518+ volatile XLogCtlData * xlogctl = XLogCtl ;
8519+
8520+ SpinLockAcquire (& xlogctl -> info_lck );
8521+ xlogctl -> ckptXidEpoch = checkPoint .nextXidEpoch ;
8522+ xlogctl -> ckptXid = checkPoint .nextXid ;
8523+ SpinLockRelease (& xlogctl -> info_lck );
8524+ }
8525+
85048526/* TLI should not change in an on-line checkpoint */
85058527if (checkPoint .ThisTimeLineID != ThisTimeLineID )
85068528ereport (PANIC ,