mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Merge pull request #37763 from ClickHouse/fix_replace_range_again
Fix flaky 01154_move_partition_long
This commit is contained in:
commit
45657d203a
@ -2183,6 +2183,29 @@ bool ReplicatedMergeTreeMergePredicate::canMergeSinglePart(
|
||||
}
|
||||
|
||||
|
||||
bool ReplicatedMergeTreeMergePredicate::partParticipatesInReplaceRange(const MergeTreeData::DataPartPtr & part, String * out_reason) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(queue.state_mutex);
|
||||
for (const auto & entry : queue.queue)
|
||||
{
|
||||
if (entry->type != ReplicatedMergeTreeLogEntry::REPLACE_RANGE)
|
||||
continue;
|
||||
|
||||
for (const auto & part_name : entry->replace_range_entry->new_part_names)
|
||||
{
|
||||
if (part->info.isDisjoint(MergeTreePartInfo::fromPartName(part_name, queue.format_version)))
|
||||
continue;
|
||||
|
||||
if (out_reason)
|
||||
*out_reason = fmt::format("Part {} participates in REPLACE_RANGE {} ({})", part_name, entry->new_part_name, entry->znode_name);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
std::optional<std::pair<Int64, int>> ReplicatedMergeTreeMergePredicate::getDesiredMutationVersion(const MergeTreeData::DataPartPtr & part) const
|
||||
{
|
||||
/// Assigning mutations is easier than assigning merges because mutations appear in the same order as
|
||||
|
@ -501,6 +501,10 @@ public:
|
||||
/// This predicate is checked for the first part of each range.
|
||||
bool canMergeSinglePart(const MergeTreeData::DataPartPtr & part, String * out_reason) const;
|
||||
|
||||
/// Returns true if part is needed for some REPLACE_RANGE entry.
|
||||
/// We should not drop part in this case, because replication queue may stuck without that part.
|
||||
bool partParticipatesInReplaceRange(const MergeTreeData::DataPartPtr & part, String * out_reason) const;
|
||||
|
||||
/// Return nonempty optional of desired mutation version and alter version.
|
||||
/// If we have no alter (modify/drop) mutations in mutations queue, than we return biggest possible
|
||||
/// mutation version (and -1 as alter version). In other case, we return biggest mutation version with
|
||||
|
@ -7128,6 +7128,13 @@ bool StorageReplicatedMergeTree::dropPartImpl(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (merge_pred.partParticipatesInReplaceRange(part, &out_reason))
|
||||
{
|
||||
if (throw_if_noop)
|
||||
throw Exception(ErrorCodes::PART_IS_TEMPORARILY_LOCKED, out_reason);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (partIsLastQuorumPart(part->info))
|
||||
{
|
||||
if (throw_if_noop)
|
||||
|
Loading…
Reference in New Issue
Block a user