fix: align region numbers to real regions (#2257)

This commit is contained in:
Weny Xu
2023-08-25 19:48:58 +08:00
committed by GitHub
parent 5160838d04
commit 7ff200c0fa

View File

@@ -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,