mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Support MergeTree settings and clickhouse local
This commit is contained in:
parent
bff84d44e8
commit
764dd82345
@ -79,6 +79,7 @@ namespace Setting
|
||||
|
||||
namespace ServerSetting
|
||||
{
|
||||
extern const ServerSettingsUInt32 allowed_feature_tier;
|
||||
extern const ServerSettingsDouble cache_size_to_ram_max_ratio;
|
||||
extern const ServerSettingsUInt64 compiled_expression_cache_elements_size;
|
||||
extern const ServerSettingsUInt64 compiled_expression_cache_size;
|
||||
@ -789,6 +790,9 @@ void LocalServer::processConfig()
|
||||
/// Initialize a dummy query cache.
|
||||
global_context->setQueryCache(0, 0, 0, 0);
|
||||
|
||||
/// Initialize allowed tiers
|
||||
global_context->getAccessControl().setAllowTierSettings(server_settings[ServerSetting::allowed_feature_tier]);
|
||||
|
||||
#if USE_EMBEDDED_COMPILER
|
||||
size_t compiled_expression_cache_max_size_in_bytes = server_settings[ServerSetting::compiled_expression_cache_size];
|
||||
size_t compiled_expression_cache_max_elements = server_settings[ServerSetting::compiled_expression_cache_elements_size];
|
||||
|
@ -2163,9 +2163,12 @@ try
|
||||
|
||||
/// Check sanity of MergeTreeSettings on server startup
|
||||
{
|
||||
/// All settings can be changed in the global config
|
||||
bool allowed_experimental = 1;
|
||||
bool allowed_beta = 1;
|
||||
size_t background_pool_tasks = global_context->getMergeMutateExecutor()->getMaxTasksCount();
|
||||
global_context->getMergeTreeSettings().sanityCheck(background_pool_tasks);
|
||||
global_context->getReplicatedMergeTreeSettings().sanityCheck(background_pool_tasks);
|
||||
global_context->getMergeTreeSettings().sanityCheck(background_pool_tasks, allowed_experimental, allowed_beta);
|
||||
global_context->getReplicatedMergeTreeSettings().sanityCheck(background_pool_tasks, allowed_experimental, allowed_beta);
|
||||
}
|
||||
/// try set up encryption. There are some errors in config, error will be printed and server wouldn't start.
|
||||
CompressionCodecEncrypted::Configuration::instance().load(config(), "encryption_codecs");
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <Storages/MergeTree/MergeTreeData.h>
|
||||
|
||||
#include <Access/AccessControl.h>
|
||||
#include <AggregateFunctions/AggregateFunctionCount.h>
|
||||
#include <Analyzer/QueryTreeBuilder.h>
|
||||
#include <Analyzer/Utils.h>
|
||||
@ -461,7 +462,12 @@ MergeTreeData::MergeTreeData(
|
||||
|
||||
/// Check sanity of MergeTreeSettings. Only when table is created.
|
||||
if (sanity_checks)
|
||||
settings->sanityCheck(getContext()->getMergeMutateExecutor()->getMaxTasksCount());
|
||||
{
|
||||
const auto & ac = getContext()->getAccessControl();
|
||||
bool allow_experimental = ac.getAllowExperimentalTierSettings();
|
||||
bool allow_beta = ac.getAllowBetaTierSettings();
|
||||
settings->sanityCheck(getContext()->getMergeMutateExecutor()->getMaxTasksCount(), allow_experimental, allow_beta);
|
||||
}
|
||||
|
||||
if (!date_column_name.empty())
|
||||
{
|
||||
@ -3895,7 +3901,10 @@ void MergeTreeData::changeSettings(
|
||||
/// Reset to default settings before applying existing.
|
||||
auto copy = getDefaultSettings();
|
||||
copy->applyChanges(new_changes);
|
||||
copy->sanityCheck(getContext()->getMergeMutateExecutor()->getMaxTasksCount());
|
||||
const auto & ac = getContext()->getAccessControl();
|
||||
bool allow_experimental = ac.getAllowExperimentalTierSettings();
|
||||
bool allow_beta = ac.getAllowBetaTierSettings();
|
||||
copy->sanityCheck(getContext()->getMergeMutateExecutor()->getMaxTasksCount(), allow_experimental, allow_beta);
|
||||
|
||||
storage_settings.set(std::move(copy));
|
||||
StorageInMemoryMetadata new_metadata = getInMemoryMetadata();
|
||||
|
@ -28,6 +28,7 @@ namespace ErrorCodes
|
||||
{
|
||||
extern const int UNKNOWN_SETTING;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
extern const int READONLY;
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
@ -295,7 +296,7 @@ struct MergeTreeSettingsImpl : public BaseSettings<MergeTreeSettingsTraits>
|
||||
void loadFromQuery(ASTStorage & storage_def, ContextPtr context, bool is_attach);
|
||||
|
||||
/// Check that the values are sane taking also query-level settings into account.
|
||||
void sanityCheck(size_t background_pool_tasks) const;
|
||||
void sanityCheck(size_t background_pool_tasks, bool allow_experimental, bool allow_beta) const;
|
||||
};
|
||||
|
||||
IMPLEMENT_SETTINGS_TRAITS(MergeTreeSettingsTraits, LIST_OF_MERGE_TREE_SETTINGS)
|
||||
@ -375,8 +376,35 @@ void MergeTreeSettingsImpl::loadFromQuery(ASTStorage & storage_def, ContextPtr c
|
||||
#undef ADD_IF_ABSENT
|
||||
}
|
||||
|
||||
void MergeTreeSettingsImpl::sanityCheck(size_t background_pool_tasks) const
|
||||
void MergeTreeSettingsImpl::sanityCheck(size_t background_pool_tasks, bool allowed_experimental, bool allowed_beta) const
|
||||
{
|
||||
if (!allowed_experimental || !allowed_beta)
|
||||
{
|
||||
for (const auto & setting : all())
|
||||
{
|
||||
if (!setting.isValueChanged())
|
||||
continue;
|
||||
|
||||
auto tier = setting.getTier();
|
||||
if (!allowed_experimental && tier == EXPERIMENTAL)
|
||||
{
|
||||
throw Exception(
|
||||
ErrorCodes::READONLY,
|
||||
"Cannot modify setting '{}'. Changes to EXPERIMENTAL settings are disabled in the server config "
|
||||
"('allowed_feature_tier')",
|
||||
setting.getName());
|
||||
}
|
||||
if (!allowed_beta && tier == BETA)
|
||||
{
|
||||
throw Exception(
|
||||
ErrorCodes::READONLY,
|
||||
"Cannot modify setting '{}'. Changes to BETA settings are disabled in the server config ('allowed_feature_tier')",
|
||||
setting.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (number_of_free_entries_in_pool_to_execute_mutation > background_pool_tasks)
|
||||
{
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "The value of 'number_of_free_entries_in_pool_to_execute_mutation' setting"
|
||||
@ -623,9 +651,9 @@ bool MergeTreeSettings::needSyncPart(size_t input_rows, size_t input_bytes) cons
|
||||
|| (impl->min_compressed_bytes_to_fsync_after_merge && input_bytes >= impl->min_compressed_bytes_to_fsync_after_merge));
|
||||
}
|
||||
|
||||
void MergeTreeSettings::sanityCheck(size_t background_pool_tasks) const
|
||||
void MergeTreeSettings::sanityCheck(size_t background_pool_tasks, bool allow_experimental, bool allow_beta) const
|
||||
{
|
||||
impl->sanityCheck(background_pool_tasks);
|
||||
impl->sanityCheck(background_pool_tasks, allow_experimental, allow_beta);
|
||||
}
|
||||
|
||||
void MergeTreeSettings::dumpToSystemMergeTreeSettingsColumns(MutableColumnsAndConstraints & params) const
|
||||
|
@ -77,7 +77,7 @@ struct MergeTreeSettings
|
||||
void loadFromConfig(const String & config_elem, const Poco::Util::AbstractConfiguration & config);
|
||||
|
||||
bool needSyncPart(size_t input_rows, size_t input_bytes) const;
|
||||
void sanityCheck(size_t background_pool_tasks) const;
|
||||
void sanityCheck(size_t background_pool_tasks, bool allow_experimental, bool allow_beta) const;
|
||||
|
||||
void dumpToSystemMergeTreeSettingsColumns(MutableColumnsAndConstraints & params) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user