Skip to content

Commit 46800ef

Browse files
committed
fix: transient table not work as expected inside explicit txn
Instead of caching table meta timestamps in txn manager, build table meta tiemstamp according to the last visible table inside the transation.
1 parent 385ae72 commit 46800ef

File tree

2 files changed

+48
-13
lines changed

2 files changed

+48
-13
lines changed

src/query/storages/common/session/src/transaction.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use std::collections::hash_map::Entry;
1615
use std::collections::BTreeMap;
1716
use std::collections::HashMap;
1817
use std::collections::HashSet;
@@ -66,8 +65,7 @@ pub struct TxnBuffer {
6665
stream_tables: HashMap<u64, StreamSnapshot>,
6766
need_purge_files: Vec<(StageInfo, Vec<String>)>,
6867

69-
pub table_meta_timestamps: HashMap<u64, TableMetaTimestamps>,
70-
68+
// pub table_meta_timestamps: HashMap<u64, TableMetaTimestamps>,
7169
temp_table_desc_to_id: HashMap<String, u64>,
7270
mutated_temp_tables: HashMap<u64, TempTable>,
7371
}
@@ -366,23 +364,25 @@ impl TxnManager {
366364

367365
pub fn get_table_meta_timestamps(
368366
&mut self,
369-
table_id: u64,
367+
_table_id: u64,
370368
previous_snapshot: Option<Arc<TableSnapshot>>,
371369
delta: Duration,
372370
) -> TableMetaTimestamps {
373371
if !self.is_active() {
374372
return TableMetaTimestamps::new(previous_snapshot, delta);
375373
}
376374

377-
let entry = self.txn_buffer.table_meta_timestamps.entry(table_id);
378-
match entry {
379-
Entry::Occupied(e) => *e.get(),
380-
Entry::Vacant(e) => {
381-
let timestamps = TableMetaTimestamps::new(previous_snapshot, delta);
382-
e.insert(timestamps);
383-
timestamps
384-
}
385-
}
375+
TableMetaTimestamps::new(previous_snapshot, delta)
376+
377+
// let entry = self.txn_buffer.table_meta_timestamps.entry(table_id);
378+
// match entry {
379+
// Entry::Occupied(e) => *e.get(),
380+
// Entry::Vacant(e) => {
381+
// let timestamps = TableMetaTimestamps::new(previous_snapshot, delta);
382+
// e.insert(timestamps);
383+
// timestamps
384+
// }
385+
//}
386386
}
387387

388388
pub fn get_base_snapshot_location(&self, table_id: u64) -> Option<String> {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
statement ok
2+
create or replace database issue_18159
3+
4+
statement ok
5+
use issue_18159
6+
7+
statement ok
8+
create or replace transient table c( c int);
9+
10+
statement ok
11+
insert into c values(1);
12+
13+
statement ok
14+
begin;
15+
16+
statement ok
17+
delete from c where c = 1;
18+
19+
statement ok
20+
insert into c values(2);
21+
22+
statement ok
23+
insert into c values(3);
24+
25+
statement ok
26+
commit;
27+
28+
query T
29+
select * from c order by c;
30+
----
31+
2
32+
3
33+
34+
statement ok
35+
drop database issue_18159

0 commit comments

Comments
 (0)