diff --git a/src/Storages/IStorageCluster.cpp b/src/Storages/IStorageCluster.cpp index 7c8d410cee53..3deacbd02c2d 100644 --- a/src/Storages/IStorageCluster.cpp +++ b/src/Storages/IStorageCluster.cpp @@ -42,6 +42,11 @@ namespace Setting extern const SettingsNonZeroUInt64 max_parallel_replicas; } +namespace ErrorCodes +{ + extern const int NO_ACTIVE_REPLICAS; +}; + IStorageCluster::IStorageCluster( const String & cluster_name_, const StorageID & table_id_, @@ -239,6 +244,9 @@ void ReadFromCluster::initializePipeline(QueryPipelineBuilder & pipeline, const pipes.emplace_back(std::move(pipe)); } + if (pipes.size() == 0) + throw Exception(ErrorCodes::NO_ACTIVE_REPLICAS, "Can't find active replicas in cluster '{}'", cluster->getName()); + auto pipe = Pipe::unitePipes(std::move(pipes)); if (pipe.empty()) pipe = Pipe(std::make_shared(getOutputHeader())); diff --git a/tests/integration/test_s3_cluster/test.py b/tests/integration/test_s3_cluster/test.py index 3573acb008b0..18f6892c6380 100644 --- a/tests/integration/test_s3_cluster/test.py +++ b/tests/integration/test_s3_cluster/test.py @@ -537,3 +537,14 @@ def test_cluster_default_expression(started_cluster): ) assert result == expected_result + + +def test_dead_cluster(started_cluster): + node = started_cluster.instances["s0_1_0"] + + with started_cluster.pause_container("s0_0_0"): + with started_cluster.pause_container("s0_0_1"): + result = node.query_and_get_error( + f"SELECT * FROM s3Cluster(first_shard, 'http://minio1:9001/root/data/clickhouse/part1.csv', 'minio', '{minio_secret_key}', 'CSV', 'name String, value UInt32, polygon Array(Array(Tuple(Float64, Float64)))') order by name" + ) + assert "Can't find active replicas in cluster" in result