提交 44c52db2 编写于 作者: A Adam Berlin 提交者: Adam Berlin

Creates a function to check if a portal is locked for a resource queue.

We have been using Portal->releaseResLock to decide if a resource queue
is locked for a given portal. Instead, we give the responsibility to
the resource queue system to decide if the portal is locked.
Co-authored-by: NAsim R P <apraveen@pivotal.io>
上级 c68cd8da
......@@ -356,7 +356,7 @@ PortalCleanup(Portal portal)
/*
* If resource scheduling is enabled, release the resource lock.
*/
if (portal->releaseResLock)
if (IsResQueueLockedForPortal(portal))
{
portal->releaseResLock = false;
ResUnLockPortal(portal);
......
......@@ -2132,7 +2132,7 @@ _SPI_pquery(QueryDesc *queryDesc, bool fire_triggers, long tcount)
*/
if (ActivePortal)
{
if (!ActivePortal->releaseResLock)
if (!IsResQueueLockedForPortal(ActivePortal))
{
/** TODO: siva - can we ever reach this point? */
ActivePortal->status = PORTAL_QUEUE;
......
......@@ -262,7 +262,7 @@ ProcessQuery(Portal portal,
* Skip if this query is added by the rewriter or
* we are superuser.
*/
if (IsResQueueEnabled() && !superuser() && portal->releaseResLock == false)
if (IsResQueueEnabled() && !superuser() && !IsResQueueLockedForPortal(portal))
{
if((!ResourceSelectOnly || portal->sourceTag == T_SelectStmt) &&
stmt->canSetTag)
......@@ -707,7 +707,7 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot,
* If not in SPI context, acquire resource queue lock with
* no additional checks.
*/
if (!SPI_context() || !saveActivePortal || !saveActivePortal->releaseResLock)
if (!SPI_context() || !saveActivePortal || !IsResQueueLockedForPortal(saveActivePortal))
portal->releaseResLock = ResLockPortal(portal, queryDesc);
}
}
......
......@@ -445,7 +445,7 @@ PortalDrop(Portal portal, bool isTopCommit)
*/
PortalHashTableDelete(portal);
if (portal->releaseResLock)
if (IsResQueueLockedForPortal(portal))
{
portal->releaseResLock = false;
ResUnLockPortal(portal);
......@@ -974,7 +974,7 @@ AtExitCleanup_ResPortals(void)
{
Portal portal = hentry->portal;
if (portal->releaseResLock)
if (IsResQueueLockedForPortal(portal))
ResUnLockPortal(portal);
}
......
......@@ -621,6 +621,11 @@ ResLockRelease(LOCKTAG *locktag, uint32 resPortalId)
return true;
}
bool
IsResQueueLockedForPortal(Portal portal) {
return portal->releaseResLock;
}
/*
* ResLockCheckLimit -- test whether the given process acquiring the this lock
......
......@@ -130,6 +130,7 @@ typedef enum
extern LockAcquireResult ResLockAcquire(LOCKTAG *locktag,
ResPortalIncrement *incrementSet);
extern bool ResLockRelease(LOCKTAG *locktag, uint32 resPortalId);
extern bool IsResQueueLockedForPortal(Portal portal);
extern int ResLockCheckLimit(LOCK *lock, PROCLOCK *proclock,
ResPortalIncrement *incrementSet,
bool increment);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册