remove WorkerNodeListGetNodeWithGroupId

tenant-schema-isolation-complete-view
Onur Tirtir 2023-10-24 18:32:48 +03:00
parent 6af8a51065
commit d9c1e992b2
1 changed files with 5 additions and 45 deletions

View File

@ -99,7 +99,6 @@ static bool TryAssignPlacementGroupToNodeGroup(
/* other helpers */ /* other helpers */
static List * PlacementListGetUniqueNodeGroupIds(List *placementList); static List * PlacementListGetUniqueNodeGroupIds(List *placementList);
static int WorkerNodeListGetNodeWithGroupId(List *workerNodeList, int32 nodeGroupId);
/* /*
@ -222,7 +221,6 @@ TryAssignPlacementGroupsToNodeGroups(RebalancerPlacementSeparationContext *conte
List *rebalancePlacementList, List *rebalancePlacementList,
FmgrInfo *shardAllowedOnNodeUDF) FmgrInfo *shardAllowedOnNodeUDF)
{ {
List *availableWorkerList = list_copy(activeWorkerNodeList);
List *unassignedPlacementList = NIL; List *unassignedPlacementList = NIL;
/* /*
@ -239,23 +237,10 @@ TryAssignPlacementGroupsToNodeGroups(RebalancerPlacementSeparationContext *conte
} }
int32 currentNodeGroupId = shardPlacement->groupId; int32 currentNodeGroupId = shardPlacement->groupId;
if (TryAssignPlacementGroupToNodeGroup(context, if (!TryAssignPlacementGroupToNodeGroup(context,
currentNodeGroupId, currentNodeGroupId,
shardPlacement, shardPlacement,
shardAllowedOnNodeUDF)) shardAllowedOnNodeUDF))
{
/*
* TryAssignPlacementGroupToNodeGroup() succeeds for each worker node
* once, hence we must not have removed the worker node from the list
* yet, and WorkerNodeListGetNodeWithGroupId() ensures that already.
*/
int currentPlacementNodeIdx =
WorkerNodeListGetNodeWithGroupId(availableWorkerList,
currentNodeGroupId);
availableWorkerList = list_delete_nth_cell(availableWorkerList,
currentPlacementNodeIdx);
}
else
{ {
unassignedPlacementList = unassignedPlacementList =
lappend(unassignedPlacementList, shardPlacement); lappend(unassignedPlacementList, shardPlacement);
@ -274,7 +259,7 @@ TryAssignPlacementGroupsToNodeGroups(RebalancerPlacementSeparationContext *conte
bool separated = false; bool separated = false;
WorkerNode *availableWorkerNode = NULL; WorkerNode *availableWorkerNode = NULL;
foreach_ptr(availableWorkerNode, availableWorkerList) foreach_ptr(availableWorkerNode, activeWorkerNodeList)
{ {
if (TryAssignPlacementGroupToNodeGroup(context, if (TryAssignPlacementGroupToNodeGroup(context,
availableWorkerNode->groupId, availableWorkerNode->groupId,
@ -430,28 +415,3 @@ PlacementListGetUniqueNodeGroupIds(List *placementList)
return placementListUniqueNodeGroupIds; return placementListUniqueNodeGroupIds;
} }
/*
* WorkerNodeListGetNodeWithGroupId returns the index of worker node with given id
* in given worker node list.
*
* Throws an error if no such node is found.
*/
static int
WorkerNodeListGetNodeWithGroupId(List *workerNodeList, int32 nodeGroupId)
{
int workerNodeIndex = 0;
WorkerNode *workerNode = NULL;
foreach_ptr(workerNode, workerNodeList)
{
if (workerNode->groupId == nodeGroupId)
{
return workerNodeIndex;
}
workerNodeIndex++;
}
ereport(ERROR, (errmsg("no such node is found")));
}