Skip to content

Commit

Permalink
fix: align region numbers to real regions (#2257)
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu authored Aug 25, 2023
1 parent 5160838 commit 7ff200c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/mito/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,12 @@ fn column_qualified_name(table_name: &str, region_name: &str, column_name: &str)

impl<R: Region> MitoTable<R> {
pub(crate) fn new(
table_info: TableInfo,
mut table_info: TableInfo,
regions: HashMap<RegionNumber, R>,
manifest: TableManifest,
) -> 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 {
table_info: ArcSwap::new(Arc::new(table_info)),
regions: ArcSwap::new(Arc::new(regions)),
Expand Down Expand Up @@ -567,6 +569,16 @@ impl<R: Region> MitoTable<R> {
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)
}

Expand Down Expand Up @@ -646,6 +658,14 @@ impl<R: Region> MitoTable<R> {
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!(
"MitoTable loads new region: {} in table: {}",
region_number,
Expand Down

0 comments on commit 7ff200c

Please sign in to comment.