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)); } }