Skip to content

Commit

Permalink
feat: invalidate cache step4
Browse files Browse the repository at this point in the history
  • Loading branch information
fengjiachun committed Mar 26, 2024
1 parent 7645118 commit 866edde
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 18 deletions.
4 changes: 1 addition & 3 deletions src/cmd/src/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,7 @@ impl StartCommand {

let executor = HandlerGroupExecutor::new(vec![
Arc::new(ParseMailboxMessageHandler),
Arc::new(InvalidateTableCacheHandler::new(
cached_meta_backend.clone(),
)),
Arc::new(InvalidateTableCacheHandler::new(catalog_manager.clone())),
]);

let heartbeat_task = HeartbeatTask::new(
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/src/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,12 @@ impl StartCommand {

let mut frontend = FrontendBuilder::new(
kv_backend,
catalog_manager,
catalog_manager.clone(),
datanode_manager,
ddl_task_executor,
)
.with_plugin(fe_plugins.clone())
.with_cache_invalidator(catalog_manager)
.try_build()
.await
.context(StartFrontendSnafu)?;
Expand Down
16 changes: 6 additions & 10 deletions src/common/meta/src/ddl/alter_logical_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,13 @@ impl Procedure for AlterLogicalTablesProcedure {
lock_key.push(CatalogLock::Read(table_ref.catalog).into());
lock_key.push(SchemaLock::read(table_ref.catalog, table_ref.schema).into());
lock_key.push(TableLock::Write(self.data.physical_table_id).into());
lock_key.extend(
self.data
.table_info_values
.iter()
.map(|table| TableLock::Write(table.table_info.ident.table_id)),
);

for task in &self.data.tasks {
lock_key.push(
TableNameLock::new(
&task.alter_table.catalog_name,
&task.alter_table.schema_name,
&task.alter_table.table_name,
)
.into(),
);
}
LockKey::new(lock_key)
}
}
Expand Down
4 changes: 1 addition & 3 deletions tests-integration/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,7 @@ impl GreptimeDbClusterBuilder {

let handlers_executor = HandlerGroupExecutor::new(vec![
Arc::new(ParseMailboxMessageHandler),
Arc::new(InvalidateTableCacheHandler::new(
cached_meta_backend.clone(),
)),
Arc::new(InvalidateTableCacheHandler::new(catalog_manager.clone())),
]);

let heartbeat_task = HeartbeatTask::new(
Expand Down
3 changes: 2 additions & 1 deletion tests-integration/src/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,12 @@ impl GreptimeDbStandaloneBuilder {

let instance = FrontendBuilder::new(
kv_backend.clone(),
catalog_manager,
catalog_manager.clone(),
datanode_manager,
ddl_task_executor,
)
.with_plugin(plugins)
.with_cache_invalidator(catalog_manager)
.try_build()
.await
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ DESC TABLE phy;
| __tsid | UInt64 | PRI | NO | | TAG |
| host | String | PRI | YES | | TAG |
| job | String | PRI | YES | | TAG |
| k | String | PRI | YES | | TAG |
+------------+----------------------+-----+------+---------+---------------+

DROP TABLE t1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ SHOW TABLES;
| phy |
+---------+

DESC TABLE phy;

+--------+----------------------+-----+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------+----------------------+-----+------+---------+---------------+
| ts | TimestampMillisecond | PRI | NO | | TIMESTAMP |
| val | Float64 | | YES | | FIELD |
+--------+----------------------+-----+------+---------+---------------+

CREATE TABLE t1 (ts timestamp time index, val double, host string primary key) engine = metric with ("on_physical_table" = "phy");

Affected Rows: 0
Expand Down
2 changes: 2 additions & 0 deletions tests/cases/standalone/common/create/create_metric_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ CREATE TABLE phy (ts timestamp time index, val double) engine=metric with ("phys

SHOW TABLES;

DESC TABLE phy;

CREATE TABLE t1 (ts timestamp time index, val double, host string primary key) engine = metric with ("on_physical_table" = "phy");

CREATE TABLE t2 (ts timestamp time index, job string primary key, val double) engine = metric with ("on_physical_table" = "phy");
Expand Down

0 comments on commit 866edde

Please sign in to comment.