]> granicus.if.org Git - postgresql/commitdiff
Fix a tiny race condition in predicate locking. Need to hold the lock while
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 31 Mar 2011 15:43:23 +0000 (18:43 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 31 Mar 2011 15:43:23 +0000 (18:43 +0300)
examining the head of predicate locks list. Also, fix the comment of
RemoveTargetIfNoLongerUsed, it was neglected when we changed the way update
chains are handled.

Kevin Grittner

src/backend/storage/lmgr/predicate.c

index 870cf4277cf991aca1c588b70330d398843a8faf..401acdb4715f75481ff94591a89f26620b8dc237 100644 (file)
@@ -1755,9 +1755,8 @@ CoarserLockCovers(const PREDICATELOCKTARGETTAG *newtargettag)
 }
 
 /*
- * Check whether both the list of related predicate locks and the pointer to
- * a prior version of the row (if this is a tuple lock target) are empty for
- * a predicate lock target, and remove the target if they are.
+ * Check whether the list of related predicate locks is empty for a
+ * predicate lock target, and remove the target if it is.
  */
 static void
 RemoveTargetIfNoLongerUsed(PREDICATELOCKTARGET *target, uint32 targettaghash)
@@ -3120,11 +3119,11 @@ ClearOldPredicateLocks(void)
        /*
         * Loop through predicate locks on dummy transaction for summarized data.
         */
+       LWLockAcquire(SerializablePredicateLockListLock, LW_SHARED);
        predlock = (PREDICATELOCK *)
                SHMQueueNext(&OldCommittedSxact->predicateLocks,
                                         &OldCommittedSxact->predicateLocks,
                                         offsetof(PREDICATELOCK, xactLink));
-       LWLockAcquire(SerializablePredicateLockListLock, LW_SHARED);
        while (predlock)
        {
                PREDICATELOCK *nextpredlock;