Add some comments about racy code for system.stack_trace

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
Azat Khuzhin 2023-12-23 13:42:26 +01:00
parent d29762f19f
commit ac542199c5

View File

@ -296,6 +296,7 @@ protected:
const auto & thread_ids_data = assert_cast<const ColumnUInt64 &>(*thread_ids).getData(); const auto & thread_ids_data = assert_cast<const ColumnUInt64 &>(*thread_ids).getData();
/// NOTE: This is racy, so you may get incorrect thread_name.
ThreadIdToName thread_names; ThreadIdToName thread_names;
if (read_thread_names) if (read_thread_names)
thread_names = getFilteredThreadNames(query, context, thread_ids_data, log); thread_names = getFilteredThreadNames(query, context, thread_ids_data, log);
@ -322,6 +323,13 @@ protected:
} }
else else
{ {
/// NOTE: This check is racy (thread can be
/// destroyed/replaced/...), but it is OK, since only the
/// following could happen:
/// - it will incorrectly detect that the signal is blocked and
/// will not send it this time
/// - it will incorrectly detect that the signal is not blocked
/// then it will wait storage_system_stack_trace_pipe_read_timeout_ms
bool signal_blocked = isSignalBlocked(tid, STACK_TRACE_SERVICE_SIGNAL); bool signal_blocked = isSignalBlocked(tid, STACK_TRACE_SERVICE_SIGNAL);
if (!signal_blocked) if (!signal_blocked)
{ {