From 2fc1411da44a2fb765ee8074a14e615bc2594dc0 Mon Sep 17 00:00:00 2001 From: Onur Tirtir Date: Fri, 6 Oct 2023 12:50:03 +0300 Subject: [PATCH] properly assign conflicting placements --- .../rebalancer_placement_isolation.c | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/backend/distributed/operations/rebalancer_placement_isolation.c b/src/backend/distributed/operations/rebalancer_placement_isolation.c index 9af57dd3d45..6b91f9db74b 100644 --- a/src/backend/distributed/operations/rebalancer_placement_isolation.c +++ b/src/backend/distributed/operations/rebalancer_placement_isolation.c @@ -279,21 +279,20 @@ NodeToPlacementGroupHashAssignNodes(HTAB *nodePlacementGroupHash, } } + bool emitWarning = false; + /* * For the shard placement groups that could not be assigned to their * current node, assign them to any other node that is available. */ - int availableNodeIdx = 0; ShardPlacement *unassignedShardPlacement = NULL; foreach_ptr(unassignedShardPlacement, unassignedPlacementList) { bool separated = false; - while (!separated && availableNodeIdx < list_length(availableWorkerList)) - { - WorkerNode *availableWorkerNode = - (WorkerNode *) list_nth(availableWorkerList, availableNodeIdx); - availableNodeIdx++; + WorkerNode *availableWorkerNode = NULL; + foreach_ptr(availableWorkerNode, availableWorkerList) + { if (NodeToPlacementGroupHashAssignNode(nodePlacementGroupHash, availableWorkerNode->groupId, unassignedShardPlacement, @@ -306,11 +305,15 @@ NodeToPlacementGroupHashAssignNodes(HTAB *nodePlacementGroupHash, if (!separated) { - ereport(WARNING, (errmsg("could not separate all shard placements " - "that need a separate node"))); - return; + emitWarning = true; } } + + if (emitWarning) + { + ereport(WARNING, (errmsg("could not separate all shard placements " + "that need a separate node"))); + } }