Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
148e3a5f
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
未验证
提交
148e3a5f
编写于
7月 12, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
7月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14818 from taosdata/fix/mnode
enh: adjust vnode fetch queue number
上级
1c6259cd
dad12c24
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
99 addition
and
65 deletion
+99
-65
include/util/tqueue.h
include/util/tqueue.h
+5
-2
source/common/src/tglobal.c
source/common/src/tglobal.c
+2
-1
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
+1
-1
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
+1
-1
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+2
-0
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+30
-22
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+3
-0
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+7
-5
source/libs/transport/test/pushServer.c
source/libs/transport/test/pushServer.c
+4
-2
source/util/src/tqueue.c
source/util/src/tqueue.c
+24
-11
source/util/src/tworker.c
source/util/src/tworker.c
+20
-20
未找到文件。
include/util/tqueue.h
浏览文件 @
148e3a5f
...
@@ -44,6 +44,8 @@ typedef struct STaosQset STaosQset;
...
@@ -44,6 +44,8 @@ typedef struct STaosQset STaosQset;
typedef
struct
STaosQall
STaosQall
;
typedef
struct
STaosQall
STaosQall
;
typedef
struct
{
typedef
struct
{
void
*
ahandle
;
void
*
ahandle
;
void
*
fp
;
void
*
queue
;
int32_t
workerId
;
int32_t
workerId
;
int32_t
threadNum
;
int32_t
threadNum
;
int64_t
timestamp
;
int64_t
timestamp
;
...
@@ -65,6 +67,7 @@ void taosFreeQitem(void *pItem);
...
@@ -65,6 +67,7 @@ void taosFreeQitem(void *pItem);
void
taosWriteQitem
(
STaosQueue
*
queue
,
void
*
pItem
);
void
taosWriteQitem
(
STaosQueue
*
queue
,
void
*
pItem
);
int32_t
taosReadQitem
(
STaosQueue
*
queue
,
void
**
ppItem
);
int32_t
taosReadQitem
(
STaosQueue
*
queue
,
void
**
ppItem
);
bool
taosQueueEmpty
(
STaosQueue
*
queue
);
bool
taosQueueEmpty
(
STaosQueue
*
queue
);
void
taosUpdateItemSize
(
STaosQueue
*
queue
,
int32_t
items
);
int32_t
taosQueueItemSize
(
STaosQueue
*
queue
);
int32_t
taosQueueItemSize
(
STaosQueue
*
queue
);
int64_t
taosQueueMemorySize
(
STaosQueue
*
queue
);
int64_t
taosQueueMemorySize
(
STaosQueue
*
queue
);
...
@@ -81,8 +84,8 @@ int32_t taosAddIntoQset(STaosQset *qset, STaosQueue *queue, void *ahandle);
...
@@ -81,8 +84,8 @@ int32_t taosAddIntoQset(STaosQset *qset, STaosQueue *queue, void *ahandle);
void
taosRemoveFromQset
(
STaosQset
*
qset
,
STaosQueue
*
queue
);
void
taosRemoveFromQset
(
STaosQset
*
qset
,
STaosQueue
*
queue
);
int32_t
taosGetQueueNumber
(
STaosQset
*
qset
);
int32_t
taosGetQueueNumber
(
STaosQset
*
qset
);
int32_t
taosReadQitemFromQset
(
STaosQset
*
qset
,
void
**
ppItem
,
int64_t
*
ts
,
void
**
ahandle
,
FItem
*
itemFp
);
int32_t
taosReadQitemFromQset
(
STaosQset
*
qset
,
void
**
ppItem
,
SQueueInfo
*
qinfo
);
int32_t
taosReadAllQitemsFromQset
(
STaosQset
*
qset
,
STaosQall
*
qall
,
void
**
ahandle
,
FItems
*
itemsFp
);
int32_t
taosReadAllQitemsFromQset
(
STaosQset
*
qset
,
STaosQall
*
qall
,
SQueueInfo
*
qinfo
);
void
taosResetQsetThread
(
STaosQset
*
qset
,
void
*
pItem
);
void
taosResetQsetThread
(
STaosQset
*
qset
,
void
*
pItem
);
extern
int64_t
tsRpcQueueMemoryAllowed
;
extern
int64_t
tsRpcQueueMemoryAllowed
;
...
...
source/common/src/tglobal.c
浏览文件 @
148e3a5f
...
@@ -412,7 +412,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
...
@@ -412,7 +412,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
tsNumOfVnodeQueryThreads
=
TMAX
(
tsNumOfVnodeQueryThreads
,
2
);
tsNumOfVnodeQueryThreads
=
TMAX
(
tsNumOfVnodeQueryThreads
,
2
);
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeQueryThreads"
,
tsNumOfVnodeQueryThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeQueryThreads"
,
tsNumOfVnodeQueryThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
tsNumOfVnodeFetchThreads
=
TRANGE
(
tsNumOfVnodeFetchThreads
,
1
,
1
);
tsNumOfVnodeFetchThreads
=
tsNumOfCores
/
4
;
tsNumOfVnodeFetchThreads
=
TMAX
(
tsNumOfVnodeFetchThreads
,
4
);
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeFetchThreads"
,
tsNumOfVnodeFetchThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeFetchThreads"
,
tsNumOfVnodeFetchThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
tsNumOfVnodeWriteThreads
=
tsNumOfCores
;
tsNumOfVnodeWriteThreads
=
tsNumOfCores
;
...
...
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
浏览文件 @
148e3a5f
...
@@ -31,7 +31,7 @@ typedef struct SVnodeMgmt {
...
@@ -31,7 +31,7 @@ typedef struct SVnodeMgmt {
const
char
*
path
;
const
char
*
path
;
const
char
*
name
;
const
char
*
name
;
SQWorkerPool
queryPool
;
SQWorkerPool
queryPool
;
S
Q
WorkerPool
fetchPool
;
S
W
WorkerPool
fetchPool
;
SWWorkerPool
syncPool
;
SWWorkerPool
syncPool
;
SWWorkerPool
writePool
;
SWWorkerPool
writePool
;
SWWorkerPool
applyPool
;
SWWorkerPool
applyPool
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
浏览文件 @
148e3a5f
...
@@ -31,7 +31,7 @@ SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
...
@@ -31,7 +31,7 @@ SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
SVnodeObj
*
pVnode
=
*
ppVnode
;
SVnodeObj
*
pVnode
=
*
ppVnode
;
if
(
pVnode
&&
num
<
size
)
{
if
(
pVnode
&&
num
<
size
)
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pVnode
->
refCount
,
1
);
int32_t
refCount
=
atomic_add_fetch_32
(
&
pVnode
->
refCount
,
1
);
// dTrace("vgId:%d, acquire vnode
, refCount
:%d", pVnode->vgId, refCount);
// dTrace("vgId:%d, acquire vnode
list, ref
:%d", pVnode->vgId, refCount);
pVnodes
[
num
++
]
=
(
*
ppVnode
);
pVnodes
[
num
++
]
=
(
*
ppVnode
);
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
pIter
);
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
pIter
);
}
else
{
}
else
{
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
148e3a5f
...
@@ -23,6 +23,7 @@ SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId) {
...
@@ -23,6 +23,7 @@ SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId) {
taosHashGetDup
(
pMgmt
->
hash
,
&
vgId
,
sizeof
(
int32_t
),
(
void
*
)
&
pVnode
);
taosHashGetDup
(
pMgmt
->
hash
,
&
vgId
,
sizeof
(
int32_t
),
(
void
*
)
&
pVnode
);
if
(
pVnode
==
NULL
||
pVnode
->
dropped
)
{
if
(
pVnode
==
NULL
||
pVnode
->
dropped
)
{
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
pVnode
=
NULL
;
}
else
{
}
else
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pVnode
->
refCount
,
1
);
int32_t
refCount
=
atomic_add_fetch_32
(
&
pVnode
->
refCount
,
1
);
// dTrace("vgId:%d, acquire vnode, ref:%d", pVnode->vgId, refCount);
// dTrace("vgId:%d, acquire vnode, ref:%d", pVnode->vgId, refCount);
...
@@ -82,6 +83,7 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
...
@@ -82,6 +83,7 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
taosThreadRwlockUnlock
(
&
pMgmt
->
lock
);
taosThreadRwlockUnlock
(
&
pMgmt
->
lock
);
vmReleaseVnode
(
pMgmt
,
pVnode
);
vmReleaseVnode
(
pMgmt
,
pVnode
);
dTrace
(
"vgId:%d, wait for vnode ref become 0"
,
pVnode
->
vgId
);
while
(
pVnode
->
refCount
>
0
)
taosMsleep
(
10
);
while
(
pVnode
->
refCount
>
0
)
taosMsleep
(
10
);
dTrace
(
"vgId:%d, wait for vnode queue is empty"
,
pVnode
->
vgId
);
dTrace
(
"vgId:%d, wait for vnode queue is empty"
,
pVnode
->
vgId
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
148e3a5f
...
@@ -81,21 +81,26 @@ static void vmProcessQueryQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
...
@@ -81,21 +81,26 @@ static void vmProcessQueryQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
taosFreeQitem
(
pMsg
);
taosFreeQitem
(
pMsg
);
}
}
static
void
vmProcessFetchQueue
(
SQueueInfo
*
pInfo
,
S
RpcMsg
*
pMsg
)
{
static
void
vmProcessFetchQueue
(
SQueueInfo
*
pInfo
,
S
TaosQall
*
qall
,
int32_t
numOfMsgs
)
{
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
SRpcMsg
*
pMsg
=
NULL
;
dGTrace
(
"vgId:%d, msg:%p get from vnode-fetch queue"
,
pVnode
->
vgId
,
pMsg
);
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
int32_t
code
=
vnodeProcessFetchMsg
(
pVnode
->
pImpl
,
pMsg
,
pInfo
);
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
if
(
code
!=
0
)
{
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
if
(
terrno
!=
0
)
code
=
terrno
;
dGTrace
(
"vgId:%d, msg:%p get from vnode-fetch queue"
,
pVnode
->
vgId
,
pMsg
);
dGError
(
"vgId:%d, msg:%p failed to fetch since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
());
vmSendRsp
(
pMsg
,
code
);
}
dGTrace
(
"vgId:%d, msg:%p is freed, code:0x%x"
,
pVnode
->
vgId
,
pMsg
,
code
);
int32_t
code
=
vnodeProcessFetchMsg
(
pVnode
->
pImpl
,
pMsg
,
pInfo
);
rpcFreeCont
(
pMsg
->
pCont
);
if
(
code
!=
0
)
{
taosFreeQitem
(
pMsg
);
if
(
terrno
!=
0
)
code
=
terrno
;
dGError
(
"vgId:%d, msg:%p failed to fetch since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
());
vmSendRsp
(
pMsg
,
code
);
}
dGTrace
(
"vgId:%d, msg:%p is freed, code:0x%x"
,
pVnode
->
vgId
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
}
}
static
void
vmProcessSyncQueue
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
static
void
vmProcessSyncQueue
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
...
@@ -201,9 +206,9 @@ int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
...
@@ -201,9 +206,9 @@ int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
int32_t
code
=
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
qtype
);
int32_t
code
=
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
qtype
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
dTrace
(
"msg:%p, is freed"
,
pMsg
);
dTrace
(
"msg:%p, is freed"
,
pMsg
);
taosFreeQitem
(
pMsg
);
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
pRpc
->
pCont
=
NULL
;
pRpc
->
pCont
=
NULL
;
taosFreeQitem
(
pMsg
);
}
}
return
code
;
return
code
;
...
@@ -232,8 +237,8 @@ int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) {
...
@@ -232,8 +237,8 @@ int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) {
default:
default:
break
;
break
;
}
}
vmReleaseVnode
(
pMgmt
,
pVnode
);
}
}
vmReleaseVnode
(
pMgmt
,
pVnode
);
return
size
;
return
size
;
}
}
...
@@ -242,7 +247,7 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
...
@@ -242,7 +247,7 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
pVnode
->
pSyncQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
syncPool
,
pVnode
,
(
FItems
)
vmProcessSyncQueue
);
pVnode
->
pSyncQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
syncPool
,
pVnode
,
(
FItems
)
vmProcessSyncQueue
);
pVnode
->
pApplyQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
applyPool
,
pVnode
->
pImpl
,
(
FItems
)
vnodeApplyWriteMsg
);
pVnode
->
pApplyQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
applyPool
,
pVnode
->
pImpl
,
(
FItems
)
vnodeApplyWriteMsg
);
pVnode
->
pQueryQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
queryPool
,
pVnode
,
(
FItem
)
vmProcessQueryQueue
);
pVnode
->
pQueryQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
queryPool
,
pVnode
,
(
FItem
)
vmProcessQueryQueue
);
pVnode
->
pFetchQ
=
t
QWorkerAllocQueue
(
&
pMgmt
->
fetchPool
,
pVnode
,
(
FItem
)
vmProcessFetchQueue
);
pVnode
->
pFetchQ
=
t
WWorkerAllocQueue
(
&
pMgmt
->
fetchPool
,
pVnode
,
(
FItems
)
vmProcessFetchQueue
);
if
(
pVnode
->
pWriteQ
==
NULL
||
pVnode
->
pSyncQ
==
NULL
||
pVnode
->
pApplyQ
==
NULL
||
pVnode
->
pQueryQ
==
NULL
||
if
(
pVnode
->
pWriteQ
==
NULL
||
pVnode
->
pSyncQ
==
NULL
||
pVnode
->
pApplyQ
==
NULL
||
pVnode
->
pQueryQ
==
NULL
||
pVnode
->
pFetchQ
==
NULL
)
{
pVnode
->
pFetchQ
==
NULL
)
{
...
@@ -250,7 +255,11 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
...
@@ -250,7 +255,11 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
return
-
1
;
return
-
1
;
}
}
dDebug
(
"vgId:%d, queue is alloced"
,
pVnode
->
vgId
);
dDebug
(
"vgId:%d, write-queue:%p is alloced"
,
pVnode
->
vgId
,
pVnode
->
pWriteQ
);
dDebug
(
"vgId:%d, sync-queue:%p is alloced"
,
pVnode
->
vgId
,
pVnode
->
pSyncQ
);
dDebug
(
"vgId:%d, apply-queue:%p is alloced"
,
pVnode
->
vgId
,
pVnode
->
pApplyQ
);
dDebug
(
"vgId:%d, query-queue:%p is alloced"
,
pVnode
->
vgId
,
pVnode
->
pQueryQ
);
dDebug
(
"vgId:%d, fetch-queue:%p is alloced"
,
pVnode
->
vgId
,
pVnode
->
pFetchQ
);
return
0
;
return
0
;
}
}
...
@@ -259,7 +268,7 @@ void vmFreeQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
...
@@ -259,7 +268,7 @@ void vmFreeQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
tWWorkerFreeQueue
(
&
pMgmt
->
applyPool
,
pVnode
->
pApplyQ
);
tWWorkerFreeQueue
(
&
pMgmt
->
applyPool
,
pVnode
->
pApplyQ
);
tWWorkerFreeQueue
(
&
pMgmt
->
syncPool
,
pVnode
->
pSyncQ
);
tWWorkerFreeQueue
(
&
pMgmt
->
syncPool
,
pVnode
->
pSyncQ
);
tQWorkerFreeQueue
(
&
pMgmt
->
queryPool
,
pVnode
->
pQueryQ
);
tQWorkerFreeQueue
(
&
pMgmt
->
queryPool
,
pVnode
->
pQueryQ
);
t
Q
WorkerFreeQueue
(
&
pMgmt
->
fetchPool
,
pVnode
->
pFetchQ
);
t
W
WorkerFreeQueue
(
&
pMgmt
->
fetchPool
,
pVnode
->
pFetchQ
);
pVnode
->
pWriteQ
=
NULL
;
pVnode
->
pWriteQ
=
NULL
;
pVnode
->
pSyncQ
=
NULL
;
pVnode
->
pSyncQ
=
NULL
;
pVnode
->
pApplyQ
=
NULL
;
pVnode
->
pApplyQ
=
NULL
;
...
@@ -275,11 +284,10 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
...
@@ -275,11 +284,10 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
pQPool
->
max
=
tsNumOfVnodeQueryThreads
;
pQPool
->
max
=
tsNumOfVnodeQueryThreads
;
if
(
tQWorkerInit
(
pQPool
)
!=
0
)
return
-
1
;
if
(
tQWorkerInit
(
pQPool
)
!=
0
)
return
-
1
;
S
Q
WorkerPool
*
pFPool
=
&
pMgmt
->
fetchPool
;
S
W
WorkerPool
*
pFPool
=
&
pMgmt
->
fetchPool
;
pFPool
->
name
=
"vnode-fetch"
;
pFPool
->
name
=
"vnode-fetch"
;
pFPool
->
min
=
tsNumOfVnodeFetchThreads
;
pFPool
->
max
=
tsNumOfVnodeFetchThreads
;
pFPool
->
max
=
tsNumOfVnodeFetchThreads
;
if
(
t
Q
WorkerInit
(
pFPool
)
!=
0
)
return
-
1
;
if
(
t
W
WorkerInit
(
pFPool
)
!=
0
)
return
-
1
;
SWWorkerPool
*
pWPool
=
&
pMgmt
->
writePool
;
SWWorkerPool
*
pWPool
=
&
pMgmt
->
writePool
;
pWPool
->
name
=
"vnode-write"
;
pWPool
->
name
=
"vnode-write"
;
...
@@ -325,6 +333,6 @@ void vmStopWorker(SVnodeMgmt *pMgmt) {
...
@@ -325,6 +333,6 @@ void vmStopWorker(SVnodeMgmt *pMgmt) {
tWWorkerCleanup
(
&
pMgmt
->
applyPool
);
tWWorkerCleanup
(
&
pMgmt
->
applyPool
);
tWWorkerCleanup
(
&
pMgmt
->
syncPool
);
tWWorkerCleanup
(
&
pMgmt
->
syncPool
);
tQWorkerCleanup
(
&
pMgmt
->
queryPool
);
tQWorkerCleanup
(
&
pMgmt
->
queryPool
);
t
Q
WorkerCleanup
(
&
pMgmt
->
fetchPool
);
t
W
WorkerCleanup
(
&
pMgmt
->
fetchPool
);
dDebug
(
"vnode workers are closed"
);
dDebug
(
"vnode workers are closed"
);
}
}
source/dnode/vnode/src/tq/tq.c
浏览文件 @
148e3a5f
...
@@ -244,6 +244,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -244,6 +244,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
STqOffsetVal
reqOffset
=
pReq
->
reqOffset
;
STqOffsetVal
reqOffset
=
pReq
->
reqOffset
;
STqOffsetVal
fetchOffsetNew
;
STqOffsetVal
fetchOffsetNew
;
// todo
workerId
=
0
;
// 1.find handle
// 1.find handle
STqHandle
*
pHandle
=
taosHashGet
(
pTq
->
handles
,
pReq
->
subKey
,
strlen
(
pReq
->
subKey
));
STqHandle
*
pHandle
=
taosHashGet
(
pTq
->
handles
,
pReq
->
subKey
,
strlen
(
pReq
->
subKey
));
/*ASSERT(pHandle);*/
/*ASSERT(pHandle);*/
...
...
source/libs/sync/src/syncIO.c
浏览文件 @
148e3a5f
...
@@ -242,13 +242,13 @@ static int32_t syncIOStopInternal(SSyncIO *io) {
...
@@ -242,13 +242,13 @@ static int32_t syncIOStopInternal(SSyncIO *io) {
}
}
static
void
*
syncIOConsumerFunc
(
void
*
param
)
{
static
void
*
syncIOConsumerFunc
(
void
*
param
)
{
SSyncIO
*
io
=
param
;
SSyncIO
*
io
=
param
;
STaosQall
*
qall
;
STaosQall
*
qall
=
taosAllocateQall
()
;
SRpcMsg
*
pRpcMsg
,
rpcMsg
;
SRpcMsg
*
pRpcMsg
,
rpcMsg
;
qall
=
taosAllocateQall
()
;
SQueueInfo
qinfo
=
{
0
}
;
while
(
1
)
{
while
(
1
)
{
int
numOfMsgs
=
taosReadAllQitemsFromQset
(
io
->
pQset
,
qall
,
NULL
,
NULL
);
int
numOfMsgs
=
taosReadAllQitemsFromQset
(
io
->
pQset
,
qall
,
&
qinfo
);
sTrace
(
"syncIOConsumerFunc %d msgs are received"
,
numOfMsgs
);
sTrace
(
"syncIOConsumerFunc %d msgs are received"
,
numOfMsgs
);
if
(
numOfMsgs
<=
0
)
{
if
(
numOfMsgs
<=
0
)
{
break
;
break
;
...
@@ -369,6 +369,8 @@ static void *syncIOConsumerFunc(void *param) {
...
@@ -369,6 +369,8 @@ static void *syncIOConsumerFunc(void *param) {
taosFreeQitem
(
pRpcMsg
);
taosFreeQitem
(
pRpcMsg
);
}
}
taosUpdateItemSize
(
qinfo
.
queue
,
numOfMsgs
);
}
}
taosFreeQall
(
qall
);
taosFreeQall
(
qall
);
...
...
source/libs/transport/test/pushServer.c
浏览文件 @
148e3a5f
...
@@ -31,12 +31,12 @@ void processShellMsg() {
...
@@ -31,12 +31,12 @@ void processShellMsg() {
STaosQall
*
qall
;
STaosQall
*
qall
;
SRpcMsg
*
pRpcMsg
,
rpcMsg
;
SRpcMsg
*
pRpcMsg
,
rpcMsg
;
int
type
;
int
type
;
void
*
pvnode
;
SQueueInfo
qinfo
=
{
0
}
;
qall
=
taosAllocateQall
();
qall
=
taosAllocateQall
();
while
(
1
)
{
while
(
1
)
{
int
numOfMsgs
=
taosReadAllQitemsFromQset
(
qset
,
qall
,
&
pvnode
,
NULL
);
int
numOfMsgs
=
taosReadAllQitemsFromQset
(
qset
,
qall
,
&
qinfo
);
tDebug
(
"%d shell msgs are received"
,
numOfMsgs
);
tDebug
(
"%d shell msgs are received"
,
numOfMsgs
);
if
(
numOfMsgs
<=
0
)
break
;
if
(
numOfMsgs
<=
0
)
break
;
...
@@ -86,6 +86,8 @@ void processShellMsg() {
...
@@ -86,6 +86,8 @@ void processShellMsg() {
rpcSendResponse
(
&
nRpcMsg
);
rpcSendResponse
(
&
nRpcMsg
);
}
}
}
}
taosUpdateItemSize
(
qinfo
.
queue
,
numOfMsgs
);
}
}
taosFreeQall
(
qall
);
taosFreeQall
(
qall
);
...
...
source/util/src/tqueue.c
浏览文件 @
148e3a5f
...
@@ -115,7 +115,7 @@ bool taosQueueEmpty(STaosQueue *queue) {
...
@@ -115,7 +115,7 @@ bool taosQueueEmpty(STaosQueue *queue) {
bool
empty
=
false
;
bool
empty
=
false
;
taosThreadMutexLock
(
&
queue
->
mutex
);
taosThreadMutexLock
(
&
queue
->
mutex
);
if
(
queue
->
head
==
NULL
&&
queue
->
tail
==
NULL
)
{
if
(
queue
->
head
==
NULL
&&
queue
->
tail
==
NULL
&&
queue
->
numOfItems
==
0
&&
queue
->
memOfItems
==
0
)
{
empty
=
true
;
empty
=
true
;
}
}
taosThreadMutexUnlock
(
&
queue
->
mutex
);
taosThreadMutexUnlock
(
&
queue
->
mutex
);
...
@@ -123,6 +123,14 @@ bool taosQueueEmpty(STaosQueue *queue) {
...
@@ -123,6 +123,14 @@ bool taosQueueEmpty(STaosQueue *queue) {
return
empty
;
return
empty
;
}
}
void
taosUpdateItemSize
(
STaosQueue
*
queue
,
int32_t
items
)
{
if
(
queue
==
NULL
)
return
;
taosThreadMutexLock
(
&
queue
->
mutex
);
queue
->
numOfItems
-=
items
;
taosThreadMutexUnlock
(
&
queue
->
mutex
);
}
int32_t
taosQueueItemSize
(
STaosQueue
*
queue
)
{
int32_t
taosQueueItemSize
(
STaosQueue
*
queue
)
{
if
(
queue
==
NULL
)
return
0
;
if
(
queue
==
NULL
)
return
0
;
...
@@ -257,6 +265,7 @@ int32_t taosReadAllQitems(STaosQueue *queue, STaosQall *qall) {
...
@@ -257,6 +265,7 @@ int32_t taosReadAllQitems(STaosQueue *queue, STaosQall *qall) {
queue
->
tail
=
NULL
;
queue
->
tail
=
NULL
;
queue
->
numOfItems
=
0
;
queue
->
numOfItems
=
0
;
queue
->
memOfItems
=
0
;
queue
->
memOfItems
=
0
;
uTrace
(
"read %d items from queue:%p, items:%d mem:%"
PRId64
,
code
,
queue
,
queue
->
numOfItems
,
queue
->
memOfItems
);
if
(
queue
->
qset
)
atomic_sub_fetch_32
(
&
queue
->
qset
->
numOfItems
,
qall
->
numOfItems
);
if
(
queue
->
qset
)
atomic_sub_fetch_32
(
&
queue
->
qset
->
numOfItems
,
qall
->
numOfItems
);
}
}
...
@@ -397,7 +406,7 @@ void taosRemoveFromQset(STaosQset *qset, STaosQueue *queue) {
...
@@ -397,7 +406,7 @@ void taosRemoveFromQset(STaosQset *qset, STaosQueue *queue) {
int32_t
taosGetQueueNumber
(
STaosQset
*
qset
)
{
return
qset
->
numOfQueues
;
}
int32_t
taosGetQueueNumber
(
STaosQset
*
qset
)
{
return
qset
->
numOfQueues
;
}
int32_t
taosReadQitemFromQset
(
STaosQset
*
qset
,
void
**
ppItem
,
int64_t
*
ts
,
void
**
ahandle
,
FItem
*
itemFp
)
{
int32_t
taosReadQitemFromQset
(
STaosQset
*
qset
,
void
**
ppItem
,
SQueueInfo
*
qinfo
)
{
STaosQnode
*
pNode
=
NULL
;
STaosQnode
*
pNode
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -417,17 +426,18 @@ int32_t taosReadQitemFromQset(STaosQset *qset, void **ppItem, int64_t *ts, void
...
@@ -417,17 +426,18 @@ int32_t taosReadQitemFromQset(STaosQset *qset, void **ppItem, int64_t *ts, void
if
(
queue
->
head
)
{
if
(
queue
->
head
)
{
pNode
=
queue
->
head
;
pNode
=
queue
->
head
;
*
ppItem
=
pNode
->
item
;
*
ppItem
=
pNode
->
item
;
if
(
ahandle
)
*
ahandle
=
queue
->
ahandle
;
qinfo
->
ahandle
=
queue
->
ahandle
;
if
(
itemFp
)
*
itemFp
=
queue
->
itemFp
;
qinfo
->
fp
=
queue
->
itemFp
;
if
(
ts
)
*
ts
=
pNode
->
timestamp
;
qinfo
->
queue
=
queue
;
qinfo
->
timestamp
=
pNode
->
timestamp
;
queue
->
head
=
pNode
->
next
;
queue
->
head
=
pNode
->
next
;
if
(
queue
->
head
==
NULL
)
queue
->
tail
=
NULL
;
if
(
queue
->
head
==
NULL
)
queue
->
tail
=
NULL
;
queue
->
numOfItems
--
;
//
queue->numOfItems--;
queue
->
memOfItems
-=
pNode
->
size
;
queue
->
memOfItems
-=
pNode
->
size
;
atomic_sub_fetch_32
(
&
qset
->
numOfItems
,
1
);
atomic_sub_fetch_32
(
&
qset
->
numOfItems
,
1
);
code
=
1
;
code
=
1
;
uTrace
(
"item:%p is read out from queue:%p, items:%d mem:%"
PRId64
,
*
ppItem
,
queue
,
queue
->
numOfItems
,
uTrace
(
"item:%p is read out from queue:%p, items:%d mem:%"
PRId64
,
*
ppItem
,
queue
,
queue
->
numOfItems
-
1
,
queue
->
memOfItems
);
queue
->
memOfItems
);
}
}
...
@@ -440,7 +450,7 @@ int32_t taosReadQitemFromQset(STaosQset *qset, void **ppItem, int64_t *ts, void
...
@@ -440,7 +450,7 @@ int32_t taosReadQitemFromQset(STaosQset *qset, void **ppItem, int64_t *ts, void
return
code
;
return
code
;
}
}
int32_t
taosReadAllQitemsFromQset
(
STaosQset
*
qset
,
STaosQall
*
qall
,
void
**
ahandle
,
FItems
*
itemsFp
)
{
int32_t
taosReadAllQitemsFromQset
(
STaosQset
*
qset
,
STaosQall
*
qall
,
SQueueInfo
*
qinfo
)
{
STaosQueue
*
queue
;
STaosQueue
*
queue
;
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -461,13 +471,16 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, void **ahand
...
@@ -461,13 +471,16 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, void **ahand
qall
->
start
=
queue
->
head
;
qall
->
start
=
queue
->
head
;
qall
->
numOfItems
=
queue
->
numOfItems
;
qall
->
numOfItems
=
queue
->
numOfItems
;
code
=
qall
->
numOfItems
;
code
=
qall
->
numOfItems
;
if
(
ahandle
)
*
ahandle
=
queue
->
ahandle
;
qinfo
->
ahandle
=
queue
->
ahandle
;
if
(
itemsFp
)
*
itemsFp
=
queue
->
itemsFp
;
qinfo
->
fp
=
queue
->
itemsFp
;
qinfo
->
queue
=
queue
;
queue
->
head
=
NULL
;
queue
->
head
=
NULL
;
queue
->
tail
=
NULL
;
queue
->
tail
=
NULL
;
queue
->
numOfItems
=
0
;
//
queue->numOfItems = 0;
queue
->
memOfItems
=
0
;
queue
->
memOfItems
=
0
;
uTrace
(
"read %d items from queue:%p, items:0 mem:%"
PRId64
,
code
,
queue
,
queue
->
memOfItems
);
atomic_sub_fetch_32
(
&
qset
->
numOfItems
,
qall
->
numOfItems
);
atomic_sub_fetch_32
(
&
qset
->
numOfItems
,
qall
->
numOfItems
);
for
(
int32_t
j
=
1
;
j
<
qall
->
numOfItems
;
++
j
)
{
for
(
int32_t
j
=
1
;
j
<
qall
->
numOfItems
;
++
j
)
{
tsem_wait
(
&
qset
->
sem
);
tsem_wait
(
&
qset
->
sem
);
...
...
source/util/src/tworker.c
浏览文件 @
148e3a5f
...
@@ -70,27 +70,27 @@ void tQWorkerCleanup(SQWorkerPool *pool) {
...
@@ -70,27 +70,27 @@ void tQWorkerCleanup(SQWorkerPool *pool) {
static
void
*
tQWorkerThreadFp
(
SQWorker
*
worker
)
{
static
void
*
tQWorkerThreadFp
(
SQWorker
*
worker
)
{
SQWorkerPool
*
pool
=
worker
->
pool
;
SQWorkerPool
*
pool
=
worker
->
pool
;
FItem
fp
=
NULL
;
SQueueInfo
qinfo
=
{
0
};
void
*
msg
=
NULL
;
void
*
msg
=
NULL
;
int32_t
code
=
0
;
void
*
ahandle
=
NULL
;
int32_t
code
=
0
;
int64_t
ts
=
0
;
taosBlockSIGPIPE
();
taosBlockSIGPIPE
();
setThreadName
(
pool
->
name
);
setThreadName
(
pool
->
name
);
uDebug
(
"worker:%s:%d is running"
,
pool
->
name
,
worker
->
id
);
uDebug
(
"worker:%s:%d is running"
,
pool
->
name
,
worker
->
id
);
while
(
1
)
{
while
(
1
)
{
if
(
taosReadQitemFromQset
(
pool
->
qset
,
(
void
**
)
&
msg
,
&
ts
,
&
ahandle
,
&
fp
)
==
0
)
{
if
(
taosReadQitemFromQset
(
pool
->
qset
,
(
void
**
)
&
msg
,
&
qinfo
)
==
0
)
{
uDebug
(
"worker:%s:%d qset:%p, got no message and exiting"
,
pool
->
name
,
worker
->
id
,
pool
->
qset
);
uDebug
(
"worker:%s:%d qset:%p, got no message and exiting"
,
pool
->
name
,
worker
->
id
,
pool
->
qset
);
break
;
break
;
}
}
if
(
fp
!=
NULL
)
{
if
(
qinfo
.
fp
!=
NULL
)
{
SQueueInfo
info
=
{.
ahandle
=
ahandle
,
.
workerId
=
worker
->
id
,
.
threadNum
=
pool
->
num
,
.
timestamp
=
ts
};
qinfo
.
workerId
=
worker
->
id
;
(
*
fp
)(
&
info
,
msg
);
qinfo
.
threadNum
=
pool
->
num
;
(
*
((
FItem
)
qinfo
.
fp
))(
&
qinfo
,
msg
);
}
}
taosUpdateItemSize
(
qinfo
.
queue
,
1
);
}
}
return
NULL
;
return
NULL
;
...
@@ -195,28 +195,28 @@ void tWWorkerCleanup(SWWorkerPool *pool) {
...
@@ -195,28 +195,28 @@ void tWWorkerCleanup(SWWorkerPool *pool) {
static
void
*
tWWorkerThreadFp
(
SWWorker
*
worker
)
{
static
void
*
tWWorkerThreadFp
(
SWWorker
*
worker
)
{
SWWorkerPool
*
pool
=
worker
->
pool
;
SWWorkerPool
*
pool
=
worker
->
pool
;
FItems
fp
=
NULL
;
SQueueInfo
qinfo
=
{
0
};
void
*
msg
=
NULL
;
void
*
msg
=
NULL
;
int32_t
code
=
0
;
void
*
ahandle
=
NULL
;
int32_t
numOfMsgs
=
0
;
int32_t
numOfMsgs
=
0
;
int32_t
qtype
=
0
;
taosBlockSIGPIPE
();
taosBlockSIGPIPE
();
setThreadName
(
pool
->
name
);
setThreadName
(
pool
->
name
);
uDebug
(
"worker:%s:%d is running"
,
pool
->
name
,
worker
->
id
);
uDebug
(
"worker:%s:%d is running"
,
pool
->
name
,
worker
->
id
);
while
(
1
)
{
while
(
1
)
{
numOfMsgs
=
taosReadAllQitemsFromQset
(
worker
->
qset
,
worker
->
qall
,
&
ahandle
,
&
fp
);
numOfMsgs
=
taosReadAllQitemsFromQset
(
worker
->
qset
,
worker
->
qall
,
&
qinfo
);
if
(
numOfMsgs
==
0
)
{
if
(
numOfMsgs
==
0
)
{
uDebug
(
"worker:%s:%d qset:%p, got no message and exiting"
,
pool
->
name
,
worker
->
id
,
worker
->
qset
);
uDebug
(
"worker:%s:%d qset:%p, got no message and exiting"
,
pool
->
name
,
worker
->
id
,
worker
->
qset
);
break
;
break
;
}
}
if
(
fp
!=
NULL
)
{
if
(
qinfo
.
fp
!=
NULL
)
{
SQueueInfo
info
=
{.
ahandle
=
ahandle
,
.
workerId
=
worker
->
id
,
.
threadNum
=
pool
->
num
};
qinfo
.
workerId
=
worker
->
id
;
(
*
fp
)(
&
info
,
worker
->
qall
,
numOfMsgs
);
qinfo
.
threadNum
=
pool
->
num
;
(
*
((
FItems
)
qinfo
.
fp
))(
&
qinfo
,
worker
->
qall
,
numOfMsgs
);
}
}
taosUpdateItemSize
(
qinfo
.
queue
,
numOfMsgs
);
}
}
return
NULL
;
return
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录