Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9eb15e41
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9eb15e41
编写于
5月 29, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:put poll to push manager if wal not exist when offset is latest
上级
5eb1c559
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
10 deletion
+30
-10
source/dnode/vnode/src/tq/tqUtil.c
source/dnode/vnode/src/tq/tqUtil.c
+30
-10
未找到文件。
source/dnode/vnode/src/tq/tqUtil.c
浏览文件 @
9eb15e41
...
...
@@ -87,12 +87,13 @@ static int32_t tqInitTaosxRsp(STaosxRsp* pRsp, const SMqPollReq* pReq) {
return
0
;
}
static
int32_t
extractResetOffsetVal
(
STqOffsetVal
*
pOffsetVal
,
STQ
*
pTq
,
STqHandle
*
pHandle
,
const
SMqPollReq
*
pRequest
)
{
static
int32_t
extractResetOffsetVal
(
STqOffsetVal
*
pOffsetVal
,
STQ
*
pTq
,
STqHandle
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pMsg
,
bool
*
pBlockReturned
)
{
uint64_t
consumerId
=
pRequest
->
consumerId
;
STqOffsetVal
reqOffset
=
pRequest
->
reqOffset
;
STqOffset
*
pOffset
=
tqOffsetRead
(
pTq
->
pOffsetStore
,
pRequest
->
subKey
);
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
*
pBlockReturned
=
false
;
// In this vnode, data has been polled by consumer for this topic, so let's continue from the last offset value.
if
(
pOffset
!=
NULL
)
{
*
pOffsetVal
=
pOffset
->
val
;
...
...
@@ -120,12 +121,27 @@ static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHand
}
}
else
if
(
reqOffset
.
type
==
TMQ_OFFSET__RESET_LATEST
)
{
walRefLastVer
(
pTq
->
pVnode
->
pWal
,
pHandle
->
pRef
);
tqOffsetResetToLog
(
pOffsetVal
,
pHandle
->
pRef
->
refVer
);
STqOffset
offset
=
{
0
};
strcpy
(
offset
.
subKey
,
pRequest
->
subKey
);
if
(
tqOffsetWrite
(
pTq
->
pOffsetStore
,
&
offset
)
<
0
)
{
terrno
=
TSDB_CODE_PAR_INTERNAL_ERROR
;
return
-
1
;
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
SMqDataRsp
dataRsp
=
{
0
};
tqInitDataRsp
(
&
dataRsp
,
pRequest
,
pHandle
->
execHandle
.
subType
);
tqOffsetResetToLog
(
&
dataRsp
.
rspOffset
,
pHandle
->
pRef
->
refVer
);
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
", subkey %s, vgId:%d, (latest) offset reset to %"
PRId64
,
consumerId
,
pHandle
->
subKey
,
vgId
,
dataRsp
.
rspOffset
.
version
);
int32_t
code
=
tqSendDataRsp
(
pTq
,
pMsg
,
pRequest
,
&
dataRsp
,
TMQ_MSG_TYPE__POLL_RSP
);
tDeleteSMqDataRsp
(
&
dataRsp
);
*
pBlockReturned
=
true
;
return
code
;
}
else
{
STaosxRsp
taosxRsp
=
{
0
};
tqInitTaosxRsp
(
&
taosxRsp
,
pRequest
);
tqOffsetResetToLog
(
&
taosxRsp
.
rspOffset
,
pHandle
->
pRef
->
refVer
);
int32_t
code
=
tqSendDataRsp
(
pTq
,
pMsg
,
pRequest
,
(
SMqDataRsp
*
)
&
taosxRsp
,
TMQ_MSG_TYPE__TAOSX_RSP
);
tDeleteSTaosxRsp
(
&
taosxRsp
);
*
pBlockReturned
=
true
;
return
code
;
}
}
else
if
(
reqOffset
.
type
==
TMQ_OFFSET__RESET_NONE
)
{
tqError
(
"tmq poll: subkey:%s, no offset committed for consumer:0x%"
PRIx64
" in vg %d, subkey %s, reset none failed"
,
...
...
@@ -154,8 +170,7 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle,
}
// till now, all data has been transferred to consumer, new data needs to push client once arrived.
if
(
terrno
==
TSDB_CODE_WAL_LOG_NOT_EXIST
||
(
dataRsp
.
blockNum
==
0
&&
dataRsp
.
reqOffset
.
type
==
TMQ_OFFSET__LOG
&&
dataRsp
.
reqOffset
.
version
==
dataRsp
.
rspOffset
.
version
&&
pHandle
->
consumerId
==
pRequest
->
consumerId
))
{
if
(
terrno
==
TSDB_CODE_WAL_LOG_NOT_EXIST
&&
dataRsp
.
blockNum
==
0
)
{
// lock
taosWLockLatch
(
&
pTq
->
lock
);
code
=
tqRegisterPushHandle
(
pTq
,
pHandle
,
pMsg
);
...
...
@@ -296,11 +311,16 @@ int32_t tqExtractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequ
// 1. reset the offset if needed
if
(
IS_OFFSET_RESET_TYPE
(
reqOffset
.
type
))
{
// handle the reset offset cases, according to the consumer's choice.
code
=
extractResetOffsetVal
(
&
offset
,
pTq
,
pHandle
,
pRequest
);
bool
blockReturned
=
false
;
code
=
extractResetOffsetVal
(
&
offset
,
pTq
,
pHandle
,
pRequest
,
pMsg
,
&
blockReturned
);
if
(
code
!=
0
)
{
return
code
;
}
// empty block returned, quit
if
(
blockReturned
)
{
return
0
;
}
}
else
{
// use the consumer specified offset
// the offset value can not be monotonious increase??
offset
=
reqOffset
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录