From 016e58ede0772ef60df3545453f47e2a7e2e8664 Mon Sep 17 00:00:00 2001 From: William Wen <44139337+wenym1@users.noreply.github.com> Date: Thu, 14 Dec 2023 21:55:38 +0800 Subject: [PATCH] feat(storage): remove table watermarks of dropped tables (#13960) --- proto/hummock.proto | 1 + src/meta/src/hummock/manager/compaction_group_manager.rs | 1 + .../hummock_sdk/src/compaction_group/hummock_version_ext.rs | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/proto/hummock.proto b/proto/hummock.proto index df582cc491ae3..63e85eed015aa 100644 --- a/proto/hummock.proto +++ b/proto/hummock.proto @@ -168,6 +168,7 @@ message HummockVersionDelta { bool trivial_move = 6; repeated uint64 gc_object_ids = 7; map new_table_watermarks = 8; + repeated uint32 removed_table_ids = 9; } message HummockVersionDeltas { diff --git a/src/meta/src/hummock/manager/compaction_group_manager.rs b/src/meta/src/hummock/manager/compaction_group_manager.rs index 01ee410db6a03..2389fe1538dc2 100644 --- a/src/meta/src/hummock/manager/compaction_group_manager.rs +++ b/src/meta/src/hummock/manager/compaction_group_manager.rs @@ -306,6 +306,7 @@ impl HummockManager { .len() as u64 - 1, ); + new_version_delta.removed_table_ids.push(*table_id); } // Remove empty group, GC SSTs and remove metric. diff --git a/src/storage/hummock_sdk/src/compaction_group/hummock_version_ext.rs b/src/storage/hummock_sdk/src/compaction_group/hummock_version_ext.rs index 1a85bea02b504..59bf9cfe559a5 100644 --- a/src/storage/hummock_sdk/src/compaction_group/hummock_version_ext.rs +++ b/src/storage/hummock_sdk/src/compaction_group/hummock_version_ext.rs @@ -572,6 +572,9 @@ impl HummockVersion { } self.id = version_delta.id; self.max_committed_epoch = version_delta.max_committed_epoch; + for table_id in &version_delta.removed_table_ids { + let _ = self.table_watermarks.remove(table_id); + } for (table_id, table_watermarks) in &version_delta.new_table_watermarks { match self.table_watermarks.entry(*table_id) { Entry::Occupied(mut entry) => { @@ -1010,6 +1013,7 @@ pub fn build_version_delta_after_version(version: &HummockVersion) -> HummockVer group_deltas: Default::default(), gc_object_ids: vec![], new_table_watermarks: HashMap::new(), + removed_table_ids: vec![], } }