Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9e71d03d
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看板
提交
9e71d03d
编写于
5月 18, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(tmq): commit when consumer_close called
上级
8a2772f8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
20 deletion
+46
-20
source/client/src/tmq.c
source/client/src/tmq.c
+30
-9
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+16
-11
未找到文件。
source/client/src/tmq.c
浏览文件 @
9e71d03d
...
@@ -119,7 +119,7 @@ enum {
...
@@ -119,7 +119,7 @@ enum {
enum
{
enum
{
TMQ_CONSUMER_STATUS__INIT
=
0
,
TMQ_CONSUMER_STATUS__INIT
=
0
,
TMQ_CONSUMER_STATUS__READY
,
TMQ_CONSUMER_STATUS__READY
,
TMQ_CONSUMER_STATUS__NO_TOPIC
,
/*TMQ_CONSUMER_STATUS__NO_TOPIC,*/
};
};
enum
{
enum
{
...
@@ -753,12 +753,19 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
...
@@ -753,12 +753,19 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
}
}
tmq_resp_err_t
tmq_subscribe
(
tmq_t
*
tmq
,
const
tmq_list_t
*
topic_list
)
{
tmq_resp_err_t
tmq_subscribe
(
tmq_t
*
tmq
,
const
tmq_list_t
*
topic_list
)
{
if
(
topic_list
==
NULL
)
{
return
TMQ_RESP_ERR__FAIL
;
}
const
SArray
*
container
=
&
topic_list
->
container
;
const
SArray
*
container
=
&
topic_list
->
container
;
int32_t
sz
=
taosArrayGetSize
(
container
);
int32_t
sz
=
taosArrayGetSize
(
container
);
void
*
buf
=
NULL
;
void
*
buf
=
NULL
;
SCMSubscribeReq
req
=
{
0
};
SCMSubscribeReq
req
=
{
0
};
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
if
(
sz
==
0
)
{
return
TMQ_RESP_ERR__FAIL
;
}
req
.
consumerId
=
tmq
->
consumerId
;
req
.
consumerId
=
tmq
->
consumerId
;
tstrncpy
(
req
.
cgroup
,
tmq
->
groupId
,
TSDB_CGROUP_LEN
);
tstrncpy
(
req
.
cgroup
,
tmq
->
groupId
,
TSDB_CGROUP_LEN
);
req
.
topicNames
=
taosArrayInit
(
sz
,
sizeof
(
void
*
));
req
.
topicNames
=
taosArrayInit
(
sz
,
sizeof
(
void
*
));
...
@@ -830,10 +837,12 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
...
@@ -830,10 +837,12 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
}
}
// init hb timer
// init hb timer
tmq
->
hbTimer
=
taosTmrStart
(
tmqAssignDelayedHbTask
,
1000
,
tmq
,
tmqMgmt
.
timer
);
if
(
tmq
->
hbTimer
==
NULL
)
{
tmq
->
hbTimer
=
taosTmrStart
(
tmqAssignDelayedHbTask
,
1000
,
tmq
,
tmqMgmt
.
timer
);
}
// init auto commit timer
// init auto commit timer
if
(
tmq
->
autoCommit
)
{
if
(
tmq
->
autoCommit
&&
tmq
->
commitTimer
==
NULL
)
{
tmq
->
commitTimer
=
taosTmrStart
(
tmqAssignDelayedCommitTask
,
tmq
->
autoCommitInterval
,
tmq
,
tmqMgmt
.
timer
);
tmq
->
commitTimer
=
taosTmrStart
(
tmqAssignDelayedCommitTask
,
tmq
->
autoCommitInterval
,
tmq
,
tmqMgmt
.
timer
);
}
}
...
@@ -1074,10 +1083,13 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) {
...
@@ -1074,10 +1083,13 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) {
taosHashCleanup
(
pHash
);
taosHashCleanup
(
pHash
);
tmq
->
clientTopics
=
newTopics
;
tmq
->
clientTopics
=
newTopics
;
if
(
taosArrayGetSize
(
tmq
->
clientTopics
)
==
0
)
ASSERT
(
taosArrayGetSize
(
tmq
->
clientTopics
)
!=
0
);
atomic_store_8
(
&
tmq
->
status
,
TMQ_CONSUMER_STATUS__NO_TOPIC
);
atomic_store_8
(
&
tmq
->
status
,
TMQ_CONSUMER_STATUS__READY
);
else
atomic_store_8
(
&
tmq
->
status
,
TMQ_CONSUMER_STATUS__READY
);
/*if (taosArrayGetSize(tmq->clientTopics) == 0)*/
/*atomic_store_8(&tmq->status, TMQ_CONSUMER_STATUS__NO_TOPIC);*/
/*else*/
/*atomic_store_8(&tmq->status, TMQ_CONSUMER_STATUS__READY);*/
atomic_store_32
(
&
tmq
->
epoch
,
epoch
);
atomic_store_32
(
&
tmq
->
epoch
,
epoch
);
return
set
;
return
set
;
...
@@ -1456,9 +1468,18 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t wait_time) {
...
@@ -1456,9 +1468,18 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t wait_time) {
tmq_resp_err_t
tmq_consumer_close
(
tmq_t
*
tmq
)
{
tmq_resp_err_t
tmq_consumer_close
(
tmq_t
*
tmq
)
{
if
(
tmq
->
status
==
TMQ_CONSUMER_STATUS__READY
)
{
if
(
tmq
->
status
==
TMQ_CONSUMER_STATUS__READY
)
{
tmq_list_t
*
lst
=
tmq_list_new
();
tmq_resp_err_t
rsp
=
tmq_commit_sync
(
tmq
,
NULL
);
tmq_resp_err_t
rsp
=
tmq_subscribe
(
tmq
,
lst
);
if
(
rsp
==
TMQ_RESP_ERR__SUCCESS
)
{
// TODO: free resources
return
TMQ_RESP_ERR__SUCCESS
;
}
else
{
return
TMQ_RESP_ERR__FAIL
;
}
tmq_list_t
*
lst
=
tmq_list_new
();
rsp
=
tmq_subscribe
(
tmq
,
lst
);
tmq_list_destroy
(
lst
);
tmq_list_destroy
(
lst
);
if
(
rsp
==
TMQ_RESP_ERR__SUCCESS
)
{
if
(
rsp
==
TMQ_RESP_ERR__SUCCESS
)
{
// TODO: free resources
// TODO: free resources
return
TMQ_RESP_ERR__SUCCESS
;
return
TMQ_RESP_ERR__SUCCESS
;
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
9e71d03d
...
@@ -627,21 +627,26 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
...
@@ -627,21 +627,26 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
if
(
pNewConsumer
->
updateType
==
CONSUMER_UPDATE__MODIFY
)
{
if
(
pNewConsumer
->
updateType
==
CONSUMER_UPDATE__MODIFY
)
{
ASSERT
(
taosArrayGetSize
(
pOldConsumer
->
rebNewTopics
)
==
0
);
ASSERT
(
taosArrayGetSize
(
pOldConsumer
->
rebNewTopics
)
==
0
);
ASSERT
(
taosArrayGetSize
(
pOldConsumer
->
rebRemovedTopics
)
==
0
);
ASSERT
(
taosArrayGetSize
(
pOldConsumer
->
rebRemovedTopics
)
==
0
);
SArray
*
tmp
=
pOldConsumer
->
rebNewTopics
;
pOldConsumer
->
rebNewTopics
=
pNewConsumer
->
rebNewTopics
;
pNewConsumer
->
rebNewTopics
=
tmp
;
tmp
=
pOldConsumer
->
rebRemovedTopics
;
if
(
taosArrayGetSize
(
pNewConsumer
->
rebNewTopics
)
==
0
&&
taosArrayGetSize
(
pNewConsumer
->
rebRemovedTopics
)
==
0
)
{
pOldConsumer
->
rebRemovedTopics
=
pNewConsumer
->
rebRemovedTopics
;
pOldConsumer
->
status
=
MQ_CONSUMER_STATUS__READY
;
pNewConsumer
->
rebRemovedTopics
=
tmp
;
}
else
{
SArray
*
tmp
=
pOldConsumer
->
rebNewTopics
;
pOldConsumer
->
rebNewTopics
=
pNewConsumer
->
rebNewTopics
;
pNewConsumer
->
rebNewTopics
=
tmp
;
tmp
=
pOldConsumer
->
assign
edTopics
;
tmp
=
pOldConsumer
->
rebRemov
edTopics
;
pOldConsumer
->
assignedTopics
=
pNewConsumer
->
assign
edTopics
;
pOldConsumer
->
rebRemovedTopics
=
pNewConsumer
->
rebRemov
edTopics
;
pNewConsumer
->
assign
edTopics
=
tmp
;
pNewConsumer
->
rebRemov
edTopics
=
tmp
;
pOldConsumer
->
subscribeTime
=
pNewConsumer
->
upTime
;
tmp
=
pOldConsumer
->
assignedTopics
;
pOldConsumer
->
assignedTopics
=
pNewConsumer
->
assignedTopics
;
pNewConsumer
->
assignedTopics
=
tmp
;
pOldConsumer
->
status
=
MQ_CONSUMER_STATUS__MODIFY
;
pOldConsumer
->
subscribeTime
=
pNewConsumer
->
upTime
;
pOldConsumer
->
status
=
MQ_CONSUMER_STATUS__MODIFY
;
}
}
else
if
(
pNewConsumer
->
updateType
==
CONSUMER_UPDATE__LOST
)
{
}
else
if
(
pNewConsumer
->
updateType
==
CONSUMER_UPDATE__LOST
)
{
ASSERT
(
taosArrayGetSize
(
pOldConsumer
->
rebNewTopics
)
==
0
);
ASSERT
(
taosArrayGetSize
(
pOldConsumer
->
rebNewTopics
)
==
0
);
ASSERT
(
taosArrayGetSize
(
pOldConsumer
->
rebRemovedTopics
)
==
0
);
ASSERT
(
taosArrayGetSize
(
pOldConsumer
->
rebRemovedTopics
)
==
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录