Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
779e35b6
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看板
提交
779e35b6
编写于
6月 16, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:drop consumer wher drop topic or group
上级
e019ed2c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
24 addition
and
18 deletion
+24
-18
source/dnode/mnode/impl/inc/mndConsumer.h
source/dnode/mnode/impl/inc/mndConsumer.h
+1
-0
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+17
-14
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+1
-4
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+5
-0
未找到文件。
source/dnode/mnode/impl/inc/mndConsumer.h
浏览文件 @
779e35b6
...
...
@@ -33,6 +33,7 @@ enum {
int32_t
mndInitConsumer
(
SMnode
*
pMnode
);
void
mndCleanupConsumer
(
SMnode
*
pMnode
);
void
mndDropConsumerFromSdb
(
SMnode
*
pMnode
,
int64_t
consumerId
);
SMqConsumerObj
*
mndAcquireConsumer
(
SMnode
*
pMnode
,
int64_t
consumerId
);
void
mndReleaseConsumer
(
SMnode
*
pMnode
,
SMqConsumerObj
*
pConsumer
);
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
779e35b6
...
...
@@ -75,6 +75,22 @@ int32_t mndInitConsumer(SMnode *pMnode) {
void
mndCleanupConsumer
(
SMnode
*
pMnode
)
{}
void
mndDropConsumerFromSdb
(
SMnode
*
pMnode
,
int64_t
consumerId
){
SMqConsumerClearMsg
*
pClearMsg
=
rpcMallocCont
(
sizeof
(
SMqConsumerClearMsg
));
if
(
pClearMsg
==
NULL
)
{
mError
(
"consumer:0x%"
PRIx64
" failed to clear consumer due to out of memory. alloc size:%d"
,
consumerId
,
(
int32_t
)
sizeof
(
SMqConsumerClearMsg
));
return
;
}
pClearMsg
->
consumerId
=
consumerId
;
SRpcMsg
rpcMsg
=
{
.
msgType
=
TDMT_MND_TMQ_LOST_CONSUMER_CLEAR
,
.
pCont
=
pClearMsg
,
.
contLen
=
sizeof
(
SMqConsumerClearMsg
)};
mInfo
(
"consumer:0x%"
PRIx64
" drop from sdb"
,
consumerId
);
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
WRITE_QUEUE
,
&
rpcMsg
);
return
;
}
bool
mndRebTryStart
()
{
int32_t
old
=
atomic_val_compare_exchange_32
(
&
mqRebInExecCnt
,
0
,
1
);
mDebug
(
"tq timer, rebalance counter old val:%d"
,
old
);
...
...
@@ -330,20 +346,7 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
}
else
if
(
status
==
MQ_CONSUMER_STATUS_LOST
)
{
// if the client is lost longer than one day, clear it. Otherwise, do nothing about the lost consumers.
if
(
hbStatus
>
MND_CONSUMER_LOST_CLEAR_THRESHOLD
||
taosArrayGetSize
(
pConsumer
->
assignedTopics
)
==
0
)
{
// clear consumer if lost a day or unsubscribe/close
SMqConsumerClearMsg
*
pClearMsg
=
rpcMallocCont
(
sizeof
(
SMqConsumerClearMsg
));
if
(
pClearMsg
==
NULL
)
{
mError
(
"consumer:0x%"
PRIx64
" failed to clear consumer due to out of memory. alloc size:%d"
,
pConsumer
->
consumerId
,
(
int32_t
)
sizeof
(
SMqConsumerClearMsg
));
continue
;
}
pClearMsg
->
consumerId
=
pConsumer
->
consumerId
;
SRpcMsg
rpcMsg
=
{
.
msgType
=
TDMT_MND_TMQ_LOST_CONSUMER_CLEAR
,
.
pCont
=
pClearMsg
,
.
contLen
=
sizeof
(
SMqConsumerClearMsg
)};
mDebug
(
"consumer:0x%"
PRIx64
" lost beyond threshold %d, clear it"
,
pConsumer
->
consumerId
,
MND_CONSUMER_LOST_CLEAR_THRESHOLD
);
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
WRITE_QUEUE
,
&
rpcMsg
);
mndDropConsumerFromSdb
(
pMnode
,
pConsumer
->
consumerId
);
}
}
else
{
// MQ_CONSUMER_STATUS_REBALANCE
taosRLockLatch
(
&
pConsumer
->
lock
);
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
779e35b6
...
...
@@ -760,10 +760,7 @@ static int32_t mndProcessDropCgroupReq(SRpcMsg *pMsg) {
}
if
(
strcmp
(
dropReq
.
cgroup
,
pConsumer
->
cgroup
)
==
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pConsumer
);
terrno
=
TSDB_CODE_MND_CGROUP_USED
;
mError
(
"cgroup:%s on topic:%s, failed to drop since %s"
,
dropReq
.
cgroup
,
dropReq
.
topic
,
terrstr
());
return
-
1
;
mndDropConsumerFromSdb
(
pMnode
,
pConsumer
->
consumerId
);
}
sdbRelease
(
pMnode
->
pSdb
,
pConsumer
);
}
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
779e35b6
...
...
@@ -697,6 +697,11 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
break
;
}
if
(
pConsumer
->
status
==
MQ_CONSUMER_STATUS_LOST
){
mndDropConsumerFromSdb
(
pMnode
,
pConsumer
->
consumerId
);
continue
;
}
int32_t
sz
=
taosArrayGetSize
(
pConsumer
->
assignedTopics
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
char
*
name
=
taosArrayGetP
(
pConsumer
->
assignedTopics
,
i
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录