mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-06 21:32:58 +00:00
fix: align region numbers to real regions (#2257)
This commit is contained in:
@@ -394,10 +394,12 @@ fn column_qualified_name(table_name: &str, region_name: &str, column_name: &str)
|
|||||||
|
|
||||||
impl<R: Region> MitoTable<R> {
|
impl<R: Region> MitoTable<R> {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
table_info: TableInfo,
|
mut table_info: TableInfo,
|
||||||
regions: HashMap<RegionNumber, R>,
|
regions: HashMap<RegionNumber, R>,
|
||||||
manifest: TableManifest,
|
manifest: TableManifest,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
// `TableInfo` is recovered from the file, which may contain incorrect content. We align it to real regions.
|
||||||
|
table_info.meta.region_numbers = regions.keys().copied().collect::<Vec<_>>();
|
||||||
Self {
|
Self {
|
||||||
table_info: ArcSwap::new(Arc::new(table_info)),
|
table_info: ArcSwap::new(Arc::new(table_info)),
|
||||||
regions: ArcSwap::new(Arc::new(regions)),
|
regions: ArcSwap::new(Arc::new(regions)),
|
||||||
@@ -567,6 +569,16 @@ impl<R: Region> MitoTable<R> {
|
|||||||
Arc::new(regions)
|
Arc::new(regions)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let _ = self.table_info.rcu(|info| {
|
||||||
|
let mut info = TableInfo::clone(info);
|
||||||
|
|
||||||
|
info.meta
|
||||||
|
.region_numbers
|
||||||
|
.retain(|r| !region_numbers.contains(r));
|
||||||
|
|
||||||
|
Arc::new(info)
|
||||||
|
});
|
||||||
|
|
||||||
Ok(removed)
|
Ok(removed)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,6 +658,14 @@ impl<R: Region> MitoTable<R> {
|
|||||||
Arc::new(regions)
|
Arc::new(regions)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let _ = self.table_info.rcu(|info| {
|
||||||
|
let mut info = TableInfo::clone(info);
|
||||||
|
|
||||||
|
info.meta.region_numbers.push(region_number);
|
||||||
|
|
||||||
|
Arc::new(info)
|
||||||
|
});
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
"MitoTable loads new region: {} in table: {}",
|
"MitoTable loads new region: {} in table: {}",
|
||||||
region_number,
|
region_number,
|
||||||
|
|||||||
Reference in New Issue
Block a user