[CP] [UPGRADE] Fix data_version retrogressive problem

This commit is contained in:
tino247 2024-02-07 18:22:34 +00:00 committed by ob-robot
parent 67f5c63f4a
commit 8d751062f6
8 changed files with 76 additions and 14 deletions

View File

@ -91,7 +91,7 @@ int ObTenantConfig::read_config()
OB_LOG(ERROR, "config item is null", "name", it->first.str(), K(ret));
} else {
key.set_version(it->second->version());
int temp_ret = system_config_.read_config(key, *(it->second));
int temp_ret = system_config_.read_config(get_tenant_id(), key, *(it->second));
if (OB_SUCCESS != temp_ret) {
OB_LOG(DEBUG, "Read config error", "name", it->first.str(), K(temp_ret));
}
@ -326,7 +326,14 @@ int ObTenantConfig::publish_special_config_after_dump()
ret = OB_INVALID_CONFIG;
LOG_WARN("Invalid config value", K(tenant_id_), K((*pp_item)->spfile_str()), K(ret));
} else {
LOG_INFO("publish special config after dump succ", K(tenant_id_), K((*pp_item)->spfile_str()), K((*pp_item)->str()));
FLOG_INFO("[COMPATIBLE] read data_version after dump",
KR(ret), K_(tenant_id),
"version", (*pp_item)->version(),
"value", (*pp_item)->str(),
"value_updated", (*pp_item)->value_updated(),
"dump_version", (*pp_item)->dumped_version(),
"dump_value", (*pp_item)->spfile_str(),
"dump_value_updated", (*pp_item)->dump_value_updated());
}
return ret;
}
@ -404,7 +411,14 @@ int ObTenantConfig::add_extra_config(const char *config_str,
} else {
(*pp_item)->set_dump_value_updated();
(*pp_item)->set_version(version);
LOG_INFO("Load tenant config dump value succ", K(name), K((*pp_item)->spfile_str()), K((*pp_item)->str()));
FLOG_INFO("[COMPATIBLE] init data_version before dump",
KR(ret), K_(tenant_id),
"version", (*pp_item)->version(),
"value", (*pp_item)->str(),
"value_updated", (*pp_item)->value_updated(),
"dump_version", (*pp_item)->dumped_version(),
"dump_value", (*pp_item)->spfile_str(),
"dump_value_updated", (*pp_item)->dump_value_updated());
}
} else if (!(*pp_item)->set_value(value)) {
ret = OB_INVALID_CONFIG;

View File

@ -82,7 +82,7 @@ public:
int read_config();
int publish_special_config_after_dump();
uint64_t get_tenant_id() const { return tenant_id_; }
virtual uint64_t get_tenant_id() const override { return tenant_id_; }
int64_t get_current_version() const { return current_version_; }
const TenantConfigUpdateTask &get_update_task() const { return update_task_; }
int64_t get_create_timestamp() const { return create_timestamp_; }

View File

@ -316,6 +316,7 @@ int ObCommonConfig::add_extra_config(const char *config_str,
}
const ObString external_kms_info_cfg(EXTERNAL_KMS_INFO);
const ObString ssl_external_kms_info_cfg(SSL_EXTERNAL_KMS_INFO);
const ObString compatible_cfg(COMPATIBLE);
auto func = [&]() {
char *saveptr_one = NULL;
const char *name = NULL;
@ -367,6 +368,16 @@ int ObCommonConfig::add_extra_config(const char *config_str,
} else {
(*pp_item)->set_version(version);
LOG_INFO("Load config succ", K(name), K(value));
if (0 == compatible_cfg.case_compare(name)) {
FLOG_INFO("[COMPATIBLE] load data_version from config file",
KR(ret), "tenant_id", get_tenant_id(),
"version", (*pp_item)->version(),
"value", (*pp_item)->str(),
"value_updated", (*pp_item)->value_updated(),
"dump_version", (*pp_item)->dumped_version(),
"dump_value", (*pp_item)->spfile_str(),
"dump_value_updated", (*pp_item)->dump_value_updated());
}
}
}
};
@ -410,12 +421,14 @@ OB_DEF_SERIALIZE(ObCommonConfig)
ObConfigContainer::const_iterator it = container_.begin();
const ObString external_kms_info_cfg(EXTERNAL_KMS_INFO);
const ObString ssl_external_kms_info_cfg(SSL_EXTERNAL_KMS_INFO);
const ObString compatible_cfg(COMPATIBLE);
HEAP_VAR(char[OB_MAX_CONFIG_VALUE_LEN], external_info_val) {
external_info_val[0] = '\0';
for (; OB_SUCC(ret) && it != container_.end(); ++it) {
if (OB_ISNULL(it->second)) {
ret = OB_ERR_UNEXPECTED;
} else if (it->second->value_updated()) {
} else if (it->second->value_updated()
|| it->second->dump_value_updated()) {
if (external_kms_info_cfg.case_compare(it->first.str()) == 0
|| ssl_external_kms_info_cfg.case_compare(it->first.str()) == 0) {
int64_t hex_pos = 0, hex_c_str_pos = 0;
@ -431,6 +444,16 @@ OB_DEF_SERIALIZE(ObCommonConfig)
ret = databuff_printf(buf, buf_len, pos, "%s=%s\n",
it->first.str(), it->second->spfile_str());
}
if (OB_SUCC(ret) && 0 == compatible_cfg.case_compare(it->first.str())) {
FLOG_INFO("[COMPATIBLE] dump data_version",
KR(ret), "tenant_id", get_tenant_id(),
"version", it->second->version(),
"value", it->second->str(),
"value_updated", it->second->value_updated(),
"dump_version", it->second->dumped_version(),
"dump_value", it->second->spfile_str(),
"dump_value_updated", it->second->dump_value_updated());
}
}
} // for
}
@ -484,7 +507,9 @@ OB_DEF_SERIALIZE_SIZE(ObCommonConfig)
for (; OB_SUCC(ret) && it != container_.end(); ++it) {
MEMSET(kv_str, '\0', OB_MAX_CONFIG_NAME_LEN + OB_MAX_CONFIG_VALUE_LEN + 1);
int64_t pos = 0;
if (OB_NOT_NULL(it->second) && it->second->value_updated()) {
if (OB_NOT_NULL(it->second)
&& (it->second->value_updated()
|| it->second->dump_value_updated())) {
if (OB_FAIL(databuff_printf(kv_str, OB_MAX_CONFIG_NAME_LEN + OB_MAX_CONFIG_VALUE_LEN,
pos, "%s=%s\n", it->first.str(), it->second->spfile_str()))) {
LOG_WARN("write data buff failed", K(ret));

View File

@ -98,6 +98,7 @@ public:
const int64_t version = 0,
const bool check_config = true);
virtual bool is_debug_sync_enabled() const { return false; }
virtual uint64_t get_tenant_id() const { return common::OB_INVALID_TENANT_ID; }
OB_UNIS_VERSION_V(1);

View File

@ -109,7 +109,7 @@ int ObServerConfig::read_config()
OB_LOG(ERROR, "config item is null", "name", it->first.str(), K(ret));
} else {
key.set_version(it->second->version());
temp_ret = system_config_->read_config(key, *(it->second));
temp_ret = system_config_->read_config(get_tenant_id(), key, *(it->second));
if (OB_SUCCESS != temp_ret) {
OB_LOG(DEBUG, "Read config error", "name", it->first.str(), K(temp_ret));
}

View File

@ -13,6 +13,7 @@
#include "share/config/ob_system_config.h"
#include "share/config/ob_config.h"
#include "share/config/ob_server_config.h"
#include "share/ob_task_define.h"
namespace oceanbase
{
@ -315,8 +316,11 @@ int ObSystemConfig::read_str(const ObSystemConfigKey &key,
return ret;
}
int ObSystemConfig::read_config(const ObSystemConfigKey &key,
ObConfigItem &item) const
// tenant_id is OB_INVALID_TENANT_ID(0) means it's cluster parameter
int ObSystemConfig::read_config(
const uint64_t tenant_id,
const ObSystemConfigKey &key,
ObConfigItem &item) const
{
int ret = OB_SUCCESS;
const ObSystemConfigValue *pvalue = NULL;
@ -350,11 +354,17 @@ int ObSystemConfig::read_config(const ObSystemConfigKey &key,
SHARE_LOG(WARN, "set config item dump value failed",
K(ret), K(key.name()), K(pvalue->value()), K(version));
} else {
item.set_value_updated();
item.set_dump_value_updated();
item.set_version(version);
SHARE_LOG(INFO, "set config item dump value success",
K(ret), K(key.name()), K(item.spfile_str()), K(item.str()), K(version));
share::ObTaskController::get().allow_next_syslog();
SHARE_LOG(INFO, "[COMPATIBLE] read data_version",
KR(ret), K(tenant_id),
"version", item.version(),
"value", item.str(),
"value_updated", item.value_updated(),
"dump_version", item.dumped_version(),
"dump_value", item.spfile_str(),
"dump_value_updated", item.dump_value_updated());
}
} else if (item.reboot_effective()) {
// 以 STATIC_EFFECTIVE 的 stack_size 举例说明:

View File

@ -47,7 +47,7 @@ public:
int read_int64(const ObSystemConfigKey &key, int64_t &value, const int64_t &def) const;
int read_int(const ObSystemConfigKey &key, int64_t &value, const int64_t &def) const;
int read_str(const ObSystemConfigKey &key, char buf[], int64_t len, const char *def) const;
int read_config(const ObSystemConfigKey &key, ObConfigItem &item) const;
int read_config(const uint64_t tenant_id, const ObSystemConfigKey &key, ObConfigItem &item) const;
int64_t to_string(char *buf, const int64_t len) const;
int reload(FILE *fp);
int dump2file(const char *path) const;

View File

@ -293,7 +293,19 @@ int ObClusterVersion::get_tenant_data_version(
} else {
// For user tenant
ret = OB_ENTRY_NOT_EXIST;
COMMON_LOG(WARN, "tenant compatible version is not refreshed", KR(ret), K(tenant_id));
if (tenant_config.is_valid()) {
COMMON_LOG(WARN, "[COMPATIBLE] data_version is not refreshed",
KR(ret), K(tenant_id),
"version", tenant_config->compatible.version(),
"value", tenant_config->compatible.str(),
"value_updated", tenant_config->compatible.value_updated(),
"dump_version", tenant_config->compatible.dumped_version(),
"dump_value", tenant_config->compatible.spfile_str(),
"dump_value_updated", tenant_config->compatible.dump_value_updated());
} else {
COMMON_LOG(WARN, "[COMPATIBLE] data_version is not refreshed",
KR(ret), K(tenant_id), "valid", tenant_config.is_valid());
}
}
}
return ret;