From f1160b0892e1b5c56bc25c5a83c6c623eae0c84c Mon Sep 17 00:00:00 2001 From: Colm Date: Thu, 24 Jul 2025 14:19:39 +0100 Subject: [PATCH] Fix assert failure introduced in 245a62df3e96f3eef The assert on the number of shards incorrectly used the value of citus.shard_replication_factor; it should check the table's metadata to determine the replication factor of its data, and not assume it is the current GUC value. --- .../distributed/planner/multi_router_planner.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/backend/distributed/planner/multi_router_planner.c b/src/backend/distributed/planner/multi_router_planner.c index 907fe1eaf..59124c5bf 100644 --- a/src/backend/distributed/planner/multi_router_planner.c +++ b/src/backend/distributed/planner/multi_router_planner.c @@ -2060,14 +2060,6 @@ CheckAndBuildDelayedFastPathPlan(DistributedPlanningContext *planContext, Task *task = (Task *) linitial(tasks); List *placements = task->taskPlacementList; int32 localGroupId = GetLocalGroupId(); - - /* - * Today FastPathRouterQuery() doesn't set delayFastPathPlanning to true for - * reference tables. We should be looking at 1 placement, or ShardReplicationFactor - * of them. - */ - Assert(list_length(placements) == 1 || list_length(placements) == - ShardReplicationFactor); ShardPlacement *primaryPlacement = (ShardPlacement *) linitial(placements); bool isLocalExecution = !IsDummyPlacement(primaryPlacement) && @@ -2081,6 +2073,14 @@ CheckAndBuildDelayedFastPathPlan(DistributedPlanningContext *planContext, RelationShard *relationShard = (RelationShard *) linitial(relationShards); Assert(relationShard->shardId == primaryPlacement->shardId); + /* + * Today FastPathRouterQuery() doesn't set delayFastPathPlanning to true for + * reference tables. We should be looking at 1 placement, or their replication + * factor. + */ + Assert(list_length(placements) == 1 || list_length(placements) == + TableShardReplicationFactor(relationShard->relationId)); + canBuildLocalPlan = ConvertToQueryOnShard(planContext->query, relationShard->relationId, relationShard->shardId);