Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Metz
oceanbase
提交
518fd355
O
oceanbase
项目概览
Metz
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
518fd355
编写于
4月 06, 2022
作者:
L
ls0
提交者:
LINGuanRen
4月 06, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix alloc local session with same sid leads memory damage
上级
21163c4f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
15 addition
and
8 deletion
+15
-8
src/sql/engine/ob_des_exec_context.cpp
src/sql/engine/ob_des_exec_context.cpp
+6
-3
src/sql/session/ob_sql_session_mgr.cpp
src/sql/session/ob_sql_session_mgr.cpp
+6
-3
src/sql/session/ob_sql_session_mgr.h
src/sql/session/ob_sql_session_mgr.h
+3
-2
未找到文件。
src/sql/engine/ob_des_exec_context.cpp
浏览文件 @
518fd355
...
...
@@ -109,10 +109,13 @@ int ObDesExecContext::create_my_session(uint64_t tenant_id)
LOG_ERROR
(
"no more memory to create sql session info"
);
}
else
{
local_session
=
new
(
local_session
)
ObSQLSessionInfo
();
uint32_t
tmp_sid
=
123456789
;
uint32_t
tmp_sid
=
0
;
uint64_t
tmp_proxy_sessid
=
proxy_sid
;
uint32_t
tmp_version
=
0
;
uint64_t
tmp_proxy_sessid
=
1234567890
;
if
(
OB_FAIL
(
local_session
->
init
(
tmp_version
,
tmp_sid
,
tmp_proxy_sessid
,
NULL
)))
{
bool
session_in_mgr
=
false
;
if
(
OB_FAIL
(
GCTX
.
session_mgr_
->
create_sessid
(
tmp_sid
,
session_in_mgr
)))
{
LOG_WARN
(
"failed to mock session id"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
local_session
->
init
(
tmp_version
,
tmp_sid
,
tmp_proxy_sessid
,
NULL
)))
{
LOG_WARN
(
"my session init failed"
,
K
(
ret
));
local_session
->~
ObSQLSessionInfo
();
}
else
{
...
...
src/sql/session/ob_sql_session_mgr.cpp
浏览文件 @
518fd355
...
...
@@ -282,11 +282,11 @@ int ObSQLSessionMgr::inc_session_ref(const ObSQLSessionInfo* my_session)
// |Mask| Server Id | Local Seq |
// +----+------------------------------+--------------------------------+
//
// MASK: 1 means session_id is generated by observer, 0 means
by proxy
.
// MASK: 1 means session_id is generated by observer, 0 means
in_mgr = false
.
// Server Id: generated by root server, and unique in cluster.
// Local Seq: max session number in an observer.
//
int
ObSQLSessionMgr
::
create_sessid
(
uint32_t
&
sessid
)
int
ObSQLSessionMgr
::
create_sessid
(
uint32_t
&
sessid
,
bool
in_mgr
)
{
int
ret
=
OB_SUCCESS
;
int
tmp_ret
=
OB_SUCCESS
;
...
...
@@ -297,6 +297,9 @@ int ObSQLSessionMgr::create_sessid(uint32_t& sessid)
if
(
server_id
>
MAX_SERVER_ID
)
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_ERROR
(
"server id maybe invalid"
,
K
(
ret
),
K
(
server_id
));
}
else
if
(
!
in_mgr
)
{
sessid
=
(
GETTID
()
|
LOCAL_SESSID_TAG
);
sessid
|=
static_cast
<
uint32_t
>
(
server_id
<<
LOCAL_SEQ_LEN
);
// set observer
}
else
if
(
0
==
server_id
)
{
local_seq
=
(
ATOMIC_FAA
(
&
abnormal_seq
,
1
)
&
MAX_LOCAL_SEQ
);
uint32_t
max_local_seq
=
MAX_LOCAL_SEQ
;
...
...
@@ -307,7 +310,7 @@ int ObSQLSessionMgr::create_sessid(uint32_t& sessid)
}
else
{
/*do nothing*/
}
if
(
OB_SUCC
(
ret
))
{
if
(
OB_SUCC
(
ret
)
&&
in_mgr
)
{
sessid
=
local_seq
|
SERVER_SESSID_TAG
;
// set observer sessid mark
sessid
|=
static_cast
<
uint32_t
>
(
server_id
<<
LOCAL_SEQ_LEN
);
// set observer
// high bit is reserved for server id
...
...
src/sql/session/ob_sql_session_mgr.h
浏览文件 @
518fd355
...
...
@@ -47,6 +47,7 @@ public:
static
const
uint32_t
NON_DURABLE_VALUE
=
0
;
static
const
uint32_t
MAX_VERSION
=
UINT8_MAX
;
// 255
static
const
uint32_t
SERVER_SESSID_TAG
=
1ULL
<<
31
;
static
const
uint32_t
LOCAL_SESSID_TAG
=
0
;
// used for sessions overflow
typedef
SessionInfoKey
Key
;
explicit
ObSQLSessionMgr
(
storage
::
ObPartitionService
*
partition_service
)
:
// null_callback_(),
...
...
@@ -121,11 +122,11 @@ public:
}
static
int
is_need_clear_sessid
(
const
observer
::
ObSMConnection
*
conn
,
bool
&
is_need
);
int
fetch_first_sessid
();
int
create_sessid
(
uint32_t
&
sessid
);
// in_mgr = false means fail back to local session allocating, avoid remote/distribute executing fail
int
create_sessid
(
uint32_t
&
sessid
,
bool
in_mgr
=
true
);
int
mark_sessid_used
(
uint32_t
sess_id
);
int
mark_sessid_unused
(
uint32_t
sess_id
);
// inline ObNullEndTransCallback &get_null_callback() { return null_callback_; }
private:
int
create_session_by_version
(
uint64_t
tenant_id
,
uint32_t
sessid
,
uint64_t
proxy_sessid
,
ObSQLSessionInfo
*&
sess_info
,
uint32_t
&
out_version
);
int
get_avaiable_local_seq
(
uint32_t
&
local_seq
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录