mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
database_atomic_wait_for_drop_and_detach_synchronously/NO DELAY/SYNC for DROP DATABASE
This commit is contained in:
parent
32c449c34f
commit
6200783629
@ -52,7 +52,7 @@ BlockIO InterpreterDropQuery::execute()
|
||||
return executeToDictionary(drop.database, drop.table, drop.kind, drop.if_exists, drop.temporary, drop.no_ddl_lock);
|
||||
}
|
||||
else if (!drop.database.empty())
|
||||
return executeToDatabase(drop.database, drop.kind, drop.if_exists);
|
||||
return executeToDatabase(drop.database, drop.kind, drop.if_exists, drop.no_delay);
|
||||
else
|
||||
throw Exception("Nothing to drop, both names are empty", ErrorCodes::LOGICAL_ERROR);
|
||||
}
|
||||
@ -223,7 +223,7 @@ BlockIO InterpreterDropQuery::executeToTemporaryTable(const String & table_name,
|
||||
}
|
||||
|
||||
|
||||
BlockIO InterpreterDropQuery::executeToDatabase(const String & database_name, ASTDropQuery::Kind kind, bool if_exists)
|
||||
BlockIO InterpreterDropQuery::executeToDatabase(const String & database_name, ASTDropQuery::Kind kind, bool if_exists, bool no_delay)
|
||||
{
|
||||
auto ddl_guard = DatabaseCatalog::instance().getDDLGuard(database_name, "");
|
||||
|
||||
@ -252,8 +252,12 @@ BlockIO InterpreterDropQuery::executeToDatabase(const String & database_name, AS
|
||||
ASTDropQuery query;
|
||||
query.kind = kind;
|
||||
query.database = database_name;
|
||||
query.no_delay = no_delay;
|
||||
|
||||
for (auto iterator = database->getTablesIterator(context); iterator->isValid(); iterator->next())
|
||||
{
|
||||
/// Reset reference counter of the StoragePtr to allow synchronous drop.
|
||||
iterator->reset();
|
||||
query.table = iterator->name();
|
||||
executeToTable({query.database, query.table}, query);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ private:
|
||||
ASTPtr query_ptr;
|
||||
Context & context;
|
||||
|
||||
BlockIO executeToDatabase(const String & database_name, ASTDropQuery::Kind kind, bool if_exists);
|
||||
BlockIO executeToDatabase(const String & database_name, ASTDropQuery::Kind kind, bool if_exists, bool no_delay);
|
||||
|
||||
BlockIO executeToTable(const StorageID & table_id, const ASTDropQuery & query);
|
||||
|
||||
|
@ -46,6 +46,9 @@ bool parseDropQuery(IParser::Pos & pos, ASTPtr & node, Expected & expected, bool
|
||||
if (!ASTQueryWithOnCluster::parse(pos, cluster_str, expected))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (s_no_delay.ignore(pos, expected) || s_sync.ignore(pos, expected))
|
||||
no_delay = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -0,0 +1,34 @@
|
||||
drop database if exists db_01530_atomic sync;
|
||||
|
||||
create database db_01530_atomic Engine=Atomic;
|
||||
create table db_01530_atomic.data (key Int) Engine=ReplicatedMergeTree('/clickhouse/tables/db_01530_atomic/data', 'test') order by key;
|
||||
drop database db_01530_atomic sync;
|
||||
|
||||
create database db_01530_atomic Engine=Atomic;
|
||||
create table db_01530_atomic.data (key Int) Engine=ReplicatedMergeTree('/clickhouse/tables/db_01530_atomic/data', 'test') order by key;
|
||||
drop database db_01530_atomic sync;
|
||||
|
||||
|
||||
set database_atomic_wait_for_drop_and_detach_synchronously=1;
|
||||
|
||||
create database db_01530_atomic Engine=Atomic;
|
||||
create table db_01530_atomic.data (key Int) Engine=ReplicatedMergeTree('/clickhouse/tables/db_01530_atomic/data', 'test') order by key;
|
||||
drop database db_01530_atomic;
|
||||
|
||||
create database db_01530_atomic Engine=Atomic;
|
||||
create table db_01530_atomic.data (key Int) Engine=ReplicatedMergeTree('/clickhouse/tables/db_01530_atomic/data', 'test') order by key;
|
||||
drop database db_01530_atomic;
|
||||
|
||||
|
||||
set database_atomic_wait_for_drop_and_detach_synchronously=0;
|
||||
|
||||
create database db_01530_atomic Engine=Atomic;
|
||||
create table db_01530_atomic.data (key Int) Engine=ReplicatedMergeTree('/clickhouse/tables/db_01530_atomic/data', 'test') order by key;
|
||||
drop database db_01530_atomic;
|
||||
|
||||
create database db_01530_atomic Engine=Atomic;
|
||||
create table db_01530_atomic.data (key Int) Engine=ReplicatedMergeTree('/clickhouse/tables/db_01530_atomic/data', 'test') order by key; -- { serverError 253; }
|
||||
-- TODO: SYSTEM FORCE DROP and uncomment the line below to cleanup the data after test
|
||||
-- (otherwise the test is not retriable...)
|
||||
--
|
||||
-- drop database db_01530_atomic sync;
|
Loading…
Reference in New Issue
Block a user