From 748d3383f632cd983dbde918503d12982cf45168 Mon Sep 17 00:00:00 2001 From: Kevin Grittner Date: Wed, 1 Dec 2010 17:24:53 -0600 Subject: [PATCH] pgindent run. No other changes. --- src/backend/storage/lmgr/predicate.c | 97 ++++++++++++----------- src/include/storage/predicate_internals.h | 32 ++++---- 2 files changed, 67 insertions(+), 62 deletions(-) diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index e5e0e18153..0f30116391 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -78,7 +78,7 @@ * may yet matter because they overlap still-active transactions. * * SerializablePredicateLockListLock - * - Protects the linked list of locks held by a transaction. Note + * - Protects the linked list of locks held by a transaction. Note * that the locks themselves are also covered by the partition * locks of their respective lock targets; this lock only affects * the linked list connecting the locks related to a transaction. @@ -89,7 +89,7 @@ * - It is relatively infrequent that another process needs to * modify the list for a transaction, but it does happen for such * things as index page splits for pages with predicate locks and - * freeing of predicate locked pages by a vacuum process. When + * freeing of predicate locked pages by a vacuum process. When * removing a lock in such cases, the lock itself contains the * pointers needed to remove it from the list. When adding a * lock in such cases, the lock can be added using the anchor in @@ -417,7 +417,7 @@ NextPredTran(SERIALIZABLEXACT *sxact) static bool RWConflictExists(const SERIALIZABLEXACT *reader, const SERIALIZABLEXACT *writer) { - RWConflict conflict; + RWConflict conflict; Assert(reader != writer); @@ -450,7 +450,7 @@ RWConflictExists(const SERIALIZABLEXACT *reader, const SERIALIZABLEXACT *writer) static void SetRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer) { - RWConflict conflict; + RWConflict conflict; Assert(reader != writer); Assert(!RWConflictExists(reader, writer)); @@ -462,7 +462,7 @@ SetRWConflict(SERIALIZABLEXACT *reader, SERIALIZABLEXACT *writer) if (!conflict) ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), - errmsg("not enough elements in RWConflictPool to record a rw-conflict"))); + errmsg("not enough elements in RWConflictPool to record a rw-conflict"))); SHMQueueDelete(&conflict->outLink); @@ -616,9 +616,9 @@ InitPredicateLocks(void) * Allocate space for tracking rw-conflicts in lists attached to the * transactions. * - * TODO SSI: Assume an average of 5 conflicts per transaction. - * This is likely to need to be adjusted or configured by a GUC. - * Gotta start somewhere.... + * TODO SSI: Assume an average of 5 conflicts per transaction. This is + * likely to need to be adjusted or configured by a GUC. Gotta start + * somewhere.... */ max_table_size *= 5; @@ -1793,7 +1793,7 @@ SetNewSxactGlobalXmin(void) if (!SxactIsRolledBack(sxact) && !SxactIsOnFinishedList(sxact)) { if (!TransactionIdIsValid(PredTran->SxactGlobalXmin) - || TransactionIdPrecedes(sxact->xmin, PredTran->SxactGlobalXmin)) + || TransactionIdPrecedes(sxact->xmin, PredTran->SxactGlobalXmin)) { PredTran->SxactGlobalXmin = sxact->xmin; PredTran->SxactGlobalXminCount = 1; @@ -1829,7 +1829,8 @@ void ReleasePredicateLocks(const bool isCommit) { bool needToClear; - RWConflict conflict, nextConflict; + RWConflict conflict, + nextConflict; if (MySerializableXact == InvalidSerializableXact) { @@ -1841,7 +1842,7 @@ ReleasePredicateLocks(const bool isCommit) /* We'd better not already be on the cleanup list. */ Assert(!SxactIsOnFinishedList((SERIALIZABLEXACT *) MySerializableXact)); - + LWLockAcquire(SerializableXactHashLock, LW_EXCLUSIVE); /* @@ -1864,9 +1865,9 @@ ReleasePredicateLocks(const bool isCommit) } /* - * Release all outConflicts from committed transactions. If we're - * rolling back clear them all. Set SXACT_FLAG_CONFLICT_OUT if any - * point to previously committed transactions. + * Release all outConflicts from committed transactions. If we're rolling + * back clear them all. Set SXACT_FLAG_CONFLICT_OUT if any point to + * previously committed transactions. */ conflict = (RWConflict) SHMQueueNext((SHM_QUEUE *) &MySerializableXact->outConflicts, @@ -1896,8 +1897,8 @@ ReleasePredicateLocks(const bool isCommit) } /* - * Release all inConflicts from committed transactions. - * If we're rolling back, clear them all. + * Release all inConflicts from committed transactions. If we're rolling + * back, clear them all. */ conflict = (RWConflict) SHMQueueNext((SHM_QUEUE *) &MySerializableXact->inConflicts, @@ -1923,7 +1924,7 @@ ReleasePredicateLocks(const bool isCommit) /* Add this to the list of transactions to check for later cleanup. */ if (isCommit) SHMQueueInsertBefore(FinishedSerializableTransactions, - (SHM_QUEUE *) &(MySerializableXact->finishedLink)); + (SHM_QUEUE *) &(MySerializableXact->finishedLink)); /* * Check whether it's time to clean up old transactions. This can only be @@ -2011,7 +2012,8 @@ ReleaseOneSerializableXact(SERIALIZABLEXACT *sxact) { PREDICATELOCK *predlock; SERIALIZABLEXIDTAG sxidtag; - RWConflict conflict, nextConflict; + RWConflict conflict, + nextConflict; Assert(sxact != NULL); Assert(SxactIsRolledBack(sxact) || SxactIsCommitted(sxact)); @@ -2045,6 +2047,7 @@ ReleaseOneSerializableXact(SERIALIZABLEXACT *sxact) LWLockAcquire(partitionLock, LW_EXCLUSIVE); SHMQueueDelete(targetLink); + /* * No need to do retail removal of predicate locks from transaction * object; it's going away. @@ -2168,10 +2171,10 @@ CheckForSerializableConflictOut(const bool valid, const Relation relation, { /* * A visible tuple has been modified. This is probably a conflict, - * but for updates we'll catch this on the new tuple -- for the - * sake of performance we don't want to check it twice. We return - * unless this is a tuple delete, in which case there is no new - * tuple to trigger the check. + * but for updates we'll catch this on the new tuple -- for the sake + * of performance we don't want to check it twice. We return unless + * this is a tuple delete, in which case there is no new tuple to + * trigger the check. */ if (!ItemPointerEquals(&(tuple->t_self), &(tuple->t_data->t_ctid))) return; @@ -2200,7 +2203,7 @@ CheckForSerializableConflictOut(const bool valid, const Relation relation, } /* - * Find top level xid. 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; @@ -2268,7 +2271,7 @@ CheckForSerializableConflictOut(const bool valid, const Relation relation, LWLockRelease(SerializableXactHashLock); return; } - + if (RWConflictExists((SERIALIZABLEXACT *) MySerializableXact, sxact)) { /* We don't want duplicate conflict records in the list. */ @@ -2426,9 +2429,8 @@ CheckTargetForConflictsIn(PREDICATELOCKTARGETTAG *targettag) DecrementParentLocks(targettag); /* - * If we've cleaned up the last of the predicate locks - * for the target, bail out before re-acquiring the - * locks. + * If we've cleaned up the last of the predicate locks for + * the target, bail out before re-acquiring the locks. */ if (rmtarget) return; @@ -2447,9 +2449,9 @@ CheckTargetForConflictsIn(PREDICATELOCKTARGETTAG *targettag) else { /* - * The predicate lock was cleared while we were - * attempting to upgrade our lightweight locks. - * Revert to the shared locks. + * The predicate lock was cleared while we were attempting + * to upgrade our lightweight locks. Revert to the shared + * locks. */ LWLockRelease(SerializableXactHashLock); LWLockRelease(partitionLock); @@ -2463,7 +2465,7 @@ CheckTargetForConflictsIn(PREDICATELOCKTARGETTAG *targettag) && (!SxactIsCommitted(sxact) || TransactionIdPrecedes(GetTransactionSnapshot()->xmin, sxact->finishedBefore)) - && !RWConflictExists(sxact, (SERIALIZABLEXACT *) MySerializableXact)) + && !RWConflictExists(sxact, (SERIALIZABLEXACT *) MySerializableXact)) { LWLockRelease(SerializableXactHashLock); LWLockAcquire(SerializableXactHashLock, LW_EXCLUSIVE); @@ -2576,16 +2578,16 @@ 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. + * Check for already-committed writer with rw-conflict out flagged. This + * means that the reader must immediately fail. */ if (SxactIsCommitted(writer) && SxactHasConflictOut(writer)) 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. + * 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 (!failure && SxactIsCommitted(writer) && !SxactIsReadOnly(reader)) { @@ -2597,7 +2599,7 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader, { if (!SxactIsRolledBack(conflict->sxactOut) && (!SxactIsCommitted(conflict->sxactOut) - || conflict->sxactOut->commitSeqNo >= writer->commitSeqNo) + || conflict->sxactOut->commitSeqNo >= writer->commitSeqNo) && (!SxactIsReadOnly(conflict->sxactOut) || conflict->sxactOut->SeqNo.lastCommitBeforeSnapshot >= writer->commitSeqNo)) { @@ -2613,12 +2615,11 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader, /* * Check whether the writer has become a pivot with an out-conflict - * committed transaction, while neither reader nor writer is committed. - * If the reader is a READ ONLY transaction, there is only a - * serialization failure if an out-conflict transaction causing the - * pivot committed before the reader acquired its snapshot. (That is, - * the reader must not have been concurrent with the out-conflict - * transaction.) + * committed transaction, while neither reader nor writer is committed. If + * the reader is a READ ONLY transaction, there is only a serialization + * failure if an out-conflict transaction causing the pivot committed + * before the reader acquired its snapshot. (That is, the reader must not + * have been concurrent with the out-conflict transaction.) */ if (!failure && !SxactIsCommitted(writer)) { @@ -2664,8 +2665,8 @@ OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader, void PreCommit_CheckForSerializationFailure(void) { - bool failure; - RWConflict nearConflict; + bool failure; + RWConflict nearConflict; if (MySerializableXact == InvalidSerializableXact) return; @@ -2677,8 +2678,8 @@ PreCommit_CheckForSerializationFailure(void) /* TODO SSI: check whether another transaction has cancelled us? */ /* - * TODO SSI: SHARED here and EXCLUSIVE below to modify? Would require - * new SerializableCommitLock for exclusive use around this method? + * TODO SSI: SHARED here and EXCLUSIVE below to modify? Would require new + * SerializableCommitLock for exclusive use around this method? */ LWLockAcquire(SerializableXactHashLock, LW_EXCLUSIVE); @@ -2691,7 +2692,7 @@ PreCommit_CheckForSerializationFailure(void) if (!SxactIsCommitted(nearConflict->sxactOut) && !SxactIsRolledBack(nearConflict->sxactOut)) { - RWConflict farConflict; + RWConflict farConflict; farConflict = (RWConflict) SHMQueueNext(&nearConflict->sxactOut->inConflicts, diff --git a/src/include/storage/predicate_internals.h b/src/include/storage/predicate_internals.h index 91e4eaa689..ffa93e903d 100644 --- a/src/include/storage/predicate_internals.h +++ b/src/include/storage/predicate_internals.h @@ -56,32 +56,35 @@ typedef struct SERIALIZABLEXACT SERIALIZABLEXACTTAG tag; /* data */ - SerCommitSeqNo commitSeqNo; - union /* these values are not both interesting at the same time */ + SerCommitSeqNo commitSeqNo; + union /* these values are not both interesting at + * the same time */ { - SerCommitSeqNo earliestOutConflictCommit; /* when committed with conflict out */ - SerCommitSeqNo lastCommitBeforeSnapshot; /* when not committed or no conflict out */ - } SeqNo; + SerCommitSeqNo earliestOutConflictCommit; /* when committed with + * conflict out */ + SerCommitSeqNo lastCommitBeforeSnapshot; /* when not committed or + * no conflict out */ + } SeqNo; SHM_QUEUE outConflicts; /* list of write transactions whose data we * couldn't read. */ SHM_QUEUE inConflicts; /* list of read transactions which couldn't * see our write. */ SHM_QUEUE predicateLocks; /* list of associated PREDICATELOCK objects */ SHM_QUEUE finishedLink; /* list link in */ - /* FinishedSerializableTransactions */ + /* FinishedSerializableTransactions */ TransactionId topXid; /* top level xid for the transaction, if one * exists; else invalid */ TransactionId finishedBefore; /* invalid means still running; else * the struct expires when no * serializable xids are before this. */ TransactionId xmin; /* the transaction's snapshot xmin */ - int flags; /* OR'd combination of values defined below */ + int flags; /* OR'd combination of values defined below */ } SERIALIZABLEXACT; /* TODO SSI: What's the best technique for dealing with these flags? */ #define SXACT_FLAG_ROLLED_BACK 1 #define SXACT_FLAG_COMMITTED 2 -#define SXACT_FLAG_CONFLICT_OUT 4 +#define SXACT_FLAG_CONFLICT_OUT 4 #define SXACT_FLAG_READ_ONLY 8 #define SXACT_FLAG_DID_WRITE 16 @@ -110,12 +113,13 @@ typedef struct PredTranListData /* * These global variables are maintained when registering and cleaning up - * serializable transactions. They must be global across all backends, but - * are not needed outside this source file, so no .h declaration is needed. + * serializable transactions. They must be global across all backends, + * but are not needed outside this source file, so no .h declaration is + * needed. */ - TransactionId SxactGlobalXmin; + TransactionId SxactGlobalXmin; int SxactGlobalXminCount; - SerCommitSeqNo LastSxactCommitSeqNo; + SerCommitSeqNo LastSxactCommitSeqNo; PredTranListElement element; } PredTranListData; @@ -137,8 +141,8 @@ typedef struct RWConflictData { SHM_QUEUE outLink; SHM_QUEUE inLink; - SERIALIZABLEXACT *sxactOut; - SERIALIZABLEXACT *sxactIn; + SERIALIZABLEXACT *sxactOut; + SERIALIZABLEXACT *sxactIn; } RWConflictData; typedef struct RWConflictData *RWConflict; -- 2.39.5