mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Merge pull request #61882 from ClickHouse/less_unformatted_exceptions
Fix 00002_log_and_exception_messages_formatting
This commit is contained in:
commit
a73d927990
@ -7790,7 +7790,7 @@ MovePartsOutcome MergeTreeData::moveParts(const CurrentlyMovingPartsTaggerPtr &
|
||||
return result;
|
||||
}
|
||||
|
||||
bool MergeTreeData::partsContainSameProjections(const DataPartPtr & left, const DataPartPtr & right, String & out_reason)
|
||||
bool MergeTreeData::partsContainSameProjections(const DataPartPtr & left, const DataPartPtr & right, PreformattedMessage & out_reason)
|
||||
{
|
||||
auto remove_broken_parts_from_consideration = [](auto & parts)
|
||||
{
|
||||
@ -7812,7 +7812,7 @@ bool MergeTreeData::partsContainSameProjections(const DataPartPtr & left, const
|
||||
|
||||
if (left_projection_parts.size() != right_projection_parts.size())
|
||||
{
|
||||
out_reason = fmt::format(
|
||||
out_reason = PreformattedMessage::create(
|
||||
"Parts have different number of projections: {} in part '{}' and {} in part '{}'",
|
||||
left_projection_parts.size(),
|
||||
left->name,
|
||||
@ -7826,7 +7826,7 @@ bool MergeTreeData::partsContainSameProjections(const DataPartPtr & left, const
|
||||
{
|
||||
if (!right_projection_parts.contains(name))
|
||||
{
|
||||
out_reason = fmt::format(
|
||||
out_reason = PreformattedMessage::create(
|
||||
"The part '{}' doesn't have projection '{}' while part '{}' does", right->name, name, left->name
|
||||
);
|
||||
return false;
|
||||
|
@ -418,7 +418,7 @@ public:
|
||||
static ReservationPtr tryReserveSpace(UInt64 expected_size, const IDataPartStorage & data_part_storage);
|
||||
static ReservationPtr reserveSpace(UInt64 expected_size, const IDataPartStorage & data_part_storage);
|
||||
|
||||
static bool partsContainSameProjections(const DataPartPtr & left, const DataPartPtr & right, String & out_reason);
|
||||
static bool partsContainSameProjections(const DataPartPtr & left, const DataPartPtr & right, PreformattedMessage & out_reason);
|
||||
|
||||
StoragePolicyPtr getStoragePolicy() const override;
|
||||
|
||||
|
@ -136,7 +136,7 @@ SelectPartsDecision MergeTreeDataMergerMutator::selectPartsToMerge(
|
||||
const AllowedMergingPredicate & can_merge_callback,
|
||||
bool merge_with_ttl_allowed,
|
||||
const MergeTreeTransactionPtr & txn,
|
||||
String & out_disable_reason,
|
||||
PreformattedMessage & out_disable_reason,
|
||||
const PartitionIdsHint * partitions_hint)
|
||||
{
|
||||
MergeTreeData::DataPartsVector data_parts = getDataPartsToSelectMergeFrom(txn, partitions_hint);
|
||||
@ -145,7 +145,7 @@ SelectPartsDecision MergeTreeDataMergerMutator::selectPartsToMerge(
|
||||
|
||||
if (data_parts.empty())
|
||||
{
|
||||
out_disable_reason = "There are no parts in the table";
|
||||
out_disable_reason = PreformattedMessage::create("There are no parts in the table");
|
||||
return SelectPartsDecision::CANNOT_SELECT;
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ SelectPartsDecision MergeTreeDataMergerMutator::selectPartsToMerge(
|
||||
|
||||
if (info.parts_selected_precondition == 0)
|
||||
{
|
||||
out_disable_reason = "No parts satisfy preconditions for merge";
|
||||
out_disable_reason = PreformattedMessage::create("No parts satisfy preconditions for merge");
|
||||
return SelectPartsDecision::CANNOT_SELECT;
|
||||
}
|
||||
|
||||
@ -177,9 +177,9 @@ SelectPartsDecision MergeTreeDataMergerMutator::selectPartsToMerge(
|
||||
/*optimize_skip_merged_partitions=*/true);
|
||||
}
|
||||
|
||||
if (!out_disable_reason.empty())
|
||||
out_disable_reason += ". ";
|
||||
out_disable_reason += "There is no need to merge parts according to merge selector algorithm";
|
||||
if (!out_disable_reason.text.empty())
|
||||
out_disable_reason.text += ". ";
|
||||
out_disable_reason.text += "There is no need to merge parts according to merge selector algorithm";
|
||||
return SelectPartsDecision::CANNOT_SELECT;
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ MergeTreeDataMergerMutator::PartitionIdsHint MergeTreeDataMergerMutator::getPart
|
||||
|
||||
auto metadata_snapshot = data.getInMemoryMetadataPtr();
|
||||
|
||||
String out_reason;
|
||||
PreformattedMessage out_reason;
|
||||
MergeSelectingInfo info = getPossibleMergeRanges(data_parts, can_merge_callback, txn, out_reason);
|
||||
|
||||
if (info.parts_selected_precondition == 0)
|
||||
@ -223,7 +223,7 @@ MergeTreeDataMergerMutator::PartitionIdsHint MergeTreeDataMergerMutator::getPart
|
||||
for (size_t i = 0; i < all_partition_ids.size(); ++i)
|
||||
{
|
||||
auto future_part = std::make_shared<FutureMergedMutatedPart>();
|
||||
String out_disable_reason;
|
||||
PreformattedMessage out_disable_reason;
|
||||
/// This method should have been const, but something went wrong... it's const with dry_run = true
|
||||
auto status = const_cast<MergeTreeDataMergerMutator *>(this)->selectPartsToMergeFromRanges(
|
||||
future_part, /*aggressive*/ false, max_total_size_to_merge, merge_with_ttl_allowed,
|
||||
@ -232,7 +232,7 @@ MergeTreeDataMergerMutator::PartitionIdsHint MergeTreeDataMergerMutator::getPart
|
||||
if (status == SelectPartsDecision::SELECTED)
|
||||
res.insert(all_partition_ids[i]);
|
||||
else
|
||||
LOG_TEST(log, "Nothing to merge in partition {}: {}", all_partition_ids[i], out_disable_reason);
|
||||
LOG_TEST(log, "Nothing to merge in partition {}: {}", all_partition_ids[i], out_disable_reason.text);
|
||||
}
|
||||
|
||||
String best_partition_id_to_optimize = getBestPartitionToOptimizeEntire(info.partitions_info);
|
||||
@ -331,7 +331,7 @@ MergeTreeDataMergerMutator::MergeSelectingInfo MergeTreeDataMergerMutator::getPo
|
||||
const MergeTreeData::DataPartsVector & data_parts,
|
||||
const AllowedMergingPredicate & can_merge_callback,
|
||||
const MergeTreeTransactionPtr & txn,
|
||||
String & out_disable_reason) const
|
||||
PreformattedMessage & out_disable_reason) const
|
||||
{
|
||||
MergeSelectingInfo res;
|
||||
|
||||
@ -444,7 +444,7 @@ SelectPartsDecision MergeTreeDataMergerMutator::selectPartsToMergeFromRanges(
|
||||
const StorageMetadataPtr & metadata_snapshot,
|
||||
const IMergeSelector::PartsRanges & parts_ranges,
|
||||
const time_t & current_time,
|
||||
String & out_disable_reason,
|
||||
PreformattedMessage & out_disable_reason,
|
||||
bool dry_run)
|
||||
{
|
||||
const auto data_settings = data.getSettings();
|
||||
@ -515,7 +515,7 @@ SelectPartsDecision MergeTreeDataMergerMutator::selectPartsToMergeFromRanges(
|
||||
|
||||
if (parts_to_merge.empty())
|
||||
{
|
||||
out_disable_reason = "Did not find any parts to merge (with usual merge selectors)";
|
||||
out_disable_reason = PreformattedMessage::create("Did not find any parts to merge (with usual merge selectors)");
|
||||
return SelectPartsDecision::CANNOT_SELECT;
|
||||
}
|
||||
}
|
||||
@ -573,20 +573,20 @@ SelectPartsDecision MergeTreeDataMergerMutator::selectAllPartsToMergeWithinParti
|
||||
bool final,
|
||||
const StorageMetadataPtr & metadata_snapshot,
|
||||
const MergeTreeTransactionPtr & txn,
|
||||
String & out_disable_reason,
|
||||
PreformattedMessage & out_disable_reason,
|
||||
bool optimize_skip_merged_partitions)
|
||||
{
|
||||
MergeTreeData::DataPartsVector parts = selectAllPartsFromPartition(partition_id);
|
||||
|
||||
if (parts.empty())
|
||||
{
|
||||
out_disable_reason = "There are no parts inside partition";
|
||||
out_disable_reason = PreformattedMessage::create("There are no parts inside partition");
|
||||
return SelectPartsDecision::CANNOT_SELECT;
|
||||
}
|
||||
|
||||
if (!final && parts.size() == 1)
|
||||
{
|
||||
out_disable_reason = "There is only one part inside partition";
|
||||
out_disable_reason = PreformattedMessage::create("There is only one part inside partition");
|
||||
return SelectPartsDecision::CANNOT_SELECT;
|
||||
}
|
||||
|
||||
@ -595,7 +595,7 @@ SelectPartsDecision MergeTreeDataMergerMutator::selectAllPartsToMergeWithinParti
|
||||
if (final && optimize_skip_merged_partitions && parts.size() == 1 && parts[0]->info.level > 0 &&
|
||||
(!metadata_snapshot->hasAnyTTL() || parts[0]->checkAllTTLCalculated(metadata_snapshot)))
|
||||
{
|
||||
out_disable_reason = "Partition skipped due to optimize_skip_merged_partitions";
|
||||
out_disable_reason = PreformattedMessage::create("Partition skipped due to optimize_skip_merged_partitions");
|
||||
return SelectPartsDecision::NOTHING_TO_MERGE;
|
||||
}
|
||||
|
||||
@ -636,7 +636,7 @@ SelectPartsDecision MergeTreeDataMergerMutator::selectAllPartsToMergeWithinParti
|
||||
static_cast<int>((DISK_USAGE_COEFFICIENT_TO_SELECT - 1.0) * 100));
|
||||
}
|
||||
|
||||
out_disable_reason = fmt::format("Insufficient available disk space, required {}", ReadableSize(required_disk_space));
|
||||
out_disable_reason = PreformattedMessage::create("Insufficient available disk space, required {}", ReadableSize(required_disk_space));
|
||||
return SelectPartsDecision::CANNOT_SELECT;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
using AllowedMergingPredicate = std::function<bool (const MergeTreeData::DataPartPtr &,
|
||||
const MergeTreeData::DataPartPtr &,
|
||||
const MergeTreeTransaction *,
|
||||
String &)>;
|
||||
PreformattedMessage &)>;
|
||||
|
||||
explicit MergeTreeDataMergerMutator(MergeTreeData & data_);
|
||||
|
||||
@ -92,7 +92,7 @@ public:
|
||||
const MergeTreeData::DataPartsVector & data_parts,
|
||||
const AllowedMergingPredicate & can_merge_callback,
|
||||
const MergeTreeTransactionPtr & txn,
|
||||
String & out_disable_reason) const;
|
||||
PreformattedMessage & out_disable_reason) const;
|
||||
|
||||
/// The third step of selecting parts to merge: takes ranges that we can merge, and selects parts that we want to merge
|
||||
SelectPartsDecision selectPartsToMergeFromRanges(
|
||||
@ -103,7 +103,7 @@ public:
|
||||
const StorageMetadataPtr & metadata_snapshot,
|
||||
const IMergeSelector::PartsRanges & parts_ranges,
|
||||
const time_t & current_time,
|
||||
String & out_disable_reason,
|
||||
PreformattedMessage & out_disable_reason,
|
||||
bool dry_run = false);
|
||||
|
||||
String getBestPartitionToOptimizeEntire(const PartitionsInfo & partitions_info) const;
|
||||
@ -129,7 +129,7 @@ public:
|
||||
const AllowedMergingPredicate & can_merge,
|
||||
bool merge_with_ttl_allowed,
|
||||
const MergeTreeTransactionPtr & txn,
|
||||
String & out_disable_reason,
|
||||
PreformattedMessage & out_disable_reason,
|
||||
const PartitionIdsHint * partitions_hint = nullptr);
|
||||
|
||||
/** Select all the parts in the specified partition for merge, if possible.
|
||||
@ -144,7 +144,7 @@ public:
|
||||
bool final,
|
||||
const StorageMetadataPtr & metadata_snapshot,
|
||||
const MergeTreeTransactionPtr & txn,
|
||||
String & out_disable_reason,
|
||||
PreformattedMessage & out_disable_reason,
|
||||
bool optimize_skip_merged_partitions = false);
|
||||
|
||||
/** Creates a task to merge parts.
|
||||
|
@ -2287,7 +2287,7 @@ bool BaseMergePredicate<VirtualPartsT, MutationsStateT>::operator()(
|
||||
const MergeTreeData::DataPartPtr & left,
|
||||
const MergeTreeData::DataPartPtr & right,
|
||||
const MergeTreeTransaction *,
|
||||
String & out_reason) const
|
||||
PreformattedMessage & out_reason) const
|
||||
{
|
||||
if (left)
|
||||
return canMergeTwoParts(left, right, out_reason);
|
||||
@ -2299,7 +2299,7 @@ template<typename VirtualPartsT, typename MutationsStateT>
|
||||
bool BaseMergePredicate<VirtualPartsT, MutationsStateT>::canMergeTwoParts(
|
||||
const MergeTreeData::DataPartPtr & left,
|
||||
const MergeTreeData::DataPartPtr & right,
|
||||
String & out_reason) const
|
||||
PreformattedMessage & out_reason) const
|
||||
{
|
||||
/// A sketch of a proof of why this method actually works:
|
||||
///
|
||||
@ -2343,19 +2343,19 @@ bool BaseMergePredicate<VirtualPartsT, MutationsStateT>::canMergeTwoParts(
|
||||
{
|
||||
if (pinned_part_uuids_ && pinned_part_uuids_->part_uuids.contains(part->uuid))
|
||||
{
|
||||
out_reason = "Part " + part->name + " has uuid " + toString(part->uuid) + " which is currently pinned";
|
||||
out_reason = PreformattedMessage::create("Part {} has uuid {} which is currently pinned", part->name, part->uuid);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (inprogress_quorum_part_ && part->name == *inprogress_quorum_part_)
|
||||
{
|
||||
out_reason = "Quorum insert for part " + part->name + " is currently in progress";
|
||||
out_reason = PreformattedMessage::create("Quorum insert for part {} is currently in progress", part->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (prev_virtual_parts_ && prev_virtual_parts_->getContainingPart(part->info).empty())
|
||||
{
|
||||
out_reason = "Entry for part " + part->name + " hasn't been read from the replication log yet";
|
||||
out_reason = PreformattedMessage::create("Entry for part {} hasn't been read from the replication log yet", part->name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2369,7 +2369,7 @@ bool BaseMergePredicate<VirtualPartsT, MutationsStateT>::canMergeTwoParts(
|
||||
{
|
||||
if (partition_ids_hint && !partition_ids_hint->contains(left->info.partition_id))
|
||||
{
|
||||
out_reason = fmt::format("Uncommitted block were not loaded for unexpected partition {}", left->info.partition_id);
|
||||
out_reason = PreformattedMessage::create("Uncommitted block were not loaded for unexpected partition {}", left->info.partition_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2381,8 +2381,7 @@ bool BaseMergePredicate<VirtualPartsT, MutationsStateT>::canMergeTwoParts(
|
||||
auto block_it = block_numbers.upper_bound(left_max_block);
|
||||
if (block_it != block_numbers.end() && *block_it < right_min_block)
|
||||
{
|
||||
out_reason = "Block number " + toString(*block_it) + " is still being inserted between parts "
|
||||
+ left->name + " and " + right->name;
|
||||
out_reason = PreformattedMessage::create("Block number {} is still being inserted between parts {} and {}", *block_it, left->name, right->name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2401,7 +2400,7 @@ bool BaseMergePredicate<VirtualPartsT, MutationsStateT>::canMergeTwoParts(
|
||||
String containing_part = virtual_parts_->getContainingPart(part->info);
|
||||
if (containing_part != part->name)
|
||||
{
|
||||
out_reason = "Part " + part->name + " has already been assigned a merge into " + containing_part;
|
||||
out_reason = PreformattedMessage::create("Part {} has already been assigned a merge into {}", part->name, containing_part);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2418,9 +2417,9 @@ bool BaseMergePredicate<VirtualPartsT, MutationsStateT>::canMergeTwoParts(
|
||||
Strings covered = virtual_parts_->getPartsCoveredBy(gap_part_info);
|
||||
if (!covered.empty())
|
||||
{
|
||||
out_reason = "There are " + toString(covered.size()) + " parts (from " + covered.front()
|
||||
+ " to " + covered.back() + ") that are still not present or being processed by "
|
||||
+ " other background process on this replica between " + left->name + " and " + right->name;
|
||||
out_reason = PreformattedMessage::create("There are {} parts (from {} to {}) "
|
||||
"that are still not present or being processed by other background process "
|
||||
"on this replica between {} and {}", covered.size(), covered.front(), covered.back(), left->name, right->name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2436,8 +2435,8 @@ bool BaseMergePredicate<VirtualPartsT, MutationsStateT>::canMergeTwoParts(
|
||||
|
||||
if (left_mutation_ver != right_mutation_ver)
|
||||
{
|
||||
out_reason = "Current mutation versions of parts " + left->name + " and " + right->name + " differ: "
|
||||
+ toString(left_mutation_ver) + " and " + toString(right_mutation_ver) + " respectively";
|
||||
out_reason = PreformattedMessage::create("Current mutation versions of parts {} and {} differ: "
|
||||
"{} and {} respectively", left->name, right->name, left_mutation_ver, right_mutation_ver);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2448,23 +2447,23 @@ bool BaseMergePredicate<VirtualPartsT, MutationsStateT>::canMergeTwoParts(
|
||||
template<typename VirtualPartsT, typename MutationsStateT>
|
||||
bool BaseMergePredicate<VirtualPartsT, MutationsStateT>::canMergeSinglePart(
|
||||
const MergeTreeData::DataPartPtr & part,
|
||||
String & out_reason) const
|
||||
PreformattedMessage & out_reason) const
|
||||
{
|
||||
if (pinned_part_uuids_ && pinned_part_uuids_->part_uuids.contains(part->uuid))
|
||||
{
|
||||
out_reason = fmt::format("Part {} has uuid {} which is currently pinned", part->name, part->uuid);
|
||||
out_reason = PreformattedMessage::create("Part {} has uuid {} which is currently pinned", part->name, part->uuid);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (inprogress_quorum_part_ && part->name == *inprogress_quorum_part_)
|
||||
{
|
||||
out_reason = fmt::format("Quorum insert for part {} is currently in progress", part->name);
|
||||
out_reason = PreformattedMessage::create("Quorum insert for part {} is currently in progress", part->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (prev_virtual_parts_ && prev_virtual_parts_->getContainingPart(part->info).empty())
|
||||
{
|
||||
out_reason = fmt::format("Entry for part {} hasn't been read from the replication log yet", part->name);
|
||||
out_reason = PreformattedMessage::create("Entry for part {} hasn't been read from the replication log yet", part->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2479,7 +2478,7 @@ bool BaseMergePredicate<VirtualPartsT, MutationsStateT>::canMergeSinglePart(
|
||||
String containing_part = virtual_parts_->getContainingPart(part->info);
|
||||
if (containing_part != part->name)
|
||||
{
|
||||
out_reason = fmt::format("Part {} has already been assigned a merge into {}", part->name, containing_part);
|
||||
out_reason = PreformattedMessage::create("Part {} has already been assigned a merge into {}", part->name, containing_part);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2488,7 +2487,7 @@ bool BaseMergePredicate<VirtualPartsT, MutationsStateT>::canMergeSinglePart(
|
||||
}
|
||||
|
||||
|
||||
bool ReplicatedMergeTreeMergePredicate::partParticipatesInReplaceRange(const MergeTreeData::DataPartPtr & part, String & out_reason) const
|
||||
bool ReplicatedMergeTreeMergePredicate::partParticipatesInReplaceRange(const MergeTreeData::DataPartPtr & part, PreformattedMessage & out_reason) const
|
||||
{
|
||||
std::lock_guard lock(queue.state_mutex);
|
||||
for (const auto & entry : queue.queue)
|
||||
@ -2501,7 +2500,7 @@ bool ReplicatedMergeTreeMergePredicate::partParticipatesInReplaceRange(const Mer
|
||||
if (part->info.isDisjoint(MergeTreePartInfo::fromPartName(part_name, queue.format_version)))
|
||||
continue;
|
||||
|
||||
out_reason = fmt::format("Part {} participates in REPLACE_RANGE {} ({})", part_name, entry->new_part_name, entry->znode_name);
|
||||
out_reason = PreformattedMessage::create("Part {} participates in REPLACE_RANGE {} ({})", part_name, entry->new_part_name, entry->znode_name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -505,19 +505,19 @@ public:
|
||||
bool operator()(const MergeTreeData::DataPartPtr & left,
|
||||
const MergeTreeData::DataPartPtr & right,
|
||||
const MergeTreeTransaction * txn,
|
||||
String & out_reason) const;
|
||||
PreformattedMessage & out_reason) const;
|
||||
|
||||
/// Can we assign a merge with these two parts?
|
||||
/// (assuming that no merge was assigned after the predicate was constructed)
|
||||
/// If we can't and out_reason is not nullptr, set it to the reason why we can't merge.
|
||||
bool canMergeTwoParts(const MergeTreeData::DataPartPtr & left,
|
||||
const MergeTreeData::DataPartPtr & right,
|
||||
String & out_reason) const;
|
||||
PreformattedMessage & out_reason) const;
|
||||
|
||||
/// Can we assign a merge this part and some other part?
|
||||
/// For example a merge of a part and itself is needed for TTL.
|
||||
/// This predicate is checked for the first part of each range.
|
||||
bool canMergeSinglePart(const MergeTreeData::DataPartPtr & part, String & out_reason) const;
|
||||
bool canMergeSinglePart(const MergeTreeData::DataPartPtr & part, PreformattedMessage & out_reason) const;
|
||||
|
||||
CommittingBlocks getCommittingBlocks(zkutil::ZooKeeperPtr & zookeeper, const std::string & zookeeper_path, LoggerPtr log_);
|
||||
|
||||
@ -561,7 +561,7 @@ public:
|
||||
|
||||
/// 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;
|
||||
bool partParticipatesInReplaceRange(const MergeTreeData::DataPartPtr & part, PreformattedMessage & 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
|
||||
|
@ -933,7 +933,7 @@ MergeMutateSelectedEntryPtr StorageMergeTree::selectPartsToMerge(
|
||||
bool aggressive,
|
||||
const String & partition_id,
|
||||
bool final,
|
||||
String & out_disable_reason,
|
||||
PreformattedMessage & out_disable_reason,
|
||||
TableLockHolder & /* table_lock_holder */,
|
||||
std::unique_lock<std::mutex> & lock,
|
||||
const MergeTreeTransactionPtr & txn,
|
||||
@ -951,7 +951,7 @@ MergeMutateSelectedEntryPtr StorageMergeTree::selectPartsToMerge(
|
||||
CurrentlyMergingPartsTaggerPtr merging_tagger;
|
||||
MergeList::EntryPtr merge_entry;
|
||||
|
||||
auto can_merge = [this, &lock](const DataPartPtr & left, const DataPartPtr & right, const MergeTreeTransaction * tx, String & disable_reason) -> bool
|
||||
auto can_merge = [this, &lock](const DataPartPtr & left, const DataPartPtr & right, const MergeTreeTransaction * tx, PreformattedMessage & disable_reason) -> bool
|
||||
{
|
||||
if (tx)
|
||||
{
|
||||
@ -960,7 +960,7 @@ MergeMutateSelectedEntryPtr StorageMergeTree::selectPartsToMerge(
|
||||
if ((left && !left->version.isVisible(tx->getSnapshot(), Tx::EmptyTID))
|
||||
|| (right && !right->version.isVisible(tx->getSnapshot(), Tx::EmptyTID)))
|
||||
{
|
||||
disable_reason = "Some part is not visible in transaction";
|
||||
disable_reason = PreformattedMessage::create("Some part is not visible in transaction");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -968,7 +968,7 @@ MergeMutateSelectedEntryPtr StorageMergeTree::selectPartsToMerge(
|
||||
if ((left && left->version.isRemovalTIDLocked())
|
||||
|| (right && right->version.isRemovalTIDLocked()))
|
||||
{
|
||||
disable_reason = "Some part is locked for removal in another cuncurrent transaction";
|
||||
disable_reason = PreformattedMessage::create("Some part is locked for removal in another cuncurrent transaction");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -979,7 +979,7 @@ MergeMutateSelectedEntryPtr StorageMergeTree::selectPartsToMerge(
|
||||
{
|
||||
if (currently_merging_mutating_parts.contains(right))
|
||||
{
|
||||
disable_reason = "Some part currently in a merging or mutating process";
|
||||
disable_reason = PreformattedMessage::create("Some part currently in a merging or mutating process");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@ -988,13 +988,13 @@ MergeMutateSelectedEntryPtr StorageMergeTree::selectPartsToMerge(
|
||||
|
||||
if (currently_merging_mutating_parts.contains(left) || currently_merging_mutating_parts.contains(right))
|
||||
{
|
||||
disable_reason = "Some part currently in a merging or mutating process";
|
||||
disable_reason = PreformattedMessage::create("Some part currently in a merging or mutating process");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getCurrentMutationVersion(left, lock) != getCurrentMutationVersion(right, lock))
|
||||
{
|
||||
disable_reason = "Some parts have different mutation version";
|
||||
disable_reason = PreformattedMessage::create("Some parts have different mutation version");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1004,7 +1004,7 @@ MergeMutateSelectedEntryPtr StorageMergeTree::selectPartsToMerge(
|
||||
auto max_possible_level = getMaxLevelInBetween(left, right);
|
||||
if (max_possible_level > std::max(left->info.level, right->info.level))
|
||||
{
|
||||
disable_reason = fmt::format("There is an outdated part in a gap between two active parts ({}, {}) with merge level {} higher than these active parts have", left->name, right->name, max_possible_level);
|
||||
disable_reason = PreformattedMessage::create("There is an outdated part in a gap between two active parts ({}, {}) with merge level {} higher than these active parts have", left->name, right->name, max_possible_level);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1013,11 +1013,11 @@ MergeMutateSelectedEntryPtr StorageMergeTree::selectPartsToMerge(
|
||||
|
||||
SelectPartsDecision select_decision = SelectPartsDecision::CANNOT_SELECT;
|
||||
|
||||
auto is_background_memory_usage_ok = [](String & disable_reason) -> bool
|
||||
auto is_background_memory_usage_ok = [](PreformattedMessage & disable_reason) -> bool
|
||||
{
|
||||
if (canEnqueueBackgroundTask())
|
||||
return true;
|
||||
disable_reason = fmt::format("Current background tasks memory usage ({}) is more than the limit ({})",
|
||||
disable_reason = PreformattedMessage::create("Current background tasks memory usage ({}) is more than the limit ({})",
|
||||
formatReadableSizeWithBinarySuffix(background_memory_tracker.get()),
|
||||
formatReadableSizeWithBinarySuffix(background_memory_tracker.getSoftLimit()));
|
||||
return false;
|
||||
@ -1045,7 +1045,7 @@ MergeMutateSelectedEntryPtr StorageMergeTree::selectPartsToMerge(
|
||||
out_disable_reason);
|
||||
}
|
||||
else
|
||||
out_disable_reason = "Current value of max_source_parts_size is zero";
|
||||
out_disable_reason = PreformattedMessage::create("Current value of max_source_parts_size is zero");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1086,7 +1086,7 @@ MergeMutateSelectedEntryPtr StorageMergeTree::selectPartsToMerge(
|
||||
|
||||
if (std::cv_status::timeout == currently_processing_in_background_condition.wait_for(lock, timeout))
|
||||
{
|
||||
out_disable_reason = fmt::format("Timeout ({} ms) while waiting for already running merges before running OPTIMIZE with FINAL", timeout_ms);
|
||||
out_disable_reason = PreformattedMessage::create("Timeout ({} ms) while waiting for already running merges before running OPTIMIZE with FINAL", timeout_ms);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1102,9 +1102,9 @@ MergeMutateSelectedEntryPtr StorageMergeTree::selectPartsToMerge(
|
||||
|
||||
if (select_decision != SelectPartsDecision::SELECTED)
|
||||
{
|
||||
if (!out_disable_reason.empty())
|
||||
out_disable_reason += ". ";
|
||||
out_disable_reason += "Cannot select parts for optimization";
|
||||
if (!out_disable_reason.text.empty())
|
||||
out_disable_reason.text += ". ";
|
||||
out_disable_reason.text += "Cannot select parts for optimization";
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -1125,7 +1125,7 @@ bool StorageMergeTree::merge(
|
||||
const Names & deduplicate_by_columns,
|
||||
bool cleanup,
|
||||
const MergeTreeTransactionPtr & txn,
|
||||
String & out_disable_reason,
|
||||
PreformattedMessage & out_disable_reason,
|
||||
bool optimize_skip_merged_partitions)
|
||||
{
|
||||
auto table_lock_holder = lockForShare(RWLockImpl::NO_QUERY, getSettings()->lock_acquire_timeout_for_background_operations);
|
||||
@ -1180,7 +1180,7 @@ bool StorageMergeTree::partIsAssignedToBackgroundOperation(const DataPartPtr & p
|
||||
}
|
||||
|
||||
MergeMutateSelectedEntryPtr StorageMergeTree::selectPartsToMutate(
|
||||
const StorageMetadataPtr & metadata_snapshot, String & /* disable_reason */, TableLockHolder & /* table_lock_holder */,
|
||||
const StorageMetadataPtr & metadata_snapshot, PreformattedMessage & /* disable_reason */, TableLockHolder & /* table_lock_holder */,
|
||||
std::unique_lock<std::mutex> & /*currently_processing_in_background_mutex_lock*/)
|
||||
{
|
||||
if (current_mutations_by_version.empty())
|
||||
@ -1396,7 +1396,7 @@ bool StorageMergeTree::scheduleDataProcessingJob(BackgroundJobsAssignee & assign
|
||||
if (merger_mutator.merges_blocker.isCancelled())
|
||||
return false;
|
||||
|
||||
String out_reason;
|
||||
PreformattedMessage out_reason;
|
||||
merge_entry = selectPartsToMerge(metadata_snapshot, false, {}, false, out_reason, shared_lock, lock, txn);
|
||||
|
||||
if (!merge_entry && !current_mutations_by_version.empty())
|
||||
@ -1559,14 +1559,12 @@ bool StorageMergeTree::optimize(
|
||||
|
||||
auto txn = local_context->getCurrentTransaction();
|
||||
|
||||
String disable_reason;
|
||||
PreformattedMessage disable_reason;
|
||||
if (!partition && final)
|
||||
{
|
||||
if (cleanup && this->merging_params.mode != MergingParams::Mode::Replacing)
|
||||
{
|
||||
constexpr const char * message = "Cannot OPTIMIZE with CLEANUP table: {}";
|
||||
disable_reason = "only ReplacingMergeTree can be CLEANUP";
|
||||
throw Exception(ErrorCodes::CANNOT_ASSIGN_OPTIMIZE, message, disable_reason);
|
||||
throw Exception(ErrorCodes::CANNOT_ASSIGN_OPTIMIZE, "Cannot OPTIMIZE with CLEANUP table: only ReplacingMergeTree can be CLEANUP");
|
||||
}
|
||||
|
||||
if (cleanup && !getSettings()->allow_experimental_replacing_merge_with_cleanup)
|
||||
@ -1592,12 +1590,12 @@ bool StorageMergeTree::optimize(
|
||||
local_context->getSettingsRef().optimize_skip_merged_partitions))
|
||||
{
|
||||
constexpr auto message = "Cannot OPTIMIZE table: {}";
|
||||
if (disable_reason.empty())
|
||||
disable_reason = "unknown reason";
|
||||
LOG_INFO(log, message, disable_reason);
|
||||
if (disable_reason.text.empty())
|
||||
disable_reason = PreformattedMessage::create("unknown reason");
|
||||
LOG_INFO(log, message, disable_reason.text);
|
||||
|
||||
if (local_context->getSettingsRef().optimize_throw_if_noop)
|
||||
throw Exception(ErrorCodes::CANNOT_ASSIGN_OPTIMIZE, message, disable_reason);
|
||||
throw Exception(ErrorCodes::CANNOT_ASSIGN_OPTIMIZE, message, disable_reason.text);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1620,12 +1618,12 @@ bool StorageMergeTree::optimize(
|
||||
local_context->getSettingsRef().optimize_skip_merged_partitions))
|
||||
{
|
||||
constexpr auto message = "Cannot OPTIMIZE table: {}";
|
||||
if (disable_reason.empty())
|
||||
disable_reason = "unknown reason";
|
||||
LOG_INFO(log, message, disable_reason);
|
||||
if (disable_reason.text.empty())
|
||||
disable_reason = PreformattedMessage::create("unknown reason");
|
||||
LOG_INFO(log, message, disable_reason.text);
|
||||
|
||||
if (local_context->getSettingsRef().optimize_throw_if_noop)
|
||||
throw Exception(ErrorCodes::CANNOT_ASSIGN_OPTIMIZE, message, disable_reason);
|
||||
throw Exception(ErrorCodes::CANNOT_ASSIGN_OPTIMIZE, message, disable_reason.text);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ private:
|
||||
const Names & deduplicate_by_columns,
|
||||
bool cleanup,
|
||||
const MergeTreeTransactionPtr & txn,
|
||||
String & out_disable_reason,
|
||||
PreformattedMessage & out_disable_reason,
|
||||
bool optimize_skip_merged_partitions = false);
|
||||
|
||||
void renameAndCommitEmptyParts(MutableDataPartsVector & new_parts, Transaction & transaction);
|
||||
@ -202,7 +202,7 @@ private:
|
||||
bool aggressive,
|
||||
const String & partition_id,
|
||||
bool final,
|
||||
String & disable_reason,
|
||||
PreformattedMessage & disable_reason,
|
||||
TableLockHolder & table_lock_holder,
|
||||
std::unique_lock<std::mutex> & lock,
|
||||
const MergeTreeTransactionPtr & txn,
|
||||
@ -211,7 +211,7 @@ private:
|
||||
|
||||
|
||||
MergeMutateSelectedEntryPtr selectPartsToMutate(
|
||||
const StorageMetadataPtr & metadata_snapshot, String & disable_reason,
|
||||
const StorageMetadataPtr & metadata_snapshot, PreformattedMessage & disable_reason,
|
||||
TableLockHolder & table_lock_holder, std::unique_lock<std::mutex> & currently_processing_in_background_mutex_lock);
|
||||
|
||||
/// For current mutations queue, returns maximum version of mutation for a part,
|
||||
|
@ -3832,7 +3832,7 @@ void StorageReplicatedMergeTree::mergeSelectingTask()
|
||||
merge_pred.emplace(queue.getMergePredicate(zookeeper, partitions_to_merge_in));
|
||||
}
|
||||
|
||||
String out_reason;
|
||||
PreformattedMessage out_reason;
|
||||
if (can_assign_merge &&
|
||||
merger_mutator.selectPartsToMerge(future_merged_part, false, max_source_parts_size_for_merge, *merge_pred,
|
||||
merge_with_ttl_allowed, NO_TRANSACTION_PTR, out_reason, &partitions_to_merge_in) == SelectPartsDecision::SELECTED)
|
||||
@ -5814,7 +5814,7 @@ bool StorageReplicatedMergeTree::optimize(
|
||||
future_merged_part->uuid = UUIDHelpers::generateV4();
|
||||
|
||||
constexpr const char * unknown_disable_reason = "unknown reason";
|
||||
String disable_reason = unknown_disable_reason;
|
||||
PreformattedMessage disable_reason = PreformattedMessage::create(unknown_disable_reason);
|
||||
SelectPartsDecision select_decision = SelectPartsDecision::CANNOT_SELECT;
|
||||
|
||||
if (partition_id.empty())
|
||||
@ -5837,10 +5837,10 @@ bool StorageReplicatedMergeTree::optimize(
|
||||
if (select_decision != SelectPartsDecision::SELECTED)
|
||||
{
|
||||
constexpr const char * message_fmt = "Cannot select parts for optimization: {}";
|
||||
assert(disable_reason != unknown_disable_reason);
|
||||
assert(disable_reason.text != unknown_disable_reason);
|
||||
if (!partition_id.empty())
|
||||
disable_reason += fmt::format(" (in partition {})", partition_id);
|
||||
return handle_noop(message_fmt, disable_reason);
|
||||
disable_reason.text += fmt::format(" (in partition {})", partition_id);
|
||||
return handle_noop(message_fmt, disable_reason.text);
|
||||
}
|
||||
|
||||
ReplicatedMergeTreeLogEntryData merge_entry;
|
||||
@ -8509,9 +8509,9 @@ void StorageReplicatedMergeTree::movePartitionToShard(
|
||||
}
|
||||
|
||||
/// canMergeSinglePart is overlapping with dropPart, let's try to use the same code.
|
||||
String out_reason;
|
||||
PreformattedMessage out_reason;
|
||||
if (!merge_pred.canMergeSinglePart(part, out_reason))
|
||||
throw Exception(ErrorCodes::PART_IS_TEMPORARILY_LOCKED, "Part is busy, reason: {}", out_reason);
|
||||
throw Exception(ErrorCodes::PART_IS_TEMPORARILY_LOCKED, "Part is busy, reason: {}", out_reason.text);
|
||||
}
|
||||
|
||||
{
|
||||
@ -8769,18 +8769,18 @@ bool StorageReplicatedMergeTree::dropPartImpl(
|
||||
|
||||
/// There isn't a lot we can do otherwise. Can't cancel merges because it is possible that a replica already
|
||||
/// finished the merge.
|
||||
String out_reason;
|
||||
PreformattedMessage out_reason;
|
||||
if (!merge_pred.canMergeSinglePart(part, out_reason))
|
||||
{
|
||||
if (throw_if_noop)
|
||||
throw Exception::createDeprecated(out_reason, ErrorCodes::PART_IS_TEMPORARILY_LOCKED);
|
||||
throw Exception(out_reason, ErrorCodes::PART_IS_TEMPORARILY_LOCKED);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (merge_pred.partParticipatesInReplaceRange(part, out_reason))
|
||||
{
|
||||
if (throw_if_noop)
|
||||
throw Exception::createDeprecated(out_reason, ErrorCodes::PART_IS_TEMPORARILY_LOCKED);
|
||||
throw Exception(out_reason, ErrorCodes::PART_IS_TEMPORARILY_LOCKED);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user