mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 02:41:59 +00:00
Fix the issue in the comment above.
This commit is contained in:
parent
f956c2c4a9
commit
7599020b87
@ -42,7 +42,7 @@ void CancellationChecker::terminateThread()
|
|||||||
cond_var.notify_all();
|
cond_var.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CancellationChecker::cancelTask(QueryToTrack task, [[maybe_unused]]CancelReason reason)
|
void CancellationChecker::cancelTask(QueryToTrack task)
|
||||||
{
|
{
|
||||||
if (task.query)
|
if (task.query)
|
||||||
{
|
{
|
||||||
@ -123,7 +123,7 @@ void CancellationChecker::workerFunction()
|
|||||||
if ((end_time_ms <= now_ms && duration_milliseconds.count() != 0))
|
if ((end_time_ms <= now_ms && duration_milliseconds.count() != 0))
|
||||||
{
|
{
|
||||||
LOG_TRACE(getLogger("CancellationChecker"), "Cancelling the task because of the timeout: {} ms, query: {}", duration, next_task.query->getInfo().query);
|
LOG_TRACE(getLogger("CancellationChecker"), "Cancelling the task because of the timeout: {} ms, query: {}", duration, next_task.query->getInfo().query);
|
||||||
cancelTask(next_task, CancelReason::TIMEOUT);
|
cancelTask(next_task);
|
||||||
querySet.erase(next_task);
|
querySet.erase(next_task);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -46,7 +46,7 @@ private:
|
|||||||
std::condition_variable cond_var;
|
std::condition_variable cond_var;
|
||||||
|
|
||||||
// Function to execute when a task's endTime is reached
|
// Function to execute when a task's endTime is reached
|
||||||
void cancelTask(QueryToTrack task, CancelReason reason);
|
void cancelTask(QueryToTrack task);
|
||||||
bool removeQueryFromSet(std::shared_ptr<QueryStatus> query);
|
bool removeQueryFromSet(std::shared_ptr<QueryStatus> query);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -498,28 +498,26 @@ CancellationCode QueryStatus::cancelQuery(CancelReason reason, std::exception_pt
|
|||||||
return CancellationCode::CancelSent;
|
return CancellationCode::CancelSent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryStatus::throwProperExceptionIfNeeded(const UInt64 & max_execution_time, const UInt64 & elapsed_ns) const
|
void QueryStatus::throwProperExceptionIfNeeded(const UInt64 & max_execution_time, const UInt64 & elapsed_ns)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(cancel_mutex);
|
std::lock_guard<std::mutex> lock(cancel_mutex);
|
||||||
if (is_killed)
|
if (is_killed)
|
||||||
{
|
{
|
||||||
throwProperException(max_execution_time, elapsed_ns);
|
String additional_error_part;
|
||||||
|
if (!elapsed_ns)
|
||||||
|
additional_error_part = fmt::format("elapsed {} ms, ", static_cast<double>(elapsed_ns) / 1000000000ULL);
|
||||||
|
|
||||||
|
if (cancel_reason == CancelReason::TIMEOUT)
|
||||||
|
{
|
||||||
|
cancel_reason = CancelReason::UNDEFINED; // We can assign only CancelReason::TIMEOUT to cancel_reason, so we need to assign it back to UNDEFINED
|
||||||
|
throw Exception(ErrorCodes::TIMEOUT_EXCEEDED, "Timeout exceeded: {}maximum: {} ms", additional_error_part, max_execution_time / 1000.0);
|
||||||
|
}
|
||||||
|
throwQueryWasCancelled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryStatus::throwProperException(const UInt64 & max_execution_time, const UInt64 & elapsed_ns) const
|
|
||||||
{
|
|
||||||
String additional_error_part;
|
|
||||||
if (!elapsed_ns)
|
|
||||||
additional_error_part = fmt::format("elapsed {} ms,", static_cast<double>(elapsed_ns) / 1000000000ULL);
|
|
||||||
|
|
||||||
if (cancel_reason == CancelReason::TIMEOUT)
|
|
||||||
throw Exception(ErrorCodes::TIMEOUT_EXCEEDED, "Timeout exceeded: {} maximum: {} ms", additional_error_part, max_execution_time / 1000.0);
|
|
||||||
throwQueryWasCancelled();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QueryStatus::addPipelineExecutor(PipelineExecutor * e)
|
void QueryStatus::addPipelineExecutor(PipelineExecutor * e)
|
||||||
{
|
{
|
||||||
/// In case of asynchronous distributed queries it is possible to call
|
/// In case of asynchronous distributed queries it is possible to call
|
||||||
|
@ -240,8 +240,7 @@ public:
|
|||||||
|
|
||||||
QueryStatusInfo getInfo(bool get_thread_list = false, bool get_profile_events = false, bool get_settings = false) const;
|
QueryStatusInfo getInfo(bool get_thread_list = false, bool get_profile_events = false, bool get_settings = false) const;
|
||||||
|
|
||||||
void throwProperExceptionIfNeeded(const UInt64 & max_execution_time, const UInt64 & elapsed_ns = 0) const;
|
void throwProperExceptionIfNeeded(const UInt64 & max_execution_time, const UInt64 & elapsed_ns = 0);
|
||||||
[[noreturn]] void throwProperException(const UInt64 & max_execution_time, const UInt64 & elapsed_ns = 0) const;
|
|
||||||
|
|
||||||
/// Cancels the current query.
|
/// Cancels the current query.
|
||||||
/// Optional argument `exception` allows to set an exception which checkTimeLimit() will throw instead of "QUERY_WAS_CANCELLED".
|
/// Optional argument `exception` allows to set an exception which checkTimeLimit() will throw instead of "QUERY_WAS_CANCELLED".
|
||||||
|
Loading…
Reference in New Issue
Block a user