Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大炮V587
oceanbase
提交
a22145fe
O
oceanbase
项目概览
大炮V587
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a22145fe
编写于
3月 15, 2023
作者:
O
obdev
提交者:
ob-robot
3月 15, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: core at calling get_tid()
上级
ed4e8ef8
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
36 addition
and
85 deletion
+36
-85
deps/oblib/src/lib/thread/thread.cpp
deps/oblib/src/lib/thread/thread.cpp
+3
-9
deps/oblib/src/lib/thread/thread.h
deps/oblib/src/lib/thread/thread.h
+0
-15
deps/oblib/src/lib/thread/threads.h
deps/oblib/src/lib/thread/threads.h
+0
-5
src/observer/ob_srv_deliver.h
src/observer/ob_srv_deliver.h
+1
-2
src/observer/omt/ob_multi_tenant.cpp
src/observer/omt/ob_multi_tenant.cpp
+1
-2
src/observer/omt/ob_tenant.cpp
src/observer/omt/ob_tenant.cpp
+6
-7
src/observer/omt/ob_th_worker.cpp
src/observer/omt/ob_th_worker.cpp
+1
-1
src/rootserver/ob_rs_reentrant_thread.cpp
src/rootserver/ob_rs_reentrant_thread.cpp
+1
-1
src/share/rc/ob_tenant_base.cpp
src/share/rc/ob_tenant_base.cpp
+2
-2
src/share/resource_manager/ob_cgroup_ctrl.cpp
src/share/resource_manager/ob_cgroup_ctrl.cpp
+8
-9
src/share/resource_manager/ob_cgroup_ctrl.h
src/share/resource_manager/ob_cgroup_ctrl.h
+3
-4
src/share/scheduler/ob_dag_scheduler.cpp
src/share/scheduler/ob_dag_scheduler.cpp
+1
-1
unittest/observer/omt/test_cgroup_ctrl.cpp
unittest/observer/omt/test_cgroup_ctrl.cpp
+9
-27
未找到文件。
deps/oblib/src/lib/thread/thread.cpp
浏览文件 @
a22145fe
...
@@ -50,8 +50,6 @@ Thread::Thread(int64_t stack_size)
...
@@ -50,8 +50,6 @@ Thread::Thread(int64_t stack_size)
Thread
::
Thread
(
Runnable
runnable
,
int64_t
stack_size
)
Thread
::
Thread
(
Runnable
runnable
,
int64_t
stack_size
)
:
pth_
(
0
),
:
pth_
(
0
),
pid_
(
0
),
tid_
(
0
),
runnable_
(
runnable
),
runnable_
(
runnable
),
#ifndef OB_USE_ASAN
#ifndef OB_USE_ASAN
stack_addr_
(
nullptr
),
stack_addr_
(
nullptr
),
...
@@ -152,8 +150,8 @@ void Thread::dump_pth() // for debug pthread join faileds
...
@@ -152,8 +150,8 @@ void Thread::dump_pth() // for debug pthread join faileds
ssize_t
size
=
0
;
ssize_t
size
=
0
;
char
path
[
PATH_SIZE
];
char
path
[
PATH_SIZE
];
len
=
(
char
*
)
stack_addr_
+
stack_size_
-
(
char
*
)
pth_
;
len
=
(
char
*
)
stack_addr_
+
stack_size_
-
(
char
*
)
pth_
;
snprintf
(
path
,
PATH_SIZE
,
"log/dump_pth.%p.%d"
,
(
char
*
)
pth_
,
(
int
)
tid_
);
snprintf
(
path
,
PATH_SIZE
,
"log/dump_pth.%p.%d"
,
(
char
*
)
pth_
,
static_cast
<
pid_t
>
(
syscall
(
__NR_gettid
))
);
LOG_WARN
(
"dump pth start"
,
K
(
path
),
K
(
pth_
),
K
(
tid_
),
K
(
len
),
K
(
stack_addr_
),
K
(
stack_size_
));
LOG_WARN
(
"dump pth start"
,
K
(
path
),
K
(
pth_
),
K
(
len
),
K
(
stack_addr_
),
K
(
stack_size_
));
if
(
NULL
==
(
char
*
)
pth_
||
len
>=
stack_size_
||
len
<=
0
)
{
if
(
NULL
==
(
char
*
)
pth_
||
len
>=
stack_size_
||
len
<=
0
)
{
LOG_WARN
(
"invalid member"
,
K
(
pth_
),
K
(
stack_addr_
),
K
(
stack_size_
));
LOG_WARN
(
"invalid member"
,
K
(
pth_
),
K
(
stack_addr_
),
K
(
stack_size_
));
}
else
if
((
fd
=
::
open
(
path
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
}
else
if
((
fd
=
::
open
(
path
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
...
@@ -176,7 +174,7 @@ void Thread::dump_pth() // for debug pthread join faileds
...
@@ -176,7 +174,7 @@ void Thread::dump_pth() // for debug pthread join faileds
ret
=
OB_IO_ERROR
;
ret
=
OB_IO_ERROR
;
LOG_WARN
(
"fail to close file fd"
,
K
(
fd
),
KERRMSG
,
K
(
ret
));
LOG_WARN
(
"fail to close file fd"
,
K
(
fd
),
KERRMSG
,
K
(
ret
));
}
else
{
}
else
{
LOG_WARN
(
"dump pth done"
,
K
(
path
),
K
(
pth_
),
K
(
tid_
),
K
(
size
));
LOG_WARN
(
"dump pth done"
,
K
(
path
),
K
(
pth_
),
K
(
size
));
}
}
#endif
#endif
}
}
...
@@ -197,8 +195,6 @@ void Thread::wait()
...
@@ -197,8 +195,6 @@ void Thread::wait()
}
}
destroy_stack
();
destroy_stack
();
pth_
=
0
;
pth_
=
0
;
pid_
=
0
;
tid_
=
0
;
runnable_
=
nullptr
;
runnable_
=
nullptr
;
if
(
1
<=
ATOMIC_AAF
(
&
join_concurrency_
,
-
1
))
{
if
(
1
<=
ATOMIC_AAF
(
&
join_concurrency_
,
-
1
))
{
abort
();
abort
();
...
@@ -284,8 +280,6 @@ void* Thread::__th_start(void *arg)
...
@@ -284,8 +280,6 @@ void* Thread::__th_start(void *arg)
.
set_label
(
"ThreadRoot"
))))
{
.
set_label
(
"ThreadRoot"
))))
{
LOG_ERROR
(
"create memory context failed"
,
K
(
ret
));
LOG_ERROR
(
"create memory context failed"
,
K
(
ret
));
}
else
{
}
else
{
th
->
pid_
=
getpid
();
th
->
tid_
=
static_cast
<
pid_t
>
(
syscall
(
__NR_gettid
));
WITH_CONTEXT
(
*
mem_context
)
{
WITH_CONTEXT
(
*
mem_context
)
{
try
{
try
{
in_try_stmt
=
true
;
in_try_stmt
=
true
;
...
...
deps/oblib/src/lib/thread/thread.h
浏览文件 @
a22145fe
...
@@ -38,9 +38,6 @@ public:
...
@@ -38,9 +38,6 @@ public:
void
destroy
();
void
destroy
();
void
dump_pth
();
void
dump_pth
();
pid_t
get_pid
()
const
;
pid_t
get_tid
()
const
;
/// \brief Get current thread object.
/// \brief Get current thread object.
///
///
/// \warning It would encounter segment fault if current thread
/// \warning It would encounter segment fault if current thread
...
@@ -72,8 +69,6 @@ private:
...
@@ -72,8 +69,6 @@ private:
static
int64_t
total_thread_count_
;
static
int64_t
total_thread_count_
;
private:
private:
pthread_t
pth_
;
pthread_t
pth_
;
pid_t
pid_
;
pid_t
tid_
;
Runnable
runnable_
;
Runnable
runnable_
;
#ifndef OB_USE_ASAN
#ifndef OB_USE_ASAN
void
*
stack_addr_
;
void
*
stack_addr_
;
...
@@ -85,16 +80,6 @@ private:
...
@@ -85,16 +80,6 @@ private:
pid_t
tid_before_stop_
;
pid_t
tid_before_stop_
;
};
};
OB_INLINE
pid_t
Thread
::
get_pid
()
const
{
return
pid_
;
}
OB_INLINE
pid_t
Thread
::
get_tid
()
const
{
return
tid_
;
}
OB_INLINE
bool
Thread
::
has_set_stop
()
const
OB_INLINE
bool
Thread
::
has_set_stop
()
const
{
{
IGNORE_RETURN
update_loop_ts
();
IGNORE_RETURN
update_loop_ts
();
...
...
deps/oblib/src/lib/thread/threads.h
浏览文件 @
a22145fe
...
@@ -96,11 +96,6 @@ public:
...
@@ -96,11 +96,6 @@ public:
virtual
void
wait
();
virtual
void
wait
();
void
destroy
();
void
destroy
();
pid_t
get_tid
()
const
{
OB_ASSERT
(
n_threads_
>
0
);
return
threads_
[
0
]
->
get_tid
();
}
public:
public:
template
<
class
Functor
>
template
<
class
Functor
>
int
submit
(
const
Functor
&
func
)
int
submit
(
const
Functor
&
func
)
...
...
src/observer/ob_srv_deliver.h
浏览文件 @
a22145fe
...
@@ -73,8 +73,7 @@ public:
...
@@ -73,8 +73,7 @@ public:
if
(
GCONF
.
_enable_new_sql_nio
&&
GCONF
.
_enable_tenant_sql_net_thread
&&
if
(
GCONF
.
_enable_new_sql_nio
&&
GCONF
.
_enable_tenant_sql_net_thread
&&
tenant_id_
!=
common
::
OB_INVALID_ID
&&
nullptr
!=
GCTX
.
cgroup_ctrl_
&&
tenant_id_
!=
common
::
OB_INVALID_ID
&&
nullptr
!=
GCTX
.
cgroup_ctrl_
&&
OB_LIKELY
(
GCTX
.
cgroup_ctrl_
->
is_valid
()))
{
OB_LIKELY
(
GCTX
.
cgroup_ctrl_
->
is_valid
()))
{
GCTX
.
cgroup_ctrl_
->
add_thread_to_cgroup
(
GCTX
.
cgroup_ctrl_
->
add_self_to_cgroup
(
tenant_id_
,
static_cast
<
pid_t
>
(
syscall
(
__NR_gettid
)),
tenant_id_
,
share
::
OBCG_MYSQL_LOGIN
);
share
::
OBCG_MYSQL_LOGIN
);
}
}
queue_
.
loop
();
queue_
.
loop
();
...
...
src/observer/omt/ob_multi_tenant.cpp
浏览文件 @
a22145fe
...
@@ -2142,8 +2142,7 @@ int obmysql::sql_nio_add_cgroup(const uint64_t tenant_id)
...
@@ -2142,8 +2142,7 @@ int obmysql::sql_nio_add_cgroup(const uint64_t tenant_id)
if
(
GCONF
.
_enable_new_sql_nio
&&
GCONF
.
_enable_tenant_sql_net_thread
&&
if
(
GCONF
.
_enable_new_sql_nio
&&
GCONF
.
_enable_tenant_sql_net_thread
&&
nullptr
!=
GCTX
.
cgroup_ctrl_
&&
nullptr
!=
GCTX
.
cgroup_ctrl_
&&
OB_LIKELY
(
GCTX
.
cgroup_ctrl_
->
is_valid
()))
{
OB_LIKELY
(
GCTX
.
cgroup_ctrl_
->
is_valid
()))
{
ret
=
GCTX
.
cgroup_ctrl_
->
add_thread_to_cgroup
(
syscall
(
__NR_gettid
),
ret
=
GCTX
.
cgroup_ctrl_
->
add_self_to_cgroup
(
tenant_id
,
OBCG_SQL_NIO
);
tenant_id
,
OBCG_SQL_NIO
);
}
}
return
ret
;
return
ret
;
}
}
...
...
src/observer/omt/ob_tenant.cpp
浏览文件 @
a22145fe
...
@@ -255,9 +255,8 @@ void ObPxPool::run1()
...
@@ -255,9 +255,8 @@ void ObPxPool::run1()
ObCgroupCtrl
*
cgroup_ctrl
=
GCTX
.
cgroup_ctrl_
;
ObCgroupCtrl
*
cgroup_ctrl
=
GCTX
.
cgroup_ctrl_
;
LOG_INFO
(
"run px pool"
,
K
(
group_id_
),
K
(
tenant_id_
),
K_
(
active_threads
));
LOG_INFO
(
"run px pool"
,
K
(
group_id_
),
K
(
tenant_id_
),
K_
(
active_threads
));
if
(
nullptr
!=
cgroup_ctrl
&&
OB_LIKELY
(
cgroup_ctrl
->
is_valid
()))
{
if
(
nullptr
!=
cgroup_ctrl
&&
OB_LIKELY
(
cgroup_ctrl
->
is_valid
()))
{
pid_t
pid
=
static_cast
<
pid_t
>
(
syscall
(
__NR_gettid
));
cgroup_ctrl
->
add_self_to_cgroup
(
tenant_id_
,
group_id_
);
cgroup_ctrl
->
add_thread_to_cgroup
(
pid
,
tenant_id_
,
group_id_
);
LOG_INFO
(
"add thread to group succ"
,
K
(
tenant_id_
),
K
(
group_id_
));
LOG_INFO
(
"set pid to group succ"
,
K
(
tenant_id_
),
K
(
group_id_
),
K
(
pid
));
}
}
if
(
!
is_inited_
)
{
if
(
!
is_inited_
)
{
...
@@ -409,7 +408,7 @@ void ObResourceGroup::check_worker_count(ObThWorker &w)
...
@@ -409,7 +408,7 @@ void ObResourceGroup::check_worker_count(ObThWorker &w)
ATOMIC_INC
(
&
token_cnt_
);
ATOMIC_INC
(
&
token_cnt_
);
ATOMIC_STORE
(
&
token_change_ts_
,
now
);
ATOMIC_STORE
(
&
token_change_ts_
,
now
);
if
(
cgroup_ctrl_
->
is_valid
()
if
(
cgroup_ctrl_
->
is_valid
()
&&
OB_FAIL
(
cgroup_ctrl_
->
remove_
thread_from_cgroup
(
w
.
get_tid
(),
tenant_
->
id
())))
{
&&
OB_FAIL
(
cgroup_ctrl_
->
remove_
self_from_cgroup
(
tenant_
->
id
())))
{
LOG_WARN
(
"remove thread from cgroup failed"
,
K
(
ret
),
"tenant:"
,
tenant_
->
id
(),
K_
(
group_id
));
LOG_WARN
(
"remove thread from cgroup failed"
,
K
(
ret
),
"tenant:"
,
tenant_
->
id
(),
K_
(
group_id
));
}
}
}
}
...
@@ -1369,7 +1368,7 @@ void ObTenant::check_worker_count(ObThWorker &w)
...
@@ -1369,7 +1368,7 @@ void ObTenant::check_worker_count(ObThWorker &w)
w
.
stop
();
w
.
stop
();
ATOMIC_INC
(
&
token_cnt_
);
ATOMIC_INC
(
&
token_cnt_
);
ATOMIC_STORE
(
&
token_change_ts_
,
now
);
ATOMIC_STORE
(
&
token_change_ts_
,
now
);
if
(
cgroup_ctrl_
.
is_valid
()
&&
OB_FAIL
(
cgroup_ctrl_
.
remove_
thread_from_cgroup
(
w
.
get_tid
(),
id_
)))
{
if
(
cgroup_ctrl_
.
is_valid
()
&&
OB_FAIL
(
cgroup_ctrl_
.
remove_
self_from_cgroup
(
id_
)))
{
LOG_WARN
(
"remove thread from cgroup failed"
,
K
(
ret
),
K_
(
id
));
LOG_WARN
(
"remove thread from cgroup failed"
,
K
(
ret
),
K_
(
id
));
}
}
}
}
...
@@ -1441,7 +1440,7 @@ void ObTenant::lq_end(ObThWorker &w)
...
@@ -1441,7 +1440,7 @@ void ObTenant::lq_end(ObThWorker &w)
{
{
int
ret
=
OB_SUCCESS
;
int
ret
=
OB_SUCCESS
;
if
(
w
.
is_lq_yield
())
{
if
(
w
.
is_lq_yield
())
{
if
(
OB_FAIL
(
cgroup_ctrl_
.
add_
thread_to_cgroup
(
w
.
get_tid
(),
id_
,
w
.
get_group_id
())))
{
if
(
OB_FAIL
(
cgroup_ctrl_
.
add_
self_to_cgroup
(
id_
,
w
.
get_group_id
())))
{
LOG_WARN
(
"move thread from lq group failed"
,
K
(
ret
),
K
(
id_
));
LOG_WARN
(
"move thread from lq group failed"
,
K
(
ret
),
K
(
id_
));
}
else
{
}
else
{
w
.
set_lq_yield
(
false
);
w
.
set_lq_yield
(
false
);
...
@@ -1475,7 +1474,7 @@ int ObTenant::lq_yield(ObThWorker &w)
...
@@ -1475,7 +1474,7 @@ int ObTenant::lq_yield(ObThWorker &w)
}
}
}
else
if
(
w
.
is_lq_yield
())
{
}
else
if
(
w
.
is_lq_yield
())
{
// avoid duplicate change group
// avoid duplicate change group
}
else
if
(
OB_FAIL
(
cgroup_ctrl_
.
add_
thread_to_cgroup
(
w
.
get_tid
(),
id_
,
OBCG_LQ
)))
{
}
else
if
(
OB_FAIL
(
cgroup_ctrl_
.
add_
self_to_cgroup
(
id_
,
OBCG_LQ
)))
{
LOG_WARN
(
"move thread to lq group failed"
,
K
(
ret
),
K
(
id_
));
LOG_WARN
(
"move thread to lq group failed"
,
K
(
ret
),
K
(
id_
));
}
else
{
}
else
{
w
.
set_lq_yield
();
w
.
set_lq_yield
();
...
...
src/observer/omt/ob_th_worker.cpp
浏览文件 @
a22145fe
...
@@ -355,7 +355,7 @@ void ObThWorker::worker(int64_t &tenant_id, int64_t &req_recv_timestamp, int32_t
...
@@ -355,7 +355,7 @@ void ObThWorker::worker(int64_t &tenant_id, int64_t &req_recv_timestamp, int32_t
LOG_ERROR
(
"invalid status, unexpected"
,
K
(
tenant_
));
LOG_ERROR
(
"invalid status, unexpected"
,
K
(
tenant_
));
}
else
{
}
else
{
if
(
nullptr
!=
GCTX
.
cgroup_ctrl_
&&
nullptr
!=
tenant_
&&
OB_LIKELY
(
GCTX
.
cgroup_ctrl_
->
is_valid
())
&&
!
has_add_to_cgroup_
)
{
if
(
nullptr
!=
GCTX
.
cgroup_ctrl_
&&
nullptr
!=
tenant_
&&
OB_LIKELY
(
GCTX
.
cgroup_ctrl_
->
is_valid
())
&&
!
has_add_to_cgroup_
)
{
if
(
OB_SUCC
(
GCTX
.
cgroup_ctrl_
->
add_
thread_to_cgroup
(
gettid
(),
tenant_
->
id
(),
get_group_id
())))
{
if
(
OB_SUCC
(
GCTX
.
cgroup_ctrl_
->
add_
self_to_cgroup
(
tenant_
->
id
(),
get_group_id
())))
{
has_add_to_cgroup_
=
true
;
has_add_to_cgroup_
=
true
;
}
}
}
}
...
...
src/rootserver/ob_rs_reentrant_thread.cpp
浏览文件 @
a22145fe
...
@@ -126,7 +126,7 @@ int64_t ObRsReentrantThread::get_last_run_timestamp() const
...
@@ -126,7 +126,7 @@ int64_t ObRsReentrantThread::get_last_run_timestamp() const
void
ObRsReentrantThread
::
check_alert
(
const
ObRsReentrantThread
&
thread
)
void
ObRsReentrantThread
::
check_alert
(
const
ObRsReentrantThread
&
thread
)
{
{
if
(
thread
.
need_monitor_check
())
{
if
(
thread
.
need_monitor_check
())
{
const
pid_t
thread_id
=
thread
.
get_tid
();
const
pid_t
thread_id
=
syscall
(
__NR_gettid
);
// only called by thread self
const
char
*
thread_name
=
thread
.
get_thread_name
();
const
char
*
thread_name
=
thread
.
get_thread_name
();
int64_t
last_run_timestamp
=
thread
.
get_last_run_timestamp
();
int64_t
last_run_timestamp
=
thread
.
get_last_run_timestamp
();
int64_t
last_run_interval
=
ObTimeUtility
::
current_time
()
-
last_run_timestamp
;
int64_t
last_run_interval
=
ObTimeUtility
::
current_time
()
-
last_run_timestamp
;
...
...
src/share/rc/ob_tenant_base.cpp
浏览文件 @
a22145fe
...
@@ -270,7 +270,7 @@ int ObTenantBase::pre_run(lib::Threads *th)
...
@@ -270,7 +270,7 @@ int ObTenantBase::pre_run(lib::Threads *th)
ObTenantEnv
::
set_tenant
(
this
);
ObTenantEnv
::
set_tenant
(
this
);
ObCgroupCtrl
*
cgroup_ctrl
=
get_cgroup
(
th
->
get_cgroup
());
ObCgroupCtrl
*
cgroup_ctrl
=
get_cgroup
(
th
->
get_cgroup
());
if
(
cgroup_ctrl
!=
nullptr
)
{
if
(
cgroup_ctrl
!=
nullptr
)
{
ret
=
cgroup_ctrl
->
add_
thread_to_cgroup
(
static_cast
<
pid_t
>
(
syscall
(
__NR_gettid
)),
id_
);
ret
=
cgroup_ctrl
->
add_
self_to_cgroup
(
id_
);
}
}
ATOMIC_INC
(
&
thread_count_
);
ATOMIC_INC
(
&
thread_count_
);
LOG_INFO
(
"tenant thread pre_run"
,
K
(
MTL_ID
()),
K
(
ret
),
K
(
thread_count_
),
KP
(
th
));
LOG_INFO
(
"tenant thread pre_run"
,
K
(
MTL_ID
()),
K
(
ret
),
K
(
thread_count_
),
KP
(
th
));
...
@@ -283,7 +283,7 @@ int ObTenantBase::end_run(lib::Threads *th)
...
@@ -283,7 +283,7 @@ int ObTenantBase::end_run(lib::Threads *th)
ObTenantEnv
::
set_tenant
(
nullptr
);
ObTenantEnv
::
set_tenant
(
nullptr
);
ObCgroupCtrl
*
cgroup_ctrl
=
get_cgroup
(
th
->
get_cgroup
());
ObCgroupCtrl
*
cgroup_ctrl
=
get_cgroup
(
th
->
get_cgroup
());
if
(
cgroup_ctrl
!=
nullptr
)
{
if
(
cgroup_ctrl
!=
nullptr
)
{
ret
=
cgroup_ctrl
->
remove_
thread_from_cgroup
(
static_cast
<
pid_t
>
(
syscall
(
__NR_gettid
)),
id_
);
ret
=
cgroup_ctrl
->
remove_
self_from_cgroup
(
id_
);
}
}
ATOMIC_DEC
(
&
thread_count_
);
ATOMIC_DEC
(
&
thread_count_
);
LOG_INFO
(
"tenant thread end_run"
,
K
(
id_
),
K
(
ret
),
K
(
thread_count_
));
LOG_INFO
(
"tenant thread end_run"
,
K
(
id_
),
K
(
ret
),
K
(
thread_count_
));
...
...
src/share/resource_manager/ob_cgroup_ctrl.cpp
浏览文件 @
a22145fe
...
@@ -368,7 +368,7 @@ int ObCgroupCtrl::create_user_tenant_group_dir(
...
@@ -368,7 +368,7 @@ int ObCgroupCtrl::create_user_tenant_group_dir(
return
ret
;
return
ret
;
}
}
int
ObCgroupCtrl
::
add_
thread_to_cgroup
(
const
pid_t
tid
,
const
uint64_t
tenant_id
,
int64_t
group_id
)
int
ObCgroupCtrl
::
add_
self_to_cgroup
(
const
uint64_t
tenant_id
,
int64_t
group_id
)
{
{
int
ret
=
OB_SUCCESS
;
int
ret
=
OB_SUCCESS
;
char
group_path
[
PATH_BUFSIZE
];
char
group_path
[
PATH_BUFSIZE
];
...
@@ -383,7 +383,7 @@ int ObCgroupCtrl::add_thread_to_cgroup(const pid_t tid, const uint64_t tenant_id
...
@@ -383,7 +383,7 @@ int ObCgroupCtrl::add_thread_to_cgroup(const pid_t tid, const uint64_t tenant_id
}
else
{
}
else
{
char
task_path
[
PATH_BUFSIZE
];
char
task_path
[
PATH_BUFSIZE
];
char
tid_value
[
VALUE_BUFSIZE
];
char
tid_value
[
VALUE_BUFSIZE
];
snprintf
(
tid_value
,
VALUE_BUFSIZE
,
"%
d"
,
tid
);
snprintf
(
tid_value
,
VALUE_BUFSIZE
,
"%
ld"
,
syscall
(
__NR_gettid
)
);
snprintf
(
task_path
,
PATH_BUFSIZE
,
"%s/tasks"
,
group_path
);
snprintf
(
task_path
,
PATH_BUFSIZE
,
"%s/tasks"
,
group_path
);
if
(
OB_FAIL
(
write_string_to_file_
(
task_path
,
tid_value
)))
{
if
(
OB_FAIL
(
write_string_to_file_
(
task_path
,
tid_value
)))
{
LOG_WARN
(
"add tid to cgroup failed"
,
K
(
ret
),
K
(
task_path
),
K
(
tid_value
),
K
(
tenant_id
));
LOG_WARN
(
"add tid to cgroup failed"
,
K
(
ret
),
K
(
task_path
),
K
(
tid_value
),
K
(
tenant_id
));
...
@@ -409,14 +409,14 @@ int ObCgroupCtrl::get_group_info_by_group_id(const uint64_t tenant_id,
...
@@ -409,14 +409,14 @@ int ObCgroupCtrl::get_group_info_by_group_id(const uint64_t tenant_id,
return
ret
;
return
ret
;
}
}
int
ObCgroupCtrl
::
remove_
thread_from_cgroup
(
const
pid_t
tid
,
const
uint64_t
tenant_id
)
int
ObCgroupCtrl
::
remove_
self_from_cgroup
(
const
uint64_t
tenant_id
)
{
{
int
ret
=
OB_SUCCESS
;
int
ret
=
OB_SUCCESS
;
char
task_path
[
PATH_BUFSIZE
];
char
task_path
[
PATH_BUFSIZE
];
char
tid_value
[
VALUE_BUFSIZE
];
char
tid_value
[
VALUE_BUFSIZE
];
// 把该tid加入other_cgroup目录的tasks文件中就会从其它tasks中删除
// 把该tid加入other_cgroup目录的tasks文件中就会从其它tasks中删除
snprintf
(
task_path
,
PATH_BUFSIZE
,
"%s/tasks"
,
other_cgroup_
);
snprintf
(
task_path
,
PATH_BUFSIZE
,
"%s/tasks"
,
other_cgroup_
);
snprintf
(
tid_value
,
VALUE_BUFSIZE
,
"%
d"
,
tid
);
snprintf
(
tid_value
,
VALUE_BUFSIZE
,
"%
ld"
,
syscall
(
__NR_gettid
)
);
if
(
OB_FAIL
(
write_string_to_file_
(
task_path
,
tid_value
)))
{
if
(
OB_FAIL
(
write_string_to_file_
(
task_path
,
tid_value
)))
{
LOG_WARN
(
"remove tid from cgroup failed"
,
K
(
ret
),
K
(
task_path
),
K
(
tid_value
),
K
(
tenant_id
));
LOG_WARN
(
"remove tid from cgroup failed"
,
K
(
ret
),
K
(
task_path
),
K
(
tid_value
),
K
(
tenant_id
));
}
else
{
}
else
{
...
@@ -425,18 +425,17 @@ int ObCgroupCtrl::remove_thread_from_cgroup(const pid_t tid, const uint64_t tena
...
@@ -425,18 +425,17 @@ int ObCgroupCtrl::remove_thread_from_cgroup(const pid_t tid, const uint64_t tena
return
ret
;
return
ret
;
}
}
int
ObCgroupCtrl
::
add_thread_to_group
(
const
pid_t
tid
,
int
ObCgroupCtrl
::
add_self_to_group
(
const
uint64_t
tenant_id
,
const
uint64_t
tenant_id
,
const
uint64_t
group_id
)
const
uint64_t
group_id
)
{
{
int
ret
=
OB_SUCCESS
;
int
ret
=
OB_SUCCESS
;
if
(
OB_UNLIKELY
(
!
is_valid_tenant_id
(
tenant_id
)))
{
if
(
OB_UNLIKELY
(
!
is_valid_tenant_id
(
tenant_id
)))
{
ret
=
OB_INVALID_CONFIG
;
ret
=
OB_INVALID_CONFIG
;
LOG_WARN
(
"invalid config"
,
K
(
ret
),
K
(
tenant_id
));
LOG_WARN
(
"invalid config"
,
K
(
ret
),
K
(
tenant_id
));
}
else
if
(
OB_FAIL
(
add_
thread_to_cgroup
(
tid
,
tenant_id
,
group_id
)))
{
}
else
if
(
OB_FAIL
(
add_
self_to_cgroup
(
tenant_id
,
group_id
)))
{
LOG_WARN
(
"fail to add thread to group"
,
K
(
ret
),
K
(
tid
),
K
(
group_id
),
K
(
tenant_id
));
LOG_WARN
(
"fail to add thread to group"
,
K
(
ret
),
K
(
group_id
),
K
(
tenant_id
));
}
else
{
}
else
{
LOG_INFO
(
"set backup pid to group success"
,
K
(
tenant_id
),
K
(
group_id
)
,
K
(
tid
)
);
LOG_INFO
(
"set backup pid to group success"
,
K
(
tenant_id
),
K
(
group_id
));
}
}
return
ret
;
return
ret
;
}
}
...
...
src/share/resource_manager/ob_cgroup_ctrl.h
浏览文件 @
a22145fe
...
@@ -115,14 +115,13 @@ public:
...
@@ -115,14 +115,13 @@ public:
// 删除租户cgroup规则
// 删除租户cgroup规则
int
remove_tenant_cgroup
(
const
uint64_t
tenant_id
);
int
remove_tenant_cgroup
(
const
uint64_t
tenant_id
);
int
add_
thread_to_cgroup
(
const
pid_t
tid
,
const
uint64_t
tenant_id
,
int64_t
group_id
=
INT64_MAX
);
int
add_
self_to_cgroup
(
const
uint64_t
tenant_id
,
int64_t
group_id
=
INT64_MAX
);
// 从指定租户cgroup组移除指定tid
// 从指定租户cgroup组移除指定tid
int
remove_
thread_from_cgroup
(
const
pid_t
tid
,
const
uint64_t
tenant_id
);
int
remove_
self_from_cgroup
(
const
uint64_t
tenant_id
);
// 后台线程绑定接口
// 后台线程绑定接口
int
add_thread_to_group
(
const
pid_t
tid
,
int
add_self_to_group
(
const
uint64_t
tenant_id
,
const
uint64_t
tenant_id
,
const
uint64_t
group_id
);
const
uint64_t
group_id
);
// 设定指定租户cgroup组的cpu.shares
// 设定指定租户cgroup组的cpu.shares
int
set_cpu_shares
(
const
int32_t
cpu_shares
,
const
uint64_t
tenant_id
,
int64_t
group_id
=
INT64_MAX
);
int
set_cpu_shares
(
const
int32_t
cpu_shares
,
const
uint64_t
tenant_id
,
int64_t
group_id
=
INT64_MAX
);
...
...
src/share/scheduler/ob_dag_scheduler.cpp
浏览文件 @
a22145fe
...
@@ -1380,7 +1380,7 @@ int ObTenantDagWorker::set_dag_resource()
...
@@ -1380,7 +1380,7 @@ int ObTenantDagWorker::set_dag_resource()
LOG_WARN
(
"fail to get group id by function"
,
K
(
ret
),
K
(
MTL_ID
()),
K
(
function_type_
),
K
(
group_id
));
LOG_WARN
(
"fail to get group id by function"
,
K
(
ret
),
K
(
MTL_ID
()),
K
(
function_type_
),
K
(
group_id
));
}
else
if
(
group_id
==
group_id_
)
{
}
else
if
(
group_id
==
group_id_
)
{
// group not change, do nothing
// group not change, do nothing
}
else
if
(
OB_FAIL
(
GCTX
.
cgroup_ctrl_
->
add_
thread_to_group
(
static_cast
<
pid_t
>
(
GETTID
()),
MTL_ID
(),
group_id
)))
{
}
else
if
(
OB_FAIL
(
GCTX
.
cgroup_ctrl_
->
add_
self_to_group
(
MTL_ID
(),
group_id
)))
{
LOG_WARN
(
"bind back thread to group failed"
,
K
(
ret
),
K
(
GETTID
()),
K
(
MTL_ID
()),
K
(
group_id
));
LOG_WARN
(
"bind back thread to group failed"
,
K
(
ret
),
K
(
GETTID
()),
K
(
MTL_ID
()),
K
(
group_id
));
}
else
{
}
else
{
ATOMIC_SET
(
&
group_id_
,
group_id
);
ATOMIC_SET
(
&
group_id_
,
group_id
);
...
...
unittest/observer/omt/test_cgroup_ctrl.cpp
浏览文件 @
a22145fe
...
@@ -24,9 +24,9 @@ using namespace oceanbase::observer;
...
@@ -24,9 +24,9 @@ using namespace oceanbase::observer;
void
*
thread_func
(
void
*
args
)
void
*
thread_func
(
void
*
args
)
{
{
int
*
tid
=
static_cast
<
int
*>
(
args
);
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
add_self_to_cgroup
(
1001
));
*
tid
=
static_cast
<
int
>
(
syscall
(
SYS_gettid
));
sleep
(
3
);
sleep
(
3
);
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
remove_self_from_cgroup
(
1001
));
return
nullptr
;
return
nullptr
;
}
}
...
@@ -37,29 +37,16 @@ TEST(TestCgroupCtrl, AddDelete)
...
@@ -37,29 +37,16 @@ TEST(TestCgroupCtrl, AddDelete)
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
init
());
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
init
());
ASSERT_TRUE
(
cg_ctrl
.
is_valid
());
ASSERT_TRUE
(
cg_ctrl
.
is_valid
());
int
tids
[
4
];
pthread_t
ts
[
4
];
pthread_t
ts
[
4
];
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
pthread_create
(
&
ts
[
i
],
nullptr
,
thread_func
,
&
tids
[
i
]
);
pthread_create
(
&
ts
[
i
],
nullptr
,
thread_func
,
NULL
);
}
}
sleep
(
1
);
sleep
(
1
);
const
uint64_t
tenant_id1
=
1001
;
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
add_thread_to_cgroup
(
tids
[
0
],
tenant_id1
));
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
add_thread_to_cgroup
(
tids
[
1
],
tenant_id1
));
const
uint64_t
tenant_id2
=
1002
;
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
add_thread_to_cgroup
(
tids
[
2
],
tenant_id2
));
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
add_thread_to_cgroup
(
tids
[
3
],
tenant_id2
));
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
remove_thread_from_cgroup
(
tids
[
2
],
tenant_id2
));
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
remove_thread_from_cgroup
(
tids
[
3
],
tenant_id2
));
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
remove_tenant_cgroup
(
tenant_id1
));
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
pthread_join
(
ts
[
i
],
nullptr
);
pthread_join
(
ts
[
i
],
nullptr
);
}
}
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
remove_tenant_cgroup
(
1001
));
}
}
TEST
(
TestCgroupCtrl
,
SetGetValue
)
TEST
(
TestCgroupCtrl
,
SetGetValue
)
...
@@ -68,27 +55,22 @@ TEST(TestCgroupCtrl, SetGetValue)
...
@@ -68,27 +55,22 @@ TEST(TestCgroupCtrl, SetGetValue)
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
init
());
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
init
());
ASSERT_TRUE
(
cg_ctrl
.
is_valid
());
ASSERT_TRUE
(
cg_ctrl
.
is_valid
());
int
tids
[
4
];
pthread_t
ts
[
4
];
pthread_t
ts
[
4
];
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
pthread_create
(
&
ts
[
i
],
nullptr
,
thread_func
,
&
tids
[
i
]
);
pthread_create
(
&
ts
[
i
],
nullptr
,
thread_func
,
NULL
);
}
}
sleep
(
1
);
sleep
(
1
);
const
uint64_t
tenant_id1
=
1001
;
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
add_thread_to_cgroup
(
tids
[
0
],
tenant_id1
));
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
add_thread_to_cgroup
(
tids
[
1
],
tenant_id1
));
const
int32_t
cpu_shares
=
2048
;
const
int32_t
cpu_shares
=
2048
;
int32_t
cpu_shares_v
=
0
;
int32_t
cpu_shares_v
=
0
;
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
set_cpu_shares
(
cpu_shares
,
tenant_id
1
));
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
set_cpu_shares
(
cpu_shares
,
100
1
));
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
get_cpu_shares
(
cpu_shares_v
,
tenant_id
1
));
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
get_cpu_shares
(
cpu_shares_v
,
100
1
));
ASSERT_EQ
(
cpu_shares
,
cpu_shares_v
);
ASSERT_EQ
(
cpu_shares
,
cpu_shares_v
);
const
int32_t
cpu_cfs_quota
=
80000
;
const
int32_t
cpu_cfs_quota
=
80000
;
int32_t
cpu_cfs_quota_v
=
0
;
int32_t
cpu_cfs_quota_v
=
0
;
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
set_cpu_cfs_quota
(
cpu_cfs_quota
,
tenant_id
1
));
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
set_cpu_cfs_quota
(
cpu_cfs_quota
,
100
1
));
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
get_cpu_cfs_quota
(
cpu_cfs_quota_v
,
tenant_id
1
));
ASSERT_EQ
(
OB_SUCCESS
,
cg_ctrl
.
get_cpu_cfs_quota
(
cpu_cfs_quota_v
,
100
1
));
ASSERT_EQ
(
cpu_cfs_quota
,
cpu_cfs_quota_v
);
ASSERT_EQ
(
cpu_cfs_quota
,
cpu_cfs_quota_v
);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录