mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-07-06 22:10:39 +00:00
fix: avoid stale metadata cache after invalidation (#8235)
Signed-off-by: WenyXu <wenymedia@gmail.com>
This commit is contained in:
11
src/common/meta/src/cache/table/table_info.rs
vendored
11
src/common/meta/src/cache/table/table_info.rs
vendored
@@ -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>> {
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user