Repository navigation
fs cache download wait timeout - #113322
Merged
Merged
Conversation
…timeout A read which needs a file segment in `DOWNLOADING` state waited for the downloader indefinitely: `FileSegment::wait` has a 60 s deadline, but the caller looped and waited again. The downloader role is held by another query for as long as it is reading the segment, so a fast point read could stall behind an arbitrarily slow foreign query downloading the same segment. Add the setting `filesystem_cache_wait_for_concurrent_download_timeout_milliseconds` (default 1 second). When the timeout is reached, the read bypasses the cache for that range and reads directly from remote storage, while the concurrent download continues to fill the cache. Value `0` means bypass immediately. The new profile event `CachedReadBufferDownloadWaitTimeouts` counts such bypasses, and the new pauseable failpoint `file_segment_pause_before_write` allows reproducing the stall in tests. Co-Authored-By: Claude Fable 5 <[email protected]>
…aller Rename the profile event `CachedReadBufferDownloadWaitTimeouts` to `FileSegmentWaitTimeouts` and increment it inside `FileSegment::wait` when the wait deadline expires. The cached read buffer no longer tracks a deadline of its own: `wait` returning a state which is still `DOWNLOADING` without usable progress is the timeout signal, so the `DOWNLOADING` branch just bypasses the cache in that case and continues otherwise. Co-Authored-By: Claude Fable 5 <[email protected]>
Contributor
|
Workflow [PR], commit [4c41771] Summary: ❌
AI ReviewSummaryThis PR adds Findings❌ Blockers
Tests
Final VerdictChanges requested. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 67/67 (100.00%) · Uncovered code |
The one-time pause failpoint must be consumed by the downloader query, but two other writers could take it first and let the downloader run unimpeded, leaving the waiter with nothing to wait on (the flaky check failed with `0` instead of `1` in the profile event check): - the mark-cache warmup query ran with default prefetch settings, and its abandoned prefetch tasks could still write to the cache from reader-pool threads after the client had already returned; - background download of partially downloaded segments could leak cache writes into the next iteration of the flaky check. Make the warmup query strictly synchronous, disable background download in all three queries, and assert that exactly one file segment is DOWNLOADING after the failpoint pause, so a stray consumer fails the test explicitly instead of making it vacuous. Failed CI: https://github.com/ClickHouse/ClickHouse/actions/runs/30908188704/job/92013126246 Related PR: #113322 Co-Authored-By: Claude Fable 5 <[email protected]>
nickitat
approved these changes
Aug 4, 2026
|
|
||
| if (download_state == FileSegment::State::DOWNLOADING && !canStartFromCache(offset, file_segment)) | ||
| { | ||
| LOG_TRACE( |
The flaky check showed the test is not isolated from server background activity: a background merge of `test.hits_s3` writes through the shared `s3_cache` and can fill it with non-releasable segments. The downloader's space reservation then fails, so it silently continues without caching and never reaches the failpoint, while the merge consumes the one-time pause instead (`FileSegmentWaitTimeouts` stayed `0` and the `DOWNLOADING` count saw the merge's segment). Rework the test to not depend on the shared cache at all: - the table uses a private inline cache disk over `local_disk`, so no other cache user can fail its reservations, and `max_file_segment_size` covers the whole data file so the waiter never becomes a downloader itself; - the failpoint is `PAUSEABLE` instead of `PAUSEABLE_ONCE`: every cache write pauses while it is enabled, so an unrelated writer cannot steal it (it just pauses too and resumes on disable); - after `SYSTEM WAIT FAILPOINT` the test additionally polls until the private cache holds exactly one `DOWNLOADING` segment, since the first pause on the server is not necessarily the downloader's. Verified locally: 25 consecutive runs pass with a concurrent workload inserting into and merging a cache-on-write table on the shared `s3_cache`. Failed CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113322&sha=c5f7fd81a5824409956120442597006de4a5935a&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20flaky%20check%29 Related PR: #113322 Co-Authored-By: Claude Fable 5 <[email protected]>
`file_segment_pause_before_write` is a server-global `PAUSEABLE` failpoint, so a script that aborts between `SYSTEM ENABLE FAILPOINT` and the explicit disable at the end left every filesystem cache write on the server paused: the following tests would hang behind it and mask the original failure. Add a `trap` right after enabling the failpoint that always disables it, ignoring cleanup errors. Addresses #113322 (comment) Co-Authored-By: Claude Opus 5 <[email protected]>
kssenii
enabled auto-merge
August 5, 2026 19:46
This was referenced Aug 7, 2026
robot-ch-test-poll3
added a commit
that referenced
this pull request
Aug 7, 2026
Cherry pick #113322 to 25.8: fs cache download wait timeout
robot-clickhouse
added a commit
that referenced
this pull request
Aug 7, 2026
robot-ch-test-poll3
added a commit
that referenced
this pull request
Aug 7, 2026
Cherry pick #113322 to 26.3: fs cache download wait timeout
robot-clickhouse
added a commit
that referenced
this pull request
Aug 7, 2026
robot-ch-test-poll3
added a commit
that referenced
this pull request
Aug 7, 2026
Cherry pick #113322 to 26.5: fs cache download wait timeout
robot-clickhouse
added a commit
that referenced
this pull request
Aug 7, 2026
robot-ch-test-poll3
added a commit
that referenced
this pull request
Aug 7, 2026
Cherry pick #113322 to 26.6: fs cache download wait timeout
robot-clickhouse
added a commit
that referenced
this pull request
Aug 7, 2026
kssenii
added a commit
that referenced
this pull request
Aug 9, 2026
Backport #113322 to 26.5: fs cache download wait timeout
nickitat
added a commit
that referenced
this pull request
Aug 27, 2026
Backport #113322 to 26.6: fs cache download wait timeout
kssenii
added a commit
that referenced
this pull request
Aug 28, 2026
The conflict resolution commit copied several master-only hunks that are not part of #113322: the `AsyncLoaderSpawnFailures` and `SelectivityEstimatorInSet*` profile events, memory-order changes in `ProfileEvents::Counters`, the `file_size_mutex` locking in `CachedOnDiskReadBufferFromFile` (the mutex does not even exist on this branch), the `statistics_max_set_size_for_exact_selectivity_estimation`, `analyzer_compatibility_multiple_joins_qualify_column_names` and `throw_on_hive_partitioning_resolution_failure` settings with their changes-history entries, and assorted setting description rewordings. Restore every file to the branch state plus exactly the hunks of the original pull request, and record the new setting in the existing 26.8 section of `SettingsChangesHistory.cpp`, where master records it. Co-Authored-By: Claude Fable 5 <[email protected]>
clickhouse-gh Bot
added a commit
that referenced
this pull request
Aug 29, 2026
Backport #113322 to 26.7: fs cache download wait timeout
kssenii
added a commit
that referenced
this pull request
Aug 31, 2026
Backport #113322 to 26.3: fs cache download wait timeout
kewin-robetti
pushed a commit
to viasoftkorp/ClickHouse
that referenced
this pull request
Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added fs cache download wait timeout configured by
filesystem_cache_wait_for_concurrent_download_timeout_milliseconds. This timeout defined only the wait for a single chunk (buffer bytes of ~1mb) of data, not the whole file segment.Version info
26.7.6.47,26.6.4.30,26.3.28.4