mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Derive oldestActiveXid at correct time for Hot Standby.
There was a timing window between when oldestActiveXid was derived and when it should have been derived that only shows itself under heavy load. Move code around to ensure correct timing of derivation. No change to StartupSUBTRANS() code, which is where this failed. Bug report by Chris Redekop
This commit is contained in:
@ -7181,6 +7181,16 @@ CreateCheckPoint(int flags)
|
||||
MemSet(&checkPoint, 0, sizeof(checkPoint));
|
||||
checkPoint.time = (pg_time_t) time(NULL);
|
||||
|
||||
/*
|
||||
* For Hot Standby, derive the oldestActiveXid before we fix the redo pointer.
|
||||
* This allows us to begin accumulating changes to assemble our starting
|
||||
* snapshot of locks and transactions.
|
||||
*/
|
||||
if (!shutdown && XLogStandbyInfoActive())
|
||||
checkPoint.oldestActiveXid = GetOldestActiveTransactionId();
|
||||
else
|
||||
checkPoint.oldestActiveXid = InvalidTransactionId;
|
||||
|
||||
/*
|
||||
* We must hold WALInsertLock while examining insert state to determine
|
||||
* the checkpoint REDO pointer.
|
||||
@ -7367,9 +7377,7 @@ CreateCheckPoint(int flags)
|
||||
* Update checkPoint.nextXid since we have a later value
|
||||
*/
|
||||
if (!shutdown && XLogStandbyInfoActive())
|
||||
LogStandbySnapshot(&checkPoint.oldestActiveXid, &checkPoint.nextXid);
|
||||
else
|
||||
checkPoint.oldestActiveXid = InvalidTransactionId;
|
||||
LogStandbySnapshot(&checkPoint.nextXid);
|
||||
|
||||
START_CRIT_SECTION();
|
||||
|
||||
|
Reference in New Issue
Block a user