Skip to content

Commit 9b4f6da

Browse files
authored
Merge pull request ClickHouse#87275 from ClickHouse/backport/25.8/86414
Backport ClickHouse#86414 to 25.8: Fail if all replicas are unavailable when reading from *cluster functions
2 parents f1975bd + 4cb634a commit 9b4f6da

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

src/Storages/IStorageCluster.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ namespace Setting
4242
extern const SettingsNonZeroUInt64 max_parallel_replicas;
4343
}
4444

45+
namespace ErrorCodes
46+
{
47+
extern const int ALL_CONNECTION_TRIES_FAILED;
48+
}
49+
4550
IStorageCluster::IStorageCluster(
4651
const String & cluster_name_,
4752
const StorageID & table_id_,
@@ -239,10 +244,10 @@ void ReadFromCluster::initializePipeline(QueryPipelineBuilder & pipeline, const
239244
pipes.emplace_back(std::move(pipe));
240245
}
241246

242-
auto pipe = Pipe::unitePipes(std::move(pipes));
243-
if (pipe.empty())
244-
pipe = Pipe(std::make_shared<NullSource>(getOutputHeader()));
247+
if (pipes.empty())
248+
throw Exception(ErrorCodes::ALL_CONNECTION_TRIES_FAILED, "Cannot connect to any replica for query execution");
245249

250+
auto pipe = Pipe::unitePipes(std::move(pipes));
246251
for (const auto & processor : pipe.getProcessors())
247252
processors.emplace_back(processor);
248253

tests/config/config.d/clusters.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,5 +325,19 @@
325325
</replica>
326326
</shard>
327327
</test_shard_bind_host_fail>
328+
<test_cluster_multiple_nodes_all_unavailable>
329+
<node>
330+
<host>127.0.0.1</host>
331+
<port>1234</port>
332+
</node>
333+
<node>
334+
<host>127.0.0.2</host>
335+
<port>1234</port>
336+
</node>
337+
<node>
338+
<host>127.0.0.3</host>
339+
<port>1234</port>
340+
</node>
341+
</test_cluster_multiple_nodes_all_unavailable>
328342
</remote_servers>
329343
</clickhouse>

tests/queries/0_stateless/03603_reading_s3_cluster_all_nodes_unavailable.reference

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Tags: no-fasttest
2+
-- s3Cluster is not used in fast tests
3+
4+
SELECT * FROM s3Cluster('test_cluster_multiple_nodes_all_unavailable', 'http://localhost:11111/test/a.tsv'); -- { serverError ALL_CONNECTION_TRIES_FAILED }

0 commit comments

Comments
 (0)