Skip to content

Commit c97c3c0

Browse files
authored
fix: recluster transient table failed with TransactionTimeout (#17868)
1 parent 4cc3cec commit c97c3c0

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

src/query/catalog/src/table_context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ pub trait TableContext: Send + Sync {
354354
previous_snapshot: Option<Arc<TableSnapshot>>,
355355
) -> Result<TableMetaTimestamps>;
356356

357+
fn clear_table_meta_timestamps_cache(&self);
358+
357359
fn get_read_block_thresholds(&self) -> BlockThresholds;
358360
fn set_read_block_thresholds(&self, _thresholds: BlockThresholds);
359361

src/query/service/src/interpreters/interpreter_table_recluster.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ impl ReclusterTableInterpreter {
192192
push_downs: &mut Option<PushDownInfo>,
193193
hilbert_info: &mut Option<HilbertBuildInfo>,
194194
) -> Result<bool> {
195+
self.ctx.clear_table_meta_timestamps_cache();
195196
let start = SystemTime::now();
196197
let settings = self.ctx.get_settings();
197198

src/query/service/src/sessions/query_ctx.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,11 @@ impl TableContext for QueryContext {
15321532
}
15331533
}
15341534

1535+
fn clear_table_meta_timestamps_cache(&self) {
1536+
let cache = self.shared.get_table_meta_timestamps();
1537+
cache.lock().clear();
1538+
}
1539+
15351540
fn get_read_block_thresholds(&self) -> BlockThresholds {
15361541
*self.block_threshold.read()
15371542
}

src/query/service/tests/it/sql/exec/get_table_bind_test.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,10 @@ impl TableContext for CtxDelegation {
10061006
self.ctx.get_table_meta_timestamps(table, previous_snapshot)
10071007
}
10081008

1009+
fn clear_table_meta_timestamps_cache(&self) {
1010+
self.ctx.clear_table_meta_timestamps_cache();
1011+
}
1012+
10091013
fn get_temp_table_prefix(&self) -> Result<String> {
10101014
todo!()
10111015
}

src/query/service/tests/it/storages/fuse/operations/commit.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,10 @@ impl TableContext for CtxDelegation {
895895
) -> Result<TableMetaTimestamps> {
896896
self.ctx.get_table_meta_timestamps(table, previous_snapshot)
897897
}
898+
899+
fn clear_table_meta_timestamps_cache(&self) {
900+
self.ctx.clear_table_meta_timestamps_cache();
901+
}
898902
}
899903

900904
#[derive(Clone, Debug)]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
statement ok
2+
create or replace transient table t (c int) cluster by (c);
3+
4+
statement ok
5+
insert into t values(1), (3), (5);
6+
7+
statement ok
8+
insert into t values(2), (7), (9);
9+
10+
statement ok
11+
alter table t recluster final;
12+
13+
statement ok
14+
insert into t values(1), (3), (5);
15+
16+
statement ok
17+
insert into t values(2), (7), (9);
18+
19+
statement ok
20+
alter table t recluster final;

0 commit comments

Comments
 (0)