From: Kevin Grittner Date: Thu, 2 Dec 2010 07:42:54 +0000 (-0600) Subject: Add an assertion to help ensure that clean-up isn't falling down. X-Git-Url: http://git.postgresql.org/gitweb/irc:/static/gitweb.js?a=commitdiff_plain;h=bf5709a32fdda29bdd07e6d68d8000a938bc224d;p=users%2Fkgrittn%2Fpostgres.git Add an assertion to help ensure that clean-up isn't falling down. Add a couple TODO comments for eager cleanup of read-only transactions. --- diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index 0f30116391..dcd44169b6 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -819,6 +819,12 @@ RegisterSerializableTransaction(const Snapshot snapshot) LWLockAcquire(SerializableXactHashLock, LW_EXCLUSIVE); + /* + * TODO SSI: If there are no serializable transactions which are not + * read-only, we can "opt out" of predicate locking and conflict + * checking. + */ + if (!TransactionIdIsValid(PredTran->SxactGlobalXmin)) { Assert(PredTran->SxactGlobalXminCount == 0); @@ -1824,6 +1830,11 @@ SetNewSxactGlobalXmin(void) * If this transaction is committing and is holding any predicate locks, * it must be added to a list of completed serializable transaction still * holding locks. + * + * TODO SSI: Maintain a count of non-read-only active serializable + * transactions. Any time this count hits zero, clean up any conflicts and + * predicate locks for read-only transactions -- active or committed. They + * need not acquire predicate locks or check for out-conflicts after that. */ void ReleasePredicateLocks(const bool isCommit) @@ -1946,6 +1957,13 @@ ReleasePredicateLocks(const bool isCommit) LWLockRelease(SerializableXactHashLock); } + /* + * Reality check: There can't be an active serializable transaction + * older than the oldest active transaction. + */ + Assert(!TransactionIdIsValid(PredTran->SxactGlobalXmin) + || TransactionIdFollowsOrEquals(PredTran->SxactGlobalXmin, RecentGlobalXmin)); + LWLockRelease(SerializableFinishedListLock); if (!isCommit)