Skip to content

Commit

Permalink
chore: remove run_pending_task in read and write path
Browse files Browse the repository at this point in the history
  • Loading branch information
killme2008 committed Oct 8, 2023
1 parent d13f753 commit 3dc97d8
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/object-store/src/layers/lru_cache/read_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ impl<C: Accessor + Clone> ReadCache<C> {
self.mem_cache
.invalidate_entries_if(move |k: &String, &_v| k.starts_with(&prefix))
.ok();
self.mem_cache.run_pending_tasks().await;
}

/// Blocking version of `invalidate_entries_with_prefix`.
Expand All @@ -129,9 +128,6 @@ impl<C: Accessor + Clone> ReadCache<C> {
self.mem_cache
.invalidate_entries_if(move |k: &String, &_v| k.starts_with(&prefix))
.ok();
common_runtime::block_on_bg(async {
self.mem_cache.run_pending_tasks().await;
});
}

/// Recover existing cache items from `file_cache` to `mem_cache`.
Expand Down Expand Up @@ -164,6 +160,7 @@ impl<C: Accessor + Clone> ReadCache<C> {

/// Returns true when the read cache contains the specific file.
pub(crate) async fn contains_file(&self, path: &str) -> bool {
self.mem_cache.run_pending_tasks().await;
self.mem_cache.contains_key(path)
&& self.file_cache.stat(path, OpStat::default()).await.is_ok()
}
Expand Down Expand Up @@ -197,7 +194,7 @@ impl<C: Accessor + Clone> ReadCache<C> {
.await
.map_err(|e| OpendalError::new(e.kind(), &e.to_string()))?;

let cache_result = match read_result {
match read_result {
ReadResult::Success(_) => {
// There is a concurrent issue here, the local cache may be purged
// while reading, we have to fallback to remote read
Expand All @@ -220,10 +217,7 @@ impl<C: Accessor + Clone> ReadCache<C> {
&format!("File not found: {path}"),
))
}
};
self.mem_cache.run_pending_tasks().await;

cache_result
}
}

/// Read the file from remote storage. If success, write the content into local cache.
Expand Down

0 comments on commit 3dc97d8

Please sign in to comment.