Do not try to send query if it was canceled in RemoteSource

With optimize_distributed_group_by_sharding_key it is possible to get
enough rows even before sending query to another shard and in this case
it shouldn't send anything to others.

This reduces NETWORK_ERROR in the 01563_distributed_query_finish from 2 to 1.
This commit is contained in:
Azat Khuzhin 2020-11-14 16:36:18 +03:00
parent ed64f2ad67
commit 8f42144097
2 changed files with 6 additions and 0 deletions

View File

@ -21,6 +21,10 @@ RemoteSource::~RemoteSource() = default;
Chunk RemoteSource::generate()
{
/// onCancel() will do the cancel if the query was sent.
if (was_query_canceled)
return {};
if (!was_query_sent)
{
/// Progress method will be called on Progress packet.
@ -62,6 +66,7 @@ Chunk RemoteSource::generate()
void RemoteSource::onCancel()
{
was_query_canceled = true;
query_executor->cancel();
}

View File

@ -36,6 +36,7 @@ protected:
void onCancel() override;
private:
bool was_query_canceled = false;
bool was_query_sent = false;
bool add_aggregation_info = false;
RemoteQueryExecutorPtr query_executor;