From 566cf59a6dce03dec89493c10bea8bd5bf5541e5 Mon Sep 17 00:00:00 2001 From: Emma Forman Ling Date: Mon, 9 Sep 2024 13:05:25 -0700 Subject: [PATCH] clean up orphaned table namespaces (#29680) In components push, we create a bunch of system and user tables in `start_push` that might not end up being used if `finish_push` is never called because of a validation error or other interruption. We should clean them up to avoid having tons of unused tables lying around. GitOrigin-RevId: e73a29b9b435d70ae44131383445c18341a92700 --- crates/database/src/bootstrap_model/table.rs | 2 +- crates/value/src/table_mapping.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/database/src/bootstrap_model/table.rs b/crates/database/src/bootstrap_model/table.rs index 1badc59a..15356217 100644 --- a/crates/database/src/bootstrap_model/table.rs +++ b/crates/database/src/bootstrap_model/table.rs @@ -223,7 +223,7 @@ impl<'a, RT: Runtime> TableModel<'a, RT> { Ok(()) } - async fn get_table_metadata( + pub async fn get_table_metadata( &mut self, tablet_id: TabletId, ) -> anyhow::Result> { diff --git a/crates/value/src/table_mapping.rs b/crates/value/src/table_mapping.rs index 23b3d3eb..21178e4b 100644 --- a/crates/value/src/table_mapping.rs +++ b/crates/value/src/table_mapping.rs @@ -119,6 +119,12 @@ impl TableMapping { }) } + pub fn iter_active_namespaces( + &self, + ) -> impl Iterator)> { + self.table_name_to_canonical_tablet.iter() + } + pub fn namespaces_for_name(&self, name: &TableName) -> Vec { self.iter() .filter(|(_, _, _, table_name)| *table_name == name)