Skip to content

Commit b37e778

Browse files
authored
feat: support vacuum leaked table data (#17022)-Revert (#17123)
* Revert "chore: add more log (#17110)" This reverts commit 0e05b43. * Revert "feat: support vacuum leaked table data (#17022)" This reverts commit 3a9f404.
1 parent ff78344 commit b37e778

File tree

6 files changed

+2
-81
lines changed

6 files changed

+2
-81
lines changed

src/query/ast/src/ast/statements/table.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,6 @@ pub struct VacuumDropTableOption {
789789
// Some(true) means dry run with summary option
790790
pub dry_run: Option<bool>,
791791
pub limit: Option<usize>,
792-
pub force: bool,
793792
}
794793

795794
impl Display for VacuumDropTableOption {
@@ -803,9 +802,6 @@ impl Display for VacuumDropTableOption {
803802
if let Some(limit) = self.limit {
804803
write!(f, " LIMIT {}", limit)?;
805804
}
806-
if self.force {
807-
write!(f, " FORCE")?;
808-
}
809805
Ok(())
810806
}
811807
}

src/query/ast/src/parser/statement.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3777,12 +3777,11 @@ pub fn literal_duration(i: Input) -> IResult<Duration> {
37773777
pub fn vacuum_drop_table_option(i: Input) -> IResult<VacuumDropTableOption> {
37783778
alt((map(
37793779
rule! {
3780-
(DRY ~ ^RUN ~ SUMMARY?)? ~ (LIMIT ~ #literal_u64)? ~ FORCE?
3780+
(DRY ~ ^RUN ~ SUMMARY?)? ~ (LIMIT ~ #literal_u64)?
37813781
},
3782-
|(opt_dry_run, opt_limit, opt_force)| VacuumDropTableOption {
3782+
|(opt_dry_run, opt_limit)| VacuumDropTableOption {
37833783
dry_run: opt_dry_run.map(|dry_run| dry_run.2.is_some()),
37843784
limit: opt_limit.map(|(_, limit)| limit as usize),
3785-
force: opt_force.is_some(),
37863785
},
37873786
),))(i)
37883787
}

src/query/ast/tests/it/testdata/stmt.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13016,7 +13016,6 @@ VacuumDropTable(
1301613016
option: VacuumDropTableOption {
1301713017
dry_run: None,
1301813018
limit: None,
13019-
force: false,
1302013019
},
1302113020
},
1302213021
)
@@ -13036,7 +13035,6 @@ VacuumDropTable(
1303613035
false,
1303713036
),
1303813037
limit: None,
13039-
force: false,
1304013038
},
1304113039
},
1304213040
)
@@ -13056,7 +13054,6 @@ VacuumDropTable(
1305613054
true,
1305713055
),
1305813056
limit: None,
13059-
force: false,
1306013057
},
1306113058
},
1306213059
)
@@ -13083,7 +13080,6 @@ VacuumDropTable(
1308313080
option: VacuumDropTableOption {
1308413081
dry_run: None,
1308513082
limit: None,
13086-
force: false,
1308713083
},
1308813084
},
1308913085
)
@@ -13112,7 +13108,6 @@ VacuumDropTable(
1311213108
limit: Some(
1311313109
10,
1311413110
),
13115-
force: false,
1311613111
},
1311713112
},
1311813113
)

src/query/service/src/interpreters/interpreter_vacuum_drop_tables.rs

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ use databend_common_meta_app::schema::DroppedId;
3131
use databend_common_meta_app::schema::GcDroppedTableReq;
3232
use databend_common_meta_app::schema::ListDroppedTableReq;
3333
use databend_common_sql::plans::VacuumDropTablePlan;
34-
use databend_common_storage::DataOperator;
3534
use databend_common_storages_view::view_table::VIEW_ENGINE;
3635
use databend_enterprise_vacuum_handler::get_vacuum_handler;
37-
use futures_util::TryStreamExt;
3836
use log::info;
3937

4038
use 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-
}

src/query/sql/src/planner/binder/ddl/table.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,6 @@ impl Binder {
12871287
VacuumDropTableOption {
12881288
dry_run: option.dry_run,
12891289
limit: option.limit,
1290-
force: option.force,
12911290
}
12921291
};
12931292
Ok(Plan::VacuumDropTable(Box::new(VacuumDropTablePlan {

src/query/sql/src/planner/plans/ddl/table.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ pub struct VacuumDropTableOption {
188188
// Some(true) means dry run with summary option
189189
pub dry_run: Option<bool>,
190190
pub limit: Option<usize>,
191-
pub force: bool,
192191
}
193192

194193
#[derive(Debug, Clone)]

0 commit comments

Comments
 (0)