mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +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);
|
return executeToDictionary(drop.database, drop.table, drop.kind, drop.if_exists, drop.temporary, drop.no_ddl_lock);
|
||||||
}
|
}
|
||||||
else if (!drop.database.empty())
|
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
|
else
|
||||||
throw Exception("Nothing to drop, both names are empty", ErrorCodes::LOGICAL_ERROR);
|
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, "");
|
auto ddl_guard = DatabaseCatalog::instance().getDDLGuard(database_name, "");
|
||||||
|
|
||||||
@ -252,8 +252,12 @@ BlockIO InterpreterDropQuery::executeToDatabase(const String & database_name, AS
|
|||||||
ASTDropQuery query;
|
ASTDropQuery query;
|
||||||
query.kind = kind;
|
query.kind = kind;
|
||||||
query.database = database_name;
|
query.database = database_name;
|
||||||
|
query.no_delay = no_delay;
|
||||||
|
|
||||||
for (auto iterator = database->getTablesIterator(context); iterator->isValid(); iterator->next())
|
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();
|
query.table = iterator->name();
|
||||||
executeToTable({query.database, query.table}, query);
|
executeToTable({query.database, query.table}, query);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ private:
|
|||||||
ASTPtr query_ptr;
|
ASTPtr query_ptr;
|
||||||
Context & context;
|
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);
|
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))
|
if (!ASTQueryWithOnCluster::parse(pos, cluster_str, expected))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s_no_delay.ignore(pos, expected) || s_sync.ignore(pos, expected))
|
||||||
|
no_delay = true;
|
||||||
}
|
}
|
||||||
else
|
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