diff --git a/src/backend/commands/resgroupcmds.c b/src/backend/commands/resgroupcmds.c index e075b055aa7f9eddcd9af1c7924acd135532d5bc..b5541d1e7ab96f5fa32e1a2d15aa49d300efbe5c 100644 --- a/src/backend/commands/resgroupcmds.c +++ b/src/backend/commands/resgroupcmds.c @@ -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); - } } /* diff --git a/src/backend/utils/resgroup/resgroup.c b/src/backend/utils/resgroup/resgroup.c index b605b761af36eaefd06a382cb9f11b1728e610ea..05a45dde46b971830715c632c92096bc86daa66d 100644 --- a/src/backend/utils/resgroup/resgroup.c +++ b/src/backend/utils/resgroup/resgroup.c @@ -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);