Repository navigation
Fix flaky cancel_insert_when_client_dies tests on fast builds - #111157
PedroTadim merged 2 commits into
Conversation
thread_cancel took a single /proc snapshot per loop then slept 3x sleep 0.$RANDOM (~1s), so it sampled for an in-flight insert only about once per second. On fast release/binary builds an insert finishes well under a second, so the sampler repeatedly lands between inserts, nothing gets cancelled in the 40s window, and the "did we cancel anything" guard returns 0. Poll at 10ms until an insert client is in flight, then kill it at once. The assertion, the SIGINT/SIGKILL mix, the row counts, and the tags are unchanged. The helper is identical across the three native cancel-insert tests and all three flake on arm_binary, so the same fix is applied to 02434, 04365 and 04366. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Internal second-model review — adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding; bounded: 1 full pass + 1 fix round + 1 delta recheck).
Severity: ❌ blocker / Session id: cron:clickhouse-author-slot-2:20260720-231200 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-author-slot-2:20260720-231200 |
|
Workflow [PR], commit [37e7705] Summary: ❌
AI ReviewSummaryThis PR replaces the coarse Final VerdictStatus: ✅ Approve |
CI finish ledger - 8a43197Both red checks are pre-existing flaky tests unrelated to this PR's change (this PR only touches
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline. |
b03b21d
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Requested by @ alexey-milovidov on #109261: fix the flaky
04365_cancel_insert_when_client_dies_distributedonStateless tests (arm_binary, parallel)(the line-3
1->0flip). This is a separate PR from the coverage-only stdout fix.thread_canceltook a single/proc/*/cmdlinesnapshot per loop, then slept3x sleep 0.$RANDOM(
0.$RANDOMis lexical, up to 0.9999s; mean of the three ~0.95s), so it sampled for an in-flightinsert only about once per second. On fast release/binary builds a 500000-row insert finishes in
well under a second, so the once-per-second snapshot repeatedly lands between inserts, no insert is
cancelled during the 40s window, no cancellation message is logged, and the guard
select count() > 0 from system.text_logreturns 0 -> the test fails. The server behavior and dataintegrity are correct (the table stays at 500000 rows); only the "did we cancel anything?"
observation is missed.
Fix:
thread_cancelnow polls at 10ms until an insert client is actually in flight, then kills itimmediately (one
sleep 0.$RANDOMretained to keep the signal timing randomized). The assertion,the SIGINT/SIGKILL mix, the row counts, and the tags are unchanged, so the test still requires a
real cancellation to be observed.
The
thread_cancelhelper is identical across the three native-protocol cancel-insert tests andall three flake on arm_binary, so the same fix is applied to each:
02434_cancel_insert_when_client_dies,04365_cancel_insert_when_client_dies_distributed,04366_cancel_insert_when_client_dies_insert_select.Note: #108864 separately adds a
no-llvm-coveragetag to02434for an unrelated coveragestdout-pollution issue; it touches only the tags line, so it does not overlap this change.
Reproduced both directions locally by extracting the actual
thread_cancelfrom the file andrunning it against fast inserts (sub-10ms in-flight window): the current version flips ~38% of
runs, the polling version is stable (30/30). The tests are
no-random-settingsand run only onrelease/binary builds, so a
--random-settingssweep does not apply.CI report for the arm_binary failure on #109261:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109261&sha=e532419f9209dd0e350462cfcc698dcbe4c1f31d&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29
Workflow [PR]
Sync PR [sync-upstream/pr/111157]