Repository navigation
fix: cache: never serve a part of a failed initial flush - #9
Merged
drmingdrmer merged 1 commit intoNov 18, 2026
Merged
drmingdrmer merged 1 commit into
drmingdrmer merged 1 commit into
Conversation
# Summary The watcher collects each initial flush in a fresh `CacheData` and replaces the shared data with it only when the flush completes. A flush that fails part way is dropped, so no reader gets it as a ready cache, on the first initialization or after a reconnect. # Details `EventWatcher::main` used to reset the shared data to empty and apply the flush to it in place. When the flush broke, the `continue` that retries released the lock with the partial data in place, and the readers queued during the initialization got it as an `Ok` answer: keys not delivered yet looked absent. The watcher still holds the write lock for the whole attempt, so readers wait for its data. Between failed attempts, a reader gets the data from before the attempt: after a reconnect, the previous copy, complete but missing the changes since the stream broke; on the first initialization, the `Unsupported` error of a cache not initialized. While a reconnect fetches its flush, the previous copy and the new one are both in memory. Fixes: databendlabs#3
xp-trumpet
reviewed
Nov 18, 2026
xp-trumpet
left a comment
There was a problem hiding this comment.
@xp-trumpet reviewed 5 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on drmingdrmer).
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.
Changelog
fix: cache: never serve a part of a failed initial flush
Summary
The watcher collects each initial flush in a fresh
CacheDataandreplaces the shared data with it only when the flush completes. A
flush that fails part way is dropped, so no reader gets it as a ready
cache, on the first initialization or after a reconnect.
Details
EventWatcher::mainused to reset the shared data to empty and applythe flush to it in place. When the flush broke, the
continuethatretries released the lock with the partial data in place, and the
readers queued during the initialization got it as an
Okanswer:keys not delivered yet looked absent.
The watcher still holds the write lock for the whole attempt, so
readers wait for its data. Between failed attempts, a reader gets the
data from before the attempt: after a reconnect, the previous copy,
complete but missing the changes since the stream broke; on the first
initialization, the
Unsupportederror of a cache not initialized.While a reconnect fetches its flush, the previous copy and the new
one are both in memory.
Fixes: #3