Skip to content

Fix flaky 05219_streaming_queries_part_offset (no per-query time limit) - #123897

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-05219-streaming-part-offset-time-limit
Oct 5, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-05219-streaming-part-offset-time-limit

Conversation

@groeneai

@groeneai groeneai commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #120957
Related: #113737
Related: #122567

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

05219_streaming_queries_part_offset failed on Stateless tests (arm_asan_ubsan, azure, parallel) with Code: 159 ... Timeout exceeded: elapsed 21292.078 ms, maximum: 20000.000 ms on an 8-row INSERT.

Root cause: on that lane MergeTree tables use a write-through filesystem cache, and debug and sanitizer builds randomly run a full cache consistency check (check_cache_probability) that holds the cache priority lock while it stats every entry. The INSERT spent 21.18 of its 21.29 s in FilesystemCachePriorityWriteLockMicroseconds (11 reservations) behind a concurrent query that ran 23 such checks; its Azure uploads took 8 ms. Same stall as 04344 (#122567).

The test's own max_execution_time = 20 asserts nothing: there is no serverError expectation, the reference holds only result values, and STREAM BOUNDED terminates by itself; a real hang still fails on the runner's timeout. So it can only turn a slow but correct run into a failure. Change: remove it, as #113737 did for 04545_streaming_queries_row_policy_multi_partition.

Validation (debug build, write-through local_cache): with the first INSERT's cache write paused for 25 s via file_segment_pause_before_write, the unchanged test fails with Code: 159 every time (3 of 3), the changed one passes and matches the reference (3 of 3). 50/50 randomized runs, 20/20 with the write-through cache as the MergeTree default.

The other failures of this test in the last 30 days are on PRs that change the test randomization themselves (prefer_optimize_projection, forced reverse primary keys). The cost of the cache check on write-through caches is its owners' call.


Workflow [PR]
Sync PR [sync-upstream/pr/123897]

Version info

  • Merged into: 26.10.1.1549-master (included in 26.10 and later)

The test failed on `Stateless tests (arm_asan_ubsan, azure, parallel)` with
`Code: 159 ... Timeout exceeded: elapsed 21292.078 ms, maximum: 20000.000 ms`
on its first 8-row INSERT. On that lane MergeTree tables use a write-through
filesystem cache, and debug/sanitizer builds randomly run
FileCache::assertCacheCorrectness (check_cache_probability), which holds the
cache priority lock while it stats every entry. The INSERT spent 21.18 of its
21.29 s in FilesystemCachePriorityWriteLockMicroseconds (11 reservations)
behind a concurrent query that ran 23 such checks; the Azure uploads took 8 ms.

The session `max_execution_time = 20` is not part of any oracle: the test has no
serverError expectation, the reference holds only result values, and
STREAM BOUNDED terminates by itself, so a real hang still fails on the runner
timeout. Remove it, as ClickHouse#113737 did for
04545_streaming_queries_row_policy_multi_partition.

Validated with file_segment_pause_before_write holding the first INSERT's cache
write for 25 s on a write-through local_cache table: the old test fails with
Code 159 every time, the new one passes and matches the reference. 50/50
randomized runs, 20/20 with the write-through cache as the MergeTree default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 4, 2026
@groeneai

groeneai commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus an independent cold review of the diff (0 blockers, 0 majors).

# Sev Finding Verdict Evidence / action
- - none - Census of streaming and commit-order tests with max_execution_time: 04545 already fixed (#113737), 04619 keeps its cap (it is the oracle), 04040 keeps its 120 s bound on SYSTEM SYNC MERGES.

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-10:20261004-195500

@groeneai

groeneai commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Table on the write-through local_cache policy, SYSTEM ENABLE FAILPOINT file_segment_pause_before_write before the first INSERT, a second session holds the pause for 25 s. The unchanged test fails Code: 159 ... elapsed 25083.081 ms, maximum: 20000.000 ms on the INSERT every time (3 of 3).
b Root cause explained? On the azure lane MergeTree uses a write-through cache; debug/sanitizer builds randomly run a full cache consistency check (check_cache_probability) holding the priority lock while it stats every entry. The failing INSERT spent 21.18 of 21.29 s waiting on that lock (FilesystemCachePriorityWriteLockMicroseconds), Azure writes took 8 ms; the test's own max_execution_time = 20 turned the slow, correct run into Code: 159.
c Fix matches root cause? Yes. The cap is the only element that can fail a correct run and it asserts nothing (no serverError, the reference holds result values, STREAM BOUNDED terminates). Nothing is widened, no tag added, no data reduced. Same as #113737 for 04545.
d Test intent preserved / new tests added? Yes. Every query and the .reference are unchanged; a real hang still fails on the runner's timeout. Test-only change, no new test needed.
e Both directions demonstrated? Yes. Same rig: unchanged test 3 of 3 Code: 159, changed test 3 of 3 pass with output equal to the reference; the 25 s stall is visible in query_log in both arms.
f Fix is general across code paths? Census of streaming / commit-order tests with max_execution_time: 04545 already fixed (#113737), 04619 keeps its cap (it is the oracle), 04040 keeps its 120 s bound on SYSTEM SYNC MERGES.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only). 50/50 randomized runs and 20/20 with the write-through cache as the MergeTree default.
h Backward compatible? (maintainer-approved exception only) N/A (test-only; no setting, format or default changes).
i Invariants and contracts preserved? Yes. The test's assertions are untouched; the session SET stays valid.

Session id: cron:clickhouse-impl-slot-7:20261004-193600

@clickhouse-gh

clickhouse-gh Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ed489b5]

Summary: ✅


AI Review

Summary

This PR removes the session-level max_execution_time from tests/queries/0_stateless/05219_streaming_queries_part_offset.sql so the test no longer fails a correct run because of unrelated filesystem-cache lock contention on sanitizer/object-storage lanes. I reviewed the current diff, the test oracle, sibling streaming tests, prior PR discussion, and the current green Praktika run; I do not see a correctness or coverage regression in the updated test, and the CI Fix or Improvement changelog category matches the change.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 4, 2026
@groeneai
groeneai requested a review from Michicosun October 4, 2026 20:20
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 4, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 5, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 5, 2026
Merged via the queue into ClickHouse:master with commit 662c216 Oct 5, 2026
149 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 5, 2026
kute1654 pushed a commit to kute1654/ClickHouse that referenced this pull request Oct 8, 2026
…for_async_insert=0 poll

Case 4 inserts with `async_insert=1&wait_for_async_insert=0` and then polled
`count()` 20 times (about 19 s on the arm_asan_ubsan azure lane) before printing
the rows. `wait_for_async_insert=0` gives no visibility deadline, and on ClickHouse#119181
the background flush took 27.4 s, 27.1 s of it waiting for the filesystem cache
priority lock while writing a 2-row part to the write-through `cached_azure` disk
(Azure writes took 5 ms). The rows landed 8 s after the final SELECT, so the
reference diff was caused only by the 20-iteration cap.

Loop until the rows land instead. The runner's per-test timeout stays the bound,
so a lost insert still fails. Same remedy as ClickHouse#123897.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-streaming-queries Streaming queries: queries that keep reading a table as data arrives - cursors, subscriptions to ... and removed comp-testing Test content only (no production code). labels Nov 22, 2026
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 comp-streaming-queries Streaming queries: queries that keep reading a table as data arrives - cursors, subscriptions to ... groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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