[FEAT MERGE] cap_config_4.2

This commit is contained in:
obdev
2023-04-18 07:41:54 +00:00
committed by ob-robot
parent 4872b46eef
commit 0e762bcbc5
12 changed files with 47 additions and 20 deletions

View File

@ -327,7 +327,8 @@ int ObTenantConfig::publish_special_config_after_dump()
int ObTenantConfig::add_extra_config(const char *config_str, int ObTenantConfig::add_extra_config(const char *config_str,
int64_t version /* = 0 */ , int64_t version /* = 0 */ ,
bool check_name /* = false */) bool check_name /* = false */,
bool check_unit /* = true */)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t MAX_OPTS_LENGTH = sysconf(_SC_ARG_MAX); const int64_t MAX_OPTS_LENGTH = sysconf(_SC_ARG_MAX);
@ -388,6 +389,9 @@ int ObTenantConfig::add_extra_config(const char *config_str,
(*pp_item)->set_version(version); (*pp_item)->set_version(version);
LOG_INFO("Load tenant config dump value succ", K(name), K((*pp_item)->spfile_str()), K((*pp_item)->str())); LOG_INFO("Load tenant config dump value succ", K(name), K((*pp_item)->spfile_str()), K((*pp_item)->str()));
} }
} else if (check_unit && !(*pp_item)->check_unit(value)) {
ret = OB_INVALID_CONFIG;
LOG_ERROR("Invalid config value", K(name), K(value), K(ret));
} else { } else {
if (!(*pp_item)->set_value(value)) { if (!(*pp_item)->set_value(value)) {
ret = OB_INVALID_CONFIG; ret = OB_INVALID_CONFIG;

View File

@ -92,7 +92,8 @@ public:
bool save2file = true); bool save2file = true);
int add_extra_config(const char *config_str, int add_extra_config(const char *config_str,
int64_t version = 0 , int64_t version = 0 ,
bool check_name = false); bool check_name = false,
bool check_unit = true);
OB_UNIS_VERSION(1); OB_UNIS_VERSION(1);
private: private:

View File

@ -859,6 +859,9 @@ int ObAdminSetConfig::verify_config(obrpc::ObAdminSetConfigArg &arg)
if (ci->is_not_editable() && !arg.is_inner_) { if (ci->is_not_editable() && !arg.is_inner_) {
ret = OB_INVALID_CONFIG; //TODO: specific report not editable ret = OB_INVALID_CONFIG; //TODO: specific report not editable
LOG_WARN("config is not editable", "item", *item, KR(ret)); LOG_WARN("config is not editable", "item", *item, KR(ret));
} else if (!ci->check_unit(item->value_.ptr())) {
ret = OB_INVALID_CONFIG;
LOG_ERROR("invalid config", "item", *item, KR(ret));
} else if (!ci->set_value(item->value_.ptr())) { } else if (!ci->set_value(item->value_.ptr())) {
ret = OB_INVALID_CONFIG; ret = OB_INVALID_CONFIG;
LOG_WARN("invalid config", "item", *item, KR(ret)); LOG_WARN("invalid config", "item", *item, KR(ret));

View File

@ -286,7 +286,8 @@ ObCommonConfig::~ObCommonConfig()
int ObCommonConfig::add_extra_config(const char *config_str, int ObCommonConfig::add_extra_config(const char *config_str,
int64_t version /* = 0 */ , int64_t version /* = 0 */ ,
bool check_name /* = false */) bool check_name /* = false */,
bool check_unit /* = true */)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t MAX_OPTS_LENGTH = sysconf(_SC_ARG_MAX); const int64_t MAX_OPTS_LENGTH = sysconf(_SC_ARG_MAX);
@ -353,6 +354,9 @@ int ObCommonConfig::add_extra_config(const char *config_str,
} }
} }
if (OB_FAIL(ret) || OB_ISNULL(pp_item)) { if (OB_FAIL(ret) || OB_ISNULL(pp_item)) {
} else if (check_unit && !(*pp_item)->check_unit(value)) {
ret = OB_INVALID_CONFIG;
LOG_ERROR("Invalid config value", K(name), K(value), K(ret));
} else if (!(*pp_item)->set_value(value)) { } else if (!(*pp_item)->set_value(value)) {
ret = OB_INVALID_CONFIG; ret = OB_INVALID_CONFIG;
LOG_ERROR("Invalid config value", K(name), K(value), K(ret)); LOG_ERROR("Invalid config value", K(name), K(value), K(ret));
@ -460,7 +464,7 @@ OB_DEF_DESERIALIZE(ObCommonConfig)
} else { } else {
MEMSET(copy_buf, '\0', data_len + 1); MEMSET(copy_buf, '\0', data_len + 1);
MEMCPY(copy_buf, buf + pos, data_len); MEMCPY(copy_buf, buf + pos, data_len);
if (OB_FAIL(ObCommonConfig::add_extra_config(copy_buf))) { if (OB_FAIL(ObCommonConfig::add_extra_config(copy_buf, 0, false, false))) {
LOG_ERROR("Read server config failed", K(ret)); LOG_ERROR("Read server config failed", K(ret));
} }

View File

@ -98,7 +98,8 @@ public:
virtual ObServerRole get_server_type() const = 0; virtual ObServerRole get_server_type() const = 0;
virtual int add_extra_config(const char *config_str, virtual int add_extra_config(const char *config_str,
const int64_t version = 0, const int64_t version = 0,
const bool check_name = false); const bool check_name = false,
const bool check_unit = true);
virtual bool is_debug_sync_enabled() const { return false; } virtual bool is_debug_sync_enabled() const { return false; }
OB_UNIS_VERSION_V(1); OB_UNIS_VERSION_V(1);

View File

@ -520,7 +520,7 @@ ObConfigCapacityItem::ObConfigCapacityItem(ObConfigContainer *container,
int64_t ObConfigCapacityItem::parse(const char *str, bool &valid) const int64_t ObConfigCapacityItem::parse(const char *str, bool &valid) const
{ {
int64_t value = ObConfigCapacityParser::get(str, valid); int64_t value = ObConfigCapacityParser::get(str, valid, false);
if (!valid) { if (!valid) {
OB_LOG_RET(ERROR, OB_ERR_UNEXPECTED, "set capacity error", "name", name(), K(str), K(valid)); OB_LOG_RET(ERROR, OB_ERR_UNEXPECTED, "set capacity error", "name", name(), K(str), K(valid));
} }

View File

@ -67,6 +67,11 @@ public:
{ {
return NULL == ck_ ? value_valid_ : value_valid_ && ck_->check(*this); return NULL == ck_ ? value_valid_ : value_valid_ && ck_->check(*this);
} }
virtual bool check_unit(const char *str) const
{
UNUSED(str);
return true;
}
bool set_value(const common::ObString &string) bool set_value(const common::ObString &string)
{ {
int64_t pos = 0; int64_t pos = 0;
@ -412,7 +417,6 @@ public:
virtual ObConfigItemType get_config_item_type() const { virtual ObConfigItemType get_config_item_type() const {
return ObConfigItemType::OB_CONF_ITEM_TYPE_INTEGRAL; return ObConfigItemType::OB_CONF_ITEM_TYPE_INTEGRAL;
} }
protected: protected:
//use current value to do input operation //use current value to do input operation
virtual bool set(const char *str); virtual bool set(const char *str);
@ -528,6 +532,12 @@ public:
virtual ~ObConfigCapacityItem() {} virtual ~ObConfigCapacityItem() {}
ObConfigCapacityItem &operator = (int64_t value); ObConfigCapacityItem &operator = (int64_t value);
virtual bool check_unit(const char *str) const
{
bool is_valid;
IGNORE_RETURN ObConfigCapacityParser::get(str, is_valid);
return is_valid;
}
protected: protected:
int64_t parse(const char *str, bool &valid) const; int64_t parse(const char *str, bool &valid) const;

View File

@ -147,7 +147,7 @@ bool ObConfigTabletSizeChecker::check(const ObConfigItem &t) const
{ {
bool is_valid = false; bool is_valid = false;
const int64_t mask = (1 << 21) - 1; const int64_t mask = (1 << 21) - 1;
int64_t value = ObConfigCapacityParser::get(t.str(), is_valid); int64_t value = ObConfigCapacityParser::get(t.str(), is_valid, false);
if (is_valid) { if (is_valid) {
// value has to be a multiple of 2M // value has to be a multiple of 2M
is_valid = (value >= 0) && !(value & mask); is_valid = (value >= 0) && !(value & mask);
@ -343,7 +343,7 @@ bool ObConfigRpcChecksumChecker::check(const ObConfigItem &t) const
bool ObConfigMemoryLimitChecker::check(const ObConfigItem &t) const bool ObConfigMemoryLimitChecker::check(const ObConfigItem &t) const
{ {
bool is_valid = false; bool is_valid = false;
int64_t value = ObConfigCapacityParser::get(t.str(), is_valid); int64_t value = ObConfigCapacityParser::get(t.str(), is_valid, false);
if (is_valid) { if (is_valid) {
is_valid = 0 == value || value >= lib::ObRunningModeConfig::instance().MIN_MEM; is_valid = 0 == value || value >= lib::ObRunningModeConfig::instance().MIN_MEM;
} }
@ -460,7 +460,8 @@ int64_t ObConfigIntParser::get(const char *str, bool &valid)
return value; return value;
} }
int64_t ObConfigCapacityParser::get(const char *str, bool &valid) int64_t ObConfigCapacityParser::get(const char *str, bool &valid,
bool check_unit /* = true */)
{ {
char *p_unit = NULL; char *p_unit = NULL;
int64_t value = 0; int64_t value = 0;
@ -476,7 +477,11 @@ int64_t ObConfigCapacityParser::get(const char *str, bool &valid)
} else if (value < 0) { } else if (value < 0) {
valid = false; valid = false;
} else if ('\0' == *p_unit) { } else if ('\0' == *p_unit) {
value <<= CAP_MB; // default if (check_unit) {
valid = false;
} else {
value <<= CAP_MB;
}
} else if (0 == STRCASECMP("b", p_unit) } else if (0 == STRCASECMP("b", p_unit)
|| 0 == STRCASECMP("byte", p_unit)) { || 0 == STRCASECMP("byte", p_unit)) {
// do nothing // do nothing
@ -671,7 +676,7 @@ bool ObCtxMemoryLimitChecker::check(const char* str, uint64_t& ctx_id, int64_t&
auto len = STRLEN(str); auto len = STRLEN(str);
for (int64_t i = 0; i + 1 < len && !is_valid; ++i) { for (int64_t i = 0; i + 1 < len && !is_valid; ++i) {
if (':' == str[i]) { if (':' == str[i]) {
limit = ObConfigCapacityParser::get(str + i + 1, is_valid); limit = ObConfigCapacityParser::get(str + i + 1, is_valid, false);
if (is_valid) { if (is_valid) {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
SMART_VAR(char[OB_MAX_CONFIG_VALUE_LEN], tmp_str) { SMART_VAR(char[OB_MAX_CONFIG_VALUE_LEN], tmp_str) {

View File

@ -566,8 +566,7 @@ class ObConfigCapacityParser
public: public:
ObConfigCapacityParser() {} ObConfigCapacityParser() {}
virtual ~ObConfigCapacityParser() {} virtual ~ObConfigCapacityParser() {}
static int64_t get(const char *str, bool &valid); static int64_t get(const char *str, bool &valid, bool check_unit = true);
private: private:
enum CAP_UNIT enum CAP_UNIT
{ {

View File

@ -193,7 +193,7 @@ int ObServerConfig::deserialize_with_compat(const char *buf, const int64_t data_
K(data_len), K(pos_data), K_(header.data_zlength), K(ret)); K(data_len), K(pos_data), K_(header.data_zlength), K(ret));
} else if (OB_FAIL(header.check_payload_checksum(p_data, data_len - pos_data))) { } else if (OB_FAIL(header.check_payload_checksum(p_data, data_len - pos_data))) {
LOG_ERROR("check data checksum failed", K(ret)); LOG_ERROR("check data checksum failed", K(ret));
} else if (OB_FAIL(add_extra_config(buf + pos))) { } else if (OB_FAIL(add_extra_config(buf + pos, 0, false, false))) {
LOG_ERROR("Read server config failed", K(ret)); LOG_ERROR("Read server config failed", K(ret));
} else { } else {
pos += header.data_length_; pos += header.data_length_;

View File

@ -32,7 +32,7 @@ DEF_STR(redundancy_level, OB_CLUSTER_PARAMETER, "NORMAL",
ObParameterAttr(Section::SSTABLE, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)) ObParameterAttr(Section::SSTABLE, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE))
// background information about disk space configuration // background information about disk space configuration
// ObServerUtils::get_data_disk_info_in_config() // ObServerUtils::get_data_disk_info_in_config()
DEF_CAP(datafile_size, OB_CLUSTER_PARAMETER, "0", "[0M,)", "size of the data file. Range: [0, +∞)", DEF_CAP(datafile_size, OB_CLUSTER_PARAMETER, "0M", "[0M,)", "size of the data file. Range: [0, +∞)",
ObParameterAttr(Section::SSTABLE, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); ObParameterAttr(Section::SSTABLE, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
DEF_INT(datafile_disk_percentage, OB_CLUSTER_PARAMETER, "0", "[0,99]", DEF_INT(datafile_disk_percentage, OB_CLUSTER_PARAMETER, "0", "[0,99]",
"the percentage of disk space used by the data files. Range: [0,99] in integer", "the percentage of disk space used by the data files. Range: [0,99] in integer",
@ -75,7 +75,7 @@ DEF_INT(rdma_io_thread_count, OB_CLUSTER_PARAMETER, "0", "[0,8]",
DEF_INT(tenant_task_queue_size, OB_CLUSTER_PARAMETER, "16384", "[1024,]", DEF_INT(tenant_task_queue_size, OB_CLUSTER_PARAMETER, "16384", "[1024,]",
"the size of the task queue for each tenant. Range: [1024,+∞)", "the size of the task queue for each tenant. Range: [1024,+∞)",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
_DEF_PARAMETER_SCOPE_CHECKER_EASY(private, Capacity, memory_limit, OB_CLUSTER_PARAMETER, "0", _DEF_PARAMETER_SCOPE_CHECKER_EASY(private, Capacity, memory_limit, OB_CLUSTER_PARAMETER, "0M",
common::ObConfigMemoryLimitChecker, "[0M,)", common::ObConfigMemoryLimitChecker, "[0M,)",
"the size of the memory reserved for internal use(for testing purpose), 0 means follow memory_limit_percentage. Range: 0, [1G,).", "the size of the memory reserved for internal use(for testing purpose), 0 means follow memory_limit_percentage. Range: 0, [1G,).",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
@ -223,7 +223,7 @@ DEF_TIME(autoinc_cache_refresh_interval, OB_CLUSTER_PARAMETER, "3600s", "[100ms,
DEF_BOOL(enable_sql_operator_dump, OB_CLUSTER_PARAMETER, "True", "specifies whether sql operators " DEF_BOOL(enable_sql_operator_dump, OB_CLUSTER_PARAMETER, "True", "specifies whether sql operators "
"(sort/hash join/material/window function/interm result/...) allowed to write to disk", "(sort/hash join/material/window function/interm result/...) allowed to write to disk",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
DEF_CAP(_chunk_row_store_mem_limit, OB_CLUSTER_PARAMETER, "0B", "[0,]", DEF_CAP(_chunk_row_store_mem_limit, OB_CLUSTER_PARAMETER, "0M", "[0M,]",
"the maximum size of memory used by ChunkRowStore, 0 means follow operator's setting. Range: [0, +∞)", "the maximum size of memory used by ChunkRowStore, 0 means follow operator's setting. Range: [0, +∞)",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
DEF_STR_WITH_CHECKER(tableapi_transport_compress_func, OB_CLUSTER_PARAMETER, "none", DEF_STR_WITH_CHECKER(tableapi_transport_compress_func, OB_CLUSTER_PARAMETER, "none",
@ -505,7 +505,7 @@ DEF_TIME(recyclebin_object_expire_time, OB_CLUSTER_PARAMETER, "0s", "[0s,)",
// ========================= LogService Config Begin ===================== // ========================= LogService Config Begin =====================
DEF_CAP(log_disk_size, OB_CLUSTER_PARAMETER, "0", "[0M,)", DEF_CAP(log_disk_size, OB_CLUSTER_PARAMETER, "0M", "[0M,)",
"the size of disk space used by the log files. Range: [0, +∞)", "the size of disk space used by the log files. Range: [0, +∞)",
ObParameterAttr(Section::LOGSERVICE, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); ObParameterAttr(Section::LOGSERVICE, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));

View File

@ -433,7 +433,7 @@ TEST_F(TestIOStruct, IOCalibration)
ASSERT_FALSE(bench.is_inited_); ASSERT_FALSE(bench.is_inited_);
ObIOBenchResult item; ObIOBenchResult item;
ASSERT_SUCC(ObIOCalibration::parse_calibration_string("READ:4096:120:100000", item)); ASSERT_SUCC(ObIOCalibration::parse_calibration_string("READ:4096M:120:100000", item));
ASSERT_TRUE(item.is_valid()); ASSERT_TRUE(item.is_valid());
ASSERT_SUCC(ObIOCalibration::parse_calibration_string("read:4K:10ms:1000", item)); ASSERT_SUCC(ObIOCalibration::parse_calibration_string("read:4K:10ms:1000", item));
ASSERT_TRUE(item.is_valid()); ASSERT_TRUE(item.is_valid());