Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a22047ec
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看板
提交
a22047ec
编写于
2月 18, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add reset offset
上级
7bbca5e4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
89 addition
and
12 deletion
+89
-12
include/common/tmsg.h
include/common/tmsg.h
+7
-3
source/client/src/tmq.c
source/client/src/tmq.c
+1
-1
source/common/src/tmsg.c
source/common/src/tmsg.c
+33
-1
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+8
-7
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+40
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
a22047ec
...
...
@@ -1751,6 +1751,11 @@ typedef struct {
char
cgroup
[
TSDB_CONSUMER_GROUP_LEN
];
}
SMqOffset
;
typedef
struct
{
int32_t
vgId
;
SArray
*
offsets
;
// SArray<SMqOffset>
}
SMqVgOffsets
;
typedef
struct
{
int32_t
num
;
SMqOffset
*
offsets
;
...
...
@@ -1761,8 +1766,8 @@ typedef struct {
}
SMqCMResetOffsetRsp
;
typedef
struct
{
int
32_t
num
;
SMq
Offset
*
offsets
;
int
64_t
leftForVer
;
SMq
VgOffsets
offsets
;
}
SMqMVResetOffsetReq
;
typedef
struct
{
...
...
@@ -1773,7 +1778,6 @@ int32_t tEncodeSMqOffset(SCoder* encoder, const SMqOffset* pOffset);
int32_t
tDecodeSMqOffset
(
SCoder
*
decoder
,
SMqOffset
*
pOffset
);
int32_t
tEncodeSMqCMResetOffsetReq
(
SCoder
*
encoder
,
const
SMqCMResetOffsetReq
*
pReq
);
int32_t
tDecodeSMqCMResetOffsetReq
(
SCoder
*
decoder
,
SMqCMResetOffsetReq
*
pReq
);
int32_t
tEncodeSMqMVResetOffsetReq
(
SCoder
*
encoder
,
const
SMqMVResetOffsetReq
*
pReq
);
int32_t
tDecodeSMqMVResetOffsetReq
(
SCoder
*
decoder
,
SMqMVResetOffsetReq
*
pReq
);
...
...
source/client/src/tmq.c
浏览文件 @
a22047ec
...
...
@@ -269,7 +269,7 @@ tmq_resp_err_t tmq_reset_offset(tmq_t* tmq, const tmq_topic_vgroup_list_t* offse
tsem_wait
(
&
param
.
rspSem
);
tsem_destroy
(
&
param
.
rspSem
);
return
TMQ_RESP_ERR__SUCCESS
;
return
param
.
rspErr
;
}
tmq_resp_err_t
tmq_subscribe
(
tmq_t
*
tmq
,
tmq_list_t
*
topic_list
)
{
...
...
source/common/src/tmsg.c
浏览文件 @
a22047ec
...
...
@@ -2323,6 +2323,34 @@ int32_t tDecodeSMqOffset(SCoder *decoder, SMqOffset *pOffset) {
return
0
;
}
int32_t
tEncodeSMqVgOffsets
(
SCoder
*
encoder
,
const
SMqVgOffsets
*
pOffsets
)
{
if
(
tStartEncode
(
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pOffsets
->
vgId
)
<
0
)
return
-
1
;
int32_t
sz
=
taosArrayGetSize
(
pOffsets
->
offsets
);
if
(
tEncodeI32
(
encoder
,
sz
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMqOffset
*
offset
=
taosArrayGet
(
pOffsets
->
offsets
,
i
);
if
(
tEncodeSMqOffset
(
encoder
,
offset
)
<
0
)
return
-
1
;
}
tEndEncode
(
encoder
);
return
encoder
->
pos
;
}
int32_t
tDecodeSMqVgOffsets
(
SCoder
*
decoder
,
SMqVgOffsets
*
pOffsets
)
{
int32_t
sz
;
if
(
tStartDecode
(
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pOffsets
->
vgId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
sz
)
<
0
)
return
-
1
;
pOffsets
->
offsets
=
taosArrayInit
(
sz
,
sizeof
(
SMqOffset
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMqOffset
offset
;
if
(
tDecodeSMqOffset
(
decoder
,
&
offset
)
<
0
)
return
-
1
;
taosArrayPush
(
pOffsets
->
offsets
,
&
offset
);
}
tEndDecode
(
decoder
);
return
0
;
}
int32_t
tEncodeSMqCMResetOffsetReq
(
SCoder
*
encoder
,
const
SMqCMResetOffsetReq
*
pReq
)
{
if
(
tStartEncode
(
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
encoder
,
pReq
->
num
)
<
0
)
return
-
1
;
...
...
@@ -2334,17 +2362,20 @@ int32_t tEncodeSMqCMResetOffsetReq(SCoder *encoder, const SMqCMResetOffsetReq *p
}
int32_t
tDecodeSMqCMResetOffsetReq
(
SCoder
*
decoder
,
SMqCMResetOffsetReq
*
pReq
)
{
if
(
tStartDecode
(
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
decoder
,
&
pReq
->
num
)
<
0
)
return
-
1
;
pReq
->
offsets
=
TCODER_MALLOC
(
pReq
->
num
*
sizeof
(
SMqOffset
),
decoder
);
if
(
pReq
->
offsets
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pReq
->
num
;
i
++
)
{
tDecodeSMqOffset
(
decoder
,
&
pReq
->
offsets
[
i
]);
}
tEndDecode
(
decoder
);
return
0
;
}
#if 0
int32_t tEncodeSMqMVResetOffsetReq(SCoder *encoder, const SMqMVResetOffsetReq *pReq) {
if
(
tEncodeI
32
(
encoder
,
pReq
->
num
)
<
0
)
return
-
1
;
if (tEncodeI
64(encoder, pReq->leftForVer
) < 0) return -1;
for (int32_t i = 0; i < pReq->num; i++) {
tEncodeSMqOffset(encoder, &pReq->offsets[i]);
}
...
...
@@ -2360,3 +2391,4 @@ int32_t tDecodeSMqMVResetOffsetReq(SCoder *decoder, SMqMVResetOffsetReq *pReq) {
}
return 0;
}
#endif
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
a22047ec
...
...
@@ -256,6 +256,7 @@ typedef struct {
int8_t
quorum
;
int8_t
update
;
int8_t
cacheLastRow
;
int8_t
streamMode
;
}
SDbCfg
;
typedef
struct
{
...
...
@@ -423,9 +424,9 @@ typedef struct {
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
];
int32_t
status
;
int32_t
vgNum
;
SArray
*
consumers
;
// SArray<SMqSubConsumer>
SArray
*
lostConsumers
;
// SArray<SMqSubConsumer>
SArray
*
unassignedVg
;
// SArray<SMqConsumerEp>
SArray
*
consumers
;
// SArray<SMqSubConsumer>
SArray
*
lostConsumers
;
// SArray<SMqSubConsumer>
SArray
*
unassignedVg
;
// SArray<SMqConsumerEp>
}
SMqSubscribeObj
;
static
FORCE_INLINE
SMqSubscribeObj
*
tNewSubscribeObj
()
{
...
...
@@ -539,13 +540,13 @@ static FORCE_INLINE void* tDecodeSubscribeObj(void* buf, SMqSubscribeObj* pSub)
static
FORCE_INLINE
void
tDeleteSMqSubscribeObj
(
SMqSubscribeObj
*
pSub
)
{
if
(
pSub
->
consumers
)
{
taosArrayDestroyEx
(
pSub
->
consumers
,
(
void
(
*
)(
void
*
))
tDeleteSMqSubConsumer
);
//taosArrayDestroy(pSub->consumers);
//
taosArrayDestroy(pSub->consumers);
pSub
->
consumers
=
NULL
;
}
if
(
pSub
->
unassignedVg
)
{
taosArrayDestroyEx
(
pSub
->
unassignedVg
,
(
void
(
*
)(
void
*
))
tDeleteSMqConsumerEp
);
//taosArrayDestroy(pSub->unassignedVg);
//
taosArrayDestroy(pSub->unassignedVg);
pSub
->
unassignedVg
=
NULL
;
}
}
...
...
@@ -570,8 +571,8 @@ typedef struct {
int64_t
connId
;
SRWLatch
lock
;
char
cgroup
[
TSDB_CONSUMER_GROUP_LEN
];
SArray
*
currentTopics
;
// SArray<char*>
SArray
*
recentRemovedTopics
;
// SArray<char*>
SArray
*
currentTopics
;
// SArray<char*>
SArray
*
recentRemovedTopics
;
// SArray<char*>
int32_t
epoch
;
// stat
int64_t
pollCnt
;
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
a22047ec
...
...
@@ -53,6 +53,7 @@ static int32_t mndProcessSubscribeInternalRsp(SMnodeMsg *pMsg);
static
int32_t
mndProcessMqTimerMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessGetSubEpReq
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessDoRebalanceMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessResetOffsetReq
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndPersistMqSetConnReq
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
SMqTopicObj
*
pTopic
,
const
char
*
cgroup
,
const
SMqConsumerEp
*
pConsumerEp
);
...
...
@@ -204,6 +205,45 @@ static int32_t mndPersistCancelConnReq(SMnode *pMnode, STrans *pTrans, const SMq
return
0
;
}
#if 0
static int32_t mndProcessResetOffsetReq(SMnodeMsg *pMsg) {
SMnode *pMnode = pMsg->pMnode;
uint8_t *str = pMsg->rpcMsg.pCont;
SMqCMResetOffsetReq req;
SCoder decoder;
tCoderInit(&decoder, TD_LITTLE_ENDIAN, str, pMsg->rpcMsg.contLen, TD_DECODER);
tDecodeSMqCMResetOffsetReq(&decoder, &req);
SHashObj *pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
if (pHash == NULL) {
return -1;
}
for (int32_t i = 0; i < req.num; i++) {
SMqOffset *pOffset = &req.offsets[i];
SMqVgOffsets *pVgOffset = taosHashGet(pHash, &pOffset->vgId, sizeof(int32_t));
if (pVgOffset == NULL) {
pVgOffset = malloc(sizeof(SMqVgOffsets));
if (pVgOffset == NULL) {
return -1;
}
pVgOffset->offsets = taosArrayInit(0, sizeof(void *));
taosArrayPush(pVgOffset->offsets, &pOffset);
}
taosHashPut(pHash, &pOffset->vgId, sizeof(int32_t), &pVgOffset, sizeof(void *));
}
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg);
if (pTrans == NULL) {
mError("mq-reset-offset: failed since %s", terrstr());
return -1;
}
return 0;
}
#endif
static
int32_t
mndProcessGetSubEpReq
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMqCMGetSubEpReq
*
pReq
=
(
SMqCMGetSubEpReq
*
)
pMsg
->
rpcMsg
.
pCont
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录