Repository navigation
Cherry pick #122211 to 26.3: Undo a filesystem cache reservation when the key directory cannot be created - #123261
Merged
Merged
Conversation
…created `FileCache::doTryReserve` created the key's directory last, after the segment had already recorded the reservation - `setQueueIterator`, `reserved_size += size`, and the size added to the main queue. When `create_directories` failed (no space or no inodes left), it returned false without undoing any of it. The segment was left `EMPTY` yet holding a queue entry, which `FileSegment::complete` asserts against, and the main queue kept counting the size. A later reservation of the same segment then took the fast path that assumes an existing queue entry, skipped creating the directory, and its write failed. Create the directory after eviction, so a full cache disk can still admit once space is reclaimed, and before the segment records the reservation. On failure undo what the exception path above already undoes: invalidate a freshly added queue entry, or give back the size added to an existing one. The per-query queue is left as the exception path leaves it; its accounting is being fixed in #114165. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The `create_directories` failure path undid the reservation with its own copy of the exception path's rollback, without the `main_size_incremented` guard - correct only because the flag is always set by the time that path runs. Both paths now call one lambda, so they cannot drift apart. Also trims the comments in the fix and its test. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A failed `reserve` leaves the segment `PARTIALLY_DOWNLOADED_NO_CONTINUATION`, so nothing reserves that segment again. The test now releases it, which removes it, and caches the same offset in a new segment. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`FileSegmentsHolder` has its own `reset` method, so `holder.reset()` on the `FileSegmentsHolderPtr` triggers `readability-ambiguous-smartptr-reset-call`. Assign `nullptr` instead, as done elsewhere in the same file. Build log: https://d1k2gkhrlfqv31.cloudfront.net/clickhouse-test-reports-private/PRs/77374/5a3ecfa4951c635875947dbdb572ebfcccf3d14f/pr/build_arm_tidy/build_clickhouse/build_clickhouse.log Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…-directory Undo a filesystem cache reservation when the key directory cannot be created
- `FileCache.cpp`: the release branch lacks the `main_size_incremented` rollback that master's `rollback_main_entry` builds on, and its `createBaseDirectory` returns `bool` and throws for errors other than a full, read-only or inaccessible disk. The base directory is still created before the reservation is marked, and both a `false` return and an exception undo it: a new entry is invalidated, an existing one gives `size` back with `decrementSize`. - `gtest_filecache.cpp`: a regular file at the key path makes `createBaseDirectory` throw here, so `ReserveUndoneWhenKeyDirectoryCannotBeCreated` expects the exception instead of a `false` return; the size checks and the later successful download are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Original pull-request #122211
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-picklocally.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.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
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:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job