Skip to content

Commit

Permalink
chore: fix vacuum drop table dry run bug (#12182)
Browse files Browse the repository at this point in the history
* chore: fix vacuum drop table dry run bug

* chore: add test case

* add info log
  • Loading branch information
lichuang authored Jul 24, 2023
1 parent 2fd4a3c commit 6e596bc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use common_meta_app::schema::GcDroppedTableReq;
use common_meta_app::schema::ListDroppedTableReq;
use common_meta_app::schema::TableInfoFilter;
use common_sql::plans::VacuumDropTablePlan;
use tracing::info;
use vacuum_handler::get_vacuum_handler;

use crate::interpreters::Interpreter;
Expand Down Expand Up @@ -102,12 +103,15 @@ impl Interpreter for VacuumDropTablesInterpreter {
},
)
.await?;
// gc meta data
let req = GcDroppedTableReq {
tenant: self.ctx.get_tenant(),
drop_ids,
};
let _ = catalog.gc_drop_tables(req).await?;
// gc meta data only when not dry run
if self.plan.option.dry_run.is_none() {
info!("vacuum drop table drop_ids: {:?}", drop_ids);
let req = GcDroppedTableReq {
tenant: self.ctx.get_tenant(),
drop_ids,
};
let _ = catalog.gc_drop_tables(req).await?;
}

match files_opt {
None => return Ok(PipelineBuildResult::create()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
4
888
1024
1
1
11 changes: 11 additions & 0 deletions tests/suites/5_ee/01_vacuum/01_0002_ee_vacuum_drop_table.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
echo "drop database if exists test_vacuum_drop" | $MYSQL_CLIENT_CONNECT
echo "drop database if exists test_vacuum_drop_2" | $MYSQL_CLIENT_CONNECT
echo "drop database if exists test_vacuum_drop_3" | $MYSQL_CLIENT_CONNECT
echo "drop database if exists test_vacuum_drop_4" | $MYSQL_CLIENT_CONNECT

echo "CREATE DATABASE test_vacuum_drop" | $MYSQL_CLIENT_CONNECT
echo "create table test_vacuum_drop.a(c int)" | $MYSQL_CLIENT_CONNECT
Expand Down Expand Up @@ -77,5 +78,15 @@ echo "drop table table_drop_external_location;" | $MYSQL_CLIENT_CONNECT

echo "vacuum drop table retain 0 hours" | $MYSQL_CLIENT_CONNECT

## dry run
echo "CREATE DATABASE test_vacuum_drop_4" | $MYSQL_CLIENT_CONNECT
echo "create table test_vacuum_drop_4.a(c int)" | $MYSQL_CLIENT_CONNECT
echo "INSERT INTO test_vacuum_drop_4.a VALUES (1)" | $MYSQL_CLIENT_CONNECT
echo "select * from test_vacuum_drop_4.a" | $MYSQL_CLIENT_CONNECT
echo "drop table test_vacuum_drop_4.a" | $MYSQL_CLIENT_CONNECT
echo "vacuum drop table retain 0 hours dry run" | $MYSQL_CLIENT_CONNECT > /dev/null
echo "undrop table test_vacuum_drop_4.a" | $MYSQL_CLIENT_CONNECT
echo "select * from test_vacuum_drop_4.a" | $MYSQL_CLIENT_CONNECT

## Drop table
echo "drop table if exists table_drop_external_location;" | $MYSQL_CLIENT_CONNECT

1 comment on commit 6e596bc

@vercel
Copy link

@vercel vercel bot commented on 6e596bc Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

databend – ./

databend-databend.vercel.app
databend-git-main-databend.vercel.app
databend.vercel.app
databend.rs

Please sign in to comment.