diff --git a/src/Processors/IProcessor.h b/src/Processors/IProcessor.h index c9dd7d8d77d..34322acb2af 100644 --- a/src/Processors/IProcessor.h +++ b/src/Processors/IProcessor.h @@ -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.