2015-07-16 21:03:53 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Poco/Util/AbstractConfiguration.h>
|
|
|
|
#include <DB/Core/Types.h>
|
|
|
|
#include <DB/IO/ReadHelpers.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2016-10-23 20:13:10 +00:00
|
|
|
/** Advanced settings of MergeTree.
|
|
|
|
* Could be loaded from config.
|
2015-07-16 21:03:53 +00:00
|
|
|
*/
|
|
|
|
struct MergeTreeSettings
|
|
|
|
{
|
2016-10-24 13:47:15 +00:00
|
|
|
/** Merge settings. */
|
2015-07-16 21:03:53 +00:00
|
|
|
|
2016-12-06 03:09:07 +00:00
|
|
|
/// Maximum in total size of parts to merge, when there are maximum (minimum) free threads in background pool (or entries in replication queue).
|
2016-10-27 22:50:02 +00:00
|
|
|
size_t max_bytes_to_merge_at_max_space_in_pool = 100ULL * 1024 * 1024 * 1024;
|
|
|
|
size_t max_bytes_to_merge_at_min_space_in_pool = 1024 * 1024;
|
2015-07-16 21:03:53 +00:00
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// How many tasks of merging parts are allowed simultaneously in ReplicatedMergeTree queue.
|
2016-11-24 22:41:27 +00:00
|
|
|
size_t max_replicated_merges_in_queue = 16;
|
2015-07-16 21:03:53 +00:00
|
|
|
|
2016-12-06 03:09:07 +00:00
|
|
|
/// When there is less than specified number of free entries in pool (or replicated queue),
|
|
|
|
/// start to lower maximum size of merge to process (or to put in queue).
|
|
|
|
/// This is to allow small merges to process - not filling the pool with long running merges.
|
|
|
|
size_t number_of_free_entries_in_pool_to_lower_max_size_of_merge = 8;
|
|
|
|
|
2016-10-23 20:13:10 +00:00
|
|
|
/// How many seconds to keep obsolete parts.
|
2015-07-16 21:03:53 +00:00
|
|
|
time_t old_parts_lifetime = 8 * 60;
|
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// How many seconds to keep tmp_-directories.
|
2016-06-06 19:16:34 +00:00
|
|
|
time_t temporary_directories_lifetime = 86400;
|
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/** Inserts settings. */
|
2015-07-16 21:03:53 +00:00
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// If table contains at least that many active parts, artificially slow down insert into table.
|
2015-07-16 21:03:53 +00:00
|
|
|
size_t parts_to_delay_insert = 150;
|
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// If more than this number active parts, throw 'Too much parts ...' exception
|
2016-10-19 17:48:02 +00:00
|
|
|
size_t parts_to_throw_insert = 300;
|
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// Max delay of inserting data into MergeTree table in seconds, if there are a lot of unmerged parts.
|
2016-10-19 17:48:02 +00:00
|
|
|
size_t max_delay_to_insert = 200;
|
2015-07-16 21:03:53 +00:00
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/** Replication settings. */
|
2015-07-16 21:03:53 +00:00
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// How many last blocks of hashes should be kept in ZooKeeper.
|
2015-07-16 21:03:53 +00:00
|
|
|
size_t replicated_deduplication_window = 100;
|
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// Keep about this number of last records in ZooKeeper log, even if they are obsolete.
|
|
|
|
/// It doesn't affect work of tables: used only to diagnose ZooKeeper log before cleaning.
|
2015-07-16 21:03:53 +00:00
|
|
|
size_t replicated_logs_to_keep = 100;
|
|
|
|
|
2016-08-02 19:02:00 +00:00
|
|
|
/// After specified amount of time passed after replication log entry creation
|
|
|
|
/// and sum size of parts is greater than threshold,
|
|
|
|
/// prefer fetching merged part from replica instead of doing merge locally.
|
|
|
|
/// To speed up very long merges.
|
|
|
|
time_t prefer_fetch_merged_part_time_threshold = 3600;
|
|
|
|
size_t prefer_fetch_merged_part_size_threshold = 10ULL * 1024 * 1024 * 1024;
|
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// Max broken parts, if more - deny automatic deletion.
|
2015-09-02 19:39:19 +00:00
|
|
|
size_t max_suspicious_broken_parts = 10;
|
2015-07-16 21:03:53 +00:00
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// Not apply ALTER if number of files for modification(deletion, addition) more than this.
|
2016-11-09 14:14:39 +00:00
|
|
|
size_t max_files_to_modify_in_alter_columns = 75;
|
2016-10-23 20:13:10 +00:00
|
|
|
/// Not apply ALTER, if number of files for deletion more than this.
|
2016-11-09 14:14:39 +00:00
|
|
|
size_t max_files_to_remove_in_alter_columns = 50;
|
2016-04-05 18:18:16 +00:00
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// Maximum number of errors during parts loading, while ReplicatedMergeTree still allowed to start.
|
2015-07-16 21:03:53 +00:00
|
|
|
size_t replicated_max_unexpected_parts = 3;
|
|
|
|
size_t replicated_max_unexpectedly_merged_parts = 2;
|
|
|
|
size_t replicated_max_missing_obsolete_parts = 5;
|
|
|
|
size_t replicated_max_missing_active_parts = 20;
|
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// If ration of wrong parts to total number of parts is less than this - allow to start anyway.
|
2015-07-16 21:03:53 +00:00
|
|
|
double replicated_max_ratio_of_wrong_parts = 0.05;
|
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// In seconds.
|
|
|
|
size_t zookeeper_session_expiration_check_period = 60;
|
|
|
|
|
2016-10-23 20:13:10 +00:00
|
|
|
/** Check delay of replicas settings. */
|
2015-11-05 19:44:19 +00:00
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// Period to check replication delay and compare with other replicas.
|
2015-11-05 19:44:19 +00:00
|
|
|
size_t check_delay_period = 60;
|
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// Minimal delay from other replicas to yield leadership. Here and further 0 means unlimited.
|
2015-11-05 19:44:19 +00:00
|
|
|
size_t min_relative_delay_to_yield_leadership = 120;
|
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// Minimal delay from other replicas to close, stop serving requests and not return Ok during status check.
|
2015-11-05 19:44:19 +00:00
|
|
|
size_t min_relative_delay_to_close = 300;
|
|
|
|
|
2016-10-24 13:47:15 +00:00
|
|
|
/// Minimal absolute delay to close, stop serving requests and not return Ok during status check.
|
2015-11-05 19:44:19 +00:00
|
|
|
size_t min_absolute_delay_to_close = 0;
|
|
|
|
|
2016-11-03 12:00:44 +00:00
|
|
|
/// Enable usage of Vertical merge algorithm.
|
|
|
|
size_t enable_vertical_merge_algorithm = 0;
|
|
|
|
|
2016-12-06 21:02:22 +00:00
|
|
|
/// Minimal (approximate) sum of rows in merging parts to activate Vertical merge algorithm
|
|
|
|
size_t vertical_merge_algorithm_min_rows_to_activate = 16 * DEFAULT_MERGE_BLOCK_SIZE;
|
|
|
|
|
2016-12-21 19:00:25 +00:00
|
|
|
/// Minimal amount of non-PK columns to activate Vertical merge algorithm
|
|
|
|
size_t vertical_merge_algorithm_min_columns_to_activate = 11;
|
|
|
|
|
2015-07-16 21:03:53 +00:00
|
|
|
|
2015-07-16 21:32:51 +00:00
|
|
|
void loadFromConfig(const String & config_elem, Poco::Util::AbstractConfiguration & config)
|
2015-07-16 21:03:53 +00:00
|
|
|
{
|
|
|
|
#define SET_DOUBLE(NAME) \
|
|
|
|
NAME = config.getDouble(config_elem + "." #NAME, NAME);
|
|
|
|
|
|
|
|
#define SET_SIZE_T(NAME) \
|
|
|
|
if (config.has(config_elem + "." #NAME)) NAME = parse<size_t>(config.getString(config_elem + "." #NAME));
|
|
|
|
|
2016-10-30 09:13:30 +00:00
|
|
|
SET_SIZE_T(max_bytes_to_merge_at_max_space_in_pool);
|
|
|
|
SET_SIZE_T(max_bytes_to_merge_at_min_space_in_pool);
|
2015-07-16 21:03:53 +00:00
|
|
|
SET_SIZE_T(max_replicated_merges_in_queue);
|
|
|
|
SET_SIZE_T(old_parts_lifetime);
|
2016-06-06 19:50:30 +00:00
|
|
|
SET_SIZE_T(temporary_directories_lifetime);
|
2015-07-16 21:03:53 +00:00
|
|
|
SET_SIZE_T(parts_to_delay_insert);
|
2016-10-19 17:48:02 +00:00
|
|
|
SET_SIZE_T(parts_to_throw_insert);
|
|
|
|
SET_SIZE_T(max_delay_to_insert);
|
2015-07-16 21:03:53 +00:00
|
|
|
SET_SIZE_T(replicated_deduplication_window);
|
|
|
|
SET_SIZE_T(replicated_logs_to_keep);
|
2016-08-02 19:02:00 +00:00
|
|
|
SET_SIZE_T(prefer_fetch_merged_part_time_threshold);
|
|
|
|
SET_SIZE_T(prefer_fetch_merged_part_size_threshold);
|
2015-07-16 21:03:53 +00:00
|
|
|
SET_SIZE_T(max_suspicious_broken_parts);
|
2016-04-05 18:18:16 +00:00
|
|
|
SET_SIZE_T(max_files_to_modify_in_alter_columns);
|
2016-06-06 19:50:30 +00:00
|
|
|
SET_SIZE_T(max_files_to_remove_in_alter_columns);
|
2015-07-16 21:03:53 +00:00
|
|
|
SET_SIZE_T(replicated_max_unexpected_parts);
|
|
|
|
SET_SIZE_T(replicated_max_unexpectedly_merged_parts);
|
|
|
|
SET_SIZE_T(replicated_max_missing_obsolete_parts);
|
|
|
|
SET_SIZE_T(replicated_max_missing_active_parts);
|
|
|
|
SET_DOUBLE(replicated_max_ratio_of_wrong_parts);
|
2016-10-24 13:47:15 +00:00
|
|
|
SET_SIZE_T(zookeeper_session_expiration_check_period);
|
2015-11-05 19:44:19 +00:00
|
|
|
SET_SIZE_T(check_delay_period);
|
|
|
|
SET_SIZE_T(min_relative_delay_to_yield_leadership);
|
|
|
|
SET_SIZE_T(min_relative_delay_to_close);
|
|
|
|
SET_SIZE_T(min_absolute_delay_to_close);
|
2016-11-03 12:00:44 +00:00
|
|
|
SET_SIZE_T(enable_vertical_merge_algorithm);
|
2016-12-06 21:02:22 +00:00
|
|
|
SET_SIZE_T(vertical_merge_algorithm_min_rows_to_activate);
|
2016-12-21 19:00:25 +00:00
|
|
|
SET_SIZE_T(vertical_merge_algorithm_min_columns_to_activate);
|
2015-07-16 21:03:53 +00:00
|
|
|
|
|
|
|
#undef SET_SIZE_T
|
|
|
|
#undef SET_DOUBLE
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|