Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1d9dd153
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
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看板
提交
1d9dd153
编写于
5月 17, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:error in pHandle lock
上级
4bb25c28
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
35 addition
and
36 deletion
+35
-36
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+1
-0
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+34
-30
source/dnode/vnode/src/tq/tqMeta.c
source/dnode/vnode/src/tq/tqMeta.c
+0
-2
source/dnode/vnode/src/tq/tqOffset.c
source/dnode/vnode/src/tq/tqOffset.c
+0
-2
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+0
-2
未找到文件。
source/dnode/vnode/src/inc/tq.h
浏览文件 @
1d9dd153
...
...
@@ -93,6 +93,7 @@ typedef struct {
typedef
enum
tq_handle_status
{
TMQ_HANDLE_STATUS_IDLE
=
0
,
TMQ_HANDLE_STATUS_EXEC
=
1
,
TMQ_HANDLE_STATUS_DELETE
=
2
,
}
tq_handle_status
;
typedef
struct
{
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
1d9dd153
...
...
@@ -25,6 +25,7 @@ static int32_t tqInitialize(STQ* pTq);
static
FORCE_INLINE
bool
tqIsHandleExec
(
STqHandle
*
pHandle
)
{
return
TMQ_HANDLE_STATUS_EXEC
==
pHandle
->
status
;
}
static
FORCE_INLINE
void
tqSetHandleExec
(
STqHandle
*
pHandle
)
{
pHandle
->
status
=
TMQ_HANDLE_STATUS_EXEC
;}
static
FORCE_INLINE
void
tqSetHandleIdle
(
STqHandle
*
pHandle
)
{
pHandle
->
status
=
TMQ_HANDLE_STATUS_IDLE
;}
static
FORCE_INLINE
void
tqSetHandleDelete
(
STqHandle
*
pHandle
)
{
pHandle
->
status
=
TMQ_HANDLE_STATUS_DELETE
;}
int32_t
tqInit
()
{
int8_t
old
;
...
...
@@ -297,13 +298,10 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, int64_t sversion, char* msg, int32_t
}
if
(
offset
.
val
.
type
==
TMQ_OFFSET__LOG
)
{
taosWLockLatch
(
&
pTq
->
lock
);
STqHandle
*
pHandle
=
taosHashGet
(
pTq
->
pHandle
,
offset
.
subKey
,
strlen
(
offset
.
subKey
));
if
(
pHandle
&&
(
walSetRefVer
(
pHandle
->
pRef
,
offset
.
val
.
version
)
<
0
))
{
taosWUnLockLatch
(
&
pTq
->
lock
);
return
-
1
;
}
taosWUnLockLatch
(
&
pTq
->
lock
);
}
return
0
;
...
...
@@ -337,6 +335,7 @@ int32_t tqCheckColModifiable(STQ* pTq, int64_t tbUid, int32_t colId) {
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
SMqPollReq
req
=
{
0
};
int
code
=
0
;
if
(
tDeserializeSMqPollReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
req
)
<
0
)
{
tqError
(
"tDeserializeSMqPollReq %d failed"
,
pMsg
->
contLen
);
terrno
=
TSDB_CODE_INVALID_MSG
;
...
...
@@ -347,10 +346,12 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
int32_t
reqEpoch
=
req
.
epoch
;
STqOffsetVal
reqOffset
=
req
.
reqOffset
;
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
STqHandle
*
pHandle
=
NULL
;
while
(
1
)
{
taosWLockLatch
(
&
pTq
->
lock
);
// 1. find handle
STqHandle
*
pHandle
=
taosHashGet
(
pTq
->
pHandle
,
req
.
subKey
,
strlen
(
req
.
subKey
));
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
;
...
...
@@ -358,9 +359,16 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
return
-
1
;
}
while
(
tqIsHandleExec
(
pHandle
))
{
bool
exec
=
tqIsHandleExec
(
pHandle
);
if
(
!
exec
)
{
tqSetHandleExec
(
pHandle
);
taosWUnLockLatch
(
&
pTq
->
lock
);
break
;
}
taosWUnLockLatch
(
&
pTq
->
lock
);
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
"vgId:%d, topic:%s, subscription is executing, wait for 5ms and retry, pHandle:%p"
,
consumerId
,
vgId
,
req
.
subKey
,
pHandle
);
taosMsleep
(
5
);
taosMsleep
(
10
);
}
// 2. check re-balance status
...
...
@@ -368,12 +376,11 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
tqDebug
(
"ERROR tmq poll: consumer:0x%"
PRIx64
" vgId:%d, subkey %s, mismatch for saved handle consumer:0x%"
PRIx64
,
consumerId
,
TD_VID
(
pTq
->
pVnode
),
req
.
subKey
,
pHandle
->
consumerId
);
terrno
=
TSDB_CODE_TMQ_CONSUMER_MISMATCH
;
taosWUnLockLatch
(
&
pTq
->
lock
)
;
return
-
1
;
code
=
-
1
;
goto
end
;
}
tqSetHandleExec
(
pHandle
);
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
"vgId:%d, topic:%s, set handle exec, pHandle:%p"
,
consumerId
,
vgId
,
req
.
subKey
,
pHandle
);
taosWUnLockLatch
(
&
pTq
->
lock
);
// 3. update the epoch value
int32_t
savedEpoch
=
pHandle
->
epoch
;
...
...
@@ -388,7 +395,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
" (epoch %d), subkey %s, recv poll req vgId:%d, req:%s, reqId:0x%"
PRIx64
,
consumerId
,
req
.
epoch
,
pHandle
->
subKey
,
vgId
,
buf
,
req
.
reqId
);
int
code
=
tqExtractDataForMq
(
pTq
,
pHandle
,
&
req
,
pMsg
);
code
=
tqExtractDataForMq
(
pTq
,
pHandle
,
&
req
,
pMsg
);
end:
tqSetHandleIdle
(
pHandle
);
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
"vgId:%d, topic:%s, , set handle idle, pHandle:%p"
,
consumerId
,
vgId
,
req
.
subKey
,
pHandle
);
return
code
;
...
...
@@ -405,8 +414,8 @@ int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
STqHandle
*
pHandle
=
taosHashGet
(
pTq
->
pHandle
,
pReq
->
subKey
,
strlen
(
pReq
->
subKey
));
if
(
pHandle
)
{
while
(
tqIsHandleExec
(
pHandle
))
{
tqDebug
(
"vgId:%d, topic:%s, subscription is executing, wait for 5ms and retry
"
,
vgId
,
pHandle
->
subKey
);
taosMsleep
(
5
);
tqDebug
(
"vgId:%d, topic:%s, subscription is executing, wait for 5ms and retry
, pHandle:%p"
,
vgId
,
pHandle
->
subKey
,
pHandle
);
taosMsleep
(
10
);
}
if
(
pHandle
->
pRef
)
{
walCloseRef
(
pTq
->
pVnode
->
pWal
,
pHandle
->
pRef
->
refId
);
...
...
@@ -473,7 +482,6 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
tqDebug
(
"vgId:%d, tq process sub req:%s, Id:0x%"
PRIx64
" -> Id:0x%"
PRIx64
,
pVnode
->
config
.
vgId
,
req
.
subKey
,
req
.
oldConsumerId
,
req
.
newConsumerId
);
taosWLockLatch
(
&
pTq
->
lock
);
STqHandle
*
pHandle
=
taosHashGet
(
pTq
->
pHandle
,
req
.
subKey
,
strlen
(
req
.
subKey
));
if
(
pHandle
==
NULL
)
{
if
(
req
.
oldConsumerId
!=
-
1
)
{
...
...
@@ -556,20 +564,14 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
ret
=
tqMetaSaveHandle
(
pTq
,
req
.
subKey
,
pHandle
);
goto
end
;
}
else
{
while
(
tqIsHandleExec
(
pHandle
))
{
tqDebug
(
"sub req vgId:%d, topic:%s, subscription is executing, wait for 5ms and retry, pHandle:%p"
,
vgId
,
pHandle
->
subKey
,
pHandle
);
taosMsleep
(
5
);
}
if
(
pHandle
->
consumerId
==
req
.
newConsumerId
)
{
// do nothing
tqInfo
(
"vgId:%d consumer:0x%"
PRIx64
" remains, no switch occurs"
,
req
.
vgId
,
req
.
newConsumerId
);
atomic_add_fetch_32
(
&
pHandle
->
epoch
,
1
);
// atomic_add_fetch_32(&pHandle->epoch, 1);
}
else
{
tqInfo
(
"vgId:%d switch consumer from Id:0x%"
PRIx64
" to Id:0x%"
PRIx64
,
req
.
vgId
,
pHandle
->
consumerId
,
req
.
newConsumerId
);
atomic_store_64
(
&
pHandle
->
consumerId
,
req
.
newConsumerId
);
atomic_store_32
(
&
pHandle
->
epoch
,
0
);
//
atomic_store_32(&pHandle->epoch, 0);
}
// kill executing task
qTaskInfo_t
pTaskInfo
=
pHandle
->
execHandle
.
task
;
...
...
@@ -580,13 +582,15 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
qStreamCloseTsdbReader
(
pTaskInfo
);
}
// remove if it has been register in the push manager, and return one empty block to consumer
taosWLockLatch
(
&
pTq
->
lock
);
tqUnregisterPushHandle
(
pTq
,
pHandle
);
taosWUnLockLatch
(
&
pTq
->
lock
);
ret
=
tqMetaSaveHandle
(
pTq
,
req
.
subKey
,
pHandle
);
goto
end
;
}
end:
taosWUnLockLatch
(
&
pTq
->
lock
);
taosMemoryFree
(
req
.
qmsg
);
return
ret
;
}
...
...
source/dnode/vnode/src/tq/tqMeta.c
浏览文件 @
1d9dd153
...
...
@@ -352,9 +352,7 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
handle
.
execHandle
.
task
=
qCreateQueueExecTaskInfo
(
NULL
,
&
reader
,
vgId
,
NULL
,
0
);
}
tqDebug
(
"tq restore %s consumer %"
PRId64
" vgId:%d"
,
handle
.
subKey
,
handle
.
consumerId
,
vgId
);
taosWLockLatch
(
&
pTq
->
lock
);
taosHashPut
(
pTq
->
pHandle
,
pKey
,
kLen
,
&
handle
,
sizeof
(
STqHandle
));
taosWUnLockLatch
(
&
pTq
->
lock
);
}
end:
...
...
source/dnode/vnode/src/tq/tqOffset.c
浏览文件 @
1d9dd153
...
...
@@ -78,7 +78,6 @@ int32_t tqOffsetRestoreFromFile(STqOffsetStore* pStore, const char* fname) {
// todo remove this
if
(
offset
.
val
.
type
==
TMQ_OFFSET__LOG
)
{
taosWLockLatch
(
&
pStore
->
pTq
->
lock
);
STqHandle
*
pHandle
=
taosHashGet
(
pStore
->
pTq
->
pHandle
,
offset
.
subKey
,
strlen
(
offset
.
subKey
));
if
(
pHandle
)
{
if
(
walSetRefVer
(
pHandle
->
pRef
,
offset
.
val
.
version
)
<
0
)
{
...
...
@@ -86,7 +85,6 @@ int32_t tqOffsetRestoreFromFile(STqOffsetStore* pStore, const char* fname) {
// offset.val.version);
}
}
taosWUnLockLatch
(
&
pStore
->
pTq
->
lock
);
}
taosMemoryFree
(
pMemBuf
);
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
1d9dd153
...
...
@@ -1035,7 +1035,6 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
// update the table list for each consumer handle
taosWLockLatch
(
&
pTq
->
lock
);
while
(
1
)
{
pIter
=
taosHashIterate
(
pTq
->
pHandle
,
pIter
);
if
(
pIter
==
NULL
)
{
...
...
@@ -1092,7 +1091,6 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
}
}
}
taosWUnLockLatch
(
&
pTq
->
lock
);
// update the table list handle for each stream scanner/wal reader
taosWLockLatch
(
&
pTq
->
pStreamMeta
->
lock
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录