Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
07978790
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
07978790
编写于
1月 25, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dead lock after refact worker
上级
5690df9a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
41 addition
and
28 deletion
+41
-28
source/dnode/mgmt/impl/src/dndVnodes.c
source/dnode/mgmt/impl/src/dndVnodes.c
+21
-21
source/util/src/tqueue.c
source/util/src/tqueue.c
+11
-3
source/util/src/tworker.c
source/util/src/tworker.c
+9
-4
未找到文件。
source/dnode/mgmt/impl/src/dndVnodes.c
浏览文件 @
07978790
...
...
@@ -910,27 +910,27 @@ static int32_t dndInitVnodeWorkers(SDnode *pDnode) {
int32_t
maxWriteThreads
=
TMAX
(
pDnode
->
env
.
numOfCores
,
1
);
int32_t
maxSyncThreads
=
TMAX
(
pDnode
->
env
.
numOfCores
/
2
,
1
);
SQWorkerPool
*
pPool
=
&
pMgmt
->
queryPool
;
pPool
->
name
=
"vnode-query"
;
pPool
->
min
=
minQueryThreads
;
pPool
->
max
=
maxQueryThreads
;
if
(
tQWorkerInit
(
pPool
)
!=
0
)
return
-
1
;
p
Pool
=
&
pMgmt
->
fetchPool
;
pPool
->
name
=
"vnode-fetch"
;
pPool
->
min
=
minFetchThreads
;
pPool
->
max
=
maxFetchThreads
;
if
(
tFWorkerInit
(
pPool
)
!=
0
)
return
-
1
;
SWWorkerPool
*
p
M
Pool
=
&
pMgmt
->
writePool
;
p
M
Pool
->
name
=
"vnode-write"
;
p
M
Pool
->
max
=
maxWriteThreads
;
if
(
tWWorkerInit
(
p
M
Pool
)
!=
0
)
return
-
1
;
p
M
Pool
=
&
pMgmt
->
syncPool
;
p
M
Pool
->
name
=
"vnode-sync"
;
p
M
Pool
->
max
=
maxSyncThreads
;
if
(
tWWorkerInit
(
p
M
Pool
)
!=
0
)
return
-
1
;
SQWorkerPool
*
p
Q
Pool
=
&
pMgmt
->
queryPool
;
p
Q
Pool
->
name
=
"vnode-query"
;
p
Q
Pool
->
min
=
minQueryThreads
;
p
Q
Pool
->
max
=
maxQueryThreads
;
if
(
tQWorkerInit
(
p
Q
Pool
)
!=
0
)
return
-
1
;
SFWorkerPool
*
pF
Pool
=
&
pMgmt
->
fetchPool
;
p
F
Pool
->
name
=
"vnode-fetch"
;
p
F
Pool
->
min
=
minFetchThreads
;
p
F
Pool
->
max
=
maxFetchThreads
;
if
(
tFWorkerInit
(
p
F
Pool
)
!=
0
)
return
-
1
;
SWWorkerPool
*
p
W
Pool
=
&
pMgmt
->
writePool
;
p
W
Pool
->
name
=
"vnode-write"
;
p
W
Pool
->
max
=
maxWriteThreads
;
if
(
tWWorkerInit
(
p
W
Pool
)
!=
0
)
return
-
1
;
p
W
Pool
=
&
pMgmt
->
syncPool
;
p
W
Pool
->
name
=
"vnode-sync"
;
p
W
Pool
->
max
=
maxSyncThreads
;
if
(
tWWorkerInit
(
p
W
Pool
)
!=
0
)
return
-
1
;
dDebug
(
"vnode workers is initialized"
);
return
0
;
...
...
source/util/src/tqueue.c
浏览文件 @
07978790
...
...
@@ -423,7 +423,9 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, void **ahand
queue
->
tail
=
NULL
;
queue
->
numOfItems
=
0
;
atomic_sub_fetch_32
(
&
qset
->
numOfItems
,
qall
->
numOfItems
);
for
(
int32_t
j
=
1
;
j
<
qall
->
numOfItems
;
++
j
)
tsem_wait
(
&
qset
->
sem
);
for
(
int32_t
j
=
1
;
j
<
qall
->
numOfItems
;
++
j
)
{
tsem_wait
(
&
qset
->
sem
);
}
}
pthread_mutex_unlock
(
&
queue
->
mutex
);
...
...
@@ -437,7 +439,7 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, void **ahand
int32_t
taosReadQitemFromQsetByThread
(
STaosQset
*
qset
,
void
**
ppItem
,
void
**
ahandle
,
FItem
*
itemFp
,
int32_t
threadId
)
{
STaosQnode
*
pNode
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
-
1
;
tsem_wait
(
&
qset
->
sem
);
...
...
@@ -449,7 +451,10 @@ int32_t taosReadQitemFromQsetByThread(STaosQset *qset, void **ppItem, void **aha
if
(
queue
)
qset
->
current
=
queue
->
next
;
if
(
queue
==
NULL
)
break
;
if
(
queue
->
head
==
NULL
)
continue
;
if
(
queue
->
threadId
!=
-
1
&&
queue
->
threadId
!=
threadId
)
continue
;
if
(
queue
->
threadId
!=
-
1
&&
queue
->
threadId
!=
threadId
)
{
code
=
0
;
continue
;
}
pthread_mutex_lock
(
&
queue
->
mutex
);
...
...
@@ -485,6 +490,9 @@ void taosResetQsetThread(STaosQset *qset, void *pItem) {
pthread_mutex_lock
(
&
qset
->
mutex
);
pNode
->
queue
->
threadId
=
-
1
;
for
(
int32_t
i
=
0
;
i
<
pNode
->
queue
->
numOfItems
;
++
i
)
{
tsem_post
(
&
qset
->
sem
);
}
pthread_mutex_unlock
(
&
qset
->
mutex
);
}
...
...
source/util/src/tworker.c
浏览文件 @
07978790
...
...
@@ -149,8 +149,8 @@ void tFWorkerCleanup(SFWorkerPool *pool) { tQWorkerCleanup(pool); }
static
void
*
tFWorkerThreadFp
(
SQWorker
*
worker
)
{
SQWorkerPool
*
pool
=
worker
->
pool
;
FItem
fp
=
NULL
;
FItem
fp
=
NULL
;
void
*
msg
=
NULL
;
void
*
ahandle
=
NULL
;
int32_t
code
=
0
;
...
...
@@ -160,9 +160,14 @@ static void *tFWorkerThreadFp(SQWorker *worker) {
uDebug
(
"worker:%s:%d is running"
,
pool
->
name
,
worker
->
id
);
while
(
1
)
{
if
(
taosReadQitemFromQsetByThread
(
pool
->
qset
,
(
void
**
)
&
msg
,
&
ahandle
,
&
fp
,
worker
->
id
)
==
0
)
{
code
=
taosReadQitemFromQsetByThread
(
pool
->
qset
,
(
void
**
)
&
msg
,
&
ahandle
,
&
fp
,
worker
->
id
);
if
(
code
<
0
)
{
uDebug
(
"worker:%s:%d qset:%p, got no message and exiting"
,
pool
->
name
,
worker
->
id
,
pool
->
qset
);
break
;
}
else
if
(
code
==
0
)
{
// uTrace("worker:%s:%d qset:%p, got no message and continue", pool->name, worker->id, pool->qset);
continue
;
}
if
(
fp
!=
NULL
)
{
...
...
@@ -231,7 +236,7 @@ void tWWorkerCleanup(SWWorkerPool *pool) {
uInfo
(
"worker:%s is closed"
,
pool
->
name
);
}
static
void
*
tW
rite
WorkerThreadFp
(
SWWorker
*
worker
)
{
static
void
*
tWWorkerThreadFp
(
SWWorker
*
worker
)
{
SWWorkerPool
*
pool
=
worker
->
pool
;
FItems
fp
=
NULL
;
...
...
@@ -293,7 +298,7 @@ STaosQueue *tWWorkerAllocQueue(SWWorkerPool *pool, void *ahandle, FItems fp) {
pthread_attr_init
(
&
thAttr
);
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
if
(
pthread_create
(
&
worker
->
thread
,
&
thAttr
,
(
ThreadFp
)
tW
rite
WorkerThreadFp
,
worker
)
!=
0
)
{
if
(
pthread_create
(
&
worker
->
thread
,
&
thAttr
,
(
ThreadFp
)
tWWorkerThreadFp
,
worker
)
!=
0
)
{
uError
(
"worker:%s:%d failed to create thread to process since %s"
,
pool
->
name
,
worker
->
id
,
strerror
(
errno
));
taosFreeQall
(
worker
->
qall
);
taosCloseQset
(
worker
->
qset
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录