未验证 提交 fafadf8e 编写于 作者: X xiong-gang 提交者: GitHub

Fix a resource queue lock issue

When ResLockAcquire errors out after proclock is allocated and before the lock
is granted, the 'holdMask' and 'nLocks' of proclock are 0, it should be removed
properly in ResLockRelease.
上级 92b6788e
......@@ -301,6 +301,8 @@ ResLockAcquire(LOCKTAG *locktag, ResPortalIncrement *incrementSet)
* Something wrong happened - our RQ is gone. Release all locks and
* clean out
*/
lock->nRequested--;
lock->requested[lockmode]--;
LWLockReleaseAll();
PG_RE_THROW();
}
......@@ -340,6 +342,8 @@ ResLockAcquire(LOCKTAG *locktag, ResPortalIncrement *incrementSet)
incrementSet = ResIncrementAdd(incrementSet, proclock, owner);
if (!incrementSet)
{
lock->nRequested--;
lock->requested[lockmode]--;
LWLockRelease(ResQueueLock);
LWLockRelease(partitionLock);
ereport(ERROR,
......@@ -442,6 +446,8 @@ ResLockAcquire(LOCKTAG *locktag, ResPortalIncrement *incrementSet)
/*
* Have been awakened, check state is consistent.
* Should not get here, ResWaitOnLock will either grant the lock or
* error out.
*/
if (!(proclock->holdMask & LOCKBIT_ON(lockmode)))
{
......@@ -557,6 +563,7 @@ ResLockRelease(LOCKTAG *locktag, uint32 resPortalId)
LWLockRelease(partitionLock);
elog(DEBUG1, "Resource queue %d: proclock not held", locktag->locktag_field1);
RemoveLocalLock(locallock);
ResCleanUpLock(lock, proclock, hashcode, false);
return false;
}
......@@ -1467,7 +1474,7 @@ ResIncrementAdd(ResPortalIncrement *incSet, PROCLOCK *proclock, ResourceOwner ow
else
{
/* We have added this portId before - something has gone wrong! */
ResIncrementRemove(&portaltag);
elog(WARNING, "duplicate portal id %u for proc %d", incSet->portalId, incSet->pid);
incrementSet = NULL;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册