fix: avoid stale metadata cache after invalidation (#8235)

Signed-off-by: WenyXu <wenymedia@gmail.com>
This commit is contained in:
Weny Xu
2026-06-04 20:05:17 +08:00
committed by GitHub
parent 6ed67167bb
commit 42eeeaa514
2 changed files with 14 additions and 4 deletions

View File

@@ -20,7 +20,7 @@ use snafu::OptionExt;
use store_api::storage::TableId;
use table::metadata::TableInfo;
use crate::cache::{CacheContainer, Initializer};
use crate::cache::{CacheContainer, InitStrategy, Initializer};
use crate::error;
use crate::error::Result;
use crate::instruction::CacheIdent;
@@ -41,7 +41,14 @@ pub fn new_table_info_cache(
let table_info_manager = Arc::new(TableInfoManager::new(kv_backend));
let init = init_factory(table_info_manager);
CacheContainer::new(name, cache, Box::new(invalidator), init, filter)
CacheContainer::with_strategy(
name,
cache,
Box::new(invalidator),
init,
filter,
InitStrategy::VersionChecked,
)
}
fn init_factory(table_info_manager: TableInfoManagerRef) -> Initializer<TableId, Arc<TableInfo>> {

View File

@@ -16,7 +16,9 @@ use std::sync::Arc;
use common_base::hash::partition_expr_version;
use common_error::ext::BoxedError;
use common_meta::cache::{CacheContainer, Initializer, TableRoute, TableRouteCacheRef};
use common_meta::cache::{
CacheContainer, InitStrategy, Initializer, TableRoute, TableRouteCacheRef,
};
use common_meta::instruction::CacheIdent;
use common_meta::rpc::router::RegionRoute;
use moka::future::Cache;
@@ -118,7 +120,7 @@ pub fn new_partition_info_cache(
cache: Cache<TableId, CachedPartitionInfo>,
table_route_cache: TableRouteCacheRef,
) -> PartitionInfoCache {
CacheContainer::new(
CacheContainer::with_strategy(
name,
cache,
Box::new(|cache, idents| {
@@ -133,6 +135,7 @@ pub fn new_partition_info_cache(
}),
init_factory(table_route_cache),
|ident| matches!(ident, CacheIdent::TableId(_)),
InitStrategy::VersionChecked,
)
}