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
This commit is contained in:
Azat Khuzhin 2021-07-21 09:58:13 +03:00
parent 09449cc101
commit 7b7e8acf4f
4 changed files with 14 additions and 8 deletions

View File

@ -38,11 +38,6 @@ void RemoteBlockInputStream::init()
query_executor.setLogger(log); query_executor.setLogger(log);
} }
void RemoteBlockInputStream::readPrefix()
{
query_executor.sendQuery();
}
void RemoteBlockInputStream::cancel(bool kill) void RemoteBlockInputStream::cancel(bool kill)
{ {
if (kill) if (kill)

View File

@ -52,9 +52,6 @@ public:
void setMainTable(StorageID main_table_) { query_executor.setMainTable(std::move(main_table_)); } 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. /// Prevent default progress notification because progress' callback is called by its own.
void progress(const Progress & /*value*/) override {} void progress(const Progress & /*value*/) override {}

View File

@ -0,0 +1 @@
Connection failed at try №1,

View File

@ -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.*,'