From 0401f042a1466cc3d8dcb913c1c33ac913055c02 Mon Sep 17 00:00:00 2001 From: WenyXu Date: Tue, 19 Sep 2023 15:33:49 +0000 Subject: [PATCH] fix: fix inconsistent cache --- src/common/meta/src/ddl/drop_table.rs | 5 +++-- src/operator/src/statement/ddl.rs | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/common/meta/src/ddl/drop_table.rs b/src/common/meta/src/ddl/drop_table.rs index 1de0f7b30636..c10296c1701d 100644 --- a/src/common/meta/src/ddl/drop_table.rs +++ b/src/common/meta/src/ddl/drop_table.rs @@ -121,12 +121,13 @@ impl DropTableProcedure { }; let cache_invalidator = &self.context.cache_invalidator; + cache_invalidator - .invalidate_table_id(&ctx, self.data.table_id()) + .invalidate_table_name(&ctx, self.data.table_ref().into()) .await?; cache_invalidator - .invalidate_table_name(&ctx, self.data.table_ref().into()) + .invalidate_table_id(&ctx, self.data.table_id()) .await?; self.data.state = DropTableState::DatanodeDropRegions; diff --git a/src/operator/src/statement/ddl.rs b/src/operator/src/statement/ddl.rs index 768f03a35878..f2752eba6b46 100644 --- a/src/operator/src/statement/ddl.rs +++ b/src/operator/src/statement/ddl.rs @@ -123,12 +123,6 @@ impl StatementExecutor { let table = DistTable::table(table_info); - // Invalidates local cache ASAP. - self.cache_invalidator - .invalidate_table_id(&Context::default(), table_id) - .await - .context(error::InvalidateTableCacheSnafu)?; - Ok(table) } @@ -154,6 +148,11 @@ impl StatementExecutor { .await .context(error::InvalidateTableCacheSnafu)?; + self.cache_invalidator + .invalidate_table_name(&Context::default(), table_name.clone()) + .await + .context(error::InvalidateTableCacheSnafu)?; + Ok(Output::AffectedRows(1)) } @@ -262,6 +261,14 @@ impl StatementExecutor { .await .context(error::InvalidateTableCacheSnafu)?; + self.cache_invalidator + .invalidate_table_name( + &Context::default(), + TableName::new(catalog_name, schema_name, table_name), + ) + .await + .context(error::InvalidateTableCacheSnafu)?; + Ok(Output::AffectedRows(0)) }