Add log message when stacktrace cannot be obtained for thread

This is to provide better diagnostics for 01051_system_stack_trace
failure [1].

  [1]: https://clickhouse-test-reports.s3.yandex.net/20881/866dfaec793f764dc9ba167d3ac9f6521b9b3381/functional_stateless_tests_(release,_wide_parts_enabled).html#fail1
This commit is contained in:
Azat Khuzhin 2021-02-20 09:11:42 +03:00
parent 3509fe88d8
commit 7c04f15c80
2 changed files with 10 additions and 0 deletions

View File

@ -16,6 +16,7 @@
#include <Common/PipeFDs.h>
#include <Common/CurrentThread.h>
#include <common/getThreadId.h>
#include <common/logger_useful.h>
namespace DB
@ -150,6 +151,7 @@ namespace
StorageSystemStackTrace::StorageSystemStackTrace(const StorageID & table_id_)
: IStorageSystemOneBlock<StorageSystemStackTrace>(table_id_)
, log(&Poco::Logger::get("StorageSystemStackTrace"))
{
notification_pipe.open();
@ -229,6 +231,8 @@ void StorageSystemStackTrace::fillData(MutableColumns & res_columns, const Conte
}
else
{
LOG_DEBUG(log, "Cannot obtain a stack trace for thread {}", tid);
/// Cannot obtain a stack trace. But create a record in result nevertheless.
res_columns[0]->insert(tid);

View File

@ -6,6 +6,10 @@
#include <ext/shared_ptr_helper.h>
#include <Storages/System/IStorageSystemOneBlock.h>
namespace Poco
{
class Logger;
}
namespace DB
{
@ -30,6 +34,8 @@ protected:
void fillData(MutableColumns & res_columns, const Context & context, const SelectQueryInfo & query_info) const override;
mutable std::mutex mutex;
Poco::Logger * log;
};
}