From 7b7e8acf4f2556f635a5373efeb148b660cc4eab Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Wed, 21 Jul 2021 09:58:13 +0300 Subject: [PATCH] Fix excessive connect attempts with skip_unavailable_shards Before this patch the query was sent from RemoteBlockInputStream::readPrefix() and also from RemoteBlockInputStream::read(). And since in case of skip_unavailable_shards=1 connection errors are ignored, it tries to do x2 connect attempts. Fix this, but removing RemoteBlockInputStream::readPrefix(). Fixes: #26511 --- src/DataStreams/RemoteBlockInputStream.cpp | 5 ----- src/DataStreams/RemoteBlockInputStream.h | 3 --- ..._unavailable_shards_excessive_attempts.reference | 1 + ...56_skip_unavailable_shards_excessive_attempts.sh | 13 +++++++++++++ 4 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 tests/queries/0_stateless/01956_skip_unavailable_shards_excessive_attempts.reference create mode 100755 tests/queries/0_stateless/01956_skip_unavailable_shards_excessive_attempts.sh diff --git a/src/DataStreams/RemoteBlockInputStream.cpp b/src/DataStreams/RemoteBlockInputStream.cpp index c633600d37f..f3a66fb3a57 100644 --- a/src/DataStreams/RemoteBlockInputStream.cpp +++ b/src/DataStreams/RemoteBlockInputStream.cpp @@ -38,11 +38,6 @@ void RemoteBlockInputStream::init() query_executor.setLogger(log); } -void RemoteBlockInputStream::readPrefix() -{ - query_executor.sendQuery(); -} - void RemoteBlockInputStream::cancel(bool kill) { if (kill) diff --git a/src/DataStreams/RemoteBlockInputStream.h b/src/DataStreams/RemoteBlockInputStream.h index b0029da91bb..0c829cb6a67 100644 --- a/src/DataStreams/RemoteBlockInputStream.h +++ b/src/DataStreams/RemoteBlockInputStream.h @@ -52,9 +52,6 @@ public: void setMainTable(StorageID main_table_) { query_executor.setMainTable(std::move(main_table_)); } - /// Sends query (initiates calculation) before read() - void readPrefix() override; - /// Prevent default progress notification because progress' callback is called by its own. void progress(const Progress & /*value*/) override {} diff --git a/tests/queries/0_stateless/01956_skip_unavailable_shards_excessive_attempts.reference b/tests/queries/0_stateless/01956_skip_unavailable_shards_excessive_attempts.reference new file mode 100644 index 00000000000..f2322e4ffc4 --- /dev/null +++ b/tests/queries/0_stateless/01956_skip_unavailable_shards_excessive_attempts.reference @@ -0,0 +1 @@ +Connection failed at try №1, diff --git a/tests/queries/0_stateless/01956_skip_unavailable_shards_excessive_attempts.sh b/tests/queries/0_stateless/01956_skip_unavailable_shards_excessive_attempts.sh new file mode 100755 index 00000000000..0e2f1857aed --- /dev/null +++ b/tests/queries/0_stateless/01956_skip_unavailable_shards_excessive_attempts.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +CLICKHOUSE_CLIENT_SERVER_LOGS_LEVEL=trace + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +opts=( + "--connections_with_failover_max_tries=1" + "--skip_unavailable_shards=1" +) +$CLICKHOUSE_CLIENT --query "select * from remote('255.255.255.255', system.one)" "${opts[@]}" 2>&1 | grep -o 'Connection failed at try.*,'