Skip to content

Cherry pick #102396 to 26.3: Fix SLRU and SplitFileCachePriority dynamic resize bugs - #108138

Merged
robot-ch-test-poll merged 9 commits into
backport/26.3/102396from
cherrypick/26.3/102396
Jun 22, 2026
Merged

robot-ch-test-poll merged 9 commits into
backport/26.3/102396from
cherrypick/26.3/102396

Conversation

@robot-ch-test-poll

Copy link
Copy Markdown
Contributor

Original pull-request #102396

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

antonio2368 and others added 9 commits April 10, 2026 18:11
…ecovery path

Fix `LOGICAL_ERROR` abort during SLRU filesystem cache dynamic resize
(issue #95983, STID `4012-44fe`).

**Per-queue stat fix (core bug):**
`SLRUFileCachePriority::collectCandidatesForEviction` shared a single
`FileCacheReserveStat` across both sub-queue passes. The probationary
pass accumulated `releasable_size`, then the protected pass's stopping
condition was immediately satisfied by probationary leftovers — so zero
protected candidates were collected. `modifySizeLimits` then threw
because the protected queue still exceeded its new limit. Fix: use
per-queue local stat objects and merge them afterward.

**SLRU recovery path fix:**
When eviction fails and entries are restored, they now go back to their
original queue (protected or probationary) instead of all defaulting to
probationary. `EvictionCandidates` captures the queue type before
invalidation, and a new `addForRestore` virtual method routes entries
back to the correct sub-queue. Recovery uses `result_limits = prev_limits`
since entries existed under those limits.

**`SplitFileCachePriority::modifySizeLimits` no-op guard fix:**
The no-op guard compared `system_segment_size_ratio` (Data/System split)
against `size_ratio_` (SLRU protected/probationary ratio) — different
concepts. This caused real resizes to be silently skipped. Fix: compare
only `max_size` and `max_elements`.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101427&sha=7b67d034be1a37512c7fbc8c9b428f2eeb0907ba&name_0=PR&name_1=Stress%20test%20%28arm_asan_ubsan%2C%20s3%29
Related PR: #101427

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Replace fragile timing-based polling with log-message-based detection
for the resize failure path, and add explicit `max_size` assertion after
successful resize.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
When `use_split_cache` + SLRU are composed, `SplitIterator::getType`
returns `SplitCache_Data`/`SplitCache_System` instead of the inner
`SLRU_Protected`/`SLRU_Probationary` type. This caused `addForRestore`
to route all restored entries to probationary after failed eviction,
reintroducing the queue-corruption bug.

Override `getNestedOrThis` in `SplitIterator` to delegate to the inner
iterator, and use `getNestedOrThis()->getType()` when saving the
original queue type in `EvictionCandidates::removeQueueEntries`.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
… test

Replace the hand-rolled sleep+`contains_in_log` loop with the
`count_log_lines`/`wait_for_log_line` pattern, which correctly scopes
the log search to lines written after the test action and avoids
matching stale log entries from earlier test cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add a third cache base path to the test fixture setup/teardown
for testing SLRU resize statistics.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Fix SLRU and SplitFileCachePriority dynamic resize bugs
@robot-ch-test-poll robot-ch-test-poll added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Jun 22, 2026
@robot-ch-test-poll
robot-ch-test-poll merged commit 9ba6da4 into backport/26.3/102396 Jun 22, 2026
@robot-ch-test-poll
robot-ch-test-poll deleted the cherrypick/26.3/102396 branch June 22, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants