blob: 65714295be42f9209dde85d9e7fb7854d5793e9d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#pragma once
#include <Interpreters/SystemLog.h>
#include <Core/NamesAndTypes.h>
#include <Core/NamesAndAliases.h>
#include <Core/Field.h>
/// Call this function on crash.
void collectCrashLog(Int32 signal, UInt64 thread_id, const String & query_id, const StackTrace & stack_trace);
namespace DB
{
/** Information about fatal errors that lead to crash.
* Before crash we are writing info into system table for further analysis.
*/
struct CrashLogElement
{
time_t event_time{};
UInt64 timestamp_ns{};
Int32 signal{};
UInt64 thread_id{};
String query_id;
Array trace;
Array trace_full;
static std::string name() { return "CrashLog"; }
static NamesAndTypesList getNamesAndTypes();
static NamesAndAliases getNamesAndAliases() { return {}; }
void appendToBlock(MutableColumns & columns) const;
static const char * getCustomColumnList() { return nullptr; }
};
class CrashLog : public SystemLog<CrashLogElement>
{
using SystemLog<CrashLogElement>::SystemLog;
friend void ::collectCrashLog(Int32, UInt64, const String &, const StackTrace &);
static std::weak_ptr<CrashLog> crash_log;
public:
static void initialize(std::shared_ptr<CrashLog> crash_log_)
{
crash_log = crash_log_;
}
static consteval size_t getDefaultMaxSize() { return 1024; }
static consteval size_t getDefaultReservedSize() { return 1024; }
static consteval size_t getDefaultFlushIntervalMilliseconds() { return 1000; }
static consteval size_t shouldNotifyFlushOnCrash() { return true; }
};
}
|