Repository navigation
Conversation
Replace the internal Mutex with an RwLock and add Cache::reader(), a cloneable handle whose try_access_now() never waits: it returns None while the watcher holds the data exclusively (initial fetch, reconnect, applying a change), so callers can fall back to the remote store instead of queueing behind it. CacheReader::request_resync() makes the watcher drop its stream and re-fetch everything; callers use it when they detect that a stream silently stopped delivering, e.g. a half-open connection. Reconnect delays get a random factor in [0.5, 1.5) so that many caches seeing the same failure do not retry in lockstep. Bump version to 0.3.0.
3 of 12 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.
Summary
Databend query nodes want to answer hot meta-service reads (users, global settings, cluster nodes) from a
Cache. Two things block that today:&mut self, so concurrent readers must wrap the cache in aMutexand fall back to the remote store whenevertry_lockfails; under load a large share of reads miss the cache this way.Changes:
RwLockinstead ofMutexCache::reader()→CacheReadertry_access_now()never waits and returnsNonewhile the watcher holds the data exclusivelyCacheReader::request_resync()cache_data()now returns anRwLockWriteGuard)Tests:
tests/reader_resync.rscovers shared reads under concurrency and recovery of a stalled stream viarequest_resync()(new test helperTestSource::set_silentlychanges data without notifying subscribers). All existing tests pass; clippy and fmt are clean.Used by databendlabs/databend#21095 (meta read cache).