Skip to content

Commit

Permalink
feat: remove index when storage lookup miss (#99)
Browse files Browse the repository at this point in the history
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
  • Loading branch information
MrCroxx committed Aug 1, 2023
1 parent 6bd19cb commit 0e5a595
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion foyer-storage/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ where
let slice = match region.load(start..end, index.version).await? {
Some(slice) => slice,
None => {
// Remove index if the storage layer fails to lookup it (because of region version mismatch).
self.indices.remove(key);
self.metrics
.latency_lookup_miss
.observe(now.elapsed().as_secs_f64());
Expand All @@ -442,7 +444,11 @@ where

let res = match read_entry::<K, V>(slice.as_ref()) {
Some((_key, value)) => Ok(Some(value)),
None => Ok(None),
None => {
// Remove index if the storage layer fails to lookup it (because of region version mismatch).
self.indices.remove(key);
Ok(None)
}
};
slice.destroy().await;

Expand Down

0 comments on commit 0e5a595

Please sign in to comment.