diff --git a/src/Processors/QueryPlan/ReadFromRemote.cpp b/src/Processors/QueryPlan/ReadFromRemote.cpp index 91c81d619a7..93c73a66b78 100644 --- a/src/Processors/QueryPlan/ReadFromRemote.cpp +++ b/src/Processors/QueryPlan/ReadFromRemote.cpp @@ -416,7 +416,10 @@ void ReadFromParallelRemoteReplicasStep::initializePipeline(QueryPipelineBuilder std::vector shuffled_pool; if (all_replicas_count < shard.getAllNodeCount()) + { shuffled_pool = shard.pool->getShuffledPools(current_settings); + shuffled_pool.resize(all_replicas_count); + } else { /// try to preserve replicas order if all replicas in cluster are used for query execution @@ -424,7 +427,6 @@ void ReadFromParallelRemoteReplicasStep::initializePipeline(QueryPipelineBuilder auto priority_func = [](size_t i) { return Priority{static_cast(i)}; }; shuffled_pool = shard.pool->getShuffledPools(current_settings, priority_func); } - shuffled_pool.resize(all_replicas_count); for (size_t i=0; i < all_replicas_count; ++i) {