@@ -6331,6 +6331,10 @@ StartupXLOG(void)
6331
6331
/* No need to hold ControlFileLock yet, we aren't up far enough */
6332
6332
UpdateControlFile ();
6333
6333
6334
+ /* initialize shared-memory copy of latest checkpoint XID/epoch */
6335
+ XLogCtl -> ckptXidEpoch = ControlFile -> checkPointCopy .nextXidEpoch ;
6336
+ XLogCtl -> ckptXid = ControlFile -> checkPointCopy .nextXid ;
6337
+
6334
6338
/* initialize our local copy of minRecoveryPoint */
6335
6339
minRecoveryPoint = ControlFile -> minRecoveryPoint ;
6336
6340
@@ -6875,10 +6879,6 @@ StartupXLOG(void)
6875
6879
/* start the archive_timeout timer running */
6876
6880
XLogCtl -> Write .lastSegSwitchTime = (pg_time_t ) time (NULL );
6877
6881
6878
- /* initialize shared-memory copy of latest checkpoint XID/epoch */
6879
- XLogCtl -> ckptXidEpoch = ControlFile -> checkPointCopy .nextXidEpoch ;
6880
- XLogCtl -> ckptXid = ControlFile -> checkPointCopy .nextXid ;
6881
-
6882
6882
/* also initialize latestCompletedXid, to nextXid - 1 */
6883
6883
ShmemVariableCache -> latestCompletedXid = ShmemVariableCache -> nextXid ;
6884
6884
TransactionIdRetreat (ShmemVariableCache -> latestCompletedXid );
@@ -8461,6 +8461,17 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
8461
8461
ControlFile -> checkPointCopy .nextXidEpoch = checkPoint .nextXidEpoch ;
8462
8462
ControlFile -> checkPointCopy .nextXid = checkPoint .nextXid ;
8463
8463
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
+
8464
8475
/*
8465
8476
* TLI may change in a shutdown checkpoint, but it shouldn't decrease
8466
8477
*/
@@ -8501,6 +8512,17 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
8501
8512
ControlFile -> checkPointCopy .nextXidEpoch = checkPoint .nextXidEpoch ;
8502
8513
ControlFile -> checkPointCopy .nextXid = checkPoint .nextXid ;
8503
8514
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
+
8504
8526
/* TLI should not change in an on-line checkpoint */
8505
8527
if (checkPoint .ThisTimeLineID != ThisTimeLineID )
8506
8528
ereport (PANIC ,
0 commit comments