@@ -42,7 +42,6 @@ use databend_storages_common_table_meta::meta::Location;
4242use databend_storages_common_table_meta:: meta:: SegmentInfo ;
4343use databend_storages_common_table_meta:: meta:: TableSnapshot ;
4444use databend_storages_common_table_meta:: meta:: TableSnapshotStatistics ;
45- use databend_storages_common_table_meta:: meta:: VACUUM2_OBJECT_KEY_PREFIX ;
4645use log:: error;
4746use log:: info;
4847use log:: warn;
@@ -58,7 +57,6 @@ use crate::io::SnapshotsIO;
5857use crate :: io:: TableMetaLocationGenerator ;
5958use crate :: FuseTable ;
6059use crate :: RetentionPolicy ;
61- use crate :: FUSE_TBL_REF_PREFIX ;
6260use crate :: FUSE_TBL_SNAPSHOT_PREFIX ;
6361
6462impl FuseTable {
@@ -743,7 +741,7 @@ impl FuseTable {
743741 /// Returns gc_root location if found
744742 async fn select_branch_gc_root (
745743 & self ,
746- ref_prefix : & str ,
744+ ref_name : & str ,
747745 snapshots_before_retention : & [ Entry ] ,
748746 ref_protected_segments : & mut HashSet < Location > ,
749747 ref_snapshots_to_purge : & mut Vec < String > ,
@@ -761,15 +759,9 @@ impl FuseTable {
761759 let Some ( ( gc_root_id, gc_root_ver) ) = last_snapshot. prev_snapshot_id else {
762760 return Ok ( None ) ;
763761 } ;
764-
765- let gc_root_path = format ! (
766- "{}{}{}_v{}.mpk" ,
767- ref_prefix,
768- VACUUM2_OBJECT_KEY_PREFIX ,
769- gc_root_id. simple( ) ,
770- gc_root_ver,
771- ) ;
772-
762+ let gc_root_path = self
763+ . meta_location_generator ( )
764+ . ref_snapshot_location_from_uuid ( ref_name, & gc_root_id, gc_root_ver) ?;
773765 // Try to read gc_root snapshot
774766 match SnapshotsIO :: read_snapshot ( gc_root_path. clone ( ) , op. clone ( ) , false ) . await {
775767 Ok ( ( gc_root_snap, _) ) => {
@@ -818,6 +810,9 @@ impl FuseTable {
818810 let now = Utc :: now ( ) ;
819811 let table_info = self . get_table_info ( ) ;
820812 let retention_policy = self . get_data_retention_policy ( ctx. as_ref ( ) ) ?;
813+ let ref_snapshot_location_prefix = self
814+ . meta_location_generator ( )
815+ . ref_snapshot_location_prefix ( ) ;
821816
822817 let mut ref_protected_segments = HashSet :: new ( ) ;
823818 let mut ref_snapshots_to_purge = Vec :: new ( ) ;
@@ -847,12 +842,7 @@ impl FuseTable {
847842 }
848843 SnapshotRefInfo :: Branch { head, anchor } => {
849844 // Branch: process based on retention policy
850- let ref_prefix = format ! (
851- "{}/{}/{}/" ,
852- self . meta_location_generator( ) . prefix( ) ,
853- FUSE_TBL_REF_PREFIX ,
854- ref_name
855- ) ;
845+ let ref_prefix = format ! ( "{}{}/" , ref_snapshot_location_prefix, ref_name) ;
856846
857847 let snapshots_before_lvt = match & retention_policy {
858848 RetentionPolicy :: ByTimePeriod ( delta_duration) => {
@@ -887,7 +877,7 @@ impl FuseTable {
887877
888878 let new_anchor = match self
889879 . select_branch_gc_root (
890- & ref_prefix ,
880+ ref_name ,
891881 & snapshots_before_lvt,
892882 & mut ref_protected_segments,
893883 & mut ref_snapshots_to_purge,
@@ -954,12 +944,7 @@ impl FuseTable {
954944 if !expired_refs. is_empty ( ) {
955945 let operator = self . get_operator ( ) ;
956946 for ref_name in & expired_refs {
957- let dir = format ! (
958- "{}/{}/{}/" ,
959- self . meta_location_generator( ) . prefix( ) ,
960- FUSE_TBL_REF_PREFIX ,
961- ref_name
962- ) ;
947+ let dir = format ! ( "{}{}/" , ref_snapshot_location_prefix, ref_name) ;
963948 operator. remove_all ( & dir) . await . inspect_err ( |err| {
964949 error ! ( "Failed to remove expired ref directory {}: {}" , dir, err) ;
965950 } ) ?;
0 commit comments