mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Sanity checks for MergeTreeSettings
This commit is contained in:
parent
fc35ce69fa
commit
b9f49d31df
@ -641,6 +641,9 @@ int Server::main(const std::vector<std::string> & /*args*/)
|
||||
global_context->setFormatSchemaPath(format_schema_path.path());
|
||||
format_schema_path.createDirectories();
|
||||
|
||||
/// Check sanity of MergeTreeSettings on server startup
|
||||
global_context->getMergeTreeSettings().sanityCheck(settings);
|
||||
|
||||
/// Limit on total memory usage
|
||||
size_t max_server_memory_usage = config().getUInt64("max_server_memory_usage", 0);
|
||||
|
||||
|
@ -147,6 +147,10 @@ MergeTreeData::MergeTreeData(
|
||||
if (relative_data_path.empty())
|
||||
throw Exception("MergeTree storages require data path", ErrorCodes::INCORRECT_FILE_NAME);
|
||||
|
||||
/// Check sanity of MergeTreeSettings. Only when table is created.
|
||||
if (!attach)
|
||||
settings->sanityCheck(global_context.getSettingsRef());
|
||||
|
||||
MergeTreeDataFormatVersion min_format_version(0);
|
||||
if (!date_column_name.empty())
|
||||
{
|
||||
|
@ -76,4 +76,31 @@ void MergeTreeSettings::loadFromQuery(ASTStorage & storage_def)
|
||||
#undef ADD_IF_ABSENT
|
||||
}
|
||||
|
||||
void MergeTreeSettings::sanityCheck(const Settings & query_settings) const
|
||||
{
|
||||
if (number_of_free_entries_in_pool_to_execute_mutation >= query_settings.background_pool_size)
|
||||
{
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "The value of 'number_of_free_entries_in_pool_to_execute_mutation' setting"
|
||||
" ({}) (default values are defined in <merge_tree> section of config.xml"
|
||||
" or the value can be specified per table in SETTINGS section of CREATE TABLE query)"
|
||||
" is greater or equals to the value of 'background_pool_size'"
|
||||
" ({}) (the value is defined in users.xml for default profile)."
|
||||
" This indicates incorrect configuration because mutations cannot work with these settings.",
|
||||
number_of_free_entries_in_pool_to_execute_mutation,
|
||||
query_settings.background_pool_size);
|
||||
}
|
||||
|
||||
if (number_of_free_entries_in_pool_to_lower_max_size_of_merge >= query_settings.background_pool_size)
|
||||
{
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "The value of 'number_of_free_entries_in_pool_to_lower_max_size_of_merge' setting"
|
||||
" ({}) (default values are defined in <merge_tree> section of config.xml"
|
||||
" or the value can be specified per table in SETTINGS section of CREATE TABLE query)"
|
||||
" is greater or equals to the value of 'background_pool_size'"
|
||||
" ({}) (the value is defined in users.xml for default profile)."
|
||||
" This indicates incorrect configuration because the maximum size of merge will be always lowered.",
|
||||
number_of_free_entries_in_pool_to_execute_mutation,
|
||||
query_settings.background_pool_size);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ namespace DB
|
||||
{
|
||||
|
||||
class ASTStorage;
|
||||
struct Settings;
|
||||
|
||||
/** Settings for the MergeTree family of engines.
|
||||
* Could be loaded from config or from a CREATE TABLE query (SETTINGS clause).
|
||||
@ -127,6 +128,9 @@ struct MergeTreeSettings : public SettingsCollection<MergeTreeSettings>
|
||||
return name == "min_bytes_for_wide_part" || name == "min_rows_for_wide_part"
|
||||
|| name == "min_bytes_for_compact_part" || name == "min_rows_for_compact_part";
|
||||
}
|
||||
|
||||
/// Check that the values are sane taking also query-level settings into account.
|
||||
void sanityCheck(const Settings & query_settings) const;
|
||||
};
|
||||
|
||||
using MergeTreeSettingsPtr = std::shared_ptr<const MergeTreeSettings>;
|
||||
|
@ -0,0 +1,21 @@
|
||||
CREATE TABLE mytable_local
|
||||
(
|
||||
created DateTime,
|
||||
eventday Date,
|
||||
user_id UInt32
|
||||
)
|
||||
ENGINE = MergeTree()
|
||||
PARTITION BY toYYYYMM(eventday)
|
||||
ORDER BY (eventday, user_id)
|
||||
SETTINGS number_of_free_entries_in_pool_to_execute_mutation = 100; -- { serverError 36 }
|
||||
|
||||
CREATE TABLE mytable_local
|
||||
(
|
||||
created DateTime,
|
||||
eventday Date,
|
||||
user_id UInt32
|
||||
)
|
||||
ENGINE = MergeTree()
|
||||
PARTITION BY toYYYYMM(eventday)
|
||||
ORDER BY (eventday, user_id)
|
||||
SETTINGS number_of_free_entries_in_pool_to_lower_max_size_of_merge = 100; -- { serverError 36 }
|
Loading…
Reference in New Issue
Block a user