Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2939e17a
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看板
未验证
提交
2939e17a
编写于
5月 27, 2022
作者:
L
Liu Jicong
提交者:
GitHub
5月 27, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13065 from taosdata/feature/stream
feat(tmq): drop cgroup
上级
40d99ea4
d6094a43
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
99 addition
and
2 deletion
+99
-2
include/common/tmsg.h
include/common/tmsg.h
+4
-0
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-0
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-0
source/dnode/mnode/impl/inc/mndOffset.h
source/dnode/mnode/impl/inc/mndOffset.h
+1
-0
source/dnode/mnode/impl/inc/mndSubscribe.h
source/dnode/mnode/impl/inc/mndSubscribe.h
+1
-0
source/dnode/mnode/impl/src/mndOffset.c
source/dnode/mnode/impl/src/mndOffset.c
+35
-1
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+55
-1
未找到文件。
include/common/tmsg.h
浏览文件 @
2939e17a
...
...
@@ -1664,6 +1664,10 @@ typedef struct {
int32_t
tSerializeSMDropCgroupReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropCgroupReq
*
pReq
);
int32_t
tDeserializeSMDropCgroupReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropCgroupReq
*
pReq
);
typedef
struct
{
int8_t
reserved
;
}
SMDropCgroupRsp
;
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
int8_t
alterType
;
...
...
include/common/tmsgdef.h
浏览文件 @
2939e17a
...
...
@@ -151,6 +151,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_CONSUMER_LOST
,
"mnode-mq-consumer-lost"
,
SMqConsumerLostMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_CONSUMER_RECOVER
,
"mnode-mq-consumer-recover"
,
SMqConsumerRecoverMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_DO_REBALANCE
,
"mnode-mq-do-rebalance"
,
SMqDoRebalanceMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_DROP_CGROUP
,
"mnode-mq-drop-cgroup"
,
SMqDropCGroupReq
,
SMqDropCGroupRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_COMMIT_OFFSET
,
"mnode-mq-commit-offset"
,
SMqCMCommitOffsetReq
,
SMqCMCommitOffsetRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_STREAM
,
"mnode-create-stream"
,
SCMCreateStreamReq
,
SCMCreateStreamRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_STREAM
,
"mnode-alter-stream"
,
NULL
,
NULL
)
...
...
include/util/taoserror.h
浏览文件 @
2939e17a
...
...
@@ -268,6 +268,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_OFFSET_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03E9)
#define TSDB_CODE_MND_CONSUMER_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x03EA)
#define TSDB_CODE_MND_TOPIC_SUBSCRIBED TAOS_DEF_ERROR_CODE(0, 0x03EB)
#define TSDB_CODE_MND_CGROUP_USED TAOS_DEF_ERROR_CODE(0, 0x03EC)
// mnode-stream
#define TSDB_CODE_MND_STREAM_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03F0)
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
2939e17a
...
...
@@ -94,6 +94,7 @@ typedef enum {
TRN_TYPE_ALTER_STREAM
=
1027
,
TRN_TYPE_CONSUMER_LOST
=
1028
,
TRN_TYPE_CONSUMER_RECOVER
=
1029
,
TRN_TYPE_DROP_CGROUP
=
1030
,
TRN_TYPE_BASIC_SCOPE_END
,
TRN_TYPE_GLOBAL_SCOPE
=
2000
,
...
...
source/dnode/mnode/impl/inc/mndOffset.h
浏览文件 @
2939e17a
...
...
@@ -39,6 +39,7 @@ static FORCE_INLINE int32_t mndMakePartitionKey(char *key, const char *cgroup, c
int32_t
mndDropOffsetByDB
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
);
int32_t
mndDropOffsetByTopic
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
char
*
topic
);
int32_t
mndDropOffsetBySubKey
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
char
*
subKey
);
bool
mndOffsetFromTopic
(
SMqOffsetObj
*
pOffset
,
const
char
*
topic
);
...
...
source/dnode/mnode/impl/inc/mndSubscribe.h
浏览文件 @
2939e17a
...
...
@@ -33,6 +33,7 @@ int32_t mndMakeSubscribeKey(char *key, const char *cgroup, const char *topicName
int32_t
mndDropSubByDB
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
);
int32_t
mndDropSubByTopic
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
char
*
topic
);
int32_t
mndSetDropSubCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SMqSubscribeObj
*
pSub
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndOffset.c
浏览文件 @
2939e17a
...
...
@@ -58,6 +58,12 @@ bool mndOffsetFromTopic(SMqOffsetObj *pOffset, const char *topic) {
return
false
;
}
bool
mndOffsetFromSubKey
(
SMqOffsetObj
*
pOffset
,
const
char
*
subKey
)
{
int32_t
i
=
0
;
while
(
pOffset
->
key
[
i
]
!=
':'
)
i
++
;
if
(
strcmp
(
&
pOffset
->
key
[
i
+
1
],
subKey
)
==
0
)
return
true
;
return
false
;
}
SSdbRaw
*
mndOffsetActionEncode
(
SMqOffsetObj
*
pOffset
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
void
*
buf
=
NULL
;
...
...
@@ -303,7 +309,35 @@ int32_t mndDropOffsetByTopic(SMnode *pMnode, STrans *pTrans, const char *topic)
continue
;
}
if
(
mndSetDropOffsetRedoLogs
(
pMnode
,
pTrans
,
pOffset
)
<
0
)
{
if
(
mndSetDropOffsetCommitLogs
(
pMnode
,
pTrans
,
pOffset
)
<
0
)
{
sdbRelease
(
pSdb
,
pOffset
);
goto
END
;
}
sdbRelease
(
pSdb
,
pOffset
);
}
code
=
0
;
END:
return
code
;
}
int32_t
mndDropOffsetBySubKey
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
char
*
subKey
)
{
int32_t
code
=
-
1
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
SMqOffsetObj
*
pOffset
=
NULL
;
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_OFFSET
,
pIter
,
(
void
**
)
&
pOffset
);
if
(
pIter
==
NULL
)
break
;
if
(
!
mndOffsetFromSubKey
(
pOffset
,
subKey
))
{
sdbRelease
(
pSdb
,
pOffset
);
continue
;
}
if
(
mndSetDropOffsetCommitLogs
(
pMnode
,
pTrans
,
pOffset
)
<
0
)
{
sdbRelease
(
pSdb
,
pOffset
);
goto
END
;
}
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
2939e17a
...
...
@@ -42,6 +42,7 @@ static int32_t mndSubActionDelete(SSdb *pSdb, SMqSubscribeObj *);
static
int32_t
mndSubActionUpdate
(
SSdb
*
pSdb
,
SMqSubscribeObj
*
pOldSub
,
SMqSubscribeObj
*
pNewSub
);
static
int32_t
mndProcessRebalanceReq
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessDropCgroupReq
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessSubscribeInternalRsp
(
SRpcMsg
*
pMsg
);
static
int32_t
mndRetrieveSubscribe
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
...
...
@@ -75,6 +76,8 @@ int32_t mndInitSubscribe(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_VND_MQ_VG_CHANGE_RSP
,
mndProcessSubscribeInternalRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_MQ_VG_DELETE_RSP
,
mndProcessSubscribeInternalRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_MQ_DO_REBALANCE
,
mndProcessRebalanceReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_MQ_DO_REBALANCE
,
mndProcessRebalanceReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_MQ_DROP_CGROUP
,
mndProcessDropCgroupReq
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_SUBSCRIPTIONS
,
mndRetrieveSubscribe
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_TOPICS
,
mndCancelGetNextSubscribe
);
...
...
@@ -581,6 +584,57 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) {
return
0
;
}
static
int32_t
mndProcessDropCgroupReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
/*SSdb *pSdb = pMnode->pSdb;*/
SMDropCgroupReq
dropReq
=
{
0
};
if
(
tDeserializeSMDropCgroupReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
dropReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
SMqSubscribeObj
*
pSub
=
mndAcquireSubscribe
(
pMnode
,
dropReq
.
cgroup
,
dropReq
.
topic
);
if
(
pSub
==
NULL
)
{
if
(
dropReq
.
igNotExists
)
{
mDebug
(
"cgroup:%s on topic:%s, not exist, ignore not exist is set"
,
dropReq
.
cgroup
,
dropReq
.
topic
);
return
0
;
}
else
{
terrno
=
TSDB_CODE_MND_SUBSCRIBE_NOT_EXIST
;
mError
(
"topic:%s, cgroup:%s, failed to drop since %s"
,
dropReq
.
topic
,
dropReq
.
cgroup
,
terrstr
());
return
-
1
;
}
}
if
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
0
)
{
terrno
=
TSDB_CODE_MND_CGROUP_USED
;
mError
(
"cgroup:%s on topic:%s, failed to drop since %s"
,
dropReq
.
cgroup
,
dropReq
.
topic
,
terrstr
());
return
-
1
;
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_DROP_CGROUP
,
pReq
);
if
(
pTrans
==
NULL
)
{
mError
(
"cgroup: %s on topic:%s, failed to drop since %s"
,
dropReq
.
cgroup
,
dropReq
.
topic
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to drop cgroup:%s on topic %s"
,
pTrans
->
id
,
dropReq
.
cgroup
,
dropReq
.
topic
);
if
(
mndDropOffsetBySubKey
(
pMnode
,
pTrans
,
pSub
->
key
)
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
if
(
mndSetDropSubCommitLogs
(
pMnode
,
pTrans
,
pSub
)
<
0
)
{
mError
(
"cgroup %s on topic:%s, failed to drop since %s"
,
dropReq
.
cgroup
,
dropReq
.
topic
,
terrstr
());
return
-
1
;
}
mndReleaseSubscribe
(
pMnode
,
pSub
);
return
TSDB_CODE_ACTION_IN_PROGRESS
;
}
void
mndCleanupSubscribe
(
SMnode
*
pMnode
)
{}
static
SSdbRaw
*
mndSubActionEncode
(
SMqSubscribeObj
*
pSub
)
{
...
...
@@ -735,7 +789,7 @@ static int32_t mndSetDropSubRedoLogs(SMnode *pMnode, STrans *pTrans, SMqSubscrib
return
0
;
}
static
int32_t
mndSetDropSubCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SMqSubscribeObj
*
pSub
)
{
int32_t
mndSetDropSubCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SMqSubscribeObj
*
pSub
)
{
SSdbRaw
*
pCommitRaw
=
mndSubActionEncode
(
pSub
);
if
(
pCommitRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录