Skip to content

Fix flaky test 02789_filesystem_cache_alignment under concurrency control - #126391

Merged
alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:fix-02789-filesystem-cache-alignment-concurrency-control
Oct 19, 2026
Merged

alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:fix-02789-filesystem-cache-alignment-concurrency-control

Conversation

@groeneai

@groeneai groeneai commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #125085
Related: #109455

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

02789_filesystem_cache_alignment failed in Stateless tests (arm_asan_ubsan, azure, sequential, 1/2) on #109455: stdout lines 2 and 6 printed FAIL because the read logged only one non-final file segment, while the check needs more than one.

The LIMIT 1 read touches several file segments of b.bin only when it runs with several streams: each stream starts at a different mark range, so at a different 20 MiB aligned offset. Since #125085 an auto max_threads is lowered to the fair share of CPU slots, which also counts background pipelines. In the failing job the read was the only query running, and the server log for the read shows Lower number of threads for query to the fair share of CPU slots 1 (8 requested) followed by Reading approx. 1000000 rows with 1 streams.

The fix sets use_concurrency_control = 0 for that read, so neither its stream count nor its thread spawning depends on what else the server runs. The reference is unchanged.

Validation, with the CI test config and an S3 (MinIO) disk: with concurrent_threads_soft_limit_num = 1 the unfixed test fails 5/5 with the same diff and the same two log lines; the fixed test passes 20/20 there (7-8 streams) and 50/50 on the default config.


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

Version info

  • Merged into: 26.11.1.186-master (included in 26.11 and later)

…trol

The two `all > 1` checks need the `LIMIT 1` read to log more than one
non-final file segment of `b.bin`. With the prefetched pool disabled (as in
CI), each stream of `MergeTreeReadPool` starts at a different mark range, so
the number of logged segments is bounded by the streams and threads that
start reading before the limit closes the query.

Since ClickHouse#125085 an auto `max_threads` is lowered to the fair share of CPU
slots. In the failing job (PR ClickHouse#109455, Stateless tests (arm_asan_ubsan,
azure, sequential, 1/2)) background pipelines held the slots and the read
got `Lower number of threads for query to the fair share of CPU slots 1
(8 requested)` and `Reading approx. 1000000 rows with 1 streams`, so it
read one granule, one segment, and printed FAIL twice.

Disable `use_concurrency_control` for the read: `getEffectiveMaxThreads`
then keeps the auto value and the executor spawns threads without slots.

Validated with the CI test config and a MinIO-backed `s3_disk`: with
`concurrent_threads_soft_limit_num = 1` the unfixed test fails 5/5 with
CI's diff and log lines, the fixed one passes 20/20 there (7-8 streams)
and 50/50 on the default config.

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

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

Pre-publication review by an independent model (engine: codex; 1 finding) plus my own review.

# Sev Finding Verdict Evidence / action
1 ⚠️ The pin does not guarantee 2+ segments: the free-memory limiter can still lower the read to 1 stream, and LIMIT 1 can close the inputs before a second source reads DISAGREE (a) 1 stream needs < 2 GiB free (MemoryTrackerUtils.cpp:148-163); in the failing job every memory lowering left 40-41 threads, and the limiter has been on master since March with no failure of this shape. (b) Even with a slot-gated executor (1 slot), the read logged 6-7 full segments in 20/20 runs; with the fix 5-7 in 20/20. A read without early cancellation would drop the background-completion coverage the test exists for.
2 💡 Why use_concurrency_control and not use_concurrency_control_for_max_threads, as in a185638 and #125715 DISAGREE Those tests check the plan shape; this one needs executor threads to start several sources, and thread spawning is also slot-gated.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261017-015000

@clickhouse-gh

clickhouse-gh Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [318e8e5]

Summary: ✅


AI Review

Summary

Disables use_concurrency_control for the LIMIT 1 read in 02789_filesystem_cache_alignment, bypassing CPU-slot limits on both planning and execution while preserving the cache-alignment assertions. No actionable findings after reviewing the diff, surrounding code, and all prior discussion. The reported before/after repetitions support this targeted CI fix.

Missing context / blind spots
  • ⚠️ No local runtime verification: this checkout has no ClickHouse binary. The current-head CI report did not expose a result for this test; repeated validation is author-reported in the PR description.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 17, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @kssenii, could you review this? The LIMIT 1 read in 02789_filesystem_cache_alignment got one stream from the CPU-slot fair share (#125085) and so logged one non-final segment; the test now disables use_concurrency_control for that read and keeps the background-completion checks unchanged.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 17, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 17, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 18, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 18, 2026
Merged via the queue into ClickHouse:master with commit 0a3c817 Oct 19, 2026
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 19, 2026
@clickhouse-gh clickhouse-gh Bot added comp-filesystem-cache Filesystem cache for remote/object storage, page cache, and read caching infrastructure. 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-filesystem-cache Filesystem cache for remote/object storage, page cache, and read caching infrastructure. 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