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

Commit22665f2

Browse files
committed
Fix race condition in committing a serializable transaction
The finished transaction list can contain XIDs that are older than theserializable global xmin. It's a short-lived state;ClearOldPredicateLocks() removes any such transactions from the list,and it's called whenever the global xmin advances. But if anotherbackend calls SummarizeOldestCommittedSxact() in that window, it willcall SerialAdd() on an XID that's older than the global xmin, or ifthere are no more transactions running, when global xmin isinvalid. That trips the assertion in SerialAdd().Fixes bug #18658 reported by Andrew Bille. Thanks to Alexander Lakhinfor analysis. Backpatch to all versions.Discussion:https://www.postgresql.org/message-id/18658-7dab125ec688c70b%40postgresql.org
1 parent1257fea commit22665f2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

‎src/backend/storage/lmgr/predicate.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,12 +854,17 @@ SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo)
854854
LWLockAcquire(SerialSLRULock,LW_EXCLUSIVE);
855855

856856
/*
857-
* If no serializable transactions are active, there shouldn't be anything
858-
* to push out to the SLRU. Hitting this assert would mean there's
859-
* something wrong with the earlier cleanup logic.
857+
* If 'xid' is older than the global xmin (== tailXid), there's no need to
858+
* store it, after all. This can happen if the oldest transaction holding
859+
* back the global xmin just finished, making 'xid' uninteresting, but
860+
* ClearOldPredicateLocks() has not yet run.
860861
*/
861862
tailXid=serialControl->tailXid;
862-
Assert(TransactionIdIsValid(tailXid));
863+
if (!TransactionIdIsValid(tailXid)||TransactionIdPrecedes(xid,tailXid))
864+
{
865+
LWLockRelease(SerialSLRULock);
866+
return;
867+
}
863868

864869
/*
865870
* If the SLRU is currently unused, zero out the whole active region from

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp