From 3f11139b5cedc59f320e75a73ea921b20b9562bb Mon Sep 17 00:00:00 2001 From: ahmet gedemenli Date: Thu, 20 Jul 2023 16:39:56 +0300 Subject: [PATCH] Do not move a shard to a node that it already exists on --- src/backend/distributed/operations/shard_rebalancer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/backend/distributed/operations/shard_rebalancer.c b/src/backend/distributed/operations/shard_rebalancer.c index 61a4ee9b0..d26c7baf2 100644 --- a/src/backend/distributed/operations/shard_rebalancer.c +++ b/src/backend/distributed/operations/shard_rebalancer.c @@ -2796,7 +2796,15 @@ FindAllowedTargetFillState(RebalanceState *state, uint64 shardId) targetFillState->node, state->functions->context)) { - return targetFillState; + bool targetHasShard = PlacementsHashFind(state->placementsHash, + shardId, + targetFillState->node); + + /* skip if the shard is already placed on the target node */ + if (!targetHasShard) + { + return targetFillState; + } } } return NULL;