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

Commit68219aa

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 parentaeca650 commit68219aa

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
@@ -6320,6 +6320,10 @@ StartupXLOG(void)
63206320
/* No need to hold ControlFileLock yet, we aren't up far enough */
63216321
UpdateControlFile();
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 */
63246328
minRecoveryPoint=ControlFile->minRecoveryPoint;
63256329

@@ -6915,10 +6919,6 @@ StartupXLOG(void)
69156919
/* start the archive_timeout timer running */
69166920
XLogCtl->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 */
69236923
LWLockAcquire(ProcArrayLock,LW_EXCLUSIVE);
69246924
ShmemVariableCache->latestCompletedXid=ShmemVariableCache->nextXid;
@@ -8601,6 +8601,17 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
86018601
ControlFile->checkPointCopy.nextXidEpoch=checkPoint.nextXidEpoch;
86028602
ControlFile->checkPointCopy.nextXid=checkPoint.nextXid;
86038603

8604+
/* Update shared-memory copy of checkpoint XID/epoch */
8605+
{
8606+
/* use volatile pointer to prevent code rearrangement */
8607+
volatileXLogCtlData*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)
86458656
ControlFile->checkPointCopy.nextXidEpoch=checkPoint.nextXidEpoch;
86468657
ControlFile->checkPointCopy.nextXid=checkPoint.nextXid;
86478658

8659+
/* Update shared-memory copy of checkpoint XID/epoch */
8660+
{
8661+
/* use volatile pointer to prevent code rearrangement */
8662+
volatileXLogCtlData*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 */
86498671
if (checkPoint.ThisTimeLineID!=ThisTimeLineID)
86508672
ereport(PANIC,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp