Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1f973123
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1f973123
编写于
5月 08, 2023
作者:
D
dapan1121
提交者:
GitHub
5月 08, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21177 from taosdata/fix/TD-23972
fix:[TD-23972] push subscribe msg to vnode even though consumer not c…
上级
1f769366
279fe080
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
62 addition
and
54 deletion
+62
-54
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+29
-21
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+25
-32
source/dnode/vnode/src/tq/tqUtil.c
source/dnode/vnode/src/tq/tqUtil.c
+8
-1
未找到文件。
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
1f973123
...
...
@@ -133,10 +133,10 @@ static int32_t mndBuildSubChangeReq(void **pBuf, int32_t *pLen, const SMqSubscri
static
int32_t
mndPersistSubChangeVgReq
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
SMqSubscribeObj
*
pSub
,
const
SMqRebOutputVg
*
pRebVg
)
{
if
(
pRebVg
->
oldConsumerId
==
pRebVg
->
newConsumerId
)
{
terrno
=
TSDB_CODE_MND_INVALID_SUB_OPTION
;
return
-
1
;
}
//
if (pRebVg->oldConsumerId == pRebVg->newConsumerId) {
//
terrno = TSDB_CODE_MND_INVALID_SUB_OPTION;
//
return -1;
//
}
void
*
buf
;
int32_t
tlen
;
...
...
@@ -269,6 +269,18 @@ static void addUnassignedVgroups(SMqRebOutputObj *pOutput, SHashObj *pHash) {
}
}
static
void
putNoTransferToOutput
(
SMqRebOutputObj
*
pOutput
,
SMqConsumerEp
*
pConsumerEp
){
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pConsumerEp
->
vgs
);
i
++
){
SMqVgEp
*
pVgEp
=
(
SMqVgEp
*
)
taosArrayGetP
(
pConsumerEp
->
vgs
,
i
);
SMqRebOutputVg
outputVg
=
{
.
oldConsumerId
=
pConsumerEp
->
consumerId
,
.
newConsumerId
=
pConsumerEp
->
consumerId
,
.
pVgEp
=
pVgEp
,
};
taosArrayPush
(
pOutput
->
rebVgs
,
&
outputVg
);
}
}
static
void
transferVgroupsForConsumers
(
SMqRebOutputObj
*
pOutput
,
SHashObj
*
pHash
,
int32_t
minVgCnt
,
int32_t
imbConsumerNum
)
{
const
char
*
pSubKey
=
pOutput
->
pSub
->
key
;
...
...
@@ -290,24 +302,19 @@ static void transferVgroupsForConsumers(SMqRebOutputObj *pOutput, SHashObj *pHas
taosArrayPush
(
pOutput
->
modifyConsumers
,
&
pConsumerEp
->
consumerId
);
if
(
consumerVgNum
>
minVgCnt
)
{
if
(
imbCnt
<
imbConsumerNum
)
{
if
(
consumerVgNum
==
minVgCnt
+
1
)
{
imbCnt
++
;
continue
;
}
else
{
// pop until equal minVg + 1
while
(
taosArrayGetSize
(
pConsumerEp
->
vgs
)
>
minVgCnt
+
1
)
{
SMqVgEp
*
pVgEp
=
*
(
SMqVgEp
**
)
taosArrayPop
(
pConsumerEp
->
vgs
);
SMqRebOutputVg
outputVg
=
{
.
oldConsumerId
=
pConsumerEp
->
consumerId
,
.
newConsumerId
=
-
1
,
.
pVgEp
=
pVgEp
,
};
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
outputVg
,
sizeof
(
SMqRebOutputVg
));
mInfo
(
"sub:%s mq rebalance remove vgId:%d from consumer:0x%"
PRIx64
",(first scan)"
,
pSubKey
,
pVgEp
->
vgId
,
pConsumerEp
->
consumerId
);
}
imbCnt
++
;
// pop until equal minVg + 1
while
(
taosArrayGetSize
(
pConsumerEp
->
vgs
)
>
minVgCnt
+
1
)
{
SMqVgEp
*
pVgEp
=
*
(
SMqVgEp
**
)
taosArrayPop
(
pConsumerEp
->
vgs
);
SMqRebOutputVg
outputVg
=
{
.
oldConsumerId
=
pConsumerEp
->
consumerId
,
.
newConsumerId
=
-
1
,
.
pVgEp
=
pVgEp
,
};
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
outputVg
,
sizeof
(
SMqRebOutputVg
));
mInfo
(
"sub:%s mq rebalance remove vgId:%d from consumer:0x%"
PRIx64
",(first scan)"
,
pSubKey
,
pVgEp
->
vgId
,
pConsumerEp
->
consumerId
);
}
imbCnt
++
;
}
else
{
// all the remain consumers should only have the number of vgroups, which is equalled to the value of minVg
while
(
taosArrayGetSize
(
pConsumerEp
->
vgs
)
>
minVgCnt
)
{
...
...
@@ -323,6 +330,7 @@ static void transferVgroupsForConsumers(SMqRebOutputObj *pOutput, SHashObj *pHas
}
}
}
putNoTransferToOutput
(
pOutput
,
pConsumerEp
);
}
}
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
1f973123
...
...
@@ -445,6 +445,7 @@ int32_t tqProcessDelCheckInfoReq(STQ* pTq, int64_t sversion, char* msg, int32_t
}
int32_t
tqProcessSubscribeReq
(
STQ
*
pTq
,
int64_t
sversion
,
char
*
msg
,
int32_t
msgLen
)
{
int
ret
=
0
;
SMqRebVgReq
req
=
{
0
};
tDecodeSMqRebVgReq
(
msg
,
&
req
);
...
...
@@ -463,8 +464,7 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
if
(
req
.
newConsumerId
==
-
1
)
{
tqError
(
"vgId:%d, tq invalid re-balance request, new consumerId %"
PRId64
""
,
req
.
vgId
,
req
.
newConsumerId
);
taosMemoryFree
(
req
.
qmsg
);
return
0
;
goto
end
;
}
STqHandle
tqHandle
=
{
0
};
...
...
@@ -481,8 +481,8 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
// TODO version should be assigned and refed during preprocess
SWalRef
*
pRef
=
walRefCommittedVer
(
pVnode
->
pWal
);
if
(
pRef
==
NULL
)
{
taosMemoryFree
(
req
.
qmsg
)
;
return
-
1
;
ret
=
-
1
;
goto
end
;
}
int64_t
ver
=
pRef
->
refVer
;
...
...
@@ -534,49 +534,42 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
taosHashPut
(
pTq
->
pHandle
,
req
.
subKey
,
strlen
(
req
.
subKey
),
pHandle
,
sizeof
(
STqHandle
));
tqDebug
(
"try to persist handle %s consumer:0x%"
PRIx64
" , old consumer:0x%"
PRIx64
,
req
.
subKey
,
pHandle
->
consumerId
,
oldConsumerId
);
if
(
tqMetaSaveHandle
(
pTq
,
req
.
subKey
,
pHandle
)
<
0
)
{
taosMemoryFree
(
req
.
qmsg
);
return
-
1
;
}
ret
=
tqMetaSaveHandle
(
pTq
,
req
.
subKey
,
pHandle
);
goto
end
;
}
else
{
if
(
pHandle
->
consumerId
==
req
.
newConsumerId
)
{
// do nothing
tqInfo
(
"vgId:%d consumer:0x%"
PRIx64
" remains, no switch occurs"
,
req
.
vgId
,
req
.
newConsumerId
);
atomic_store_32
(
&
pHandle
->
epoch
,
-
1
);
atomic_add_fetch_32
(
&
pHandle
->
epoch
,
1
);
taosMemoryFree
(
req
.
qmsg
);
return
tqMetaSaveHandle
(
pTq
,
req
.
subKey
,
pHandle
);
}
else
{
tqInfo
(
"vgId:%d switch consumer from Id:0x%"
PRIx64
" to Id:0x%"
PRIx64
,
req
.
vgId
,
pHandle
->
consumerId
,
req
.
newConsumerId
);
// kill executing task
qTaskInfo_t
pTaskInfo
=
pHandle
->
execHandle
.
task
;
if
(
pTaskInfo
!=
NULL
)
{
qKillTask
(
pTaskInfo
,
TSDB_CODE_SUCCESS
);
}
taosWLockLatch
(
&
pTq
->
lock
);
atomic_store_64
(
&
pHandle
->
consumerId
,
req
.
newConsumerId
);
atomic_store_32
(
&
pHandle
->
epoch
,
0
);
}
// kill executing task
qTaskInfo_t
pTaskInfo
=
pHandle
->
execHandle
.
task
;
if
(
pTaskInfo
!=
NULL
)
{
qKillTask
(
pTaskInfo
,
TSDB_CODE_SUCCESS
);
}
// remove if it has been register in the push manager, and return one empty block to consumer
tqUnregisterPushHandle
(
pTq
,
pHandle
);
atomic_store_64
(
&
pHandle
->
consumerId
,
req
.
newConsumerId
);
taosWLockLatch
(
&
pTq
->
lock
);
// remove if it has been register in the push manager, and return one empty block to consumer
tqUnregisterPushHandle
(
pTq
,
pHandle
);
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
qStreamCloseTsdbReader
(
pTaskInfo
);
}
taosWUnLockLatch
(
&
pTq
->
lock
);
if
(
tqMetaSaveHandle
(
pTq
,
req
.
subKey
,
pHandle
)
<
0
)
{
taosMemoryFree
(
req
.
qmsg
);
return
-
1
;
}
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
qStreamCloseTsdbReader
(
pTaskInfo
);
}
taosWUnLockLatch
(
&
pTq
->
lock
);
ret
=
tqMetaSaveHandle
(
pTq
,
req
.
subKey
,
pHandle
);
goto
end
;
}
end:
taosMemoryFree
(
req
.
qmsg
);
return
0
;
return
ret
;
}
int32_t
tqExpandTask
(
STQ
*
pTq
,
SStreamTask
*
pTask
,
int64_t
ver
)
{
...
...
source/dnode/vnode/src/tq/tqUtil.c
浏览文件 @
1f973123
...
...
@@ -165,12 +165,19 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
SRpcMsg
*
pMsg
,
STqOffsetVal
*
pOffset
)
{
uint64_t
consumerId
=
pRequest
->
consumerId
;
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
int
code
=
0
;
SMqDataRsp
dataRsp
=
{
0
};
tqInitDataRsp
(
&
dataRsp
,
pRequest
,
pHandle
->
execHandle
.
subType
);
qTaskInfo_t
task
=
pHandle
->
execHandle
.
task
;
if
(
qTaskIsExecuting
(
task
)){
code
=
tqSendDataRsp
(
pTq
,
pMsg
,
pRequest
,
&
dataRsp
,
TMQ_MSG_TYPE__POLL_RSP
);
tDeleteSMqDataRsp
(
&
dataRsp
);
return
code
;
}
qSetTaskId
(
pHandle
->
execHandle
.
task
,
consumerId
,
pRequest
->
reqId
);
int
code
=
tqScanData
(
pTq
,
pHandle
,
&
dataRsp
,
pOffset
);
code
=
tqScanData
(
pTq
,
pHandle
,
&
dataRsp
,
pOffset
);
if
(
code
!=
0
)
{
goto
end
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录