@@ -6022,6 +6022,10 @@ StartupXLOG(void)
6022
6022
/* No need to hold ControlFileLock yet, we aren't up far enough */
6023
6023
UpdateControlFile ();
6024
6024
6025
+ /* initialize shared-memory copy of latest checkpoint XID/epoch */
6026
+ XLogCtl -> ckptXidEpoch = ControlFile -> checkPointCopy .nextXidEpoch ;
6027
+ XLogCtl -> ckptXid = ControlFile -> checkPointCopy .nextXid ;
6028
+
6025
6029
/* initialize our local copy of minRecoveryPoint */
6026
6030
minRecoveryPoint = ControlFile -> minRecoveryPoint ;
6027
6031
@@ -6529,10 +6533,6 @@ StartupXLOG(void)
6529
6533
/* start the archive_timeout timer running */
6530
6534
XLogCtl -> Write .lastSegSwitchTime = (pg_time_t ) time (NULL );
6531
6535
6532
- /* initialize shared-memory copy of latest checkpoint XID/epoch */
6533
- XLogCtl -> ckptXidEpoch = ControlFile -> checkPointCopy .nextXidEpoch ;
6534
- XLogCtl -> ckptXid = ControlFile -> checkPointCopy .nextXid ;
6535
-
6536
6536
/* also initialize latestCompletedXid, to nextXid - 1 */
6537
6537
ShmemVariableCache -> latestCompletedXid = ShmemVariableCache -> nextXid ;
6538
6538
TransactionIdRetreat (ShmemVariableCache -> latestCompletedXid );
@@ -8013,6 +8013,17 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
8013
8013
ControlFile -> checkPointCopy .nextXidEpoch = checkPoint .nextXidEpoch ;
8014
8014
ControlFile -> checkPointCopy .nextXid = checkPoint .nextXid ;
8015
8015
8016
+ /* Update shared-memory copy of checkpoint XID/epoch */
8017
+ {
8018
+ /* use volatile pointer to prevent code rearrangement */
8019
+ volatile XLogCtlData * xlogctl = XLogCtl ;
8020
+
8021
+ SpinLockAcquire (& xlogctl -> info_lck );
8022
+ xlogctl -> ckptXidEpoch = checkPoint .nextXidEpoch ;
8023
+ xlogctl -> ckptXid = checkPoint .nextXid ;
8024
+ SpinLockRelease (& xlogctl -> info_lck );
8025
+ }
8026
+
8016
8027
/*
8017
8028
* TLI may change in a shutdown checkpoint, but it shouldn't decrease
8018
8029
*/
@@ -8053,6 +8064,17 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
8053
8064
ControlFile -> checkPointCopy .nextXidEpoch = checkPoint .nextXidEpoch ;
8054
8065
ControlFile -> checkPointCopy .nextXid = checkPoint .nextXid ;
8055
8066
8067
+ /* Update shared-memory copy of checkpoint XID/epoch */
8068
+ {
8069
+ /* use volatile pointer to prevent code rearrangement */
8070
+ volatile XLogCtlData * xlogctl = XLogCtl ;
8071
+
8072
+ SpinLockAcquire (& xlogctl -> info_lck );
8073
+ xlogctl -> ckptXidEpoch = checkPoint .nextXidEpoch ;
8074
+ xlogctl -> ckptXid = checkPoint .nextXid ;
8075
+ SpinLockRelease (& xlogctl -> info_lck );
8076
+ }
8077
+
8056
8078
/* TLI should not change in an on-line checkpoint */
8057
8079
if (checkPoint .ThisTimeLineID != ThisTimeLineID )
8058
8080
ereport (PANIC ,
0 commit comments