Fix: SYS_VARS_STR_SIZE alloc not enough
This commit is contained in:
@ -98,6 +98,7 @@ ObBasicSessionInfo::ObBasicSessionInfo()
|
|||||||
is_first_gen_config_(true),
|
is_first_gen_config_(true),
|
||||||
sys_var_fac_(),
|
sys_var_fac_(),
|
||||||
next_frag_mem_point_(OB_MALLOC_NORMAL_BLOCK_SIZE), // 8KB
|
next_frag_mem_point_(OB_MALLOC_NORMAL_BLOCK_SIZE), // 8KB
|
||||||
|
sys_vars_encode_max_size_(0),
|
||||||
consistency_level_(INVALID_CONSISTENCY),
|
consistency_level_(INVALID_CONSISTENCY),
|
||||||
tz_info_wrap_(),
|
tz_info_wrap_(),
|
||||||
next_tx_read_only_(-1),
|
next_tx_read_only_(-1),
|
||||||
@ -1453,19 +1454,45 @@ int ObBasicSessionInfo::gen_sys_var_in_pc_str()
|
|||||||
if (NULL == (buf = (char *)name_pool_.alloc(MAX_SYS_VARS_STR_SIZE))) {
|
if (NULL == (buf = (char *)name_pool_.alloc(MAX_SYS_VARS_STR_SIZE))) {
|
||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
LOG_WARN("fail to allocator memory", K(ret), K(MAX_SYS_VARS_STR_SIZE));
|
LOG_WARN("fail to allocator memory", K(ret), K(MAX_SYS_VARS_STR_SIZE));
|
||||||
|
} else {
|
||||||
|
set_sys_vars_encode_max_size(MAX_SYS_VARS_STR_SIZE);
|
||||||
|
is_first_gen_ = false;
|
||||||
}
|
}
|
||||||
is_first_gen_ = false;
|
|
||||||
} else {
|
} else {
|
||||||
buf = sys_var_in_pc_str_.ptr();
|
buf = sys_var_in_pc_str_.ptr();
|
||||||
MEMSET(buf, 0, sys_var_in_pc_str_.length());
|
MEMSET(buf, 0, sys_var_in_pc_str_.length());
|
||||||
sys_var_in_pc_str_.reset();
|
sys_var_in_pc_str_.reset();
|
||||||
}
|
}
|
||||||
|
int64_t sys_var_encode_max_size = get_sys_vars_encode_max_size();
|
||||||
if (OB_FAIL(ret)) {
|
if (OB_FAIL(ret)) {
|
||||||
} else if (OB_FAIL(get_influence_plan_sys_var(sys_vars))) {
|
} else if (OB_FAIL(get_influence_plan_sys_var(sys_vars))) {
|
||||||
LOG_WARN("fail to get influence plan system variables", K(ret));
|
LOG_WARN("fail to get influence plan system variables", K(ret));
|
||||||
} else if (OB_FAIL(sys_vars.serialize_sys_vars(buf, MAX_SYS_VARS_STR_SIZE, pos))) {
|
} else if (OB_FAIL(sys_vars.serialize_sys_vars(buf, sys_var_encode_max_size, pos))) {
|
||||||
LOG_WARN("fail to serialize system vars");
|
if (OB_BUF_NOT_ENOUGH == ret || OB_SIZE_OVERFLOW ==ret) {
|
||||||
|
ret = OB_SUCCESS;
|
||||||
|
// expand MAX_SYS_VARS_STR_SIZE 3 times.
|
||||||
|
for (int64_t i = 0; OB_SUCC(ret) && i < 3; ++i) {
|
||||||
|
sys_var_encode_max_size = 2 * sys_var_encode_max_size;
|
||||||
|
if (NULL == (buf = (char *)name_pool_.alloc(sys_var_encode_max_size))) {
|
||||||
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
|
LOG_WARN("fail to allocator memory", K(ret), K(sys_var_encode_max_size));
|
||||||
|
} else if (OB_FAIL(sys_vars.serialize_sys_vars(buf, sys_var_encode_max_size, pos))) {
|
||||||
|
if (i != 2 && (OB_BUF_NOT_ENOUGH == ret || OB_SIZE_OVERFLOW ==ret)) {
|
||||||
|
ret = OB_SUCCESS;
|
||||||
|
} else {
|
||||||
|
LOG_WARN("fail to serialize system vars", K(ret));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG_WARN("fail to serialize system vars", K(ret));
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
set_sys_vars_encode_max_size(sys_var_encode_max_size);
|
||||||
|
(void)sys_var_in_pc_str_.assign(buf, int32_t(pos));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
(void)sys_var_in_pc_str_.assign(buf, int32_t(pos));
|
(void)sys_var_in_pc_str_.assign(buf, int32_t(pos));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -426,6 +426,8 @@ public:
|
|||||||
void set_valid(const bool valid) {is_valid_ = valid;};
|
void set_valid(const bool valid) {is_valid_ = valid;};
|
||||||
int set_client_version(const common::ObString &client_version);
|
int set_client_version(const common::ObString &client_version);
|
||||||
int set_driver_version(const common::ObString &driver_version);
|
int set_driver_version(const common::ObString &driver_version);
|
||||||
|
int64_t get_sys_vars_encode_max_size() { return sys_vars_encode_max_size_; }
|
||||||
|
void set_sys_vars_encode_max_size(int64_t size) { sys_vars_encode_max_size_ = size; }
|
||||||
void set_sql_mode(const ObSQLMode sql_mode)
|
void set_sql_mode(const ObSQLMode sql_mode)
|
||||||
{
|
{
|
||||||
// Compatibility mode store in sql_mode_ but controlled by ob_compatibility_mode variable,
|
// Compatibility mode store in sql_mode_ but controlled by ob_compatibility_mode variable,
|
||||||
@ -1909,6 +1911,7 @@ private:
|
|||||||
share::ObSysVarFactory sys_var_fac_;
|
share::ObSysVarFactory sys_var_fac_;
|
||||||
char trace_id_buff_[64];//由于trace_id系统变量在出现slow query的情况下会进行更新,因此通过一个buffer来存储其内容,防止内存频繁分配
|
char trace_id_buff_[64];//由于trace_id系统变量在出现slow query的情况下会进行更新,因此通过一个buffer来存储其内容,防止内存频繁分配
|
||||||
int64_t next_frag_mem_point_; // 用于控制 sys var 内存占用的碎片整理(反复设置同一个 varchar 值会产生内存碎片)
|
int64_t next_frag_mem_point_; // 用于控制 sys var 内存占用的碎片整理(反复设置同一个 varchar 值会产生内存碎片)
|
||||||
|
int64_t sys_vars_encode_max_size_;
|
||||||
|
|
||||||
//==============系统变量相关的变量,需要序列化到远端==============
|
//==============系统变量相关的变量,需要序列化到远端==============
|
||||||
common::ObConsistencyLevel consistency_level_;
|
common::ObConsistencyLevel consistency_level_;
|
||||||
|
|||||||
Reference in New Issue
Block a user