Skip to content

Commit a8f1ed7

Browse files
authored
feat: add recover_sync to ManifestCache::new (GreptimeTeam#7652)
feat: add recover_sync to ManifestCache::new This ensures tests can recover in sync Signed-off-by: evenyag <realevenyag@gmail.com>
1 parent faa3096 commit a8f1ed7

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/mito2/src/cache/manifest_cache.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ impl ManifestCache {
5555
local_store: ObjectStore,
5656
capacity: ReadableSize,
5757
ttl: Option<Duration>,
58+
recover_sync: bool,
5859
) -> ManifestCache {
5960
let total_capacity = capacity.as_bytes();
6061

@@ -67,8 +68,8 @@ impl ManifestCache {
6768

6869
let cache = ManifestCache { local_store, index };
6970

70-
// Recovers the cache index from local store asynchronously
71-
cache.recover(false).await;
71+
// Recovers the cache index from local store.
72+
cache.recover(recover_sync).await;
7273

7374
cache
7475
}
@@ -483,7 +484,7 @@ mod tests {
483484
let dir = create_temp_dir("");
484485
let local_store = new_fs_store(dir.path().to_str().unwrap());
485486

486-
let cache = ManifestCache::new(local_store.clone(), ReadableSize::mb(10), None).await;
487+
let cache = ManifestCache::new(local_store.clone(), ReadableSize::mb(10), None, true).await;
487488
let key = "region_1/manifest/00000000000000000007.json";
488489
let file_path = cache.cache_file_path(key);
489490

@@ -527,7 +528,7 @@ mod tests {
527528

528529
let dir = create_temp_dir("");
529530
let local_store = new_fs_store(dir.path().to_str().unwrap());
530-
let cache = ManifestCache::new(local_store.clone(), ReadableSize::mb(10), None).await;
531+
let cache = ManifestCache::new(local_store.clone(), ReadableSize::mb(10), None, true).await;
531532

532533
// Write some manifest files with different paths
533534
let keys = [
@@ -559,10 +560,7 @@ mod tests {
559560
}
560561

561562
// Create a new cache instance which will automatically recover from local store
562-
let cache = ManifestCache::new(local_store.clone(), ReadableSize::mb(10), None).await;
563-
564-
// Wait for recovery to complete synchronously
565-
cache.recover(true).await;
563+
let cache = ManifestCache::new(local_store.clone(), ReadableSize::mb(10), None, true).await;
566564

567565
// Check size.
568566
cache.index.run_pending_tasks().await;
@@ -580,7 +578,7 @@ mod tests {
580578
async fn test_cache_file_path() {
581579
let dir = create_temp_dir("");
582580
let local_store = new_fs_store(dir.path().to_str().unwrap());
583-
let cache = ManifestCache::new(local_store, ReadableSize::mb(10), None).await;
581+
let cache = ManifestCache::new(local_store, ReadableSize::mb(10), None, true).await;
584582

585583
assert_eq!(
586584
"cache/object/manifest/region_1/manifest/00000000000000000007.json",

src/mito2/src/cache/write_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl WriteCache {
112112

113113
// Create manifest cache if capacity is non-zero
114114
let manifest_cache = if manifest_cache_capacity.as_bytes() > 0 {
115-
Some(ManifestCache::new(local_store.clone(), manifest_cache_capacity, ttl).await)
115+
Some(ManifestCache::new(local_store.clone(), manifest_cache_capacity, ttl, false).await)
116116
} else {
117117
None
118118
};

0 commit comments

Comments
 (0)