Skip to content

Commit

Permalink
Initialize oldestActiveXid, if it's not set in the checkpoint
Browse files Browse the repository at this point in the history
This is needed by the works to initialize running-xids data by
scanning the CLOG at startup.
  • Loading branch information
hlinnaka committed May 23, 2024
1 parent ac74f31 commit 05d21e2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/backend/access/transam/xlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -7025,6 +7025,22 @@ StartupXLOG(void)
XLogCtl->RedoStartLSN = RedoStartLSN;
EndRecPtr = ControlFile->checkPointCopy.redo;

if (!TransactionIdIsNormal(ControlFile->checkPointCopy.oldestActiveXid))
{
/*
* No checkpoint or running-xacts record was written, so use most
* conservative approximation for oldestActiveXid:
* firstNormalTransactionId. There are should not be problems
* with wraparounf because it is not possible that XID is
* overflown without writting any checkpoint or running-xact
* record.
*
* HEIKKI: I don't understand this. Why is it not always set
* correctly in the checkpoint?
*/
ControlFile->checkPointCopy.oldestActiveXid = FirstNormalTransactionId;
}

memcpy(&checkPoint, &ControlFile->checkPointCopy, sizeof(CheckPoint));

/*
Expand Down

0 comments on commit 05d21e2

Please sign in to comment.