Skip to content

Cherry pick #106387 to 26.5: Fix memory usage growth in fs cache - #107906

Merged
robot-ch-test-poll merged 13 commits into
backport/26.5/106387from
cherrypick/26.5/106387
Jun 22, 2026
Merged

robot-ch-test-poll merged 13 commits into
backport/26.5/106387from
cherrypick/26.5/106387

Conversation

@robot-clickhouse

Copy link
Copy Markdown
Member

Original pull-request #106387

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

kssenii and others added 12 commits June 3, 2026 15:41
…invalidated-entries-cleanup

# Conflicts:
#	src/Interpreters/FileCache/IFileCachePriority.cpp
#	src/Interpreters/FileCache/IFileCachePriority.h
…atedEntries

The invalidate contract must not throw: mark `IFileCachePriority::Iterator::invalidate`
and its `SLRU`/`Split` overrides `noexcept` (only `LRUIterator` was), and mark the
`addInvalidatedRef` helper `noexcept` too so the compiler enforces it.

Also guard the `push_front` in the `removeInvalidatedEntries` catch block with
`LockMemoryExceptionInThread`: it runs while handling a caught exception (so
`std::uncaught_exceptions()` no longer blocks the tracker), and a throw there would
lose the ref and mask the original exception.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`LRUIterator::invalidate` recorded every invalidated queue entry into
`invalidated_refs` for the background cleanup task to drain. However, that
cleanup task is only started in `startup`, which is called for `main_priority`
only. A `Query` priority (constructed by `FileCacheQueryLimit::QueryContext`)
never drains `invalidated_refs`, so when per-query recache evicts entries with
`enable_filesystem_query_cache_limit` enabled, `EvictionCandidates` calls
`invalidate` and one stale ref accumulated per eviction until query end.

Only register refs for the `Main` priority, which is the one actually drained.
The queue node itself is still removed opportunistically through `remove`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ated-entries-cleanup

Fix memory usage growth in fs cache
@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 Jun 18, 2026
@robot-clickhouse-ci-1

Copy link
Copy Markdown
Contributor

Dear @antonio2368, @kssenii, this cherry-pick PR has not been updated for 3d0h48m36s. Please resolve the conflicts to backport #106387, or close this PR if the backport is no longer needed. This PR will be automatically closed after 7 days of inactivity.

…rrypick/26.5/106387

# Conflicts:
#	src/Interpreters/FileCache/CacheUsage.h
#	src/Interpreters/FileCache/LRUFileCachePriority.h
@robot-ch-test-poll
robot-ch-test-poll merged commit e70957c into backport/26.5/106387 Jun 22, 2026
@robot-ch-test-poll
robot-ch-test-poll deleted the cherrypick/26.5/106387 branch June 22, 2026 17:53
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.

5 participants