From 60b142b9a6f413a92665766a1f265b361f68c20b Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Thu, 31 Mar 2011 18:43:23 +0300 Subject: [PATCH] Fix a tiny race condition in predicate locking. Need to hold the lock while 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 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index 870cf4277c..401acdb471 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -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;