From c96719685c99e207df2bbf3b89e8df8d0124c98e Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 22 Jun 2017 19:17:01 +0300 Subject: [PATCH] Lowered max_delay_to_insert to one second, because higher values are non practical and could be harmful for usual failover logic in client apps [#CLICKHOUSE-3091]. --- dbms/src/Storages/MergeTree/MergeTreeData.cpp | 10 +++++----- dbms/src/Storages/MergeTree/MergeTreeSettings.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dbms/src/Storages/MergeTree/MergeTreeData.cpp b/dbms/src/Storages/MergeTree/MergeTreeData.cpp index 020ad3333ad..a41bb9a14ab 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeData.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeData.cpp @@ -1487,20 +1487,20 @@ void MergeTreeData::delayInsertIfNeeded(Poco::Event * until) const size_t max_k = settings.parts_to_throw_insert - settings.parts_to_delay_insert; /// always > 0 const size_t k = 1 + parts_count - settings.parts_to_delay_insert; /// from 1 to max_k - const double delay_sec = ::pow(settings.max_delay_to_insert, static_cast(k) / max_k); + const double delay_milliseconds = ::pow(settings.max_delay_to_insert * 1000, static_cast(k) / max_k); ProfileEvents::increment(ProfileEvents::DelayedInserts); - ProfileEvents::increment(ProfileEvents::DelayedInsertsMilliseconds, delay_sec * 1000); + ProfileEvents::increment(ProfileEvents::DelayedInsertsMilliseconds, delay_milliseconds); CurrentMetrics::Increment metric_increment(CurrentMetrics::DelayedInserts); LOG_INFO(log, "Delaying inserting block by " - << std::fixed << std::setprecision(4) << delay_sec << " sec. because there are " << parts_count << " parts"); + << std::fixed << std::setprecision(4) << delay_milliseconds << " ms. because there are " << parts_count << " parts"); if (until) - until->tryWait(delay_sec * 1000); + until->tryWait(delay_milliseconds); else - std::this_thread::sleep_for(std::chrono::duration(delay_sec)); + std::this_thread::sleep_for(std::chrono::duration(delay_milliseconds)); } MergeTreeData::DataPartPtr MergeTreeData::getActiveContainingPart(const String & part_name) diff --git a/dbms/src/Storages/MergeTree/MergeTreeSettings.h b/dbms/src/Storages/MergeTree/MergeTreeSettings.h index 4fceefe29e9..6cb8f9252ce 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeSettings.h +++ b/dbms/src/Storages/MergeTree/MergeTreeSettings.h @@ -48,7 +48,7 @@ struct MergeTreeSettings size_t parts_to_throw_insert = 300; /// Max delay of inserting data into MergeTree table in seconds, if there are a lot of unmerged parts. - size_t max_delay_to_insert = 200; + size_t max_delay_to_insert = 1; /** Replication settings. */