fix config not init when init sys_vars
This commit is contained in:
@ -352,6 +352,8 @@ int ObInnerSQLConnection::init_session(sql::ObSQLSessionInfo* extern_session, co
|
||||
} else if (OB_FAIL(inner_session_.update_sys_variable(SYS_VAR_NLS_TIMESTAMP_TZ_FORMAT,
|
||||
ObTimeConverter::COMPAT_OLD_NLS_TIMESTAMP_TZ_FORMAT))) {
|
||||
LOG_WARN("update sys variables failed", K(ret));
|
||||
} else if (OB_FAIL(inner_session_.gen_configs_in_pc_str())) {
|
||||
LOG_WARN("fail to generate configuration strings that can influence execution plan", K(ret));
|
||||
} else {
|
||||
ObString database_name(OB_SYS_DATABASE_NAME);
|
||||
if (OB_FAIL(inner_session_.set_default_database(database_name))) {
|
||||
|
||||
@ -104,6 +104,7 @@ public:
|
||||
bool in_major_version_upgrade_mode() const { return in_upgrade_mode() && is_major_version_upgrade(); }
|
||||
bool enable_new_major() const { return true; }
|
||||
bool in_upgrade_mode() const;
|
||||
bool is_valid() const { return system_config_!= NULL; };
|
||||
int64_t get_current_version() { return system_config_->get_version(); }
|
||||
|
||||
// 兼容性需求,兼容老的SPFILE格式
|
||||
|
||||
@ -980,6 +980,8 @@ int ObBasicSessionInfo::init_system_variables(const bool print_info_log, const b
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(gen_sys_var_in_pc_str())) { //将影响plan的系统变量序列化并缓存
|
||||
LOG_INFO("fail to generate system variables in pc str");
|
||||
} else if (OB_FAIL(gen_configs_in_pc_str())) {
|
||||
LOG_INFO("fail to generate system config in pc str");
|
||||
} else {
|
||||
global_vars_version_ = 0;
|
||||
}
|
||||
@ -1637,37 +1639,42 @@ int ObBasicSessionInfo::gen_configs_in_pc_str()
|
||||
const int64_t MAX_CONFIG_STR_SIZE = 512;
|
||||
char *buf = NULL;
|
||||
int64_t pos = 0;
|
||||
int64_t cluster_config_version = GCONF.get_current_version();
|
||||
int64_t tenant_config_version = (::oceanbase::omt::ObTenantConfigMgr::get_instance()).get_tenant_config_version(tenant_id_);
|
||||
|
||||
if (!inf_pc_configs_.is_out_of_date(cluster_config_version, tenant_config_version)) {
|
||||
// unupdated configs do nothing
|
||||
if (!GCONF.is_valid()) {
|
||||
// do nothing
|
||||
} else {
|
||||
// update out-dated cached configs
|
||||
// first time to generate configuaration strings, init allocator
|
||||
if (is_first_gen_config_) {
|
||||
inf_pc_configs_.init(tenant_id_);
|
||||
if (NULL == (buf = (char *)name_pool_.alloc(MAX_CONFIG_STR_SIZE))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("fail to allocate memory", K(ret), K(MAX_CONFIG_STR_SIZE));
|
||||
}
|
||||
is_first_gen_config_ = false;
|
||||
} else {
|
||||
// reuse memory
|
||||
buf = config_in_pc_str_.ptr();
|
||||
MEMSET(buf, 0, config_in_pc_str_.length());
|
||||
config_in_pc_str_.reset();
|
||||
}
|
||||
int64_t cluster_config_version = GCONF.get_current_version();
|
||||
int64_t tenant_config_version = (::oceanbase::omt::ObTenantConfigMgr::get_instance()).get_tenant_config_version(tenant_id_);
|
||||
|
||||
// update configs
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(inf_pc_configs_.load_influence_plan_config())) {
|
||||
LOG_WARN("failed to load configurations that will influence executions plan.", K(ret));
|
||||
} else if (OB_FAIL(inf_pc_configs_.serialize_configs(buf, MAX_CONFIG_STR_SIZE, pos))) {
|
||||
LOG_WARN("failed to serialize configs", K(ret));
|
||||
if (!config_in_pc_str_.empty() &&
|
||||
!inf_pc_configs_.is_out_of_date(cluster_config_version, tenant_config_version)) {
|
||||
// unupdated configs do nothing
|
||||
} else {
|
||||
(void)config_in_pc_str_.assign(buf, int32_t(pos));
|
||||
inf_pc_configs_.update_version(cluster_config_version, tenant_config_version);
|
||||
// update out-dated cached configs
|
||||
// first time to generate configuaration strings, init allocator
|
||||
if (is_first_gen_config_) {
|
||||
inf_pc_configs_.init(tenant_id_);
|
||||
if (NULL == (buf = (char *)name_pool_.alloc(MAX_CONFIG_STR_SIZE))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("fail to allocate memory", K(ret), K(MAX_CONFIG_STR_SIZE));
|
||||
}
|
||||
is_first_gen_config_ = false;
|
||||
} else {
|
||||
// reuse memory
|
||||
buf = config_in_pc_str_.ptr();
|
||||
MEMSET(buf, 0, config_in_pc_str_.length());
|
||||
config_in_pc_str_.reset();
|
||||
}
|
||||
|
||||
// update configs
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(inf_pc_configs_.load_influence_plan_config())) {
|
||||
LOG_WARN("failed to load configurations that will influence executions plan.", K(ret));
|
||||
} else if (OB_FAIL(inf_pc_configs_.serialize_configs(buf, MAX_CONFIG_STR_SIZE, pos))) {
|
||||
LOG_WARN("failed to serialize configs", K(ret));
|
||||
} else {
|
||||
(void)config_in_pc_str_.assign(buf, int32_t(pos));
|
||||
inf_pc_configs_.update_version(cluster_config_version, tenant_config_version);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -4113,6 +4120,7 @@ int ObBasicSessionInfo::load_all_sys_vars(const ObSysVariableSchema &sys_var_sch
|
||||
release_to_pool_ = OB_SUCC(ret);
|
||||
if (!is_deserialized_) {
|
||||
OZ (gen_sys_var_in_pc_str());
|
||||
OZ (gen_configs_in_pc_str());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user