From a937721f18bb229b857c37debfd543d7cb3a85e0 Mon Sep 17 00:00:00 2001 From: August Date: Tue, 6 Aug 2024 17:03:24 +0800 Subject: [PATCH] clear tracker for non-background jobs when clean --- src/meta/src/manager/catalog/database.rs | 12 ++++++++++++ src/meta/src/manager/catalog/mod.rs | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/src/meta/src/manager/catalog/database.rs b/src/meta/src/manager/catalog/database.rs index da1238d43d54b..747c1fe91de9d 100644 --- a/src/meta/src/manager/catalog/database.rs +++ b/src/meta/src/manager/catalog/database.rs @@ -352,6 +352,18 @@ impl DatabaseManager { .collect_vec() } + pub fn list_creating_background_mv_ids(&self) -> HashSet { + self.tables + .values() + .filter(|&t| { + t.stream_job_status == PbStreamJobStatus::Creating as i32 + && t.table_type == TableType::MaterializedView as i32 + && t.create_type == CreateType::Background as i32 + }) + .map(|t| t.id) + .collect() + } + pub fn list_persisted_creating_tables(&self) -> Vec { self.tables .values() diff --git a/src/meta/src/manager/catalog/mod.rs b/src/meta/src/manager/catalog/mod.rs index 2997b0cc3b164..b04ea11afb09d 100644 --- a/src/meta/src/manager/catalog/mod.rs +++ b/src/meta/src/manager/catalog/mod.rs @@ -249,6 +249,10 @@ impl CatalogManagerCore { { let _ = tx.send(Err(err.clone())); } + let creating_background_mvs = self.database.list_creating_background_mv_ids(); + self.database + .in_progress_creation_streaming_job + .retain(|id, _| creating_background_mvs.contains(id)); } }