Skip to content

Commit b5c2320

Browse files
committed
update
1 parent 71eb8a2 commit b5c2320

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/query/ee/src/storages/fuse/operations/vacuum_table_v2.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ pub async fn do_vacuum2(
227227

228228
let start = std::time::Instant::now();
229229
let gc_root_timestamp = gc_root.timestamp.unwrap();
230-
// Persist the LVT only if we have not written it before.
230+
// NOTE: when using the time-based retention policy we already persisted an LVT above to
231+
// constrain snapshot listing, and that value can legitimately be newer than the gc_root.
232+
// The meta side only ever moves LVT forward, so only retention policies that have not
233+
// written an LVT in this run (e.g. keep-N-snapshots) need to persist it here.
231234
if need_update_lvt {
232235
let cat = ctx.get_default_catalog()?;
233236
cat.set_table_lvt(

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub struct TxnBuffer {
6767
table_desc_to_id: HashMap<String, u64>,
6868
mutated_tables: HashMap<u64, TableInfo>,
6969
base_snapshot_location: HashMap<u64, Option<String>>,
70-
snapshot_ts: HashMap<u64, Option<DateTime<Utc>>>,
70+
snapshot_ts: HashMap<u64, DateTime<Utc>>,
7171
tenant: HashMap<u64, Tenant>,
7272
copied_files: HashMap<u64, Vec<UpsertTableCopiedFileReq>>,
7373
update_stream_meta: HashMap<u64, UpdateStreamMetaReq>,
@@ -109,7 +109,9 @@ impl TxnBuffer {
109109
.entry(table_id)
110110
.or_insert(req.base_snapshot_location);
111111

112-
self.snapshot_ts.entry(table_id).or_insert(req.snapshot_ts);
112+
if let Some(ts) = req.snapshot_ts {
113+
self.snapshot_ts.entry(table_id).or_insert(ts);
114+
}
113115

114116
self.tenant.entry(table_id).or_insert(req.tenant);
115117
}
@@ -321,7 +323,7 @@ impl TxnManager {
321323
seq: MatchSeq::Exact(info.ident.seq),
322324
new_table_meta: info.meta.clone(),
323325
base_snapshot_location: None,
324-
snapshot_ts: self.txn_buffer.snapshot_ts.get(id).cloned().flatten(),
326+
snapshot_ts: self.txn_buffer.snapshot_ts.get(id).cloned(),
325327
},
326328
info.clone(),
327329
)

0 commit comments

Comments
 (0)