Merge pull request #21716 from azat/concurrent-OPTIMIZE-DROP-fix

[RFC] Fix concurrent OPTIMIZE and DROP for ReplicatedMergeTree
This commit is contained in:
alexey-milovidov 2021-03-15 14:12:27 +03:00 committed by GitHub
commit 8d1bf002e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4151,6 +4151,10 @@ bool StorageReplicatedMergeTree::optimize(
const Names & deduplicate_by_columns,
const Context & query_context)
{
/// NOTE: exclusive lock cannot be used here, since this may lead to deadlock (see comments below),
/// but it should be safe to use non-exclusive to avoid dropping parts that may be required for processing queue.
auto table_lock = lockForShare(query_context.getCurrentQueryId(), query_context.getSettingsRef().lock_acquire_timeout);
assertNotReadonly();
if (!is_leader)