Skip to content

Commit

Permalink
fix: fix inconsistent cache
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu committed Sep 19, 2023
1 parent f83b24e commit 0401f04
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/common/meta/src/ddl/drop_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 13 additions & 6 deletions src/operator/src/statement/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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))
}

Expand Down Expand Up @@ -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))
}

Expand Down

0 comments on commit 0401f04

Please sign in to comment.