Skip to content

Fix flaky test 04312_client_chime_on_slow_query_92718 - #109001

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-flaky-04312-chime-throwif-eval-order
Jul 1, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-flaky-04312-chime-throwif-eval-order

Conversation

@groeneai

@groeneai groeneai commented Jun 30, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Description

Fixes flaky 04312_client_chime_on_slow_query_92718 (seen on Stateless tests (amd_tsan, parallel, 1/2) and (arm_asan_ubsan, azure, parallel)).

Cases 4 and 11 ran SELECT sleep(1.5), throwIf(1 = 1, 'expected error') as two sibling projection columns. Their evaluation order is unspecified, so throwIf could fire before sleep ran: the query then errored at ~0s elapsed, below the --chime 1 threshold, and no BEL was emitted. Case 11 (pty) intermittently printed no BEL instead of the expected BEL while the 'expected error' message was still present, which is exactly the diff signature seen in CI. Thread-fuzzer / sanitizer slowdown widens the race window, so it surfaced mostly under tsan/asan.

The fix nests sleep inside throwIf's argument: SELECT throwIf(sleep(1.5) = 0, 'expected error'). sleep(1.5) returns 0, so the predicate is true and throwIf still throws 'expected error', but only after the 1.5s sleep has run. Elapsed time is therefore always >= 1.5s and the chime fires deterministically.

Verified locally with a --chime-capable build (clickhouse-local exercises the same ClientBase chime path): the new form emits BEL 25/25 under a pty, wall time is always ~1.85s, and --chime 10 still emits no BEL (the threshold gate, hence the test's ability to catch a threshold regression, is unchanged).

Version info

  • Merged into: 26.7.1.321 (included in 26.7 and later)

Cases 4 and 11 ran 'SELECT sleep(1.5), throwIf(1 = 1, ...)' as two sibling
projection columns. Their evaluation order is unspecified, so throwIf could
fire before sleep ran: the query then errored at ~0s elapsed, below the
--chime 1 threshold, and no BEL was emitted. Case 11 (pty) intermittently
printed 'no BEL' instead of the expected 'BEL'; the error message was still
present, which is the signature seen in CI (amd_tsan, arm_asan_ubsan), where
thread-fuzzer slowdown widens the race window.

Nest sleep inside throwIf's argument: 'SELECT throwIf(sleep(1.5) = 0, ...)'.
sleep(1.5) returns 0, so the predicate is true and throwIf still throws
'expected error', but only after the 1.5s sleep has run. Elapsed time is
therefore always >= 1.5s and the chime fires deterministically. The threshold
gate is unchanged (verified: --chime 10 still emits no BEL), so the test still
catches a threshold regression.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @azat — flaky-test fix: cases 4/11 ran sleep(1.5), throwIf(1=1,...) as sibling columns with unspecified eval order, so throwIf could fire at ~0s elapsed (below the chime threshold) and case 11 intermittently lost the BEL under tsan/asan. Nesting as throwIf(sleep(1.5)=0,...) forces sleep first, so elapsed is always >= 1.5s and the chime is deterministic; the threshold gate is unchanged.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The failure mode is throwIf evaluating before sleep (sibling projection columns, unspecified order), so the query errors at ~0s elapsed < the --chime 1 threshold and no BEL is emitted while 'expected error' is still present. This is the exact CI diff (only case 11 differs: expected BEL, got no BEL) on 3 of 4 hits. The race is timing-dependent (widened by tsan/asan thread-fuzzer slowdown), so the trigger is the unordered evaluation, not a randomized setting.
b Root cause explained? sleep(1.5) and throwIf(1=1,...) are independent projection columns; the executor may evaluate throwIf first. When it does, the exception is thrown at ~0s, progress_indication.elapsedSeconds() is below the 1s threshold (ClientBase.cpp:2677-2683), and the chime is suppressed even though the query ran on a TTY. Both sleep and throwIf have isSuitableForConstantFolding()=false, so they execute at runtime, not during analysis.
c Fix matches root cause? Yes. Nesting sleep inside throwIf's argument — throwIf(sleep(1.5) = 0, 'expected error') — creates a data dependency: throwIf's condition needs sleep(1.5)'s result, so sleep must complete first. Elapsed is always >= 1.5s; the chime fires deterministically. This directly removes the unordered-evaluation mechanism from (b), not a symptom.
d Test intent preserved? Yes. The query still ends in an error (sleep(1.5) returns 0 → predicate true → throwIf throws 'expected error'), so the case-4/case-11 rc != 0 + grep 'expected error' gates still fire. The chime threshold gate is preserved: verified --chime 10 on the new form emits no BEL (the test still catches a threshold regression). .reference is unchanged.
e Both directions demonstrated? Old form's race confirmed from CI data (3 hits = case-11 no BEL with error present). New form verified locally with a --chime-capable build: 25/25 BEL under a pty with --chime 1, wall time always ~1.85s, 0 missing-error; and 0/5 BEL with --chime 10 (threshold respected).
f Fix is general across code paths? Applied to BOTH affected cases (case 4 non-TTY and case 11 pty) which shared the identical racy query. No other case uses the sibling-column pattern. N/A for source code (test-only change).
g Fix generalizes across inputs? N/A (test-only change, not a code bug).
h Backward compatible? N/A (test-only change, not a code bug).
i Invariants and contracts preserved? N/A (test-only change, not a code bug).

Session id: cron:clickhouse-worker-slot-7:20260630-225600

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 30, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2f86126]

Summary: ✅


AI Review

Summary
  • This PR fixes the flaky 04312_client_chime_on_slow_query_92718 stateless test by replacing the racy sibling projection sleep, throwIf pattern with a data dependency inside throwIf. The changed expression still exercises the slow error path, still fails with the expected message, and removes the unspecified evaluation order that could skip the elapsed-time threshold before the BEL check. I found no blocking or major issues.
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 30, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.69% 85.70% +0.01%
Functions 91.45% 91.46% +0.00%
Branches 78.32% 78.36% +0.04%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 112 line(s), 28 function(s) across 30 file(s) · Details

Top files
  • src/Processors/Formats/Impl/Parquet/Decoding.cpp: 27 line(s)
  • src/Functions/FunctionsNumericIndexedVector.h: 15 line(s), 4 function(s)
  • src/Columns/ColumnObject.cpp: 5 line(s)
  • src/Functions/catboostEvaluate.cpp: 4 line(s)
  • src/Functions/h3ExactEdgeLengthRads.cpp: 4 line(s)

Full report

@groeneai

groeneai commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 2f86126

CI fully finished (Finish Workflow = success). All checks green; no failures.

Check / test Reason Owner / fixing PR
(all 64 checks) passed n/a - no failures

Our test 04312_client_chime_on_slow_query_92718 passes on every lane (amd_debug, amd_tsan, amd_msan, arm, and all four flaky-check runs OK 5/5). No PR-caused failures.

Session id: cron:our-pr-ci-monitor:20260701-033000

@alexey-milovidov alexey-milovidov self-assigned this Jul 1, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 1, 2026
Merged via the queue into ClickHouse:master with commit c54f2be Jul 1, 2026
174 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 1, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-04312-chime-throwif-eval-order

Fix flaky test 04312_client_chime_on_slow_query_92718
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants