]> granicus.if.org Git - postgresql/commitdiff
Be sure to release proc->backendLock after SetupLockInTable() failure.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 29 Nov 2013 22:35:09 +0000 (17:35 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 29 Nov 2013 22:35:09 +0000 (17:35 -0500)
The various places that transferred fast-path locks to the main lock table
neglected to release the PGPROC's backendLock if SetupLockInTable failed
due to being out of shared memory.  In most cases this is no big deal since
ensuing error cleanup would release all held LWLocks anyway.  But there are
some hot-standby functions that don't consider failure of
FastPathTransferRelationLocks to be a hard error, and in those cases this
oversight could lead to system lockup.  For consistency, make all of these
places look the same as FastPathTransferRelationLocks.

Noted while looking for the cause of Dan Wood's bugs --- this wasn't it,
but it's a bug anyway.

src/backend/storage/lmgr/lock.c

index fde20425f684bc1f42f3029a46d4b55b12580a23..e4c9fa4ab423b96c8b5cdb7977f7ecc5d9d709ad 100644 (file)
@@ -2536,6 +2536,7 @@ FastPathTransferRelationLocks(LockMethod lockMethodTable, const LOCKTAG *locktag
                                if (!proclock)
                                {
                                        LWLockRelease(partitionLock);
+                                       LWLockRelease(proc->backendLock);
                                        return false;
                                }
                                GrantLock(proclock->tag.myLock, proclock, lockmode);
@@ -2591,6 +2592,7 @@ FastPathGetRelationLockEntry(LOCALLOCK *locallock)
                if (!proclock)
                {
                        LWLockRelease(partitionLock);
+                       LWLockRelease(MyProc->backendLock);
                        ereport(ERROR,
                                        (errcode(ERRCODE_OUT_OF_MEMORY),
                                         errmsg("out of shared memory"),
@@ -4054,6 +4056,7 @@ VirtualXactLock(VirtualTransactionId vxid, bool wait)
                if (!proclock)
                {
                        LWLockRelease(partitionLock);
+                       LWLockRelease(proc->backendLock);
                        ereport(ERROR,
                                        (errcode(ERRCODE_OUT_OF_MEMORY),
                                         errmsg("out of shared memory"),