Add backoff for merges when always_fetch_merged_part turned on

This commit is contained in:
alesapin 2022-06-10 19:33:28 +02:00
parent e32133ff8f
commit ffff1c22a6

View File

@ -1256,6 +1256,25 @@ bool ReplicatedMergeTreeQueue::shouldExecuteLogEntry(
{
ignore_max_size = max_source_parts_size == data_settings->max_bytes_to_merge_at_max_space_in_pool;
if (data_settings->always_fetch_merged_part && entry.num_tries > 0)
{
static constexpr auto MAX_SECONDS_TO_WAIT = 300L;
static constexpr auto BACKOFF_SECONDS = 3;
auto time_to_wait_seconds = std::min<int64_t>(MAX_SECONDS_TO_WAIT, entry.num_tries * BACKOFF_SECONDS);
auto time_since_last_try_seconds = std::time(nullptr) - entry.last_attempt_time;
if (time_to_wait_seconds > time_since_last_try_seconds)
{
out_postpone_reason = fmt::format(
"Not executing log entry ({}) to merge parts for part {} because `always_fetch_merged_part` enabled and "
" too less time passed since last try, have to wait {}",
entry.znode_name, entry.new_part_name, time_to_wait_seconds - time_since_last_try_seconds);
LOG_DEBUG(log, fmt::runtime(out_postpone_reason));
return false;
}
}
if (isTTLMergeType(entry.merge_type))
{
if (merger_mutator.ttl_merges_blocker.isCancelled())