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

Fix resgroup unusable if its dropping failed

In function DropResourceGroup(), group->lockedForDrop is set
to true by calling ResGroupCheckForDrop, however, it can only
be set to false inside dropResgroupCallback. This callback is
registered at the ending of function DropResourceGroup. If an
error occured between them, group->lockedForDrop would be true
forever.

Fix it by putting the register process ahead of the lock call.
To prevent Assert(group->nRunning* > 0) if ResGroupCheckForDrop
throws an error, return directly if group->lockedForDrop did
not change.

See:

```
gpconfig -c gp_resource_manager -v group
gpstop -r -a

psql
                CPU_RATE_LIMIT=20,
                MEMORY_LIMIT=20,
                CONCURRENCY=50,
                MEMORY_SHARED_QUOTA=80,
                MEMORY_SPILL_RATIO=20,
                MEMORY_AUDITOR=vmtracker
        );

psql -U user_test
> \d -- hang
```
Co-authored-by: Ndh-cloud <60729713+dh-cloud@users.noreply.github.com>
上级 cbcd2b5b
......@@ -312,7 +312,15 @@ DropResourceGroup(DropResourceGroupStmt *stmt)
/* check before dispatch to segment */
if (IsResGroupActivated())
{
/* Argument of callback function should be allocated in heap region */
callbackCtx = (ResourceGroupCallbackContext *)
MemoryContextAlloc(TopMemoryContext, sizeof(*callbackCtx));
callbackCtx->groupid = groupid;
RegisterXactCallbackOnce(dropResgroupCallback, callbackCtx);
ResGroupCheckForDrop(groupid, stmt->name);
}
/*
* Check to see if any roles are in this resource group.
......@@ -346,15 +354,6 @@ DropResourceGroup(DropResourceGroupStmt *stmt)
NIL,
NULL);
}
if (IsResGroupActivated())
{
/* Argument of callback function should be allocated in heap region */
callbackCtx = (ResourceGroupCallbackContext *)
MemoryContextAlloc(TopMemoryContext, sizeof(*callbackCtx));
callbackCtx->groupid = groupid;
RegisterXactCallbackOnce(dropResgroupCallback, callbackCtx);
}
}
/*
......
......@@ -3318,6 +3318,8 @@ slotGetId(const ResGroupSlotData *slot)
static void
lockResGroupForDrop(ResGroupData *group)
{
if (group->lockedForDrop)
return;
Assert(LWLockHeldExclusiveByMe(ResGroupLock));
Assert(Gp_role == GP_ROLE_DISPATCH);
Assert(group->nRunning == 0);
......@@ -3328,6 +3330,8 @@ lockResGroupForDrop(ResGroupData *group)
static void
unlockResGroupForDrop(ResGroupData *group)
{
if (!group->lockedForDrop)
return;
Assert(LWLockHeldExclusiveByMe(ResGroupLock));
Assert(Gp_role == GP_ROLE_DISPATCH);
Assert(group->nRunning == 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册