mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
Avoid SentryWriter deps for Exception
$ ninja unit_tests_dbms FAILED: src/unit_tests_dbms : && /usr/bin/clang++ --target=x86_64-linux-gnu --sysroot=/src/ch/clickhouse/cmake/linux/../../contrib/sysroot/linux-x86_64/x86_64-linux-gnu/libc --gcc-toolchain=/src/ch/clickhouse/cmake/linux/../../contrib/sysroot/linux-x86_64 -fdiagnostics-color=always -Xclang -fuse-ctor-homing -Wno-enum-constexpr-conversion -fsized-deallocation -gdwarf-aranges -pipe -mssse3 -msse4.1 -msse4.2 -mpclmul -mpopcnt -fasynchronous-unwind-tables -falign-functions=32 -mbranches-within-32B-boundaries -ffp-contract=off -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdiagnostics-absolute-paths -fstrict-vtable-pointers -Wall -Wextra -Wframe-larger-than=65536 -Weverything -Wpedantic -Wno-zero-length-array -Wno-c++98-compat-pedantic -Wno-c++98-compat -Wno-c++20-compat -Wno-sign-conversion -Wno-implicit-int-conversion -Wno-implicit-int-float-conversion -Wno-ctad-maybe-unsupported -Wno-disabled-macro-expansion -Wno-documentation-unknown-command -Wno-double-promotion -Wno-exit-time-destructors -Wno-float-equal -Wno-global-constructors -Wno-missing-prototypes -Wno-missing-variable-declarations -Wno-padded -Wno-switch-enum -Wno-undefined-func-template -Wno-unused-template -Wno-vla -Wno-weak-template-vtables -Wno-weak-vtables -Wno-thread-safety-negative -Wno-enum-constexpr-conversion -Wno-unsafe-buffer-usage -Wno-switch-default -O2 -g -DNDEBUG -O3 -g -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-pie --gcc-toolchain=/src/ch/clickhouse/cmake/linux/../../contrib/sysroot/linux-x86_64 --ld-path=/usr/bin/ld.lld -Wl,--no-export-dynamic -Wl,--gc-sections -Wl,--gdb-index -Wl,--build-id=sha1 -no-pie -Wl,-no-pie -Xlinker --no-undefined @CMakeFiles/unit_tests_dbms.rsp -o src/unit_tests_dbms && : ld.lld: error: undefined symbol: SentryWriter::getInstance() >>> referenced by Exception.cpp:63 (/src/ch/clickhouse/src/Common/Exception.cpp:63) >>> Exception.cpp.o:(DB::handle_error_code(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, bool, std::__1::vector<void*, std::__1::allocator<void*>> const&)) in archive src/libclickhouse_common_io.a >>> referenced by Exception.cpp:63 (/src/ch/clickhouse/src/Common/Exception.cpp:63) >>> Exception.cpp.o:(DB::Exception::Exception(DB::Exception::MessageMasked const&, int, bool)) in archive src/libclickhouse_common_io.a >>> referenced by Exception.cpp:63 (/src/ch/clickhouse/src/Common/Exception.cpp:63) >>> Exception.cpp.o:(DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool)) in archive src/libclickhouse_common_io.a ld.lld: error: undefined symbol: SentryWriter::onFault(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::array<void*, 45ul> const&, unsigned long, unsigned long) >>> referenced by Exception.cpp:68 (/src/ch/clickhouse/src/Common/Exception.cpp:68) >>> Exception.cpp.o:(DB::handle_error_code(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, bool, std::__1::vector<void*, std::__1::allocator<void*>> const&)) in archive src/libclickhouse_common_io.a >>> referenced by Exception.cpp:68 (/src/ch/clickhouse/src/Common/Exception.cpp:68) >>> Exception.cpp.o:(DB::Exception::Exception(DB::Exception::MessageMasked const&, int, bool)) in archive src/libclickhouse_common_io.a >>> referenced by Exception.cpp:68 (/src/ch/clickhouse/src/Common/Exception.cpp:68) >>> Exception.cpp.o:(DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool)) in archive src/libclickhouse_common_io.a clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed. Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
parent
f854595cd4
commit
81dec9a077
@ -5,7 +5,6 @@
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <base/demangle.h>
|
||||
#include <Common/AtomicLogger.h>
|
||||
#include <Daemon/SentryWriter.h>
|
||||
#include <Common/ErrorCodes.h>
|
||||
#include <Common/Exception.h>
|
||||
#include <Common/LockMemoryExceptionInThread.h>
|
||||
@ -48,28 +47,23 @@ void abortOnFailedAssertion(const String & description)
|
||||
bool terminate_on_any_exception = false;
|
||||
static int terminate_status_code = 128 + SIGABRT;
|
||||
thread_local bool update_error_statistics = true;
|
||||
std::function<void(const std::string & msg, int code, bool remote, const Exception::FramePointers & trace)> Exception::callback = {};
|
||||
|
||||
/// - Aborts the process if error code is LOGICAL_ERROR.
|
||||
/// - Increments error codes statistics.
|
||||
void handle_error_code([[maybe_unused]] const std::string & msg, int code, bool remote, const Exception::FramePointers & trace)
|
||||
void handle_error_code(const std::string & msg, int code, bool remote, const Exception::FramePointers & trace)
|
||||
{
|
||||
// In debug builds and builds with sanitizers, treat LOGICAL_ERROR as an assertion failure.
|
||||
// Log the message before we fail.
|
||||
#ifdef ABORT_ON_LOGICAL_ERROR
|
||||
if (code == ErrorCodes::LOGICAL_ERROR)
|
||||
{
|
||||
// In debug builds and builds with sanitizers, treat LOGICAL_ERROR as an assertion failure.
|
||||
// Log the message before we fail.
|
||||
#ifdef ABORT_ON_LOGICAL_ERROR
|
||||
abortOnFailedAssertion(msg);
|
||||
#else
|
||||
/// In release builds send it to sentry (if it is configured)
|
||||
if (auto * sentry = SentryWriter::getInstance())
|
||||
{
|
||||
SentryWriter::FramePointers frame_pointers;
|
||||
for (size_t i = 0; i < trace.size(); ++i)
|
||||
frame_pointers[i] = trace[i];
|
||||
sentry->onFault(-code, msg, frame_pointers, /* offset= */ 0, trace.size());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Exception::callback)
|
||||
Exception::callback(msg, code, remote, trace);
|
||||
|
||||
if (!update_error_statistics) [[unlikely]]
|
||||
return;
|
||||
|
@ -72,6 +72,8 @@ public:
|
||||
/// Collect call stacks of all previous jobs' schedulings leading to this thread job's execution
|
||||
static thread_local bool enable_job_stack_trace;
|
||||
static thread_local std::vector<StackTrace::FramePointers> thread_frame_pointers;
|
||||
/// Callback for any exception
|
||||
static std::function<void(const std::string & msg, int code, bool remote, const Exception::FramePointers & trace)> callback;
|
||||
|
||||
protected:
|
||||
// used to remove the sensitive information from exceptions if query_masking_rules is configured
|
||||
|
@ -80,6 +80,7 @@ namespace DB
|
||||
extern const int CANNOT_SET_SIGNAL_HANDLER;
|
||||
extern const int CANNOT_SEND_SIGNAL;
|
||||
extern const int SYSTEM_ERROR;
|
||||
extern const int LOGICAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1016,6 +1017,20 @@ extern const char * GIT_HASH;
|
||||
void BaseDaemon::initializeTerminationAndSignalProcessing()
|
||||
{
|
||||
SentryWriter::initializeInstance(config());
|
||||
/// In release builds send it to sentry (if it is configured)
|
||||
if (auto * sentry = SentryWriter::getInstance())
|
||||
{
|
||||
Exception::callback = [sentry](const std::string & msg, int code, bool remote, const Exception::FramePointers & trace)
|
||||
{
|
||||
if (!remote && code == ErrorCodes::LOGICAL_ERROR)
|
||||
{
|
||||
SentryWriter::FramePointers frame_pointers;
|
||||
for (size_t i = 0; i < trace.size(); ++i)
|
||||
frame_pointers[i] = trace[i];
|
||||
sentry->onFault(-code, msg, frame_pointers, /* offset= */ 0, trace.size());
|
||||
}
|
||||
};
|
||||
}
|
||||
std::set_terminate(terminate_handler);
|
||||
|
||||
/// We want to avoid SIGPIPE when working with sockets and pipes, and just handle return value/errno instead.
|
||||
|
Loading…
Reference in New Issue
Block a user