Skip to content

Commit

Permalink
Add comment explaining why it is safe to use FirstNormalTransactionXi…
Browse files Browse the repository at this point in the history
…d for oldestActiveXid while replica startup (#388)

Co-authored-by: Konstantin Knizhnik <knizhnik@neon.tech>
  • Loading branch information
2 people authored and tristan957 committed May 20, 2024
1 parent 6a9a2c2 commit 5ec96e1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/backend/access/transam/xlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -5194,13 +5194,13 @@ StartupXLOG(void)
else if (!TransactionIdIsValid(checkPoint.oldestActiveXid))
{
/*
* It should not actually happen: PS oldestActiveXid
* from running xacts WAL records and include it in checkpoint
* sent in basebackup.
* FirstNormalTransactionId is conservative estimation of oldest active XACT, unless
* current XID is greater than 1^31. So it is also not 100% safe solution but better than assertion failure.
* Pageserver extracts oldestActiveXid from snapshot and running xacts WAL records
* and include it in checkpoint sent in basebackup.
* So oldestActiveXid can be zero only after database initialization when no checkpoints are yet performed
* and not running xacts records was logged.
* In this case it is possible to use FirstNormalTransactionId as safe conservative estimation
* of oldest active transaction XID.
*/
elog(FATAL, "oldestActiveXid=%d", checkPoint.oldestActiveXid);
checkPoint.oldestActiveXid = FirstNormalTransactionId;
}
}
Expand Down

0 comments on commit 5ec96e1

Please sign in to comment.