Skip to content

Reject an SLRU filesystem cache whose file segment does not fit each queue - #125817

Merged
CheSema merged 9 commits into
masterfrom
filecache-slru-segment-size-rule
Oct 22, 2026
Merged

CheSema merged 9 commits into
masterfrom
filecache-slru-segment-size-rule

Conversation

@CheSema

@CheSema CheSema commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

With SLRU, a file segment larger than an SLRU queue cannot be cached whole. Such a cache is now rejected: max_file_segment_size must fit each queue. The check is a part of the cache settings validation.

Test caches smaller than 80 MiB now use smaller file segments.

Related: #125657
Related: #123607

Changelog category (leave one):

  • Backward Incompatible Change

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

A filesystem cache with the SLRU policy (the default) now requires max_file_segment_size <= max_size * min(slru_size_ratio, 1 - slru_size_ratio) (of each part with use_split_cache), so that a file segment fits whole into each SLRU queue. With the default settings, a cache smaller than 80 MiB must set a smaller max_file_segment_size (and boundary_alignment); otherwise creating the cache disk, server startup or config reload fails. This also applies when an existing table with such a cache disk is attached.

🤖 Generated with Claude Code


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

Version info

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

… each queue

With the SLRU policy, a file segment larger than the protected or the probationary
queue cannot be cached whole. Reject such a configuration when a cache disk is
created (not on ATTACH), at startup and on config reload.
@mintlify

mintlify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Oct 20, 2026, 2:52 PM

@clickhouse-gh

clickhouse-gh Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5fb7200]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_asan_ubsan, flaky check) FAIL
02808_filesystem_cache_drop_query FAIL cidb
02808_filesystem_cache_drop_query FAIL cidb
Stateless tests (amd_binary, flaky check) FAIL
02808_filesystem_cache_drop_query FAIL cidb
02808_filesystem_cache_drop_query FAIL cidb

AI Review

Summary

The PR rejects SLRU filesystem-cache configurations whose maximum file segment exceeds either queue, including both partitions of a split cache, and updates affected fixtures and documentation. Reviewed head: 5fb720094b68c3ed988d5e926d18e6139835b140. The split-system-partition finding is fixed. Four previously reported concerns remain in the current code; the author's dismissals are recorded below, without reopening their threads or posting duplicate inline findings.

Missing context / blind spots
  • ⚠️ Runtime reproductions were not executed: this checkout has no runnable ClickHouse binary or configured build. Running 05397_filesystem_cache_slru_file_segment_fits_queues and the focused cases below would close the runtime-verification gap.
Findings

❌ Blockers

  • Existing tables can become unavailable after an upgrade. src/Interpreters/FileCache/FileCacheSettings.cpp:340 [dismissed by author -- https://github.com/Reject an SLRU filesystem cache whose file segment does not fit each queue #125817#discussion_r4284582352]

    RegisterDiskCache.cpp loads and validates settings unconditionally during attachment, including inline disk definitions persisted in table metadata. A previously accepted table with max_size = '16Mi' and the default segment size therefore cannot attach; configured caches can also prevent startup. The author intends this incompatibility and considers small inline caches test-only. The concern remains because there is no compatibility path for existing metadata, and normal ALTER cannot repair a table that cannot attach. Apply enforcement only to new disks, or provide a startup/attachment compatibility option and a supported migration path.

⚠️ Majors

  • Reload validates requested settings rather than the queues that remain active. src/Interpreters/FileCache/FileCacheSettings.cpp:326 [dismissed by author -- https://github.com/Reject an SLRU filesystem cache whose file segment does not fit each queue #125817#discussion_r4272914018]

    Start with max_size = '16Mi', slru_size_ratio = 0.75, and max_file_segment_size = '4Mi'; reload with ratio 0.5 and segment size '8Mi'. Validation accepts hypothetical 8 MiB queues, but FileCache::applySettingsIfPossible skips the ratio change and still applies the segment size at FileCache.cpp:3009, leaving a 4 MiB probationary queue. The author excludes live-settings mismatches from scope. The concern remains because the existing reload API still applies the incompatible combination, allowing segments that cannot finish downloading. Validate against the effective settings, or reject unsupported combinations before applying changes.

  • A shrink can retain partial segments larger than the new queues. src/Interpreters/FileCache/FileCacheSettings.cpp:339 [dismissed by author -- https://github.com/Reject an SLRU filesystem cache whose file segment does not fit each queue #125817#discussion_r4272914028]

    With a 16 MiB cache, ratio 0.75, 2 MiB segments/alignment, and background download disabled, a narrow read can leave a 128 KiB prefix in a 2 MiB range. Reloading with a 4 MiB cache and 1 MiB segments/alignment passes validation. Dynamic resize retains the prefix because its reserved bytes fit, but changing the segment limit does not resize the old range; continuation can exceed the new 1 MiB probationary queue. The author excludes existing ranges across reload from scope. The concern remains because dynamic resize still accepts this transition. Reject it or safely split/evict incompatible ranges before applying the new limits.

  • Disk-accounted segments can exceed the validated limit. src/Interpreters/FileCache/FileCacheSettings.cpp:339 [dismissed by author -- https://github.com/Reject an SLRU filesystem cache whose file segment does not fit each queue #125817#discussion_r4284582378]

    With use_real_disk_size = 1, max_size = '1Mi', max_file_segment_size = 419430, and boundary_alignment = 1, validation accepts the 419430-byte probationary queue. On a filesystem with 4096-byte blocks, completing the segment requires 421888 accounted bytes, which FileCache::doTryReserve cannot fit even in an empty queue. The author excludes filesystem-block margins from scope. The concern remains because the accepted segment cannot satisfy the full-download invariant under a supported accounting mode. Compare the block-aligned reservation footprint when that mode is enabled.

Tests
  • ⚠️ The added stateless test covers fresh-cache acceptance/rejection. Add focused coverage for attaching previously accepted inline disk metadata, reloading settings that are not applied to the live queues, retaining a partial segment across a shrink, and fully downloading a segment at an unaligned queue boundary with use_real_disk_size = 1.
Final Verdict

Status: ❌ Block. Minimum actions: provide a working upgrade/attachment migration path, enforce the bound against effective reload settings and retained ranges, and account for filesystem-block rounding. Add the focused regressions above. No new inline findings were posted because each outstanding issue already has a discussion thread.

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label Oct 14, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-filesystem-cache Filesystem cache for remote/object storage, page cache, and read caching infrastructure. label Oct 14, 2026
@kssenii kssenii self-assigned this Oct 15, 2026
…ent-size-rule

# Conflicts:
#	tests/queries/0_stateless/02344_describe_cache.reference
…ent-size-rule

# Conflicts:
#	tests/queries/0_stateless/02344_describe_cache.reference
@clickhouse-gh

clickhouse-gh Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 5fb720094 with master f7de1ab43 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 9 s compile time in total, 7 of them have a recent master baseline.

Job report

@CheSema
CheSema added this pull request to the merge queue Oct 20, 2026
@CheSema
CheSema removed this pull request from the merge queue due to a manual request Oct 20, 2026
@CheSema
CheSema enabled auto-merge October 20, 2026 14:18
@CheSema
CheSema disabled auto-merge October 20, 2026 14:20
@CheSema
CheSema enabled auto-merge October 21, 2026 11:00
@CheSema
CheSema disabled auto-merge October 22, 2026 17:25
@CheSema
CheSema added this pull request to the merge queue Oct 22, 2026
Merged via the queue into master with commit 32303b1 Oct 22, 2026
177 of 180 checks passed
@CheSema
CheSema deleted the filecache-slru-segment-size-rule branch October 22, 2026 18:09
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 22, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 23, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 23, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 23, 2026
…ru-rule-02908

Fix 26.10 upgrade check after #125817, part 2
CheSema added a commit that referenced this pull request Oct 23, 2026
…u-rule-02908

Fix 26.9 upgrade check after #125817, part 2
upman pushed a commit to upman/ClickHouse that referenced this pull request Oct 24, 2026
…chain

`find_master_builds` walked `master_commits`, the raw `commits?sha=master`
listing that Config Workflow fetches when it runs. A re-run (for example
after the `can be tested` label lands hours after the PR event) runs Config
Workflow again, so the listing is the current master, while the checkout,
`tests/config` and `ci/` stay those of the original merge commit. The
downloaded binary can then be newer than the tree it is started with. After
ClickHouse#125817 added a startup check that a filesystem cache's
`max_file_segment_size` fits each SLRU queue, such binaries exit with
BAD_ARGUMENTS on the older trees' 1Mi cache disk
(`tests/config/config.d/storage_conf_03517.xml`), and the changed tests
never run.

In the public repository walk `master_track_commits_sha` instead: the
first-parent chain from the merge commit's master parent, already stored
for every PR and used by the performance, build-profile diff, coverage and
parser-memory jobs. The binary is then the newest built master commit that
the tested tree contains. Like those jobs, it does not fall back to the
unanchored listing: a chain without a built commit fails the job. Synced
private PRs keep `master_commits`, because their own master commits have
no public builds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-filesystem-cache Filesystem cache for remote/object storage, page cache, and read caching infrastructure. pr-backward-incompatible Pull request with backwards incompatible changes 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