From 3c0ae96e1c377b21bbb2b02baa6e10511b76b326 Mon Sep 17 00:00:00 2001 From: August Date: Thu, 29 Feb 2024 18:19:38 +0800 Subject: [PATCH] fix recovery test --- src/meta/src/manager/catalog/mod.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/meta/src/manager/catalog/mod.rs b/src/meta/src/manager/catalog/mod.rs index 33990548f01b8..5edc761914ebf 100644 --- a/src/meta/src/manager/catalog/mod.rs +++ b/src/meta/src/manager/catalog/mod.rs @@ -797,13 +797,15 @@ impl CatalogManager { Ok(()) } - fn assert_table_creating(tables: &BTreeMap, table: &Table) { - if let Some(t) = tables.get(&table.id) - && let Ok(StreamJobStatus::Creating) = t.get_stream_job_status() - { + fn check_table_creating(tables: &BTreeMap, table: &Table) -> MetaResult<()> { + return if let Some(t) = tables.get(&table.id) { + assert_eq!(t.get_stream_job_status(), Ok(StreamJobStatus::Creating)); + Ok(()) } else { - panic!("Table must be in creating procedure: {table:#?}") - } + // If the table does not exist, it should be created in Foreground and cleaned during recovery in some cases. + assert_eq!(table.create_type(), CreateType::Foreground); + Err(anyhow!("failed to create table during recovery").into()) + }; } pub async fn assert_tables_deleted(&self, table_ids: Vec) { @@ -1007,7 +1009,7 @@ impl CatalogManager { let database_core = &mut core.database; let tables = &mut database_core.tables; if cfg!(not(test)) { - Self::assert_table_creating(tables, &table); + Self::check_table_creating(tables, &table)?; } let mut tables = BTreeMapTransaction::new(tables);