Repository navigation
Fix flaky 04604_parallel_replicas_unsent_query_not_cancelled on instrumented builds - #121874
Conversation
04604_parallel_replicas_unsent_query_not_cancelled fails only on the amd_llvm_coverage lanes: 29 times on master over 30 days, every one of them on a coverage lane (22/1174 = 1.87% on the plain 3/3 lane, 4/1179 on AsyncInsert+s3, 3/390 on s3+DBReplicated), against 0 of ~15000 runs on every non-coverage lane. 28 of the 29 are currently hidden as OK because the diagnostics rerun relabels them flaky. The discriminator is the instrumented binary, not the Replicated database and not s3: 22 of the 29 ran with no Replicated database at all. It is not a cancellation bug. Measured from the failing job's own artifacts, the follower receives and honours the Cancel 11 ms after its query starts, at its first cancellation checkpoint, and throws QUERY_WAS_CANCELLED_BY_CLIENT. It then spends 4.17 more seconds resolving that exception's text stack trace in logExceptionBeforeStart, and its system.processes row is released only when that finishes; trace_log caught the thread 8 of 8 times in the gap on a byte-identical 17-frame DWARF lookup stack, with both the real and the CPU timer firing at full rate. Since code 735 sets log_error = false, the only thing that can demand the trace is query_log_will_read, and log_queries is forced to 1 by the CI config, so the whole 4.17 s exists to populate system.query_log.stack_trace for a query that was cancelled on purpose. The cost is intermittent because StackTrace::toString is cached per process on the frame triple: over all 4510 ExceptionBeforeStart rows of that job the post-throw cost is p50 1 ms, p90 72 ms, p99 2202 ms, max 4533 ms. The test polls system.processes for ~3.4 s, so it reports a parked replica that was in fact cancelled 4.1 s earlier. Turn the symbolization off for the measured query. calculate_text_stack_trace is the documented lever for exactly this cost and is already used this way by five tests in the suite, so no new setting appears. The poll budget, receive_timeout, the assertion and the reference are all untouched, which keeps the test's discriminating power intact and leaves a ~300x margin over the 11 ms the cancellation actually needs. Raising the timeout was rejected because it widens a margin instead of removing the cause and would make a genuine regression cost ~60 s; a retry was rejected because it can mask a real cancellation gap; and no-replicated-database was rejected because it would claim a mechanism the measurements refute. The setting reaches the follower through the per-replica context copy (updateContextForParallelReplicas -> Context::createCopy) and is not in initiator_only_setting_names, so nothing strips it. Verified on one binary: the follower's query_log row carries a 7199-byte stack_trace without this change and an empty one with it, while recording calculate_text_stack_trace = 0 on its own row. Sensitivity was checked against a genuinely parked follower using the parallel_replicas_delay_announcement failpoint, where the changed test still reports "FAIL: 1 replica(s) still running" 16 times out of 20 versus 14 out of 20 for the unchanged test. 100 of 100 local runs green, 50 randomized and 50 not. One consequence worth knowing: system.query_log.stack_trace is now empty for this test's queries. No assertion depends on it, and a regression is still identified by the reference diff and the server log. Related: ClickHouse#113551 CI report: https://github.com/ClickHouse/ClickHouse/actions/runs/35917766208/job/107380811116 Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 gate findings) plus my own cold
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-10:20260924-010800 |
|
Workflow [PR], commit [88889a5] Summary: ✅ AI ReviewSummaryThis PR narrows Final Verdict✅ Approve. No new inline findings to post. |
b014c16
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
04604_parallel_replicas_unsent_query_not_cancellednow asks the server not to build a text stack trace for the replica query it deliberately cancels.Description
04604_parallel_replicas_unsent_query_not_cancelledfails only on the coverage lanes: 29 timeson master in 30 days, all on
amd_llvm_coverage(1.87 % on3/3), versus 0 of ~15 000 runselsewhere; 28 are hidden as
OKby theflakyrelabelling. Failing job:https://github.com/ClickHouse/ClickHouse/actions/runs/35917766208/job/107380811116
Not a cancellation bug. From that job's own artifacts: the follower receives and honours the
Cancel11 ms after starting and throwsQUERY_WAS_CANCELLED_BY_CLIENT. It then spends4.17 more seconds symbolizing that exception's text stack trace (
trace_logcaught thethread 8/8 times there on one DWARF-lookup stack), and its
system.processesrow is releasedonly when that finishes. The test polls for ~3.4 s, so it reports a parked replica that was
cancelled 4.1 s earlier. That trace is computed only because
system.query_logis configured,and is intermittent because the trace cache is per process (p50 1 ms, p99 2.2 s over that job's
4510
ExceptionBeforeStartrows).So the test now sets
calculate_text_stack_trace = 0, the setting already documented for exactlythis cost; #121512 made the same trade in two other tests last week. The poll budget,
receive_timeout, the assertion and the reference are untouched, so nothing is relaxed; themargin becomes ~300x. I did not raise the timeout or add a retry: either would hide a real
cancellation gap.
Validation: on one binary the follower's
stack_tracegoes from 7199 bytes to empty, which alsoproves the setting reaches the replica; with a failpoint that genuinely parks a follower it still
fails with the original signature (16/20 vs 14/20 unchanged); 100/100 green locally.
A query stays in
system.processeswhile its exception trace is resolved. That is milliseconds ona normal build, so I have not touched the shared path.
stack_traceis now empty for this test'squeries, and a regression's log line loses its trace too; no assertion reads either.
Workflow [PR]
Sync PR [sync-upstream/pr/121874]
Version info
26.10.1.604-master(included in26.10and later)