Fix: session sync error in upgrade scene

This commit is contained in:
yaojing624
2023-08-10 09:48:25 +00:00
committed by ob-robot
parent b66dd1ebf2
commit 33b1f93501
3 changed files with 70 additions and 11 deletions

View File

@ -2826,67 +2826,101 @@ int ObPreProcessSysVars::change_initial_value()
LOG_WARN("fail to change initial value", K(OB_SV_VERSION_COMMENT), LOG_WARN("fail to change initial value", K(OB_SV_VERSION_COMMENT),
K(ObSpecialSysVarValues::version_comment_)); K(ObSpecialSysVarValues::version_comment_));
} else if (OB_FAIL(ObSysVariables::set_base_value(OB_SV_VERSION_COMMENT,
ObSpecialSysVarValues::version_comment_))) {
LOG_WARN("fail to change initial value", K(OB_SV_VERSION_COMMENT),
K(ObSpecialSysVarValues::version_comment_));
// OB_SV_SYSTEM_TIME_ZONE // OB_SV_SYSTEM_TIME_ZONE
} else if (OB_FAIL(ObSysVariables::set_value(OB_SV_SYSTEM_TIME_ZONE, } else if (OB_FAIL(ObSysVariables::set_value(OB_SV_SYSTEM_TIME_ZONE,
ObSpecialSysVarValues::system_time_zone_str_))) { ObSpecialSysVarValues::system_time_zone_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_SYSTEM_TIME_ZONE), LOG_WARN("fail to change initial value", K(OB_SV_SYSTEM_TIME_ZONE),
K(ObSpecialSysVarValues::system_time_zone_str_)); K(ObSpecialSysVarValues::system_time_zone_str_));
} else if (OB_FAIL(ObSysVariables::set_base_value(OB_SV_SYSTEM_TIME_ZONE,
ObSpecialSysVarValues::system_time_zone_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_SYSTEM_TIME_ZONE),
K(ObSpecialSysVarValues::system_time_zone_str_));
// charset和collation相关 // charset和collation相关
// OB_SV_CHARACTER_SET_SERVER // OB_SV_CHARACTER_SET_SERVER
} else if (OB_FAIL(ObSysVariables::set_value(OB_SV_CHARACTER_SET_SERVER, } else if (OB_FAIL(ObSysVariables::set_value(OB_SV_CHARACTER_SET_SERVER,
ObSpecialSysVarValues::default_coll_int_str_))) { ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(ret), K(OB_SV_CHARACTER_SET_SERVER), LOG_WARN("fail to change initial value", K(ret), K(OB_SV_CHARACTER_SET_SERVER),
K(ObSpecialSysVarValues::default_coll_int_str_)); K(ObSpecialSysVarValues::default_coll_int_str_));
} else if (OB_FAIL(ObSysVariables::set_base_value(OB_SV_CHARACTER_SET_SERVER,
ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(ret), K(OB_SV_CHARACTER_SET_SERVER),
K(ObSpecialSysVarValues::default_coll_int_str_));
// OB_SV_CHARACTER_SET_CONNECTION // OB_SV_CHARACTER_SET_CONNECTION
} else if (OB_FAIL(ObSysVariables::set_value(OB_SV_CHARACTER_SET_CONNECTION, } else if (OB_FAIL(ObSysVariables::set_value(OB_SV_CHARACTER_SET_CONNECTION,
ObSpecialSysVarValues::default_coll_int_str_))) { ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_CHARACTER_SET_CONNECTION), LOG_WARN("fail to change initial value", K(OB_SV_CHARACTER_SET_CONNECTION),
K(ObSpecialSysVarValues::default_coll_int_str_)); K(ObSpecialSysVarValues::default_coll_int_str_));
} else if (OB_FAIL(ObSysVariables::set_base_value(OB_SV_CHARACTER_SET_CONNECTION,
ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_CHARACTER_SET_CONNECTION),
K(ObSpecialSysVarValues::default_coll_int_str_));
// OB_SV_CHARACTER_SET_CLIENT // OB_SV_CHARACTER_SET_CLIENT
} else if (OB_FAIL(ObSysVariables::set_value(OB_SV_CHARACTER_SET_CLIENT, } else if (OB_FAIL(ObSysVariables::set_value(OB_SV_CHARACTER_SET_CLIENT,
ObSpecialSysVarValues::default_coll_int_str_))) { ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_CHARACTER_SET_CLIENT), LOG_WARN("fail to change initial value", K(OB_SV_CHARACTER_SET_CLIENT),
K(ObSpecialSysVarValues::default_coll_int_str_)); K(ObSpecialSysVarValues::default_coll_int_str_));
} else if (OB_FAIL(ObSysVariables::set_base_value(OB_SV_CHARACTER_SET_CLIENT,
ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_CHARACTER_SET_CLIENT),
K(ObSpecialSysVarValues::default_coll_int_str_));
// OB_SV_CHARACTER_SET_RESULTS // OB_SV_CHARACTER_SET_RESULTS
} else if (OB_FAIL(ObSysVariables::set_value(OB_SV_CHARACTER_SET_RESULTS, } else if (OB_FAIL(ObSysVariables::set_value(OB_SV_CHARACTER_SET_RESULTS,
ObSpecialSysVarValues::default_coll_int_str_))) { ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_CHARACTER_SET_RESULTS), LOG_WARN("fail to change initial value", K(OB_SV_CHARACTER_SET_RESULTS),
K(ObSpecialSysVarValues::default_coll_int_str_)); K(ObSpecialSysVarValues::default_coll_int_str_));
} else if (OB_FAIL(ObSysVariables::set_base_value(OB_SV_CHARACTER_SET_RESULTS,
ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_CHARACTER_SET_RESULTS),
K(ObSpecialSysVarValues::default_coll_int_str_));
// OB_SV_CHARACTER_SET_SYSTEM // OB_SV_CHARACTER_SET_SYSTEM
} else if (OB_FAIL(ObSysVariables::set_value(OB_SV_CHARACTER_SET_SYSTEM, } else if (OB_FAIL(ObSysVariables::set_value(OB_SV_CHARACTER_SET_SYSTEM,
ObSpecialSysVarValues::default_coll_int_str_))) { ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_CHARACTER_SET_SYSTEM), LOG_WARN("fail to change initial value", K(OB_SV_CHARACTER_SET_SYSTEM),
K(ObSpecialSysVarValues::default_coll_int_str_)); K(ObSpecialSysVarValues::default_coll_int_str_));
} else if (OB_FAIL(ObSysVariables::set_base_value(OB_SV_CHARACTER_SET_SYSTEM,
ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_CHARACTER_SET_SYSTEM),
K(ObSpecialSysVarValues::default_coll_int_str_));
// OB_SV_COLLATION_SERVER // OB_SV_COLLATION_SERVER
} else if (OB_FAIL(ObSysVariables::set_value(OB_SV_COLLATION_SERVER, } else if (OB_FAIL(ObSysVariables::set_value(OB_SV_COLLATION_SERVER,
ObSpecialSysVarValues::default_coll_int_str_))) { ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_COLLATION_SERVER), LOG_WARN("fail to change initial value", K(OB_SV_COLLATION_SERVER),
K(ObSpecialSysVarValues::default_coll_int_str_)); K(ObSpecialSysVarValues::default_coll_int_str_));
} else if (OB_FAIL(ObSysVariables::set_base_value(OB_SV_COLLATION_SERVER,
ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_COLLATION_SERVER),
K(ObSpecialSysVarValues::default_coll_int_str_));
// OB_SV_COLLATION_DATABASE // OB_SV_COLLATION_DATABASE
} else if (OB_FAIL(ObSysVariables::set_value(OB_SV_COLLATION_DATABASE, } else if (OB_FAIL(ObSysVariables::set_value(OB_SV_COLLATION_DATABASE,
ObSpecialSysVarValues::default_coll_int_str_))) { ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_COLLATION_DATABASE), LOG_WARN("fail to change initial value", K(OB_SV_COLLATION_DATABASE),
K(ObSpecialSysVarValues::default_coll_int_str_)); K(ObSpecialSysVarValues::default_coll_int_str_));
} else if (OB_FAIL(ObSysVariables::set_base_value(OB_SV_COLLATION_DATABASE,
ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_COLLATION_DATABASE),
K(ObSpecialSysVarValues::default_coll_int_str_));
// OB_SV_COLLATION_CONNECTION // OB_SV_COLLATION_CONNECTION
} else if (OB_FAIL(ObSysVariables::set_value(OB_SV_COLLATION_CONNECTION, } else if (OB_FAIL(ObSysVariables::set_value(OB_SV_COLLATION_CONNECTION,
ObSpecialSysVarValues::default_coll_int_str_))) { ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_COLLATION_CONNECTION), LOG_WARN("fail to change initial value", K(OB_SV_COLLATION_CONNECTION),
K(ObSpecialSysVarValues::default_coll_int_str_)); K(ObSpecialSysVarValues::default_coll_int_str_));
} else if (OB_FAIL(ObSysVariables::set_base_value(OB_SV_COLLATION_CONNECTION,
ObSpecialSysVarValues::default_coll_int_str_))) {
LOG_WARN("fail to change initial value", K(OB_SV_COLLATION_CONNECTION),
K(ObSpecialSysVarValues::default_coll_int_str_));
// OB_SV_SERVER_UUID // OB_SV_SERVER_UUID
} else if (OB_FAIL(ObSysVariables::set_value(OB_SV_SERVER_UUID, } else if (OB_FAIL(ObSysVariables::set_value(OB_SV_SERVER_UUID,
ObSpecialSysVarValues::server_uuid_))) { ObSpecialSysVarValues::server_uuid_))) {
LOG_WARN("fail to change initial value", K(OB_SV_SERVER_UUID), LOG_WARN("fail to change initial value", K(OB_SV_SERVER_UUID),
K(ObSpecialSysVarValues::server_uuid_)); K(ObSpecialSysVarValues::server_uuid_));
} else if (OB_FAIL(ObSysVariables::set_base_value(OB_SV_SERVER_UUID,
ObSpecialSysVarValues::server_uuid_))) {
LOG_WARN("fail to change initial value", K(OB_SV_SERVER_UUID),
K(ObSpecialSysVarValues::server_uuid_));
} else { } else {
LOG_INFO("succ to change_initial_value", LOG_INFO("succ to change_initial_value",
"version_comment", ObSpecialSysVarValues::version_comment_, "version_comment", ObSpecialSysVarValues::version_comment_,
@ -2896,7 +2930,6 @@ int ObPreProcessSysVars::change_initial_value()
} }
return ret; return ret;
} }
int ObPreProcessSysVars::init_sys_var() int ObPreProcessSysVars::init_sys_var()
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;

View File

@ -3342,6 +3342,30 @@ int ObSysVariables::set_value(const common::ObString &name, const common::ObStri
return ret; return ret;
} }
int ObSysVariables::set_base_value(const char *name, const char * new_value)
{
ObString tmp_name(static_cast<int32_t>(strlen(name)), name);
ObString tmp_value(static_cast<int32_t>(strlen(new_value)), new_value);
return set_base_value(tmp_name, tmp_value);
}
int ObSysVariables::set_base_value(const common::ObString &name, const common::ObString &new_value)
{
int ret = OB_SUCCESS;
bool name_exist = false;
for (int64_t i = 0; OB_SUCC(ret) && false == name_exist && i < var_amount; ++i){
if (0 == ObSysVars[i].name_.compare(name)) {
ObSysVars[i].base_value_.assign_ptr(new_value.ptr(), new_value.length());
name_exist = true;
}
}
if (OB_SUCC(ret)) {
if (false == name_exist) {
ret = OB_ENTRY_NOT_EXIST;
}
}
return ret;
}
int ObSysVariables::init_default_values() int ObSysVariables::init_default_values()
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;

View File

@ -82,6 +82,8 @@ public:
static int64_t get_amount(); static int64_t get_amount();
static int set_value(const char *name, const char * new_value); static int set_value(const char *name, const char * new_value);
static int set_value(const common::ObString &name, const common::ObString &new_value); static int set_value(const common::ObString &name, const common::ObString &new_value);
static int set_base_value(const char *name, const char * new_value);
static int set_base_value(const common::ObString &name, const common::ObString &new_value);
static int init_default_values(); static int init_default_values();
}; };