Merge pull request #48687 from ClickHouse/processor-call-oncancel-once

Call IProcessor::onCancel() once
This commit is contained in:
Alexey Milovidov 2023-04-16 00:25:06 +03:00 committed by GitHub
commit 44f05e3fca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -237,11 +237,12 @@ public:
/// In case if query was cancelled executor will wait till all processors finish their jobs.
/// Generally, there is no reason to check this flag. However, it may be reasonable for long operations (e.g. i/o).
bool isCancelled() const { return is_cancelled; }
bool isCancelled() const { return is_cancelled.load(std::memory_order_acquire); }
void cancel()
{
is_cancelled = true;
onCancel();
bool already_cancelled = is_cancelled.exchange(true, std::memory_order_acq_rel);
if (!already_cancelled)
onCancel();
}
/// Additional method which is called in case if ports were updated while work() method.