@@ -31,10 +31,8 @@ use databend_common_meta_app::schema::DroppedId;
3131use databend_common_meta_app:: schema:: GcDroppedTableReq ;
3232use databend_common_meta_app:: schema:: ListDroppedTableReq ;
3333use databend_common_sql:: plans:: VacuumDropTablePlan ;
34- use databend_common_storage:: DataOperator ;
3534use databend_common_storages_view:: view_table:: VIEW_ENGINE ;
3635use databend_enterprise_vacuum_handler:: get_vacuum_handler;
37- use futures_util:: TryStreamExt ;
3836use log:: info;
3937
4038use crate :: interpreters:: Interpreter ;
@@ -118,11 +116,6 @@ impl Interpreter for VacuumDropTablesInterpreter {
118116 LicenseManagerSwitch :: instance ( )
119117 . check_enterprise_enabled ( self . ctx . get_license_key ( ) , Vacuum ) ?;
120118
121- if self . plan . option . force {
122- self . vacuum_drop_tables_force ( ) . await ?;
123- return Ok ( PipelineBuildResult :: create ( ) ) ;
124- }
125-
126119 let ctx = self . ctx . clone ( ) ;
127120 let duration = Duration :: days ( ctx. get_settings ( ) . get_data_retention_time_in_days ( ) ? as i64 ) ;
128121
@@ -140,7 +133,6 @@ impl Interpreter for VacuumDropTablesInterpreter {
140133 } ;
141134
142135 let tenant = self . ctx . get_tenant ( ) ;
143-
144136 let ( tables, drop_ids) = catalog
145137 . get_drop_table_infos ( ListDroppedTableReq :: new4 (
146138 & tenant,
@@ -283,62 +275,3 @@ impl Interpreter for VacuumDropTablesInterpreter {
283275 }
284276 }
285277}
286-
287- impl VacuumDropTablesInterpreter {
288- async fn vacuum_drop_tables_force ( & self ) -> Result < ( ) > {
289- let catalog = self . ctx . get_catalog ( self . plan . catalog . as_str ( ) ) . await ?;
290- let op = DataOperator :: instance ( ) . operator ( ) ;
291- let databases = match self . plan . database . is_empty ( ) {
292- true => catalog. list_databases ( & self . ctx . get_tenant ( ) ) . await ?,
293- false => {
294- let database = catalog
295- . get_database ( & self . ctx . get_tenant ( ) , & self . plan . database )
296- . await ?;
297- vec ! [ database]
298- }
299- } ;
300-
301- for database in databases {
302- if database. name ( ) == "system" || database. name ( ) == "information_schema" {
303- continue ;
304- }
305- let db_id = database. get_db_info ( ) . database_id . db_id ;
306- info ! (
307- "vacuum drop table force from db name: {}, id: {}" ,
308- database. name( ) ,
309- db_id
310- ) ;
311- let mut lister = op. lister_with ( & db_id. to_string ( ) ) . recursive ( true ) . await ?;
312- let mut paths = vec ! [ ] ;
313- let mut orphan_paths = vec ! [ ] ;
314- while let Some ( entry) = lister. try_next ( ) . await ? {
315- paths. push ( entry. path ( ) . to_string ( ) ) ;
316- }
317- let tables_in_meta = database. list_tables_history ( ) . await ?;
318- let table_ids_in_meta = tables_in_meta
319- . iter ( )
320- . map ( |t| t. get_id ( ) )
321- . collect :: < HashSet < _ > > ( ) ;
322- info ! ( "table_ids_in_meta: {:?}" , table_ids_in_meta) ;
323- for path in paths {
324- let Some ( table_id) = path. split ( '/' ) . nth ( 1 ) else {
325- info ! ( "can not parse table id from path: {}" , path) ;
326- continue ;
327- } ;
328- info ! ( "split table id:{} from path: {}" , table_id, path) ;
329- let Some ( table_id) = table_id. parse :: < u64 > ( ) . ok ( ) else {
330- info ! ( "can not parse table id from path: {}" , path) ;
331- continue ;
332- } ;
333- info ! ( "parse table id:{} from path: {}" , table_id, path) ;
334- if !table_ids_in_meta. contains ( & table_id) {
335- orphan_paths. push ( path) ;
336- }
337- }
338- info ! ( "orphan_paths summary: {:?}" , orphan_paths) ;
339- op. remove ( orphan_paths) . await ?;
340- }
341-
342- Ok ( ( ) )
343- }
344- }
0 commit comments