mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
cancel merges before acquiring lock for truncate
This commit is contained in:
parent
9b844c6b42
commit
3e700e854d
@ -35,6 +35,10 @@ namespace ErrorCodes
|
|||||||
extern const int TABLE_IS_READ_ONLY;
|
extern const int TABLE_IS_READ_ONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ActionLocks
|
||||||
|
{
|
||||||
|
extern const StorageActionBlockType PartsMerge;
|
||||||
|
}
|
||||||
|
|
||||||
static DatabasePtr tryGetDatabase(const String & database_name, bool if_exists)
|
static DatabasePtr tryGetDatabase(const String & database_name, bool if_exists)
|
||||||
{
|
{
|
||||||
@ -202,7 +206,15 @@ BlockIO InterpreterDropQuery::executeToTableImpl(ContextPtr context_, ASTDropQue
|
|||||||
|
|
||||||
table->checkTableCanBeDropped();
|
table->checkTableCanBeDropped();
|
||||||
|
|
||||||
auto table_lock = table->lockExclusively(context_->getCurrentQueryId(), context_->getSettingsRef().lock_acquire_timeout);
|
TableExclusiveLockHolder table_lock;
|
||||||
|
/// We don't need this lock for ReplicatedMergeTree
|
||||||
|
if (!table->supportsReplication())
|
||||||
|
{
|
||||||
|
/// And for simple MergeTree we can stop merges before acquiring the lock
|
||||||
|
auto merges_blocker = table->getActionLock(ActionLocks::PartsMerge);
|
||||||
|
auto table_lock = table->lockExclusively(context_->getCurrentQueryId(), context_->getSettingsRef().lock_acquire_timeout);
|
||||||
|
}
|
||||||
|
|
||||||
auto metadata_snapshot = table->getInMemoryMetadataPtr();
|
auto metadata_snapshot = table->getInMemoryMetadataPtr();
|
||||||
/// Drop table data, don't touch metadata
|
/// Drop table data, don't touch metadata
|
||||||
table->truncate(query_ptr, metadata_snapshot, context_, table_lock);
|
table->truncate(query_ptr, metadata_snapshot, context_, table_lock);
|
||||||
|
Loading…
Reference in New Issue
Block a user