mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-11 18:14:03 +00:00
Don't drop all traces if frequency is too high
This commit is contained in:
parent
796dfeb44e
commit
f031d064b6
@ -47,11 +47,17 @@ namespace
|
|||||||
/// Thus upper bound on query_id length should be introduced to avoid buffer overflow in signal handler.
|
/// Thus upper bound on query_id length should be introduced to avoid buffer overflow in signal handler.
|
||||||
constexpr size_t QUERY_ID_MAX_LEN = 1024;
|
constexpr size_t QUERY_ID_MAX_LEN = 1024;
|
||||||
|
|
||||||
|
thread_local size_t write_trace_iteration = 0;
|
||||||
|
|
||||||
void writeTraceInfo(TimerType timer_type, int /* sig */, siginfo_t * info, void * context)
|
void writeTraceInfo(TimerType timer_type, int /* sig */, siginfo_t * info, void * context)
|
||||||
{
|
{
|
||||||
/// Quickly drop if signal handler is called too frequently.
|
/// Quickly drop if signal handler is called too frequently.
|
||||||
/// Otherwise we may end up infinitelly processing signals instead of doing any useful work.
|
/// Otherwise we may end up infinitelly processing signals instead of doing any useful work.
|
||||||
if (info && info->si_overrun > 0)
|
++write_trace_iteration;
|
||||||
|
if (info
|
||||||
|
&& info->si_overrun > 0
|
||||||
|
/// But pass with some frequency to avoid drop of all traces.
|
||||||
|
&& write_trace_iteration % info->si_overrun != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
constexpr size_t buf_size = sizeof(char) + // TraceCollector stop flag
|
constexpr size_t buf_size = sizeof(char) + // TraceCollector stop flag
|
||||||
|
Loading…
Reference in New Issue
Block a user