introduce replicated_can_become_leader merge_tree setting [#CLICKHOUSE-3109]

This commit is contained in:
Alexey Zatelepin 2017-07-11 16:48:26 +03:00 committed by alexey-milovidov
parent 632d9188cf
commit 4a98d83a3b
3 changed files with 13 additions and 8 deletions

View File

@ -84,6 +84,9 @@ struct MergeTreeSettings
size_t replicated_max_parallel_sends = 0;
size_t replicated_max_parallel_sends_for_table = 0;
/// If true, Replicated tables replicas on this node will try to acquire leadership.
bool replicated_can_become_leader = true;
/// In seconds.
size_t zookeeper_session_expiration_check_period = 60;
@ -141,11 +144,12 @@ struct MergeTreeSettings
SET(max_suspicious_broken_parts, getUInt64);
SET(max_files_to_modify_in_alter_columns, getUInt64);
SET(max_files_to_remove_in_alter_columns, getUInt64);
SET(replicated_max_ratio_of_wrong_parts, getDouble);
SET(replicated_max_parallel_fetches, getUInt64);
SET(replicated_max_parallel_fetches_for_table, getUInt64);
SET(replicated_max_parallel_sends, getUInt64);
SET(replicated_max_parallel_sends_for_table, getUInt64);
SET(replicated_max_ratio_of_wrong_parts, getDouble);
SET(replicated_can_become_leader, getBool);
SET(zookeeper_session_expiration_check_period, getUInt64);
SET(check_delay_period, getUInt64);
SET(min_relative_delay_to_yield_leadership, getUInt64);

View File

@ -197,12 +197,13 @@ bool ReplicatedMergeTreeRestartingThread::tryStartup()
activateReplica();
updateQuorumIfWeHavePart();
storage.leader_election = std::make_shared<zkutil::LeaderElection>(
storage.zookeeper_path + "/leader_election",
*storage.current_zookeeper, /// current_zookeeper lives for the lifetime of leader_election,
/// since before changing `current_zookeeper`, `leader_election` object is destroyed in `partialShutdown` method.
[this] { storage.becomeLeader(); CurrentMetrics::add(CurrentMetrics::LeaderReplica); },
storage.replica_name);
if (storage.data.settings.replicated_can_become_leader)
storage.leader_election = std::make_shared<zkutil::LeaderElection>(
storage.zookeeper_path + "/leader_election",
*storage.current_zookeeper, /// current_zookeeper lives for the lifetime of leader_election,
/// since before changing `current_zookeeper`, `leader_election` object is destroyed in `partialShutdown` method.
[this] { storage.becomeLeader(); CurrentMetrics::add(CurrentMetrics::LeaderReplica); },
storage.replica_name);
/// Anything above can throw a KeeperException if something is wrong with ZK.
/// Anything below should not throw exceptions.

View File

@ -257,7 +257,7 @@ private:
*/
int columns_version = -1;
/** Is this replica "master". The master replica selects the parts to merge.
/** Is this replica "leading". The leader replica selects the parts to merge.
*/
bool is_leader_node = false;
std::mutex leader_node_mutex;