Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4b7c88bc
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看板
提交
4b7c88bc
编写于
2月 22, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: do some internal refactor.
上级
37fea8cf
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
15 deletion
+17
-15
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+17
-15
未找到文件。
source/client/src/clientTmq.c
浏览文件 @
4b7c88bc
...
@@ -1080,7 +1080,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
...
@@ -1080,7 +1080,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
SCMSubscribeReq
req
=
{
0
};
SCMSubscribeReq
req
=
{
0
};
int32_t
code
=
0
;
int32_t
code
=
0
;
tscDebug
(
"consumer:0x%"
PRIx64
"
tmq subscribe start, numOfTopic %d
"
,
tmq
->
consumerId
,
sz
);
tscDebug
(
"consumer:0x%"
PRIx64
"
subscribe %d topics
"
,
tmq
->
consumerId
,
sz
);
req
.
consumerId
=
tmq
->
consumerId
;
req
.
consumerId
=
tmq
->
consumerId
;
tstrncpy
(
req
.
clientId
,
tmq
->
clientId
,
256
);
tstrncpy
(
req
.
clientId
,
tmq
->
clientId
,
256
);
...
@@ -1103,7 +1103,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
...
@@ -1103,7 +1103,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
}
}
tNameExtractFullName
(
&
name
,
topicFName
);
tNameExtractFullName
(
&
name
,
topicFName
);
tscDebug
(
"consumer:0x%"
PRIx64
" subscribe topic:
%s"
,
tmq
->
consumerId
,
topicFName
);
tscDebug
(
"consumer:0x%"
PRIx64
" subscribe topic:%s"
,
tmq
->
consumerId
,
topicFName
);
taosArrayPush
(
req
.
topicNames
,
&
topicFName
);
taosArrayPush
(
req
.
topicNames
,
&
topicFName
);
}
}
...
@@ -1774,6 +1774,8 @@ int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* pReset)
...
@@ -1774,6 +1774,8 @@ int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* pReset)
}
}
void
*
tmqHandleAllRsp
(
tmq_t
*
tmq
,
int64_t
timeout
,
bool
pollIfReset
)
{
void
*
tmqHandleAllRsp
(
tmq_t
*
tmq
,
int64_t
timeout
,
bool
pollIfReset
)
{
tscDebug
(
"consumer:0x%"
PRIx64
" start to handle the rsp"
,
tmq
->
consumerId
);
while
(
1
)
{
while
(
1
)
{
SMqRspWrapper
*
rspWrapper
=
NULL
;
SMqRspWrapper
*
rspWrapper
=
NULL
;
taosGetQitem
(
tmq
->
qall
,
(
void
**
)
&
rspWrapper
);
taosGetQitem
(
tmq
->
qall
,
(
void
**
)
&
rspWrapper
);
...
@@ -1783,20 +1785,17 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
...
@@ -1783,20 +1785,17 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
taosGetQitem
(
tmq
->
qall
,
(
void
**
)
&
rspWrapper
);
taosGetQitem
(
tmq
->
qall
,
(
void
**
)
&
rspWrapper
);
if
(
rspWrapper
==
NULL
)
{
if
(
rspWrapper
==
NULL
)
{
/*tscDebug("consumer %" PRId64 " mqueue empty", tmq->consumerId);*/
return
NULL
;
return
NULL
;
}
}
}
}
tscDebug
(
"consumer:0x%"
PRIx64
" handle rsp %p"
,
tmq
->
consumerId
,
rspWrapper
);
if
(
rspWrapper
->
tmqRspType
==
TMQ_MSG_TYPE__END_RSP
)
{
if
(
rspWrapper
->
tmqRspType
==
TMQ_MSG_TYPE__END_RSP
)
{
taosFreeQitem
(
rspWrapper
);
taosFreeQitem
(
rspWrapper
);
terrno
=
TSDB_CODE_TQ_NO_COMMITTED_OFFSET
;
terrno
=
TSDB_CODE_TQ_NO_COMMITTED_OFFSET
;
return
NULL
;
return
NULL
;
}
else
if
(
rspWrapper
->
tmqRspType
==
TMQ_MSG_TYPE__POLL_RSP
)
{
}
else
if
(
rspWrapper
->
tmqRspType
==
TMQ_MSG_TYPE__POLL_RSP
)
{
SMqPollRspWrapper
*
pollRspWrapper
=
(
SMqPollRspWrapper
*
)
rspWrapper
;
SMqPollRspWrapper
*
pollRspWrapper
=
(
SMqPollRspWrapper
*
)
rspWrapper
;
tscDebug
(
"consumer:0x%"
PRIx64
"
actual
process poll rsp"
,
tmq
->
consumerId
);
tscDebug
(
"consumer:0x%"
PRIx64
" process poll rsp"
,
tmq
->
consumerId
);
/*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/
/*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/
int32_t
consumerEpoch
=
atomic_load_32
(
&
tmq
->
epoch
);
int32_t
consumerEpoch
=
atomic_load_32
(
&
tmq
->
epoch
);
if
(
pollRspWrapper
->
dataRsp
.
head
.
epoch
==
consumerEpoch
)
{
if
(
pollRspWrapper
->
dataRsp
.
head
.
epoch
==
consumerEpoch
)
{
...
@@ -1823,6 +1822,9 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
...
@@ -1823,6 +1822,9 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
}
else
if
(
rspWrapper
->
tmqRspType
==
TMQ_MSG_TYPE__POLL_META_RSP
)
{
}
else
if
(
rspWrapper
->
tmqRspType
==
TMQ_MSG_TYPE__POLL_META_RSP
)
{
SMqPollRspWrapper
*
pollRspWrapper
=
(
SMqPollRspWrapper
*
)
rspWrapper
;
SMqPollRspWrapper
*
pollRspWrapper
=
(
SMqPollRspWrapper
*
)
rspWrapper
;
int32_t
consumerEpoch
=
atomic_load_32
(
&
tmq
->
epoch
);
int32_t
consumerEpoch
=
atomic_load_32
(
&
tmq
->
epoch
);
tscDebug
(
"consumer:0x%"
PRIx64
" process meta rsp"
,
tmq
->
consumerId
);
if
(
pollRspWrapper
->
metaRsp
.
head
.
epoch
==
consumerEpoch
)
{
if
(
pollRspWrapper
->
metaRsp
.
head
.
epoch
==
consumerEpoch
)
{
SMqClientVg
*
pVg
=
pollRspWrapper
->
vgHandle
;
SMqClientVg
*
pVg
=
pollRspWrapper
->
vgHandle
;
/*printf("vgId:%d, offset %" PRId64 " up to %" PRId64 "\n", pVg->vgId, pVg->currentOffset,
/*printf("vgId:%d, offset %" PRId64 " up to %" PRId64 "\n", pVg->vgId, pVg->currentOffset,
...
@@ -1887,7 +1889,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
...
@@ -1887,7 +1889,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
void
*
rspObj
;
void
*
rspObj
;
int64_t
startTime
=
taosGetTimestampMs
();
int64_t
startTime
=
taosGetTimestampMs
();
tscDebug
(
"consumer:0x%"
PRIx64
"
, start
poll at %"
PRId64
,
tmq
->
consumerId
,
startTime
);
tscDebug
(
"consumer:0x%"
PRIx64
"
start to
poll at %"
PRId64
,
tmq
->
consumerId
,
startTime
);
#if 0
#if 0
tmqHandleAllDelayedTask(tmq);
tmqHandleAllDelayedTask(tmq);
...
@@ -1900,7 +1902,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
...
@@ -1900,7 +1902,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
// in no topic status, delayed task also need to be processed
// in no topic status, delayed task also need to be processed
if
(
atomic_load_8
(
&
tmq
->
status
)
==
TMQ_CONSUMER_STATUS__INIT
)
{
if
(
atomic_load_8
(
&
tmq
->
status
)
==
TMQ_CONSUMER_STATUS__INIT
)
{
tscDebug
(
"consumer:0x%"
PRIx64
"
,
poll return since consumer is init"
,
tmq
->
consumerId
);
tscDebug
(
"consumer:0x%"
PRIx64
" poll return since consumer is init"
,
tmq
->
consumerId
);
return
NULL
;
return
NULL
;
}
}
...
@@ -1926,25 +1928,25 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
...
@@ -1926,25 +1928,25 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
rspObj
=
tmqHandleAllRsp
(
tmq
,
timeout
,
false
);
rspObj
=
tmqHandleAllRsp
(
tmq
,
timeout
,
false
);
if
(
rspObj
)
{
if
(
rspObj
)
{
tscDebug
(
"consumer:0x%"
PRIx64
"
,
return rsp %p"
,
tmq
->
consumerId
,
rspObj
);
tscDebug
(
"consumer:0x%"
PRIx64
" return rsp %p"
,
tmq
->
consumerId
,
rspObj
);
return
(
TAOS_RES
*
)
rspObj
;
return
(
TAOS_RES
*
)
rspObj
;
}
else
if
(
terrno
==
TSDB_CODE_TQ_NO_COMMITTED_OFFSET
)
{
}
else
if
(
terrno
==
TSDB_CODE_TQ_NO_COMMITTED_OFFSET
)
{
tscDebug
(
"consumer:0x%"
PRIx64
"
,
return null since no committed offset"
,
tmq
->
consumerId
);
tscDebug
(
"consumer:0x%"
PRIx64
" return null since no committed offset"
,
tmq
->
consumerId
);
return
NULL
;
return
NULL
;
}
}
if
(
timeout
!=
-
1
)
{
if
(
timeout
!=
-
1
)
{
int64_t
currentTime
=
taosGetTimestampMs
();
int64_t
currentTime
=
taosGetTimestampMs
();
int64_t
pas
sedTime
=
currentTime
-
startTime
;
int64_t
elap
sedTime
=
currentTime
-
startTime
;
if
(
pas
sedTime
>
timeout
)
{
if
(
elap
sedTime
>
timeout
)
{
tscDebug
(
"consumer:0x%"
PRIx64
"
,
(epoch %d) timeout, no rsp, start time %"
PRId64
", current time %"
PRId64
,
tscDebug
(
"consumer:0x%"
PRIx64
" (epoch %d) timeout, no rsp, start time %"
PRId64
", current time %"
PRId64
,
tmq
->
consumerId
,
tmq
->
epoch
,
startTime
,
currentTime
);
tmq
->
consumerId
,
tmq
->
epoch
,
startTime
,
currentTime
);
return
NULL
;
return
NULL
;
}
}
/*tscInfo("consumer:0x%" PRIx64 ", (epoch %d) wait, start time %" PRId64 ", current time %" PRId64*/
/*tscInfo("consumer:0x%" PRIx64 ", (epoch %d) wait, start time %" PRId64 ", current time %" PRId64*/
/*", left time %" PRId64,*/
/*", left time %" PRId64,*/
/*tmq->consumerId, tmq->epoch, startTime, currentTime, (timeout -
pas
sedTime));*/
/*tmq->consumerId, tmq->epoch, startTime, currentTime, (timeout -
elap
sedTime));*/
tsem_timewait
(
&
tmq
->
rspSem
,
(
timeout
-
pas
sedTime
));
tsem_timewait
(
&
tmq
->
rspSem
,
(
timeout
-
elap
sedTime
));
}
else
{
}
else
{
// use tsem_timewait instead of tsem_wait to avoid unexpected stuck
// use tsem_timewait instead of tsem_wait to avoid unexpected stuck
tsem_timewait
(
&
tmq
->
rspSem
,
1000
);
tsem_timewait
(
&
tmq
->
rspSem
,
1000
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录