Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bae028d6
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,发现更多精彩内容 >>
未验证
提交
bae028d6
编写于
7月 31, 2023
作者:
W
wade zhang
提交者:
GitHub
7月 31, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #22230 from taosdata/mark/tmq
fix:semaphore always wait in tmq commit logic
上级
3c187414
ce7db7bf
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
62 addition
and
42 deletion
+62
-42
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+39
-29
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+3
-3
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+12
-4
source/dnode/vnode/src/tq/tqMeta.c
source/dnode/vnode/src/tq/tqMeta.c
+3
-3
source/libs/wal/src/walRead.c
source/libs/wal/src/walRead.c
+3
-3
source/util/src/terror.c
source/util/src/terror.c
+1
-0
未找到文件。
include/util/taoserror.h
浏览文件 @
bae028d6
...
...
@@ -780,6 +780,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_TMQ_INVALID_TOPIC TAOS_DEF_ERROR_CODE(0, 0x4009)
#define TSDB_CODE_TMQ_NEED_INITIALIZED TAOS_DEF_ERROR_CODE(0, 0x4010)
#define TSDB_CODE_TMQ_NO_COMMITTED TAOS_DEF_ERROR_CODE(0, 0x4011)
#define TSDB_CODE_TMQ_SAME_COMMITTED_VALUE TAOS_DEF_ERROR_CODE(0, 0x4012)
// stream
#define TSDB_CODE_STREAM_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x4100)
...
...
source/client/src/clientTmq.c
浏览文件 @
bae028d6
...
...
@@ -586,31 +586,37 @@ static int32_t asyncCommitOffset(tmq_t* tmq, char* pTopicName, int32_t vgId, STq
if
(
code
!=
0
){
goto
end
;
}
if
(
offsetVal
->
type
>
0
&&
!
tOffsetEqual
(
offsetVal
,
&
pVg
->
offsetInfo
.
committedOffset
))
{
char
offsetBuf
[
TSDB_OFFSET_LEN
]
=
{
0
};
tFormatOffset
(
offsetBuf
,
tListLen
(
offsetBuf
),
offsetVal
);
if
(
offsetVal
->
type
<=
0
)
{
code
=
TSDB_CODE_TMQ_INVALID_MSG
;
goto
end
;
}
if
(
tOffsetEqual
(
offsetVal
,
&
pVg
->
offsetInfo
.
committedOffset
)){
code
=
TSDB_CODE_TMQ_SAME_COMMITTED_VALUE
;
goto
end
;
}
char
offsetBuf
[
TSDB_OFFSET_LEN
]
=
{
0
};
tFormatOffset
(
offsetBuf
,
tListLen
(
offsetBuf
),
offsetVal
);
char
commitBuf
[
TSDB_OFFSET_LEN
]
=
{
0
};
tFormatOffset
(
commitBuf
,
tListLen
(
commitBuf
),
&
pVg
->
offsetInfo
.
committedOffset
);
char
commitBuf
[
TSDB_OFFSET_LEN
]
=
{
0
};
tFormatOffset
(
commitBuf
,
tListLen
(
commitBuf
),
&
pVg
->
offsetInfo
.
committedOffset
);
SMqCommitCbParamSet
*
pParamSet
=
prepareCommitCbParamSet
(
tmq
,
pCommitFp
,
userParam
,
0
);
if
(
pParamSet
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
end
;
}
code
=
doSendCommitMsg
(
tmq
,
pVg
->
vgId
,
&
pVg
->
epSet
,
offsetVal
,
pTopicName
,
pParamSet
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"consumer:0x%"
PRIx64
" topic:%s on vgId:%d end commit msg failed, send offset:%s committed:%s, code:%s"
,
tmq
->
consumerId
,
pTopicName
,
pVg
->
vgId
,
offsetBuf
,
commitBuf
,
tstrerror
(
terrno
));
taosMemoryFree
(
pParamSet
);
goto
end
;
}
tscInfo
(
"consumer:0x%"
PRIx64
" topic:%s on vgId:%d send commit msg success, send offset:%s committed:%s"
,
tmq
->
consumerId
,
pTopicName
,
pVg
->
vgId
,
offsetBuf
,
commitBuf
);
pVg
->
offsetInfo
.
committedOffset
=
*
offsetVal
;
SMqCommitCbParamSet
*
pParamSet
=
prepareCommitCbParamSet
(
tmq
,
pCommitFp
,
userParam
,
0
);
if
(
pParamSet
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
end
;
}
code
=
doSendCommitMsg
(
tmq
,
pVg
->
vgId
,
&
pVg
->
epSet
,
offsetVal
,
pTopicName
,
pParamSet
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"consumer:0x%"
PRIx64
" topic:%s on vgId:%d end commit msg failed, send offset:%s committed:%s, code:%s"
,
tmq
->
consumerId
,
pTopicName
,
pVg
->
vgId
,
offsetBuf
,
commitBuf
,
tstrerror
(
terrno
));
taosMemoryFree
(
pParamSet
);
goto
end
;
}
tscInfo
(
"consumer:0x%"
PRIx64
" topic:%s on vgId:%d send commit msg success, send offset:%s committed:%s"
,
tmq
->
consumerId
,
pTopicName
,
pVg
->
vgId
,
offsetBuf
,
commitBuf
);
pVg
->
offsetInfo
.
committedOffset
=
*
offsetVal
;
end:
taosRUnLockLatch
(
&
tmq
->
lock
);
return
code
;
...
...
@@ -650,7 +656,8 @@ static void asyncCommitFromResult(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_c
code
=
asyncCommitOffset
(
tmq
,
pTopicName
,
vgId
,
&
offsetVal
,
pCommitFp
,
userParam
);
end:
if
(
code
!=
TSDB_CODE_SUCCESS
){
if
(
code
!=
TSDB_CODE_SUCCESS
&&
pCommitFp
!=
NULL
){
if
(
code
==
TSDB_CODE_TMQ_SAME_COMMITTED_VALUE
)
code
=
TSDB_CODE_SUCCESS
;
pCommitFp
(
tmq
,
code
,
userParam
);
}
}
...
...
@@ -2350,7 +2357,7 @@ int32_t tmq_commit_sync(tmq_t* tmq, const TAOS_RES* pRes) {
tsem_destroy
(
&
pInfo
->
sem
);
taosMemoryFree
(
pInfo
);
tsc
Debug
(
"consumer:0x%"
PRIx64
" sync
commit done, code:%s"
,
tmq
->
consumerId
,
tstrerror
(
code
));
tsc
Info
(
"consumer:0x%"
PRIx64
" sync res
commit done, code:%s"
,
tmq
->
consumerId
,
tstrerror
(
code
));
return
code
;
}
...
...
@@ -2406,15 +2413,17 @@ int32_t tmq_commit_offset_sync(tmq_t *tmq, const char *pTopicName, int32_t vgId,
tsem_init
(
&
pInfo
->
sem
,
0
,
0
);
pInfo
->
code
=
0
;
asyncCommitOffset
(
tmq
,
tname
,
vgId
,
&
offsetVal
,
commitCallBackFn
,
pInfo
);
tsem_wait
(
&
pInfo
->
sem
);
code
=
pInfo
->
code
;
code
=
asyncCommitOffset
(
tmq
,
tname
,
vgId
,
&
offsetVal
,
commitCallBackFn
,
pInfo
);
if
(
code
==
0
){
tsem_wait
(
&
pInfo
->
sem
);
code
=
pInfo
->
code
;
}
if
(
code
==
TSDB_CODE_TMQ_SAME_COMMITTED_VALUE
)
code
=
TSDB_CODE_SUCCESS
;
tsem_destroy
(
&
pInfo
->
sem
);
taosMemoryFree
(
pInfo
);
tscInfo
(
"consumer:0x%"
PRIx64
" sync send
seek
to vgId:%d, offset:%"
PRId64
" code:%s"
,
tmq
->
consumerId
,
vgId
,
offset
,
tstrerror
(
code
));
tscInfo
(
"consumer:0x%"
PRIx64
" sync send
commit
to vgId:%d, offset:%"
PRId64
" code:%s"
,
tmq
->
consumerId
,
vgId
,
offset
,
tstrerror
(
code
));
return
code
;
}
...
...
@@ -2451,10 +2460,11 @@ void tmq_commit_offset_async(tmq_t *tmq, const char *pTopicName, int32_t vgId, i
code
=
asyncCommitOffset
(
tmq
,
tname
,
vgId
,
&
offsetVal
,
cb
,
param
);
tscInfo
(
"consumer:0x%"
PRIx64
" async send
seek
to vgId:%d, offset:%"
PRId64
" code:%s"
,
tmq
->
consumerId
,
vgId
,
offset
,
tstrerror
(
code
));
tscInfo
(
"consumer:0x%"
PRIx64
" async send
commit
to vgId:%d, offset:%"
PRId64
" code:%s"
,
tmq
->
consumerId
,
vgId
,
offset
,
tstrerror
(
code
));
end:
if
(
code
!=
0
&&
cb
!=
NULL
){
if
(
code
==
TSDB_CODE_TMQ_SAME_COMMITTED_VALUE
)
code
=
TSDB_CODE_SUCCESS
;
cb
(
tmq
,
code
,
param
);
}
}
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
bae028d6
...
...
@@ -94,7 +94,7 @@ void mndDropConsumerFromSdb(SMnode *pMnode, int64_t consumerId){
bool
mndRebTryStart
()
{
int32_t
old
=
atomic_val_compare_exchange_32
(
&
mqRebInExecCnt
,
0
,
1
);
m
Info
(
"tq timer, rebalance counter old val:%d"
,
old
);
m
Debug
(
"tq timer, rebalance counter old val:%d"
,
old
);
return
old
==
0
;
}
...
...
@@ -116,7 +116,7 @@ void mndRebCntDec() {
int32_t
newVal
=
val
-
1
;
int32_t
oldVal
=
atomic_val_compare_exchange_32
(
&
mqRebInExecCnt
,
val
,
newVal
);
if
(
oldVal
==
val
)
{
m
Info
(
"rebalance trans end, rebalance counter:%d"
,
newVal
);
m
Debug
(
"rebalance trans end, rebalance counter:%d"
,
newVal
);
break
;
}
}
...
...
@@ -903,7 +903,7 @@ static int32_t mndConsumerActionInsert(SSdb *pSdb, SMqConsumerObj *pConsumer) {
mInfo
(
"consumer:0x%"
PRIx64
" sub insert, cgroup:%s status:%d(%s) epoch:%d"
,
pConsumer
->
consumerId
,
pConsumer
->
cgroup
,
pConsumer
->
status
,
mndConsumerStatusName
(
pConsumer
->
status
),
pConsumer
->
epoch
);
pConsumer
->
subscribeTime
=
taosGetTimestampMs
()
;
pConsumer
->
subscribeTime
=
pConsumer
->
createTime
;
return
0
;
}
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
bae028d6
...
...
@@ -575,10 +575,18 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
// 1. find handle
pHandle
=
taosHashGet
(
pTq
->
pHandle
,
req
.
subKey
,
strlen
(
req
.
subKey
));
if
(
pHandle
==
NULL
)
{
tqError
(
"tmq poll: consumer:0x%"
PRIx64
" vgId:%d subkey %s not found"
,
consumerId
,
vgId
,
req
.
subKey
);
terrno
=
TSDB_CODE_INVALID_MSG
;
taosWUnLockLatch
(
&
pTq
->
lock
);
return
-
1
;
do
{
if
(
tqMetaGetHandle
(
pTq
,
req
.
subKey
)
==
0
){
pHandle
=
taosHashGet
(
pTq
->
pHandle
,
req
.
subKey
,
strlen
(
req
.
subKey
));
if
(
pHandle
!=
NULL
){
break
;
}
}
tqError
(
"tmq poll: consumer:0x%"
PRIx64
" vgId:%d subkey %s not found"
,
consumerId
,
vgId
,
req
.
subKey
);
terrno
=
TSDB_CODE_INVALID_MSG
;
taosWUnLockLatch
(
&
pTq
->
lock
);
return
-
1
;
}
while
(
0
);
}
// 2. check re-balance status
...
...
source/dnode/vnode/src/tq/tqMeta.c
浏览文件 @
bae028d6
...
...
@@ -338,7 +338,7 @@ static int buildHandle(STQ* pTq, STqHandle* handle){
taosArrayDestroy
(
tbUidList
);
return
-
1
;
}
tq
Debug
(
"vgId:%d, tq try to get ctb for stb subscribe, suid:%"
PRId64
,
pVnode
->
config
.
vgId
,
handle
->
execHandle
.
execTb
.
suid
);
tq
Info
(
"vgId:%d, tq try to get ctb for stb subscribe, suid:%"
PRId64
,
pVnode
->
config
.
vgId
,
handle
->
execHandle
.
execTb
.
suid
);
handle
->
execHandle
.
pTqReader
=
tqReaderOpen
(
pVnode
);
tqReaderSetTbUidList
(
handle
->
execHandle
.
pTqReader
,
tbUidList
,
NULL
);
taosArrayDestroy
(
tbUidList
);
...
...
@@ -356,7 +356,7 @@ static int restoreHandle(STQ* pTq, void* pVal, int vLen, STqHandle* handle){
if
(
buildHandle
(
pTq
,
handle
)
<
0
){
return
-
1
;
}
tq
Debug
(
"tq restore %s consumer %"
PRId64
" vgId:%d"
,
handle
->
subKey
,
handle
->
consumerId
,
vgId
);
tq
Info
(
"tq restore %s consumer %"
PRId64
" vgId:%d"
,
handle
->
subKey
,
handle
->
consumerId
,
vgId
);
return
taosHashPut
(
pTq
->
pHandle
,
handle
->
subKey
,
strlen
(
handle
->
subKey
),
handle
,
sizeof
(
STqHandle
));
}
...
...
@@ -384,7 +384,7 @@ int32_t tqCreateHandle(STQ* pTq, SMqRebVgReq* req, STqHandle* handle){
if
(
buildHandle
(
pTq
,
handle
)
<
0
){
return
-
1
;
}
tq
Debug
(
"tq restore %s consumer %"
PRId64
" vgId:%d"
,
handle
->
subKey
,
handle
->
consumerId
,
vgId
);
tq
Info
(
"tq restore %s consumer %"
PRId64
" vgId:%d"
,
handle
->
subKey
,
handle
->
consumerId
,
vgId
);
return
taosHashPut
(
pTq
->
pHandle
,
handle
->
subKey
,
strlen
(
handle
->
subKey
),
handle
,
sizeof
(
STqHandle
));
}
...
...
source/libs/wal/src/walRead.c
浏览文件 @
bae028d6
...
...
@@ -371,9 +371,9 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead) {
pRead
->
pWal
->
vers
.
appliedVer
);
// TODO: valid ver
// if (ver > pRead->pWal->vers.applied
Ver) {
//
return -1;
//
}
if
(
ver
>
pRead
->
pWal
->
vers
.
commit
Ver
)
{
return
-
1
;
}
if
(
pRead
->
curVersion
!=
ver
)
{
code
=
walReaderSeekVer
(
pRead
,
ver
);
...
...
source/util/src/terror.c
浏览文件 @
bae028d6
...
...
@@ -643,6 +643,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_CONSUMER_CLOSED, "Consumer closed")
TAOS_DEFINE_ERROR
(
TSDB_CODE_TMQ_CONSUMER_ERROR
,
"Consumer error, to see log"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TMQ_TOPIC_OUT_OF_RANGE
,
"Topic num out of range"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TMQ_GROUP_OUT_OF_RANGE
,
"Group num out of range 100"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TMQ_SAME_COMMITTED_VALUE
,
"Same committed value"
)
// stream
TAOS_DEFINE_ERROR
(
TSDB_CODE_STREAM_TASK_NOT_EXIST
,
"Stream task not exist"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录