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

Commit7381b79

Browse files
committed
Reset lastOverflowedXid on standby when needed
Currently, lastOverflowedXid is never reset. It's just adjusted on newtransactions known to be overflowed. But if there are no overflowedtransactions for a long time, snapshots could be mistakenly marked assuboverflowed due to wraparound.This commit fixes this issue by resetting lastOverflowedXid when neededaltogether with KnownAssignedXids.Backpatch to all supported versions.Reported-by: Stan HuDiscussion:https://postgr.es/m/CAMBWrQ%3DFp5UAsU_nATY7EMY7NHczG4-DTDU%3DmCvBQZAQ6wa2xQ%40mail.gmail.comAuthor: Kyotaro Horiguchi, Alexander KorotkovReviewed-by: Stan Hu, Simon Riggs, Nikolay Samokhvalov, Andrey Borodin, Dmitry Dolgov
1 parente0eaeaf commit7381b79

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

‎src/backend/storage/ipc/procarray.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,24 +3289,41 @@ ExpireTreeKnownAssignedTransactionIds(TransactionId xid, int nsubxids,
32893289

32903290
/*
32913291
* ExpireAllKnownAssignedTransactionIds
3292-
*Remove all entries in KnownAssignedXids
3292+
*Remove all entries in KnownAssignedXids and reset lastOverflowedXid.
32933293
*/
32943294
void
32953295
ExpireAllKnownAssignedTransactionIds(void)
32963296
{
32973297
LWLockAcquire(ProcArrayLock,LW_EXCLUSIVE);
32983298
KnownAssignedXidsRemovePreceding(InvalidTransactionId);
3299+
3300+
/*
3301+
* Reset lastOverflowedXid. Currently, lastOverflowedXid has no use after
3302+
* the call of this function. But do this for unification with what
3303+
* ExpireOldKnownAssignedTransactionIds() do.
3304+
*/
3305+
procArray->lastOverflowedXid=InvalidTransactionId;
32993306
LWLockRelease(ProcArrayLock);
33003307
}
33013308

33023309
/*
33033310
* ExpireOldKnownAssignedTransactionIds
3304-
*Remove KnownAssignedXids entries preceding the given XID
3311+
*Remove KnownAssignedXids entries preceding the given XID and
3312+
*potentially reset lastOverflowedXid.
33053313
*/
33063314
void
33073315
ExpireOldKnownAssignedTransactionIds(TransactionIdxid)
33083316
{
33093317
LWLockAcquire(ProcArrayLock,LW_EXCLUSIVE);
3318+
3319+
/*
3320+
* Reset lastOverflowedXid if we know all transactions that have been
3321+
* possibly running are being gone. Not doing so could cause an incorrect
3322+
* lastOverflowedXid value, which makes extra snapshots be marked as
3323+
* suboverflowed.
3324+
*/
3325+
if (TransactionIdPrecedes(procArray->lastOverflowedXid,xid))
3326+
procArray->lastOverflowedXid=InvalidTransactionId;
33103327
KnownAssignedXidsRemovePreceding(xid);
33113328
LWLockRelease(ProcArrayLock);
33123329
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp