mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Use full 64-bit XID for checking if a deleted GiST page is old enough.
Otherwise, after a deleted page gets even older, it becomes unrecyclable again. B-tree has the same problem, and has had since time immemorial, but let's at least fix this in GiST, where this is new. Backpatch to v12, where GiST page deletion was introduced. Reviewed-by: Andrey Borodin Discussion: https://www.postgresql.org/message-id/835A15A5-F1B4-4446-A711-BF48357EB602%40yandex-team.ru
This commit is contained in:
@@ -956,6 +956,36 @@ xmin_cmp(const pairingheap_node *a, const pairingheap_node *b, void *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get current RecentGlobalXmin value, as a FullTransactionId.
|
||||
*/
|
||||
FullTransactionId
|
||||
GetFullRecentGlobalXmin(void)
|
||||
{
|
||||
FullTransactionId nextxid_full;
|
||||
uint32 nextxid_epoch;
|
||||
TransactionId nextxid_xid;
|
||||
uint32 epoch;
|
||||
|
||||
Assert(TransactionIdIsNormal(RecentGlobalXmin));
|
||||
|
||||
/*
|
||||
* Compute the epoch from the next XID's epoch. This relies on the fact
|
||||
* that RecentGlobalXmin must be within the 2 billion XID horizon from the
|
||||
* next XID.
|
||||
*/
|
||||
nextxid_full = ReadNextFullTransactionId();
|
||||
nextxid_epoch = EpochFromFullTransactionId(nextxid_full);
|
||||
nextxid_xid = XidFromFullTransactionId(nextxid_full);
|
||||
|
||||
if (RecentGlobalXmin > nextxid_xid)
|
||||
epoch = nextxid_epoch - 1;
|
||||
else
|
||||
epoch = nextxid_epoch;
|
||||
|
||||
return FullTransactionIdFromEpochAndXid(epoch, RecentGlobalXmin);
|
||||
}
|
||||
|
||||
/*
|
||||
* SnapshotResetXmin
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user