diff --git a/src/rootserver/ob_root_service.cpp b/src/rootserver/ob_root_service.cpp index 232034afa0..072bd54db6 100644 --- a/src/rootserver/ob_root_service.cpp +++ b/src/rootserver/ob_root_service.cpp @@ -39,6 +39,7 @@ #include "share/schema/ob_schema_mgr.h" #include "share/ob_lease_struct.h" #include "share/ob_common_rpc_proxy.h" +#include "share/config/ob_config_helper.h" #include "share/config/ob_config_manager.h" #include "share/inner_table/ob_inner_table_schema.h" #include "share/schema/ob_part_mgr_util.h" @@ -8667,10 +8668,28 @@ int ObRootService::set_config_pre_hook(obrpc::ObAdminSetConfigArg &arg) LOG_WARN("invalid argument", K(ret), K(arg)); } FOREACH_X(item, arg.items_, OB_SUCCESS == ret) { - bool valid; + bool valid = true; if (item->name_.is_empty()) { ret = OB_INVALID_ARGUMENT; LOG_WARN("empty config name", "item", *item, K(ret)); + } else if (0 == STRCMP(item->name_.ptr(), FREEZE_TRIGGER_PERCENTAGE)) { + // check write throttle percentage + for (int i = 0; i < item->tenant_ids_.count() && valid; i++) { + valid = valid && ObConfigFreezeTriggerIntChecker::check(item->tenant_ids_.at(i), *item); + if (!valid) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("config invalid", "item", *item, K(ret), K(i), K(item->tenant_ids_.at(i))); + } + } + } else if (0 == STRCMP(item->name_.ptr(), WRITING_THROTTLEIUNG_TRIGGER_PERCENTAGE)) { + // check freeze trigger + for (int i = 0; i < item->tenant_ids_.count() && valid; i++) { + valid = valid && ObConfigWriteThrottleTriggerIntChecker::check(item->tenant_ids_.at(i), *item); + if (!valid) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("config invalid", "item", *item, K(ret), K(i), K(item->tenant_ids_.at(i))); + } + } } } return ret; diff --git a/src/share/config/ob_config_helper.cpp b/src/share/config/ob_config_helper.cpp index 46e9de340f..61d72558ab 100644 --- a/src/share/config/ob_config_helper.cpp +++ b/src/share/config/ob_config_helper.cpp @@ -31,6 +31,7 @@ namespace oceanbase { using namespace share; +using namespace obrpc; namespace common { @@ -86,6 +87,62 @@ bool ObConfigEvenIntChecker::check(const ObConfigItem &t) const return is_valid; } +bool ObConfigFreezeTriggerIntChecker::check(const uint64_t tenant_id, + const ObAdminSetConfigItem &t) +{ + bool is_valid = false; + int64_t value = ObConfigIntParser::get(t.value_.ptr(), is_valid); + int64_t write_throttle_trigger = get_write_throttle_trigger_percentage_(tenant_id); + if (is_valid) { + is_valid = value > 0 && value < 100; + } + if (is_valid) { + is_valid = write_throttle_trigger != 0; + } + if (is_valid) { + is_valid = value < write_throttle_trigger; + } + return is_valid; +} + +int64_t ObConfigFreezeTriggerIntChecker::get_write_throttle_trigger_percentage_(const uint64_t tenant_id) +{ + int64_t percent = 0; + omt::ObTenantConfigGuard tenant_config(TENANT_CONF(tenant_id)); + if (tenant_config.is_valid()) { + percent = tenant_config->writing_throttling_trigger_percentage; + } + return percent; +} + +bool ObConfigWriteThrottleTriggerIntChecker::check(const uint64_t tenant_id, + const ObAdminSetConfigItem &t) +{ + bool is_valid = false; + int64_t value = ObConfigIntParser::get(t.value_.ptr(), is_valid); + int64_t freeze_trigger = get_freeze_trigger_percentage_(tenant_id); + if (is_valid) { + is_valid = value > 0 && value <= 100; + } + if (is_valid) { + is_valid = freeze_trigger != 0; + } + if (is_valid) { + is_valid = value > freeze_trigger; + } + return is_valid; +} + +int64_t ObConfigWriteThrottleTriggerIntChecker::get_freeze_trigger_percentage_(const uint64_t tenant_id) +{ + int64_t percent = 0; + omt::ObTenantConfigGuard tenant_config(TENANT_CONF(tenant_id)); + if (tenant_config.is_valid()) { + percent = tenant_config->freeze_trigger_percentage; + } + return percent; +} + bool ObConfigTabletSizeChecker::check(const ObConfigItem &t) const { bool is_valid = false; diff --git a/src/share/config/ob_config_helper.h b/src/share/config/ob_config_helper.h index b5a25bb75f..1333b753aa 100644 --- a/src/share/config/ob_config_helper.h +++ b/src/share/config/ob_config_helper.h @@ -21,6 +21,11 @@ namespace oceanbase { +namespace obrpc +{ +struct ObAdminSetConfigItem; +} + namespace common { class ObConfigItem; @@ -157,6 +162,26 @@ private: DISALLOW_COPY_AND_ASSIGN(ObConfigEvenIntChecker); }; +class ObConfigFreezeTriggerIntChecker +{ +public: + static bool check(const uint64_t tenant_id, + const obrpc::ObAdminSetConfigItem &t); +private: + static int64_t get_write_throttle_trigger_percentage_(const uint64_t tenant_id); + DISALLOW_COPY_AND_ASSIGN(ObConfigFreezeTriggerIntChecker); +}; + +class ObConfigWriteThrottleTriggerIntChecker +{ +public: + static bool check(const uint64_t tenant_id, + const obrpc::ObAdminSetConfigItem &t); +private: + static int64_t get_freeze_trigger_percentage_(const uint64_t tenant_id); + DISALLOW_COPY_AND_ASSIGN(ObConfigWriteThrottleTriggerIntChecker); +}; + class ObConfigTabletSizeChecker : public ObConfigChecker { diff --git a/src/share/config/ob_server_config.h b/src/share/config/ob_server_config.h index 36e0ca13c3..80f69f5848 100644 --- a/src/share/config/ob_server_config.h +++ b/src/share/config/ob_server_config.h @@ -50,6 +50,8 @@ const char* const EXTERNAL_KMS_INFO = "external_kms_info"; const char* const SSL_EXTERNAL_KMS_INFO = "ssl_external_kms_info"; const char* const CLUSTER_ID = "cluster_id"; const char* const CLUSTER_NAME = "cluster"; +const char* const FREEZE_TRIGGER_PERCENTAGE = "freeze_trigger_percentage"; +const char* const WRITING_THROTTLEIUNG_TRIGGER_PERCENTAGE = "writing_throttling_trigger_percentage"; class ObServerMemoryConfig; class ObServerConfig : public ObCommonConfig