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
This commit is contained in:
proller 2018-04-06 20:49:49 -07:00 committed by proller
parent 5ce62809da
commit 9a9c2a1e9d
5 changed files with 9 additions and 9 deletions

2
contrib/zstd vendored

@ -1 +1 @@
Subproject commit 255597502c3a4ef150abc964e376d4202a8c2929 Subproject commit f4340f46b2387bc8de7d5320c0b83bb1499933ad

View File

@ -238,7 +238,7 @@ void IProfilingBlockInputStream::progressImpl(const Progress & value)
if (process_list_elem) if (process_list_elem)
{ {
if (!process_list_elem->updateProgressIn(value)) 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. /// The total amount of data processed or intended for processing in all leaf sources, possibly on remote servers.

View File

@ -66,7 +66,7 @@ ProcessList::EntryPtr ProcessList::insert(
/// Ask queries to cancel. They will check this flag. /// Ask queries to cancel. They will check this flag.
for (auto it = range.first; it != range.second; ++it) 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);
} }
} }
} }

View File

@ -78,7 +78,7 @@ private:
CurrentMetrics::Increment num_queries {CurrentMetrics::Query}; CurrentMetrics::Increment num_queries {CurrentMetrics::Query};
std::atomic<bool> is_cancelled { false }; std::atomic<bool> is_killed { false };
/// Be careful using it. For example, queries field could be modified concurrently. /// Be careful using it. For example, queries field could be modified concurrently.
const ProcessListForUser * user_process_list = nullptr; const ProcessListForUser * user_process_list = nullptr;
@ -140,13 +140,13 @@ public:
if (priority_handle) if (priority_handle)
priority_handle->waitIfNeed(std::chrono::seconds(1)); /// NOTE Could make timeout customizable. 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) bool updateProgressOut(const Progress & value)
{ {
progress_out.incrementPiecewiseAtomically(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.query = query;
res.client_info = client_info; res.client_info = client_info;
res.elapsed_seconds = watch.elapsedSeconds(); 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_rows = progress_in.rows;
res.read_bytes = progress_in.bytes; res.read_bytes = progress_in.bytes;
res.total_rows = progress_in.total_rows; res.total_rows = progress_in.total_rows;

View File

@ -5,7 +5,7 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
set -e -o pipefail 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. 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 wait