Repository navigation
Conversation
The hardcoded `timeout_seconds` constant in `SystemLogQueue::waitFlush`
was bumped from 60s to 180s long ago to accommodate parallel functional
tests on slow disks. Heavy parallel CI runners still hit the 180s ceiling
and produce `TIMEOUT_EXCEEDED` exceptions from `SYSTEM FLUSH LOGS`:
Code: 159. DB::Exception: Received from localhost:9000.
DB::Exception: Timeout exceeded (180 s) while flushing system log
'DB::SystemLogQueue<DB::QueryLogElement>'. (TIMEOUT_EXCEEDED)
(query: SYSTEM FLUSH LOGS query_log;)
This is the cause of recurring failures of `02345_implicit_transaction`
(and similar tests using `SYSTEM FLUSH LOGS query_log` on parallel
runners): 23 master hits across 4 distinct PRs in the last 30 days,
spanning `amd_tsan parallel`, `amd_asan_ubsan distributed plan parallel`,
`arm_binary parallel`, `amd_llvm_coverage`, `amd_debug parallel`,
`arm_asan_ubsan azure`, and others.
Bump the limit to 600s for the same reason the previous bump was made:
heavy parallel tests on slow disks can stall flush longer than 180s
without anything actually going wrong. Update the comment to reflect
the latest tune-up rationale.
This is the third test in the bundle requested by @rschu1ze in ClickHouse#104648.
Companion PRs: ClickHouse#105474 (02435) and ClickHouse#105457 (01563).
Pre-PR validation gateSession: cron:clickhouse-ci-task-worker:20260521-020000 a) Deterministic repro? Not reproducible locally — the failure only occurs on heavily loaded parallel CI runners where multiple parallel tests saturate disk I/O. The mechanism is well understood from the previous 60s -> 180s bump (commit history of b) Root cause explained?
c) Fix matches root cause? Yes. The root cause is that the upper bound on a bursty wait is too low for one specific deployment scenario (parallel CI), and the value is hardcoded. Raising the hardcoded value gives the wait more headroom while keeping the same "avoid endless waiting" property. The previous 60s -> 180s bump was made for exactly the same reason, by the same kind of fix. Promoting this to a server setting (option B in the worker plan) is a strictly larger change and was rejected as premature; if 600s also turns out to be insufficient, the next step is to introduce a setting. d) Test intent preserved? / new tests?
e) Demonstrated in both directions? Strictly, no — the failure cannot be reliably reproduced on this hardware. What I did verify locally:
f) Fix is general? The change covers all |
|
cc @rschu1ze @azat @alesapin — could you review this? This is the third of the three flaky-test fixes you asked for in #104648 ( One-line server-side change to |
|
Workflow [PR], commit [98b907f] Summary: ✅ AI ReviewSummaryThis PR changes Final VerdictStatus: ✅ Approve |
`SignalHandlers.cpp` gives the fatal-signal handler a hard ~303s wall before it re-raises the signal and lets the default handler kill the process. `SystemLogs::handleCrash` walks every system log queue in sequence and `crash_log` is flushed first because it carries the diagnostics we most want on disk. Bumping the shared `waitFlush` timeout to 600s lets a single stuck queue (for example `query_log` under a clogged disk) eat the entire crash budget before `crash_log` finishes draining, so the kernel SIGKILLs the process with the diagnostics half-written. Split the timeout: keep 600s as the default for the user-triggered `SYSTEM FLUSH LOGS` path (which originally needed the bump for heavy parallel CI runners), and force the crash path to 60s so each queue fails fast and the rest of the chain still gets a fair share of the 303s budget.
|
Thanks @clickhouse-gh for catching the crash-budget concern. Pushed
Verified locally: Only two call sites in the codebase, both updated. PTAL. |
Algunenano
left a comment
There was a problem hiding this comment.
@groeneai This not the proper way to address this problem. Bumping the flush times won't fix the problems, and will only need to more unrelated timeouts. If we need to optimize the process (like we've done several times in the past) then we need to profile and optimize
LLVM Coverage Report
Changed lines: 50.00% (2/4) | lost baseline coverage: 1 line(s) · Uncovered code |
Stateless jobs on amd_llvm_coverage lose whole runs to `Timeout exceeded (180 s) while flushing system log 'DB::SystemLogQueue<DB::TraceLogElement>'`. Six different tests died on this signature inside a single coverage job run on 2026-09-05, so it is a job-wide trace_log drain stall rather than a property of any one test. trace_log.symbolize defaults to true, and in-flush symbolization (SymbolIndex::findSymbol + tryDemangle + AddressToLineCache::get, per frame in TraceLogElement::appendToBlock) is what the single flusher thread spends the hardcoded 180 s of SystemLogQueue::waitFlush on. ClickHouse#100242 already fixed that by shipping tests/config/config.d/trace_log_no_symbolize.xml, but its gate probes CXX_FLAGS LIKE '%-DSANITIZER%' and the else arm removes the file again. A coverage build is configured -DSANITIZE= ... -DWITH_COVERAGE=ON, so it carries no -DSANITIZER: coverage was the one stateless flavour left symbolizing at full cost. Probe the dedicated WITH_COVERAGE row of system.build_options instead. Plain -DWITH_COVERAGE never reaches CXX_FLAGS (cmake/sanitize.cmake adds it only under WITH_COVERAGE_DEPTH; the coverage compile flags are applied per-directory), which is why build_option_flag cannot be reused and why tests/clickhouse-test keys off the same row. The new helper keeps the fail-closed contract of its neighbour: a renamed or missing row aborts the install rather than reading as "not a coverage build", and every probe is resolved before any file is touched, so a failing probe cannot leave a half-adjusted config directory. Measured on a debug build, a fresh server per arm (AddressToLineCache is a process-wide static, so a warmed process understates the cost) and an identical workload, timing the first SYSTEM FLUSH LOGS trace_log: 0.35 s with symbolize=false, 0 of 13226 rows symbolized, versus 3.12 s with symbolize=true, 13388 of 13388 symbolized. That is 8.9x, i.e. symbolization is ~89% of flush cost; ClickHouse#100242 measured up to 2.5 minutes for ~180k entries on an instrumented build. This removes the dominant per-row cost without making the 180 s budget unconditional, and deliberately does not touch that constant: raising it is the shape ClickHouse#105484 was closed for. The tests that assert a non-empty symbols or lines column (03150_trace_log_add_build_id, 03150_trace_log_source_lines) already carry no-llvm-coverage, and 00974_query_profiler resolves symbols on read, so nothing regresses; the comments naming the affected flavours are updated to match. One consumer did not resolve on read: the MemoryAllocatedWithoutCheck advisory in tests/clickhouse-test suggests a diagnostic query grouped by the symbols column. Those rows reach trace_log through MemoryTracker -> TraceSender -> TraceCollector, which stamps every row with the config's symbolize value, so the suggested query has collapsed every stack into a single empty bucket on all sanitizer builds since 2026-05-08. It now resolves symbols on read with addressToSymbol, which repairs the guidance for both flavours. Co-Authored-By: Claude Opus 5 <[email protected]>
Bump the hardcoded
timeout_secondsinSystemLogQueue::waitFlushfrom 180s to 600s.The previous bump (60s -> 180s) is no longer sufficient on heavily loaded parallel CI runners.
SYSTEM FLUSH LOGS query_logperiodically throws:CIDB shows 23 master hits across 4 distinct PRs in the last 30 days for
02345_implicit_transactionalone, spanningamd_tsan parallel,amd_asan_ubsan distributed plan parallel,arm_binary parallel,amd_llvm_coverage,amd_debug parallel,arm_asan_ubsan azure, and others. The common factor isparallelrunners with heavyquery_logbacklog, not a specific sanitizer or storage backend.The throw is server-side from
SystemLogQueue::waitFlushand is not influenced by clientreceive_timeout. So bumping the server-side constant is the only way to give the flush more headroom under load. Updated the comment to reflect the latest tune-up rationale.This is the third test in the bundle requested by @rschu1ze in #104648. Companion PRs:
02435_rollback_cancelled_queries(LSan leak check skip)01563_distributed_query_finish(CI log-sender bursts)Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes