Repository navigation
fix: cache: stop the watcher on drop, also while establishing - #11
Merged
drmingdrmer merged 1 commit intoNov 18, 2026
Merged
drmingdrmer merged 1 commit into
drmingdrmer merged 1 commit into
Conversation
# Summary A watcher stops when its `Cache` is dropped, whatever it waits for: the retries of `subscribe` while the source is unreachable, the 5-minute delay after `subscribe` returned `Unsupported`, or an initial flush that does not finish. # Details `EventWatcher::main` observed its cancel future only inside `watch_kv_changes`. It now races the retry delay, `retry_new_stream()` and `initialize_cache()` against it too, with `futures::select!`, and returns when it is ready. Before, a caller that rebuilt a `Cache`, e.g. to resync, leaked one watcher task, holding its `Source`, per rebuild while the source was unreachable or unsupported. The data lock is not raced: readers hold it only through a `&Cache`, so it is free once the `Cache` is dropped. Fixes: databendlabs#10
xp-trumpet
reviewed
Nov 18, 2026
xp-trumpet
left a comment
There was a problem hiding this comment.
@xp-trumpet reviewed 3 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on drmingdrmer).
Merged
3 of 6 tasks
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: stop the watcher on drop, also while establishing
Summary
A watcher stops when its
Cacheis dropped, whatever it waits for:the retries of
subscribewhile the source is unreachable, the5-minute delay after
subscribereturnedUnsupported, or an initialflush that does not finish.
Details
EventWatcher::mainobserved its cancel future only insidewatch_kv_changes. It now races the retry delay,retry_new_stream()and
initialize_cache()against it too, withfutures::select!, andreturns when it is ready. Before, a caller that rebuilt a
Cache,e.g. to resync, leaked one watcher task, holding its
Source, perrebuild while the source was unreachable or unsupported.
The data lock is not raced: readers hold it only through a
&Cache,so it is free once the
Cacheis dropped.Fixes: #10