Skip to content

Commit a0e7639

Browse files
authored
Merge pull request #993 from Altinity/backport/antalya-25.6.5/86414
Backport of ClickHouse#86414 Fail when all replicas are unavailable for *cluster functions
2 parents df3fd1a + 0a347b6 commit a0e7639

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
@@ -55,6 +55,11 @@ namespace ErrorCodes
5555
extern const int NOT_IMPLEMENTED;
5656
}
5757

58+
namespace ErrorCodes
59+
{
60+
extern const int ALL_CONNECTION_TRIES_FAILED;
61+
}
62+
5863
IStorageCluster::IStorageCluster(
5964
const String & cluster_name_,
6065
const StorageID & table_id_,
@@ -293,10 +298,10 @@ void ReadFromCluster::initializePipeline(QueryPipelineBuilder & pipeline, const
293298
pipes.emplace_back(std::move(pipe));
294299
}
295300

296-
auto pipe = Pipe::unitePipes(std::move(pipes));
297-
if (pipe.empty())
298-
pipe = Pipe(std::make_shared<NullSource>(getOutputHeader()));
301+
if (pipes.empty())
302+
throw Exception(ErrorCodes::ALL_CONNECTION_TRIES_FAILED, "Cannot connect to any replica for query execution");
299303

304+
auto pipe = Pipe::unitePipes(std::move(pipes));
300305
for (const auto & processor : pipe.getProcessors())
301306
processors.emplace_back(processor);
302307

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)