diff --git a/src/common/meta/src/ddl/drop_table/metadata.rs b/src/common/meta/src/ddl/drop_table/metadata.rs index 706dc398ab33..5e182720fe87 100644 --- a/src/common/meta/src/ddl/drop_table/metadata.rs +++ b/src/common/meta/src/ddl/drop_table/metadata.rs @@ -14,7 +14,7 @@ use common_catalog::format_full_table_name; use snafu::OptionExt; -use store_api::metric_engine_consts::{LOGICAL_TABLE_METADATA_KEY, METRIC_ENGINE_NAME}; +use store_api::metric_engine_consts::METRIC_ENGINE_NAME; use crate::ddl::drop_table::DropTableProcedure; use crate::error::{self, Result}; @@ -33,26 +33,21 @@ impl DropTableProcedure { self.data.physical_region_routes = physical_table_route_value.region_routes; self.data.physical_table_id = Some(physical_table_id); - let table_info_value = self - .context - .table_metadata_manager - .table_info_manager() - .get(task.table_id) - .await? - .with_context(|| error::TableInfoNotFoundSnafu { - table: format_full_table_name(&task.catalog, &task.schema, &task.table), - })? - .into_inner(); + if physical_table_id == self.data.table_id() { + let table_info_value = self + .context + .table_metadata_manager + .table_info_manager() + .get(task.table_id) + .await? + .with_context(|| error::TableInfoNotFoundSnafu { + table: format_full_table_name(&task.catalog, &task.schema, &task.table), + })? + .into_inner(); - let engine = table_info_value.table_info.meta.engine; - if engine.as_str() == METRIC_ENGINE_NAME { - let physical = !table_info_value - .table_info - .meta - .options - .extra_options - .contains_key(LOGICAL_TABLE_METADATA_KEY); - self.data.allow_rollback = physical; + let engine = table_info_value.table_info.meta.engine; + // rollback only if dropping the metric physical table fails + self.data.allow_rollback = engine.as_str() == METRIC_ENGINE_NAME } Ok(())