mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Avoid herd effect in ReplicatedMergeTreeCleanupThread [#CLICKHOUSE-2]
This commit is contained in:
parent
af226d62f5
commit
fa776b93c2
@ -104,6 +104,9 @@ struct MergeTreeSettings
|
|||||||
\
|
\
|
||||||
/** Period to clean old queue logs, blocks hashes and parts */ \
|
/** Period to clean old queue logs, blocks hashes and parts */ \
|
||||||
M(SettingUInt64, cleanup_delay_period, 30) \
|
M(SettingUInt64, cleanup_delay_period, 30) \
|
||||||
|
/** Add uniformly distributed value from 0 to x seconds to cleanup_delay_period \
|
||||||
|
to avoid thundering herd effect and subsequent DoS of ZooKeeper in case of very large number of tables */ \
|
||||||
|
M(SettingUInt64, cleanup_delay_period_random_add, 10) \
|
||||||
\
|
\
|
||||||
/** Minimal delay from other replicas to yield leadership. Here and further 0 means unlimited. */ \
|
/** Minimal delay from other replicas to yield leadership. Here and further 0 means unlimited. */ \
|
||||||
M(SettingUInt64, min_relative_delay_to_yield_leadership, 120) \
|
M(SettingUInt64, min_relative_delay_to_yield_leadership, 120) \
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include <Common/setThreadName.h>
|
#include <Common/setThreadName.h>
|
||||||
#include <Poco/Timestamp.h>
|
#include <Poco/Timestamp.h>
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
@ -25,7 +27,8 @@ void ReplicatedMergeTreeCleanupThread::run()
|
|||||||
{
|
{
|
||||||
setThreadName("ReplMTCleanup");
|
setThreadName("ReplMTCleanup");
|
||||||
|
|
||||||
const auto CLEANUP_SLEEP_MS = storage.data.settings.cleanup_delay_period * 1000;
|
const auto CLEANUP_SLEEP_MS = (storage.data.settings.cleanup_delay_period
|
||||||
|
+ std::uniform_int_distribution<UInt64>(0, storage.data.settings.cleanup_delay_period_random_add)(rng)) * 1000;
|
||||||
|
|
||||||
while (!storage.shutdown_called)
|
while (!storage.shutdown_called)
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#include <pcg_random.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
@ -27,6 +29,7 @@ private:
|
|||||||
StorageReplicatedMergeTree & storage;
|
StorageReplicatedMergeTree & storage;
|
||||||
Logger * log;
|
Logger * log;
|
||||||
std::thread thread;
|
std::thread thread;
|
||||||
|
pcg64 rng;
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
void iterate();
|
void iterate();
|
||||||
|
Loading…
Reference in New Issue
Block a user