Merge branch 'master' into tavplubix-patch-1

This commit is contained in:
Alexander Tokmakov 2022-07-14 18:20:22 +03:00 committed by GitHub
commit c8ae75da19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

View File

@ -206,10 +206,12 @@ namespace
filtered_thread_names.emplace(thread_name);
}
for (const auto & [tid, name] : tid_to_name)
for (auto it = tid_to_name.begin(); it != tid_to_name.end();)
{
if (!filtered_thread_names.contains(name))
tid_to_name.erase(tid);
if (!filtered_thread_names.contains(it->second))
it = tid_to_name.erase(it);
else
++it;
}
return tid_to_name;
@ -302,8 +304,13 @@ Pipe StorageSystemStackTrace::read(
size_t res_index = 0;
String thread_name;
if (auto it = thread_names.find(tid); it != thread_names.end())
thread_name = it->second;
if (read_thread_names)
{
if (auto it = thread_names.find(tid); it != thread_names.end())
thread_name = it->second;
else
continue; /// was filtered out by "thread_name" condition
}
if (!send_signal)
{

View File

@ -13,3 +13,6 @@ SELECT length(query_id) > 0 FROM system.stack_trace WHERE query_id != '' LIMIT 1
-- optimization for thread_name
SELECT length(thread_name) > 0 FROM system.stack_trace WHERE thread_name != '' LIMIT 1;
1
-- enough rows (optimizations works "correctly")
SELECT count() > 100 FROM system.stack_trace;
1

View File

@ -10,3 +10,5 @@ SELECT length(trace) > 0 FROM system.stack_trace LIMIT 1;
SELECT length(query_id) > 0 FROM system.stack_trace WHERE query_id != '' LIMIT 1;
-- optimization for thread_name
SELECT length(thread_name) > 0 FROM system.stack_trace WHERE thread_name != '' LIMIT 1;
-- enough rows (optimizations works "correctly")
SELECT count() > 100 FROM system.stack_trace;