From 9a9c2a1e9d65f4645cf8c70eeed943e3e7777cb0 Mon Sep 17 00:00:00 2001 From: proller Date: Fri, 6 Apr 2018 20:49:49 -0700 Subject: [PATCH] CLICKHOUSE-3444: show error for old query on replace_running_query (#2127) * Add tests * Fix test * Fix test build * CLICKHOUSE-3444: show error for replace_running_query * fix naming * fix * fix test * Update IProfilingBlockInputStream.cpp --- contrib/zstd | 2 +- dbms/src/DataStreams/IProfilingBlockInputStream.cpp | 2 +- dbms/src/Interpreters/ProcessList.cpp | 2 +- dbms/src/Interpreters/ProcessList.h | 8 ++++---- .../queries/0_stateless/00600_replace_running_query.sh | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/contrib/zstd b/contrib/zstd index 255597502c3..f4340f46b23 160000 --- a/contrib/zstd +++ b/contrib/zstd @@ -1 +1 @@ -Subproject commit 255597502c3a4ef150abc964e376d4202a8c2929 +Subproject commit f4340f46b2387bc8de7d5320c0b83bb1499933ad diff --git a/dbms/src/DataStreams/IProfilingBlockInputStream.cpp b/dbms/src/DataStreams/IProfilingBlockInputStream.cpp index 8cb570bbf62..09eeff2225c 100644 --- a/dbms/src/DataStreams/IProfilingBlockInputStream.cpp +++ b/dbms/src/DataStreams/IProfilingBlockInputStream.cpp @@ -238,7 +238,7 @@ void IProfilingBlockInputStream::progressImpl(const Progress & value) if (process_list_elem) { if (!process_list_elem->updateProgressIn(value)) - cancel(false); + cancel(/* kill */ true); /// The total amount of data processed or intended for processing in all leaf sources, possibly on remote servers. diff --git a/dbms/src/Interpreters/ProcessList.cpp b/dbms/src/Interpreters/ProcessList.cpp index e6e77c85180..59c481e6e3a 100644 --- a/dbms/src/Interpreters/ProcessList.cpp +++ b/dbms/src/Interpreters/ProcessList.cpp @@ -66,7 +66,7 @@ ProcessList::EntryPtr ProcessList::insert( /// Ask queries to cancel. They will check this flag. for (auto it = range.first; it != range.second; ++it) - it->second->is_cancelled.store(true, std::memory_order_relaxed); + it->second->is_killed.store(true, std::memory_order_relaxed); } } } diff --git a/dbms/src/Interpreters/ProcessList.h b/dbms/src/Interpreters/ProcessList.h index a76e886414d..ecc29d671fe 100644 --- a/dbms/src/Interpreters/ProcessList.h +++ b/dbms/src/Interpreters/ProcessList.h @@ -78,7 +78,7 @@ private: CurrentMetrics::Increment num_queries {CurrentMetrics::Query}; - std::atomic is_cancelled { false }; + std::atomic is_killed { false }; /// Be careful using it. For example, queries field could be modified concurrently. const ProcessListForUser * user_process_list = nullptr; @@ -140,13 +140,13 @@ public: if (priority_handle) priority_handle->waitIfNeed(std::chrono::seconds(1)); /// NOTE Could make timeout customizable. - return !is_cancelled.load(std::memory_order_relaxed); + return !is_killed.load(std::memory_order_relaxed); } bool updateProgressOut(const Progress & value) { progress_out.incrementPiecewiseAtomically(value); - return !is_cancelled.load(std::memory_order_relaxed); + return !is_killed.load(std::memory_order_relaxed); } @@ -157,7 +157,7 @@ public: res.query = query; res.client_info = client_info; res.elapsed_seconds = watch.elapsedSeconds(); - res.is_cancelled = is_cancelled.load(std::memory_order_relaxed); + res.is_cancelled = is_killed.load(std::memory_order_relaxed); res.read_rows = progress_in.rows; res.read_bytes = progress_in.bytes; res.total_rows = progress_in.total_rows; diff --git a/dbms/tests/queries/0_stateless/00600_replace_running_query.sh b/dbms/tests/queries/0_stateless/00600_replace_running_query.sh index 37799069779..6778bbce149 100755 --- a/dbms/tests/queries/0_stateless/00600_replace_running_query.sh +++ b/dbms/tests/queries/0_stateless/00600_replace_running_query.sh @@ -5,7 +5,7 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) set -e -o pipefail -$CLICKHOUSE_CURL -sS "$CLICKHOUSE_URL?query_id=hello&replace_running_query=1" -d 'SELECT sum(ignore(*)) FROM (SELECT number % 1000 AS k, groupArray(number) FROM numbers(100000000) GROUP BY k)' & +$CLICKHOUSE_CURL -sS "$CLICKHOUSE_URL?query_id=hello&replace_running_query=1" -d 'SELECT sum(ignore(*)) FROM (SELECT number % 1000 AS k, groupArray(number) FROM numbers(100000000) GROUP BY k)' 2>&1 > /dev/null & sleep 0.1 # First query (usually) should be received by the server after this sleep. -$CLICKHOUSE_CURL -sS "$CLICKHOUSE_URL?query_id=hello&replace_running_query=1" -d 'SELECT 1 WHERE 0' +$CLICKHOUSE_CURL -sS "$CLICKHOUSE_URL?query_id=hello&replace_running_query=1" -d 'SELECT 0' wait