Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Storages/IStorageCluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_,
Expand Down Expand Up @@ -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<NullSource>(getOutputHeader()));
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/test_s3_cluster/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading