Progress on using conflict lists rather than conflict pointers.
authorKevin Grittner <Kevin.Grittner@wicourts.gov>
Fri, 26 Nov 2010 17:16:12 +0000 (11:16 -0600)
committerKevin Grittner <Kevin.Grittner@wicourts.gov>
Fri, 26 Nov 2010 17:16:12 +0000 (11:16 -0600)
This commit brings us back to having no false negatives, although
the false positive rate is still high.

src/backend/storage/lmgr/predicate.c

index bc481d5232b46541dc2f0c54d5aa9fd39fbd31cb..b73fcaf77a3a9f2a7a9d8bcc80450103ccb3b7f7 100644 (file)
@@ -1930,7 +1930,7 @@ ReleasePredicateLocks(const bool isCommit)
     */
    needToClear = false;
    LWLockAcquire(SerializableXactHashLock, LW_EXCLUSIVE);
-   if (MySerializableXact->xmin == SerializableGlobalXmin)
+   if (TransactionIdEquals(MySerializableXact->xmin, SerializableGlobalXmin))
    {
        Assert(SerializableGlobalXminCount > 0);
        if (--SerializableGlobalXminCount == 0)
@@ -2186,7 +2186,9 @@ CheckForSerializableConflictOut(const bool valid, const Relation relation,
        xid = HeapTupleHeaderGetXmin(tuple->t_data);
    }
 
-   /* Bail out if xid is too early to be a conflict. */
+   /*
+    * Find top level xid.  Bail out if xid is too early to be a conflict.
+    */
    if (TransactionIdPrecedes(xid, TransactionXmin))
        return;
    xid = SubTransGetTopmostTransaction(xid);
@@ -2540,12 +2542,19 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
 
    failure = false;
 
+   /*
+    * Check for already-committed writer with rw-conflict out flagged.
+    * This means that the reader must immediately fail.
+    */
+   if (SxactIsCommitted(writer) && (writer->flags & SXACT_FLAG_CONFLICT_OUT))
+       failure = true;
+
    /*
     * Check whether the reader has become a pivot with a committed writer.
     * If so, we must roll back unless every in-conflict either committed
     * before the writer committed or is READ ONLY and overlaps the writer.
     */
-   if (SxactIsCommitted(writer) && !SxactIsReadOnly(reader))
+   if (!failure && SxactIsCommitted(writer) && !SxactIsReadOnly(reader))
    {
        conflict = (RWConflict)
            SHMQueueNext(&reader->inConflicts,
@@ -2555,7 +2564,7 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
        {
            if (!SxactIsRolledBack(conflict->sxactIn)
                && (!SxactIsCommitted(conflict->sxactIn)
-                || conflict->sxactIn->commitSeqNo > writer->commitSeqNo)
+                || conflict->sxactIn->commitSeqNo >= writer->commitSeqNo)
                && (!SxactIsReadOnly(conflict->sxactIn)
                    || conflict->sxactIn->lastCommitBeforeSnapshot >= writer->commitSeqNo))
            {