From 11f144f5890984fac18d571fe9f3da6e70039214 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sun, 31 Jan 2021 13:02:35 +0300 Subject: [PATCH] Fix deadlock in system.text_log --- src/Interpreters/SystemLog.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Interpreters/SystemLog.h b/src/Interpreters/SystemLog.h index 6c56565a152..101bc752f43 100644 --- a/src/Interpreters/SystemLog.h +++ b/src/Interpreters/SystemLog.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -229,9 +230,18 @@ void SystemLog::startup() } +static thread_local bool recursive_add_call = false; + template void SystemLog::add(const LogElement & element) { + /// It is possible that the method will be called recursively. + /// Better to drop these events to avoid complications. + if (recursive_add_call) + return; + recursive_add_call = true; + SCOPE_EXIT({ recursive_add_call = false; }); + /// Memory can be allocated while resizing on queue.push_back. /// The size of allocation can be in order of a few megabytes. /// But this should not be accounted for query memory usage.