mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
commit
bdc7614c77
@ -3014,7 +3014,7 @@ bool StorageReplicatedMergeTree::optimize(const ASTPtr & query, const ASTPtr & p
|
||||
return true;
|
||||
}
|
||||
|
||||
ReplicatedMergeTreeLogEntryData merge_entry;
|
||||
std::vector<ReplicatedMergeTreeLogEntryData> merge_entries;
|
||||
{
|
||||
/// We must select parts for merge under merge_selecting_mutex because other threads
|
||||
/// (merge_selecting_thread or OPTIMIZE queries) could assign new merges.
|
||||
@ -3045,9 +3045,12 @@ bool StorageReplicatedMergeTree::optimize(const ASTPtr & query, const ASTPtr & p
|
||||
FutureMergedMutatedPart future_merged_part;
|
||||
bool selected = merger_mutator.selectAllPartsToMergeWithinPartition(
|
||||
future_merged_part, disk_space, can_merge, partition_id, true, nullptr);
|
||||
ReplicatedMergeTreeLogEntryData merge_entry;
|
||||
if (selected &&
|
||||
!createLogEntryToMergeParts(zookeeper, future_merged_part.parts, future_merged_part.name, deduplicate, &merge_entry))
|
||||
return handle_noop("Can't create merge queue node in ZooKeeper");
|
||||
if (merge_entry.type != ReplicatedMergeTreeLogEntryData::Type::EMPTY)
|
||||
merge_entries.push_back(std::move(merge_entry));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -3074,15 +3077,20 @@ bool StorageReplicatedMergeTree::optimize(const ASTPtr & query, const ASTPtr & p
|
||||
return handle_noop(disable_reason);
|
||||
}
|
||||
|
||||
ReplicatedMergeTreeLogEntryData merge_entry;
|
||||
if (!createLogEntryToMergeParts(zookeeper, future_merged_part.parts, future_merged_part.name, deduplicate, &merge_entry))
|
||||
return handle_noop("Can't create merge queue node in ZooKeeper");
|
||||
if (merge_entry.type != ReplicatedMergeTreeLogEntryData::Type::EMPTY)
|
||||
merge_entries.push_back(std::move(merge_entry));
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO: Bad setting name for such purpose
|
||||
if (merge_entry.type != ReplicatedMergeTreeLogEntryData::Type::EMPTY
|
||||
&& query_context.getSettingsRef().replication_alter_partitions_sync != 0)
|
||||
waitForAllReplicasToProcessLogEntry(merge_entry);
|
||||
if (query_context.getSettingsRef().replication_alter_partitions_sync != 0)
|
||||
{
|
||||
for (auto & merge_entry : merge_entries)
|
||||
waitForAllReplicasToProcessLogEntry(merge_entry);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
DROP TABLE IF EXISTS test.replicated_optimize1;
|
||||
DROP TABLE IF EXISTS test.replicated_optimize2;
|
||||
CREATE TABLE test.replicated_optimize1 (d Date, k UInt64, i32 Int32) ENGINE=ReplicatedMergeTree('/clickhouse/tables/test/optimize', 'r1', d, k, 8192);
|
||||
CREATE TABLE test.replicated_optimize2 (d Date, k UInt64, i32 Int32) ENGINE=ReplicatedMergeTree('/clickhouse/tables/test/optimize', 'r2', d, k, 8192);
|
||||
|
||||
OPTIMIZE TABLE test.replicated_optimize1 FINAL;
|
||||
|
||||
DROP TABLE test.replicated_optimize1;
|
||||
DROP TABLE test.replicated_optimize2;
|
Loading…
Reference in New Issue
Block a user