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

Commit02f377d

Browse files
committed
Fix corner case in cleanup of transactions using SSI.
When the only remaining active transactions are READ ONLY, we do a "partialcleanup" of committed transactions because certain types of conflictsaren't possible anymore. For committed r/w transactions, we release theSIREAD locks but keep the SERIALIZABLEXACT. However, for committed r/otransactions, we can go further and release the SERIALIZABLEXACT too. Theproblem was with the latter case: we were returning the SERIALIZABLEXACT tothe free list without removing it from the finished list.The only real change in the patch is the SHMQueueDelete line, but I alsoreworked some of the surrounding code to make it obvious that r/o and r/wtransactions are handled differently -- the existing code felt a bit tooclever.Dan Ports
1 parentef007e6 commit02f377d

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3457,10 +3457,29 @@ ClearOldPredicateLocks(void)
34573457
elseif (finishedSxact->commitSeqNo>PredXact->HavePartialClearedThrough
34583458
&&finishedSxact->commitSeqNo <=PredXact->CanPartialClearThrough)
34593459
{
3460+
/*
3461+
* Any active transactions that took their snapshot before this
3462+
* transaction committed are read-only, so we can clear part of
3463+
* its state.
3464+
*/
34603465
LWLockRelease(SerializableXactHashLock);
3461-
ReleaseOneSerializableXact(finishedSxact,
3462-
!SxactIsReadOnly(finishedSxact),
3463-
false);
3466+
3467+
if (SxactIsReadOnly(finishedSxact))
3468+
{
3469+
/* A read-only transaction can be removed entirely */
3470+
SHMQueueDelete(&(finishedSxact->finishedLink));
3471+
ReleaseOneSerializableXact(finishedSxact, false, false);
3472+
}
3473+
else
3474+
{
3475+
/*
3476+
* A read-write transaction can only be partially
3477+
* cleared. We need to keep the SERIALIZABLEXACT but
3478+
* can release the SIREAD locks and conflicts in.
3479+
*/
3480+
ReleaseOneSerializableXact(finishedSxact, true, false);
3481+
}
3482+
34643483
PredXact->HavePartialClearedThrough=finishedSxact->commitSeqNo;
34653484
LWLockAcquire(SerializableXactHashLock,LW_SHARED);
34663485
}
@@ -3566,6 +3585,7 @@ ReleaseOneSerializableXact(SERIALIZABLEXACT *sxact, bool partial,
35663585

35673586
Assert(sxact!=NULL);
35683587
Assert(SxactIsRolledBack(sxact)||SxactIsCommitted(sxact));
3588+
Assert(partial|| !SxactIsOnFinishedList(sxact));
35693589
Assert(LWLockHeldByMe(SerializableFinishedListLock));
35703590

35713591
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp