diff --git a/src/Storages/IStorageCluster.cpp b/src/Storages/IStorageCluster.cpp index 0e8a2e69651f..6826eb12627e 100644 --- a/src/Storages/IStorageCluster.cpp +++ b/src/Storages/IStorageCluster.cpp @@ -55,6 +55,11 @@ namespace ErrorCodes extern const int NOT_IMPLEMENTED; } +namespace ErrorCodes +{ + extern const int ALL_CONNECTION_TRIES_FAILED; +} + IStorageCluster::IStorageCluster( const String & cluster_name_, const StorageID & table_id_, @@ -293,10 +298,10 @@ void ReadFromCluster::initializePipeline(QueryPipelineBuilder & pipeline, const pipes.emplace_back(std::move(pipe)); } - auto pipe = Pipe::unitePipes(std::move(pipes)); - if (pipe.empty()) - pipe = Pipe(std::make_shared(getOutputHeader())); + if (pipes.empty()) + throw Exception(ErrorCodes::ALL_CONNECTION_TRIES_FAILED, "Cannot connect to any replica for query execution"); + auto pipe = Pipe::unitePipes(std::move(pipes)); for (const auto & processor : pipe.getProcessors()) processors.emplace_back(processor); diff --git a/tests/config/config.d/clusters.xml b/tests/config/config.d/clusters.xml index 0ee6ce774e43..1a507a76fd85 100644 --- a/tests/config/config.d/clusters.xml +++ b/tests/config/config.d/clusters.xml @@ -325,5 +325,19 @@ + + + 127.0.0.1 + 1234 + + + 127.0.0.2 + 1234 + + + 127.0.0.3 + 1234 + + diff --git a/tests/queries/0_stateless/03603_reading_s3_cluster_all_nodes_unavailable.reference b/tests/queries/0_stateless/03603_reading_s3_cluster_all_nodes_unavailable.reference new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/queries/0_stateless/03603_reading_s3_cluster_all_nodes_unavailable.sql b/tests/queries/0_stateless/03603_reading_s3_cluster_all_nodes_unavailable.sql new file mode 100644 index 000000000000..80da21ffacf8 --- /dev/null +++ b/tests/queries/0_stateless/03603_reading_s3_cluster_all_nodes_unavailable.sql @@ -0,0 +1,4 @@ +-- Tags: no-fasttest +-- s3Cluster is not used in fast tests + +SELECT * FROM s3Cluster('test_cluster_multiple_nodes_all_unavailable', 'http://localhost:11111/test/a.tsv'); -- { serverError ALL_CONNECTION_TRIES_FAILED }