]> granicus.if.org Git - postgresql/commitdiff
Assert that strong-lock count is >0 everywhere it's decremented.
authorRobert Haas <rhaas@postgresql.org>
Mon, 7 Apr 2014 14:59:42 +0000 (10:59 -0400)
committerRobert Haas <rhaas@postgresql.org>
Mon, 7 Apr 2014 15:15:13 +0000 (11:15 -0400)
The one existing assertion of this type has tripped a few times in the
buildfarm lately, but it's not clear whether the problem is really
originating there or whether it's leftovers from a trip through one
of the other two paths that lack a matching assertion.  So add one.

Since the same bug(s) most likely exist(s) in the back-branches also,
back-patch to 9.2, where the fast-path lock mechanism was added.

src/backend/storage/lmgr/lock.c

index 3566208904c344212580fa320c580a94e89ec36c..15fbe86107d4cdf91f6c83a229bbd6ea631dc43b 100644 (file)
@@ -1516,6 +1516,7 @@ AbortStrongLockAcquire(void)
        fasthashcode = FastPathStrongLockHashPartition(locallock->hashcode);
        Assert(locallock->holdsStrongLockCount == TRUE);
        SpinLockAcquire(&FastPathStrongRelationLocks->mutex);
+       Assert(FastPathStrongRelationLocks->count[fasthashcode] > 0);
        FastPathStrongRelationLocks->count[fasthashcode]--;
        locallock->holdsStrongLockCount = FALSE;
        StrongLockInProgress = NULL;
@@ -2882,6 +2883,7 @@ LockRefindAndRelease(LockMethod lockMethodTable, PGPROC *proc,
                uint32          fasthashcode = FastPathStrongLockHashPartition(hashcode);
 
                SpinLockAcquire(&FastPathStrongRelationLocks->mutex);
+               Assert(FastPathStrongRelationLocks->count[fasthashcode] > 0);
                FastPathStrongRelationLocks->count[fasthashcode]--;
                SpinLockRelease(&FastPathStrongRelationLocks->mutex);
        }