Skip to content

Cherry pick #104313 to 26.4: Fix SLRU free-space-keeping crash when probationary queue is empty - #104400

Merged
robot-clickhouse merged 3 commits into
backport/26.4/104313from
cherrypick/26.4/104313
May 8, 2026
Merged

robot-clickhouse merged 3 commits into
backport/26.4/104313from
cherrypick/26.4/104313

Conversation

@robot-clickhouse

Copy link
Copy Markdown
Member

Original pull-request #104313

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

groeneai and others added 3 commits May 7, 2026 16:58
`SLRUFileCachePriority::collectEvictionInfo` had a `chassert` requiring
that `evict_size_from_probationary || evict_elements_from_probationary`
in the `is_total_space_cleanup` branch. This is wrong when the
probationary queue is empty but the protected queue still has entries:
the function must still be able to evict from the protected queue.

This is reachable in production via the
`keep_free_space_size_ratio` / `keep_free_space_elements_ratio`
features. The background `freeSpaceRatioKeepingThreadFunc` aborts the
server (debug/sanitizer) or throws `LOGICAL_ERROR` (release) whenever
all entries have been promoted to the protected queue and the free-space
target asks the cache to evict them.

Removed the assertion. The downstream code already handles the case
correctly: it passes zero size/elements to `probationary_queue.collectEvictionInfo`
(which returns an empty info immediately) and routes the full requested
amount to the protected queue.

Added a regression unit test `FileCacheTest.SLRUFreeSpaceKeepingProtectedOnly`
that reproduces the exact stack trace from the issue.

Closes #104307
…104307

Fix SLRU free-space-keeping crash when probationary queue is empty
@robot-clickhouse robot-clickhouse 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 May 8, 2026
@robot-clickhouse
robot-clickhouse merged commit 4750697 into backport/26.4/104313 May 8, 2026
@robot-clickhouse
robot-clickhouse deleted the cherrypick/26.4/104313 branch May 8, 2026 15:48
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