From: Kevin Grittner Date: Fri, 26 Nov 2010 17:16:12 +0000 (-0600) Subject: Progress on using conflict lists rather than conflict pointers. X-Git-Url: http://git.postgresql.org/gitweb/static/We?a=commitdiff_plain;h=97d806a9b543fdde222e461d97af9b0f141d4772;p=users%2Fkgrittn%2Fpostgres.git Progress on using conflict lists rather than conflict pointers. This commit brings us back to having no false negatives, although the false positive rate is still high. --- diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index bc481d5232..b73fcaf77a 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -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)) {