-
Notifications
You must be signed in to change notification settings - Fork 670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add missing continue to shard cache put #7496
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have some existing tests which cover this scenario? Can we extend them to include assertions about the state of the cache?
@@ -144,6 +144,7 @@ impl TrieCacheInner { | |||
} | |||
None => { | |||
self.metrics.shard_cache_pop_misses.inc(); | |||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! If we already caught a bug here, let's try to compress this experssion to make it simpler and less error prone. Something like this should work I think:
// First, try to evict value using the key from deletions queue.
if let Some(key) = self.deletions.pop() {
match self.cache.pop(&key) {
Some(value) => {
self.total_size -= value.len() as u64;
self.metrics.shard_cache_pop_hits.inc();
}
None => self.metrics.shard_cache_pop_misses.inc(),
}
continue;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for adding the test (as we shouldn't be in a hurry now).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add the test.
I suspect this PR is no longer being actively worked on. Feel free to reopen when you are ready to start working on it again. |
If we are unable to remove element with hash taken from deletions queue, we remove LRU item from cache. This is not optimal - we should continue iterating over deletions queue until we don't exhaust it.
Testing
Existing tests - but we will have to add more #7498