Commit 326b922e authored by Heikki Linnakangas's avatar Heikki Linnakangas

Fix corner case in cleanup of transactions using SSI.

When the only remaining active transactions are READ ONLY, we do a "partial
cleanup" of committed transactions because certain types of conflicts
aren't possible anymore. For committed r/w transactions, we release the
SIREAD locks but keep the SERIALIZABLEXACT. However, for committed r/o
transactions, we can go further and release the SERIALIZABLEXACT too. The
problem was with the latter case: we were returning the SERIALIZABLEXACT to
the free list without removing it from the finished list.

The only real change in the patch is the SHMQueueDelete line, but I also
reworked some of the surrounding code to make it obvious that r/o and r/w
transactions are handled differently -- the existing code felt a bit too
clever.

Dan Ports
parent 2106c55a
...@@ -3528,10 +3528,29 @@ ClearOldPredicateLocks(void) ...@@ -3528,10 +3528,29 @@ ClearOldPredicateLocks(void)
else if (finishedSxact->commitSeqNo > PredXact->HavePartialClearedThrough else if (finishedSxact->commitSeqNo > PredXact->HavePartialClearedThrough
&& finishedSxact->commitSeqNo <= PredXact->CanPartialClearThrough) && finishedSxact->commitSeqNo <= PredXact->CanPartialClearThrough)
{ {
/*
* Any active transactions that took their snapshot before this
* transaction committed are read-only, so we can clear part of
* its state.
*/
LWLockRelease(SerializableXactHashLock); LWLockRelease(SerializableXactHashLock);
ReleaseOneSerializableXact(finishedSxact,
!SxactIsReadOnly(finishedSxact), if (SxactIsReadOnly(finishedSxact))
false); {
/* A read-only transaction can be removed entirely */
SHMQueueDelete(&(finishedSxact->finishedLink));
ReleaseOneSerializableXact(finishedSxact, false, false);
}
else
{
/*
* A read-write transaction can only be partially
* cleared. We need to keep the SERIALIZABLEXACT but
* can release the SIREAD locks and conflicts in.
*/
ReleaseOneSerializableXact(finishedSxact, true, false);
}
PredXact->HavePartialClearedThrough = finishedSxact->commitSeqNo; PredXact->HavePartialClearedThrough = finishedSxact->commitSeqNo;
LWLockAcquire(SerializableXactHashLock, LW_SHARED); LWLockAcquire(SerializableXactHashLock, LW_SHARED);
} }
...@@ -3637,6 +3656,7 @@ ReleaseOneSerializableXact(SERIALIZABLEXACT *sxact, bool partial, ...@@ -3637,6 +3656,7 @@ ReleaseOneSerializableXact(SERIALIZABLEXACT *sxact, bool partial,
Assert(sxact != NULL); Assert(sxact != NULL);
Assert(SxactIsRolledBack(sxact) || SxactIsCommitted(sxact)); Assert(SxactIsRolledBack(sxact) || SxactIsCommitted(sxact));
Assert(partial || !SxactIsOnFinishedList(sxact));
Assert(LWLockHeldByMe(SerializableFinishedListLock)); Assert(LWLockHeldByMe(SerializableFinishedListLock));
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment