Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitefff1cc

Browse files
Correct epoch of txid_current() when executed on a Hot Standby server.
Initialise ckptXidEpoch from starting checkpoint and maintain the correctvalue as we roll forwards. This allows GetNextXidAndEpoch() to return thecorrect epoch when executed during recovery. Backpatch to 9.0 when theproblem is first observable by a user.Bug report from Daniel Farina
1 parent70e94d2 commitefff1cc

File tree

1 file changed

+26
-4
lines changed
  • src/backend/access/transam

1 file changed

+26
-4
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6022,6 +6022,10 @@ StartupXLOG(void)
60226022
/* No need to hold ControlFileLock yet, we aren't up far enough */
60236023
UpdateControlFile();
60246024

6025+
/* initialize shared-memory copy of latest checkpoint XID/epoch */
6026+
XLogCtl->ckptXidEpoch=ControlFile->checkPointCopy.nextXidEpoch;
6027+
XLogCtl->ckptXid=ControlFile->checkPointCopy.nextXid;
6028+
60256029
/* initialize our local copy of minRecoveryPoint */
60266030
minRecoveryPoint=ControlFile->minRecoveryPoint;
60276031

@@ -6529,10 +6533,6 @@ StartupXLOG(void)
65296533
/* start the archive_timeout timer running */
65306534
XLogCtl->Write.lastSegSwitchTime= (pg_time_t)time(NULL);
65316535

6532-
/* initialize shared-memory copy of latest checkpoint XID/epoch */
6533-
XLogCtl->ckptXidEpoch=ControlFile->checkPointCopy.nextXidEpoch;
6534-
XLogCtl->ckptXid=ControlFile->checkPointCopy.nextXid;
6535-
65366536
/* also initialize latestCompletedXid, to nextXid - 1 */
65376537
ShmemVariableCache->latestCompletedXid=ShmemVariableCache->nextXid;
65386538
TransactionIdRetreat(ShmemVariableCache->latestCompletedXid);
@@ -8013,6 +8013,17 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
80138013
ControlFile->checkPointCopy.nextXidEpoch=checkPoint.nextXidEpoch;
80148014
ControlFile->checkPointCopy.nextXid=checkPoint.nextXid;
80158015

8016+
/* Update shared-memory copy of checkpoint XID/epoch */
8017+
{
8018+
/* use volatile pointer to prevent code rearrangement */
8019+
volatileXLogCtlData*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+
80168027
/*
80178028
* TLI may change in a shutdown checkpoint, but it shouldn't decrease
80188029
*/
@@ -8053,6 +8064,17 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
80538064
ControlFile->checkPointCopy.nextXidEpoch=checkPoint.nextXidEpoch;
80548065
ControlFile->checkPointCopy.nextXid=checkPoint.nextXid;
80558066

8067+
/* Update shared-memory copy of checkpoint XID/epoch */
8068+
{
8069+
/* use volatile pointer to prevent code rearrangement */
8070+
volatileXLogCtlData*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+
80568078
/* TLI should not change in an on-line checkpoint */
80578079
if (checkPoint.ThisTimeLineID!=ThisTimeLineID)
80588080
ereport(PANIC,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp