Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fe155898
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
提交
fe155898
编写于
6月 12, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:modify offset description to string
上级
5c5e76f8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
61 addition
and
34 deletion
+61
-34
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+20
-13
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+1
-1
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+3
-2
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+1
-0
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+33
-15
tests/system-test/7-tmq/checkOffsetRowParams.py
tests/system-test/7-tmq/checkOffsetRowParams.py
+3
-3
未找到文件。
source/client/src/clientTmq.c
浏览文件 @
fe155898
...
...
@@ -99,6 +99,7 @@ struct tmq_t {
// poll info
int64_t
pollCnt
;
int64_t
totalRows
;
bool
needReportOffsetRows
;
// timer
tmr_h
hbLiveTimer
;
...
...
@@ -796,20 +797,24 @@ void tmqSendHbReq(void* param, void* tmrId) {
SMqHbReq
req
=
{
0
};
req
.
consumerId
=
tmq
->
consumerId
;
req
.
epoch
=
tmq
->
epoch
;
req
.
topics
=
taosArrayInit
(
taosArrayGetSize
(
tmq
->
clientTopics
),
sizeof
(
TopicOffsetRows
));
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tmq
->
clientTopics
);
i
++
){
SMqClientTopic
*
pTopic
=
taosArrayGet
(
tmq
->
clientTopics
,
i
);
int32_t
numOfVgroups
=
taosArrayGetSize
(
pTopic
->
vgs
);
TopicOffsetRows
*
data
=
taosArrayReserve
(
req
.
topics
,
1
);
strcpy
(
data
->
topicName
,
pTopic
->
topicName
);
data
->
offsetRows
=
taosArrayInit
(
numOfVgroups
,
sizeof
(
OffsetRows
));
for
(
int
j
=
0
;
j
<
numOfVgroups
;
j
++
){
SMqClientVg
*
pVg
=
taosArrayGet
(
pTopic
->
vgs
,
j
);
OffsetRows
*
offRows
=
taosArrayReserve
(
data
->
offsetRows
,
1
);
offRows
->
vgId
=
pVg
->
vgId
;
offRows
->
rows
=
pVg
->
numOfRows
;
offRows
->
offset
=
pVg
->
offsetInfo
.
committedOffset
;
if
(
tmq
->
needReportOffsetRows
){
req
.
topics
=
taosArrayInit
(
taosArrayGetSize
(
tmq
->
clientTopics
),
sizeof
(
TopicOffsetRows
));
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tmq
->
clientTopics
);
i
++
){
SMqClientTopic
*
pTopic
=
taosArrayGet
(
tmq
->
clientTopics
,
i
);
int32_t
numOfVgroups
=
taosArrayGetSize
(
pTopic
->
vgs
);
TopicOffsetRows
*
data
=
taosArrayReserve
(
req
.
topics
,
1
);
strcpy
(
data
->
topicName
,
pTopic
->
topicName
);
data
->
offsetRows
=
taosArrayInit
(
numOfVgroups
,
sizeof
(
OffsetRows
));
for
(
int
j
=
0
;
j
<
numOfVgroups
;
j
++
){
SMqClientVg
*
pVg
=
taosArrayGet
(
pTopic
->
vgs
,
j
);
OffsetRows
*
offRows
=
taosArrayReserve
(
data
->
offsetRows
,
1
);
offRows
->
vgId
=
pVg
->
vgId
;
offRows
->
rows
=
pVg
->
numOfRows
;
offRows
->
offset
=
pVg
->
offsetInfo
.
committedOffset
;
tscDebug
(
"report offset: %d"
,
offRows
->
offset
.
type
);
}
}
tmq
->
needReportOffsetRows
=
false
;
}
int32_t
tlen
=
tSerializeSMqHbReq
(
NULL
,
0
,
&
req
);
...
...
@@ -1087,6 +1092,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
pTmq
->
status
=
TMQ_CONSUMER_STATUS__INIT
;
pTmq
->
pollCnt
=
0
;
pTmq
->
epoch
=
0
;
pTmq
->
needReportOffsetRows
=
true
;
// set conf
strcpy
(
pTmq
->
clientId
,
conf
->
clientId
);
...
...
@@ -2449,6 +2455,7 @@ int32_t tmqCommitDone(SMqCommitCbParamSet* pParamSet) {
// if no more waiting rsp
pParamSet
->
callbackFn
(
tmq
,
pParamSet
->
code
,
pParamSet
->
userParam
);
taosMemoryFree
(
pParamSet
);
tmq
->
needReportOffsetRows
=
true
;
taosReleaseRef
(
tmqMgmt
.
rsetId
,
refId
);
return
0
;
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
fe155898
...
...
@@ -163,7 +163,7 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_TMQ_DROP_TOPIC
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_TMQ_SUBSCRIBE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_TMQ_ASK_EP
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_TMQ_HB
,
mmPutMsgTo
Read
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_TMQ_HB
,
mmPutMsgTo
Write
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_TMQ_DROP_CGROUP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_TMQ_DROP_CGROUP_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_KILL_TRANS
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
fe155898
...
...
@@ -431,13 +431,14 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
mDebug
(
"heartbeat report offset rows.%s:%s"
,
pConsumer
->
cgroup
,
data
->
topicName
);
SMqSubscribeObj
*
pSub
=
mndAcquireSubscribe
(
pMnode
,
pConsumer
->
cgroup
,
data
->
topicName
);
taos
R
LockLatch
(
&
pSub
->
lock
);
taos
W
LockLatch
(
&
pSub
->
lock
);
SMqConsumerEp
*
pConsumerEp
=
taosHashGet
(
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
));
if
(
pConsumerEp
){
taosArrayDestroy
(
pConsumerEp
->
offsetRows
);
pConsumerEp
->
offsetRows
=
data
->
offsetRows
;
data
->
offsetRows
=
NULL
;
}
taos
R
UnLockLatch
(
&
pSub
->
lock
);
taos
W
UnLockLatch
(
&
pSub
->
lock
);
mndReleaseSubscribe
(
pMnode
,
pSub
);
}
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
fe155898
...
...
@@ -519,6 +519,7 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
taosHashPut
(
pSubNew
->
consumerHash
,
&
newEp
.
consumerId
,
sizeof
(
int64_t
),
&
newEp
,
sizeof
(
SMqConsumerEp
));
}
pSubNew
->
unassignedVgs
=
taosArrayDup
(
pSub
->
unassignedVgs
,
(
__array_item_dup_fn_t
)
tCloneSMqVgEp
);
pSubNew
->
offsetRows
=
taosArrayDup
(
pSub
->
offsetRows
,
NULL
);
memcpy
(
pSubNew
->
dbName
,
pSub
->
dbName
,
TSDB_DB_FNAME_LEN
);
return
pSubNew
;
}
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
fe155898
...
...
@@ -451,24 +451,42 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
taosArrayPush
(
pOutput
->
rebVgs
,
pRebOutput
);
if
(
taosHashGetSize
(
pOutput
->
pSub
->
consumerHash
)
==
0
){
// if all consumer is removed
taosArrayPush
(
pOutput
->
pSub
->
unassignedVgs
,
&
pRebOutput
->
pVgEp
);
// put all vg into unassigned
SMqSubscribeObj
*
pSub
=
mndAcquireSubscribeByKey
(
pMnode
,
pInput
->
pRebInfo
->
key
);
// put all offset rows
if
(
pSub
){
taosRLockLatch
(
&
pSub
->
lock
);
if
(
pOutput
->
pSub
->
offsetRows
==
NULL
){
pOutput
->
pSub
->
offsetRows
=
taosArrayInit
(
4
,
sizeof
(
OffsetRows
));
}
else
{
taosArrayClear
(
pOutput
->
pSub
->
offsetRows
);
}
pIter
=
NULL
;
while
(
1
){
pIter
=
taosHashIterate
(
pSub
->
consumerHash
,
pIter
);
if
(
pIter
==
NULL
)
break
;
SMqConsumerEp
*
pConsumerEp
=
(
SMqConsumerEp
*
)
pIter
;
}
}
if
(
taosHashGetSize
(
pOutput
->
pSub
->
consumerHash
)
==
0
)
{
// if all consumer is removed
SMqSubscribeObj
*
pSub
=
mndAcquireSubscribeByKey
(
pMnode
,
pInput
->
pRebInfo
->
key
);
// put all offset rows
if
(
pSub
)
{
taosRLockLatch
(
&
pSub
->
lock
);
bool
init
=
false
;
if
(
pOutput
->
pSub
->
offsetRows
==
NULL
)
{
pOutput
->
pSub
->
offsetRows
=
taosArrayInit
(
4
,
sizeof
(
OffsetRows
));
init
=
true
;
}
pIter
=
NULL
;
while
(
1
)
{
pIter
=
taosHashIterate
(
pSub
->
consumerHash
,
pIter
);
if
(
pIter
==
NULL
)
break
;
SMqConsumerEp
*
pConsumerEp
=
(
SMqConsumerEp
*
)
pIter
;
if
(
init
)
{
taosArrayAddAll
(
pOutput
->
pSub
->
offsetRows
,
pConsumerEp
->
offsetRows
);
mDebug
(
"pSub->offsetRows is init"
);
}
else
{
for
(
int
j
=
0
;
j
<
taosArrayGetSize
(
pConsumerEp
->
offsetRows
);
j
++
)
{
OffsetRows
*
d1
=
taosArrayGet
(
pConsumerEp
->
offsetRows
,
j
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pOutput
->
pSub
->
offsetRows
);
i
++
)
{
OffsetRows
*
d2
=
taosArrayGet
(
pOutput
->
pSub
->
offsetRows
,
i
);
if
(
d1
->
vgId
==
d2
->
vgId
)
{
d2
->
rows
+=
d1
->
rows
;
d2
->
offset
=
d1
->
offset
;
mDebug
(
"pSub->offsetRows add vgId:%d, after:%lld, before:%lld"
,
d2
->
vgId
,
d2
->
rows
,
d1
->
rows
);
}
}
}
}
taosRUnLockLatch
(
&
pSub
->
lock
);
mndReleaseSubscribe
(
pMnode
,
pSub
);
}
taosRUnLockLatch
(
&
pSub
->
lock
);
mndReleaseSubscribe
(
pMnode
,
pSub
);
}
}
...
...
tests/system-test/7-tmq/checkOffsetRowParams.py
浏览文件 @
fe155898
...
...
@@ -227,12 +227,11 @@ class TDTestCase:
self
.
insertConsumerInfo
(
consumerId
,
expectrowcnt
,
topicList
,
keyList
,
ifcheckdata
,
ifManualCommit
)
tdLog
.
info
(
"start consume processor"
)
pollDelay
=
1
0
pollDelay
=
2
0
showMsg
=
1
showRow
=
1
self
.
startTmqSimProcess
(
buildPath
,
cfgPath
,
pollDelay
,
parameterDict
[
"dbName"
],
showMsg
,
showRow
)
time
.
sleep
(
2
)
tdLog
.
info
(
"start show subscriptions 1"
)
while
(
1
):
tdSql
.
query
(
"show subscriptions"
)
...
...
@@ -240,10 +239,11 @@ class TDTestCase:
tdLog
.
info
(
"sleep"
)
time
.
sleep
(
1
)
elif
(
tdSql
.
queryResult
[
0
][
4
]
!=
None
):
tdSql
.
checkData
(
0
,
4
,
"offset(reset to earlieast)
"
)
# tdSql.checkData(0, 4, "earliest
")
tdSql
.
checkData
(
0
,
5
,
0
)
break
time
.
sleep
(
2
)
tdLog
.
info
(
"start insert data"
)
self
.
create_ctables
(
tdSql
,
parameterDict
[
"dbName"
],
parameterDict
[
"stbName"
],
parameterDict
[
"ctbNum"
])
self
.
insert_data
(
tdSql
,
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录