Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d85f0f56
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1181
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d85f0f56
编写于
5月 12, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:[TD-24111]avoid exec pHandle task in multi query thread
上级
35fcb348
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
41 addition
and
37 deletion
+41
-37
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+1
-0
source/dnode/vnode/src/tq/tqPush.c
source/dnode/vnode/src/tq/tqPush.c
+1
-0
source/dnode/vnode/src/tq/tqUtil.c
source/dnode/vnode/src/tq/tqUtil.c
+39
-37
未找到文件。
source/dnode/vnode/src/inc/tq.h
浏览文件 @
d85f0f56
...
...
@@ -102,6 +102,7 @@ typedef struct {
STqExecHandle
execHandle
;
// exec
SRpcMsg
*
msg
;
int32_t
noDataPollCnt
;
int8_t
sendRsp
;
}
STqHandle
;
typedef
struct
{
...
...
source/dnode/vnode/src/tq/tqPush.c
浏览文件 @
d85f0f56
...
...
@@ -55,6 +55,7 @@ int32_t tqRegisterPushHandle(STQ* pTq, void* handle, SRpcMsg* pMsg) {
memcpy
(
pHandle
->
msg
,
pMsg
,
sizeof
(
SRpcMsg
));
pHandle
->
msg
->
pCont
=
rpcMallocCont
(
pMsg
->
contLen
);
}
else
{
tqPushDataRsp
(
pTq
,
pHandle
);
void
*
tmp
=
pHandle
->
msg
->
pCont
;
memcpy
(
pHandle
->
msg
,
pMsg
,
sizeof
(
SRpcMsg
));
pHandle
->
msg
->
pCont
=
tmp
;
...
...
source/dnode/vnode/src/tq/tqUtil.c
浏览文件 @
d85f0f56
...
...
@@ -162,6 +162,10 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
return
0
;
}
static
bool
isHandleExecuting
(
STqHandle
*
pHandle
){
return
0
==
atomic_load_8
(
&
pHandle
->
sendRsp
);
}
static
int32_t
extractDataAndRspForNormalSubscribe
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pMsg
,
STqOffsetVal
*
pOffset
)
{
uint64_t
consumerId
=
pRequest
->
consumerId
;
...
...
@@ -177,6 +181,12 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
return
code
;
}
while
(
isHandleExecuting
(
pHandle
)){
tqInfo
(
"sub is executing, pHandle:%p"
,
pHandle
);
taosMsleep
(
5
);
}
atomic_store_8
(
&
pHandle
->
sendRsp
,
0
);
qSetTaskId
(
pHandle
->
execHandle
.
task
,
consumerId
,
pRequest
->
reqId
);
code
=
tqScanData
(
pTq
,
pHandle
,
&
dataRsp
,
pOffset
);
if
(
code
!=
0
)
{
...
...
@@ -193,6 +203,7 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
code
=
tqRegisterPushHandle
(
pTq
,
pHandle
,
pMsg
);
taosWUnLockLatch
(
&
pTq
->
lock
);
tDeleteSMqDataRsp
(
&
dataRsp
);
atomic_store_8
(
&
pHandle
->
sendRsp
,
1
);
return
code
;
}
else
{
...
...
@@ -202,7 +213,6 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
code
=
tqSendDataRsp
(
pTq
,
pMsg
,
pRequest
,
(
SMqDataRsp
*
)
&
dataRsp
,
TMQ_MSG_TYPE__POLL_RSP
);
// NOTE: this pHandle->consumerId may have been changed already.
end:
...
...
@@ -214,6 +224,8 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
// taosWUnLockLatch(&pTq->lock);
tDeleteSMqDataRsp
(
&
dataRsp
);
}
atomic_store_8
(
&
pHandle
->
sendRsp
,
1
);
return
code
;
}
...
...
@@ -232,10 +244,16 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
return
code
;
}
while
(
isHandleExecuting
(
pHandle
)){
tqInfo
(
"sub is executing, pHandle:%p"
,
pHandle
);
taosMsleep
(
5
);
}
atomic_store_8
(
&
pHandle
->
sendRsp
,
0
);
if
(
offset
->
type
!=
TMQ_OFFSET__LOG
)
{
if
(
tqScanTaosx
(
pTq
,
pHandle
,
&
taosxRsp
,
&
metaRsp
,
offset
)
<
0
)
{
tDeleteSTaosxRsp
(
&
taosxRsp
)
;
return
-
1
;
code
=
-
1
;
goto
end
;
}
if
(
metaRsp
.
metaRspLen
>
0
)
{
...
...
@@ -243,16 +261,14 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
" subkey:%s vgId:%d, send meta offset type:%d,uid:%"
PRId64
",ts:%"
PRId64
,
pRequest
->
consumerId
,
pHandle
->
subKey
,
vgId
,
metaRsp
.
rspOffset
.
type
,
metaRsp
.
rspOffset
.
uid
,
metaRsp
.
rspOffset
.
ts
);
taosMemoryFree
(
metaRsp
.
metaRsp
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
return
code
;
goto
end
;
}
tqDebug
(
"taosx poll: consumer:0x%"
PRIx64
" subkey:%s vgId:%d, send data blockNum:%d, offset type:%d,uid:%"
PRId64
",ts:%"
PRId64
,
pRequest
->
consumerId
,
pHandle
->
subKey
,
vgId
,
taosxRsp
.
blockNum
,
taosxRsp
.
rspOffset
.
type
,
taosxRsp
.
rspOffset
.
uid
,
taosxRsp
.
rspOffset
.
ts
);
if
(
taosxRsp
.
blockNum
>
0
)
{
code
=
tqSendDataRsp
(
pTq
,
pMsg
,
pRequest
,
(
SMqDataRsp
*
)
&
taosxRsp
,
TMQ_MSG_TYPE__TAOSX_RSP
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
return
code
;
goto
end
;
}
else
{
*
offset
=
taosxRsp
.
rspOffset
;
}
...
...
@@ -264,9 +280,9 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
int64_t
fetchVer
=
offset
->
version
+
1
;
pCkHead
=
taosMemoryMalloc
(
sizeof
(
SWalCkHead
)
+
2048
);
if
(
pCkHead
==
NULL
)
{
tDeleteSTaosxRsp
(
&
taosxRsp
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
code
=
-
1
;
goto
end
;
}
walSetReaderCapacity
(
pHandle
->
pWalReader
,
2048
);
int
totalRows
=
0
;
...
...
@@ -281,9 +297,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
if
(
tqFetchLog
(
pTq
,
pHandle
,
&
fetchVer
,
&
pCkHead
,
pRequest
->
reqId
)
<
0
)
{
tqOffsetResetToLog
(
&
taosxRsp
.
rspOffset
,
fetchVer
);
code
=
tqSendDataRsp
(
pTq
,
pMsg
,
pRequest
,
(
SMqDataRsp
*
)
&
taosxRsp
,
TMQ_MSG_TYPE__TAOSX_RSP
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
taosMemoryFreeClear
(
pCkHead
);
return
code
;
goto
end
;
}
SWalCont
*
pHead
=
&
pCkHead
->
head
;
...
...
@@ -295,9 +309,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
if
(
totalRows
>
0
)
{
tqOffsetResetToLog
(
&
taosxRsp
.
rspOffset
,
fetchVer
-
1
);
code
=
tqSendDataRsp
(
pTq
,
pMsg
,
pRequest
,
(
SMqDataRsp
*
)
&
taosxRsp
,
TMQ_MSG_TYPE__TAOSX_RSP
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
taosMemoryFreeClear
(
pCkHead
);
return
code
;
goto
end
;
}
tqDebug
(
"fetch meta msg, ver:%"
PRId64
", type:%s"
,
pHead
->
version
,
TMSG_INFO
(
pHead
->
msgType
));
...
...
@@ -305,17 +317,8 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
metaRsp
.
resMsgType
=
pHead
->
msgType
;
metaRsp
.
metaRspLen
=
pHead
->
bodyLen
;
metaRsp
.
metaRsp
=
pHead
->
body
;
if
(
tqSendMetaPollRsp
(
pTq
,
pMsg
,
pRequest
,
&
metaRsp
)
<
0
)
{
code
=
-
1
;
taosMemoryFreeClear
(
pCkHead
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
return
code
;
}
code
=
0
;
taosMemoryFreeClear
(
pCkHead
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
return
code
;
code
=
tqSendMetaPollRsp
(
pTq
,
pMsg
,
pRequest
,
&
metaRsp
);
goto
end
;
}
// process data
...
...
@@ -325,29 +328,28 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle,
.
ver
=
pHead
->
version
,
};
if
(
tqTaosxScanLog
(
pTq
,
pHandle
,
submit
,
&
taosxRsp
,
&
totalRows
)
<
0
)
{
tqError
(
"tmq poll: tqTaosxScanLog error %"
PRId64
", in vgId:%d, subkey %s"
,
pRequest
->
consumerId
,
vgId
,
pRequest
->
subKey
);
taosMemoryFreeClear
(
pCkHead
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
return
-
1
;
code
=
tqTaosxScanLog
(
pTq
,
pHandle
,
submit
,
&
taosxRsp
,
&
totalRows
);
if
(
code
<
0
)
{
tqError
(
"tmq poll: tqTaosxScanLog error %"
PRId64
", in vgId:%d, subkey %s"
,
pRequest
->
consumerId
,
vgId
,
pRequest
->
subKey
);
goto
end
;
}
if
(
totalRows
>=
4096
||
taosxRsp
.
createTableNum
>
0
)
{
tqOffsetResetToLog
(
&
taosxRsp
.
rspOffset
,
fetchVer
);
code
=
tqSendDataRsp
(
pTq
,
pMsg
,
pRequest
,
(
SMqDataRsp
*
)
&
taosxRsp
,
TMQ_MSG_TYPE__TAOSX_RSP
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
taosMemoryFreeClear
(
pCkHead
);
return
code
;
goto
end
;
}
else
{
fetchVer
++
;
}
}
}
end:
atomic_store_8
(
&
pHandle
->
sendRsp
,
1
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
taosMemoryFreeClear
(
pCkHead
);
return
0
;
return
code
;
}
int32_t
tqExtractDataForMq
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pMsg
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录