Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
108b9ffe
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
108b9ffe
编写于
11月 03, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact: add sequence for status msg
上级
b98e3f34
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
32 addition
and
16 deletion
+32
-16
include/common/tmsg.h
include/common/tmsg.h
+2
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+4
-0
source/dnode/mgmt/mgmt_dnode/inc/dmInt.h
source/dnode/mgmt/mgmt_dnode/inc/dmInt.h
+1
-0
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
+11
-4
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+14
-12
未找到文件。
include/common/tmsg.h
浏览文件 @
108b9ffe
...
...
@@ -1128,6 +1128,7 @@ typedef struct {
SQnodeLoad
qload
;
SClusterCfg
clusterCfg
;
SArray
*
pVloads
;
// array of SVnodeLoad
int32_t
statusSeq
;
}
SStatusReq
;
int32_t
tSerializeSStatusReq
(
void
*
buf
,
int32_t
bufLen
,
SStatusReq
*
pReq
);
...
...
@@ -1149,6 +1150,7 @@ typedef struct {
int64_t
dnodeVer
;
SDnodeCfg
dnodeCfg
;
SArray
*
pDnodeEps
;
// Array of SDnodeEp
int32_t
statusSeq
;
}
SStatusRsp
;
int32_t
tSerializeSStatusRsp
(
void
*
buf
,
int32_t
bufLen
,
SStatusRsp
*
pRsp
);
...
...
source/common/src/tmsg.c
浏览文件 @
108b9ffe
...
...
@@ -1020,6 +1020,7 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
if
(
tEncodeI64
(
&
encoder
,
pReq
->
qload
.
timeInQueryQueue
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
qload
.
timeInFetchQueue
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
statusSeq
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
...
...
@@ -1095,6 +1096,7 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
qload
.
timeInQueryQueue
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
qload
.
timeInFetchQueue
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
statusSeq
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
...
...
@@ -1126,6 +1128,7 @@ int32_t tSerializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) {
if
(
tEncodeU16
(
&
encoder
,
pDnodeEp
->
ep
.
port
)
<
0
)
return
-
1
;
}
if
(
tEncodeI32
(
&
encoder
,
pRsp
->
statusSeq
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
...
...
@@ -1167,6 +1170,7 @@ int32_t tDeserializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) {
}
}
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
statusSeq
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
...
...
source/dnode/mgmt/mgmt_dnode/inc/dmInt.h
浏览文件 @
108b9ffe
...
...
@@ -36,6 +36,7 @@ typedef struct SDnodeMgmt {
GetVnodeLoadsFp
getVnodeLoadsFp
;
GetMnodeLoadsFp
getMnodeLoadsFp
;
GetQnodeLoadsFp
getQnodeLoadsFp
;
int32_t
statusSeq
;
}
SDnodeMgmt
;
// dmHandle.c
...
...
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
浏览文件 @
108b9ffe
...
...
@@ -32,9 +32,13 @@ static void dmUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) {
}
static
void
dmProcessStatusRsp
(
SDnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRsp
)
{
const
STraceId
*
trace
=
&
pRsp
->
info
.
traceId
;
dGTrace
(
"status msg received from mnode, statusSeq:%d code:0x%x"
,
pMgmt
->
statusSeq
,
pRsp
->
code
);
if
(
pRsp
->
code
!=
0
)
{
if
(
pRsp
->
code
==
TSDB_CODE_MND_DNODE_NOT_EXIST
&&
!
pMgmt
->
pData
->
dropped
&&
pMgmt
->
pData
->
dnodeId
>
0
)
{
dInfo
(
"dnode:%d, set to dropped since not exist in mnode"
,
pMgmt
->
pData
->
dnodeId
);
dGInfo
(
"dnode:%d, set to dropped since not exist in mnode, statusSeq:%d"
,
pMgmt
->
pData
->
dnodeId
,
pMgmt
->
statusSeq
);
pMgmt
->
pData
->
dropped
=
1
;
dmWriteEps
(
pMgmt
->
pData
);
}
...
...
@@ -42,9 +46,9 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
SStatusRsp
statusRsp
=
{
0
};
if
(
pRsp
->
pCont
!=
NULL
&&
pRsp
->
contLen
>
0
&&
tDeserializeSStatusRsp
(
pRsp
->
pCont
,
pRsp
->
contLen
,
&
statusRsp
)
==
0
)
{
dTrace
(
"status msg received from mnode, dnodeVer:%"
PRId64
" saved:%"
PRId64
,
statusRsp
.
dnodeVer
,
pMgmt
->
pData
->
dnodeVer
);
if
(
pMgmt
->
pData
->
dnodeVer
!=
statusRsp
.
dnodeVer
)
{
dGInfo
(
"status msg received from mnode, statusSeq:%d:%d dnodeVer:%"
PRId64
":%"
PRId64
,
pMgmt
->
statusSeq
,
statusRsp
.
statusSeq
,
pMgmt
->
pData
->
dnodeVer
,
statusRsp
.
dnodeVer
);
pMgmt
->
pData
->
dnodeVer
=
statusRsp
.
dnodeVer
;
dmUpdateDnodeCfg
(
pMgmt
,
&
statusRsp
.
dnodeCfg
);
dmUpdateEps
(
pMgmt
->
pData
,
statusRsp
.
pDnodeEps
);
...
...
@@ -91,6 +95,9 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
(
*
pMgmt
->
getQnodeLoadsFp
)(
&
req
.
qload
);
pMgmt
->
statusSeq
++
;
req
.
statusSeq
=
pMgmt
->
statusSeq
;
int32_t
contLen
=
tSerializeSStatusReq
(
NULL
,
0
,
&
req
);
void
*
pHead
=
rpcMallocCont
(
contLen
);
tSerializeSStatusReq
(
pHead
,
contLen
,
&
req
);
...
...
@@ -99,7 +106,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
SRpcMsg
rpcMsg
=
{.
pCont
=
pHead
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_MND_STATUS
,
.
info
.
ahandle
=
(
void
*
)
0x9527
};
SRpcMsg
rpcRsp
=
{
0
};
dTrace
(
"send status msg to mnode, dnodeVer:%"
PRId64
,
req
.
dnodeVer
);
dTrace
(
"send status msg to mnode, dnodeVer:%"
PRId64
" statusSeq:%d"
,
req
.
dnodeVer
,
req
.
statusSeq
);
SEpSet
epSet
=
{
0
};
dmGetMnodeEpSet
(
pMgmt
->
pData
,
&
epSet
);
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
108b9ffe
...
...
@@ -345,6 +345,19 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
}
}
int64_t
dnodeVer
=
sdbGetTableVer
(
pMnode
->
pSdb
,
SDB_DNODE
)
+
sdbGetTableVer
(
pMnode
->
pSdb
,
SDB_MNODE
);
int64_t
curMs
=
taosGetTimestampMs
();
bool
online
=
mndIsDnodeOnline
(
pDnode
,
curMs
);
bool
dnodeChanged
=
(
statusReq
.
dnodeVer
==
0
)
||
(
statusReq
.
dnodeVer
!=
dnodeVer
);
bool
reboot
=
(
pDnode
->
rebootTime
!=
statusReq
.
rebootTime
);
bool
needCheck
=
!
online
||
dnodeChanged
||
reboot
;
pDnode
->
accessTimes
++
;
pDnode
->
lastAccessTime
=
curMs
;
const
STraceId
*
trace
=
&
pReq
->
info
.
traceId
;
mGTrace
(
"dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d"
,
pDnode
->
id
,
pDnode
->
accessTimes
,
needCheck
,
online
,
reboot
,
dnodeChanged
,
statusReq
.
statusSeq
);
for
(
int32_t
v
=
0
;
v
<
taosArrayGetSize
(
statusReq
.
pVloads
);
++
v
)
{
SVnodeLoad
*
pVload
=
taosArrayGet
(
statusReq
.
pVloads
,
v
);
...
...
@@ -396,18 +409,6 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
mndReleaseQnode
(
pMnode
,
pQnode
);
}
int64_t
dnodeVer
=
sdbGetTableVer
(
pMnode
->
pSdb
,
SDB_DNODE
)
+
sdbGetTableVer
(
pMnode
->
pSdb
,
SDB_MNODE
);
int64_t
curMs
=
taosGetTimestampMs
();
bool
online
=
mndIsDnodeOnline
(
pDnode
,
curMs
);
bool
dnodeChanged
=
(
statusReq
.
dnodeVer
==
0
)
||
(
statusReq
.
dnodeVer
!=
dnodeVer
);
bool
reboot
=
(
pDnode
->
rebootTime
!=
statusReq
.
rebootTime
);
bool
needCheck
=
!
online
||
dnodeChanged
||
reboot
;
pDnode
->
accessTimes
++
;
pDnode
->
lastAccessTime
=
curMs
;
mTrace
(
"dnode:%d, status received, access times:%d check:%d online:%d reboot:%d changed:%d"
,
pDnode
->
id
,
pDnode
->
accessTimes
,
needCheck
,
online
,
reboot
,
dnodeChanged
);
if
(
needCheck
)
{
if
(
statusReq
.
sver
!=
tsVersion
)
{
if
(
pDnode
!=
NULL
)
{
...
...
@@ -455,6 +456,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
pDnode
->
memTotal
=
statusReq
.
memTotal
;
SStatusRsp
statusRsp
=
{
0
};
statusRsp
.
statusSeq
++
;
statusRsp
.
dnodeVer
=
dnodeVer
;
statusRsp
.
dnodeCfg
.
dnodeId
=
pDnode
->
id
;
statusRsp
.
dnodeCfg
.
clusterId
=
pMnode
->
clusterId
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录