Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
62f620fa
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
62f620fa
编写于
12月 29, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
process the status msg only once
上级
28359096
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
63 addition
and
56 deletion
+63
-56
source/dnode/mgmt/impl/src/dndDnode.c
source/dnode/mgmt/impl/src/dndDnode.c
+14
-12
source/dnode/mnode/impl/inc/mndDnode.h
source/dnode/mnode/impl/inc/mndDnode.h
+1
-1
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+46
-42
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+2
-1
未找到文件。
source/dnode/mgmt/impl/src/dndDnode.c
浏览文件 @
62f620fa
...
...
@@ -397,7 +397,7 @@ void dndSendStatusMsg(SDnode *pDnode) {
static
void
dndUpdateDnodeCfg
(
SDnode
*
pDnode
,
SDnodeCfg
*
pCfg
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
if
(
pMgmt
->
dnodeId
==
0
)
{
dInfo
(
"set dnodeId:%d clusterId:%
"
PRId64
,
pCfg
->
dnodeId
,
pCfg
->
clusterId
);
dInfo
(
"set dnodeId:%d clusterId:%"
PRId64
,
pCfg
->
dnodeId
,
pCfg
->
clusterId
);
taosWLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
dnodeId
=
pCfg
->
dnodeId
;
pMgmt
->
clusterId
=
pCfg
->
clusterId
;
...
...
@@ -440,19 +440,21 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) {
}
SStatusRsp
*
pRsp
=
pMsg
->
pCont
;
SDnodeCfg
*
pCfg
=
&
pRsp
->
dnodeCfg
;
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
pCfg
->
clusterId
=
htobe64
(
pCfg
->
clusterId
);
dndUpdateDnodeCfg
(
pDnode
,
pCfg
);
if
(
pMsg
->
pCont
!=
NULL
)
{
SDnodeCfg
*
pCfg
=
&
pRsp
->
dnodeCfg
;
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
pCfg
->
clusterId
=
htobe64
(
pCfg
->
clusterId
);
dndUpdateDnodeCfg
(
pDnode
,
pCfg
);
SDnodeEps
*
pDnodeEps
=
&
pRsp
->
dnodeEps
;
pDnodeEps
->
num
=
htonl
(
pDnodeEps
->
num
);
for
(
int32_t
i
=
0
;
i
<
pDnodeEps
->
num
;
++
i
)
{
pDnodeEps
->
eps
[
i
].
id
=
htonl
(
pDnodeEps
->
eps
[
i
].
id
);
pDnodeEps
->
eps
[
i
].
port
=
htons
(
pDnodeEps
->
eps
[
i
].
port
);
}
SDnodeEps
*
pDnodeEps
=
&
pRsp
->
dnodeEps
;
pDnodeEps
->
num
=
htonl
(
pDnodeEps
->
num
);
for
(
int32_t
i
=
0
;
i
<
pDnodeEps
->
num
;
++
i
)
{
pDnodeEps
->
eps
[
i
].
id
=
htonl
(
pDnodeEps
->
eps
[
i
].
id
);
pDnodeEps
->
eps
[
i
].
port
=
htons
(
pDnodeEps
->
eps
[
i
].
port
);
dndUpdateDnodeEps
(
pDnode
,
pDnodeEps
);
}
dndUpdateDnodeEps
(
pDnode
,
pDnodeEps
);
pMgmt
->
statusSent
=
0
;
}
...
...
source/dnode/mnode/impl/inc/mndDnode.h
浏览文件 @
62f620fa
...
...
@@ -28,7 +28,7 @@ SDnodeObj *mndAcquireDnode(SMnode *pMnode, int32_t dnodeId);
void
mndReleaseDnode
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
);
SEpSet
mndGetDnodeEpset
(
SDnodeObj
*
pDnode
);
int32_t
mndGetDnodeSize
(
SMnode
*
pMnode
);
bool
mndIsDnodeOnline
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
);
bool
mndIsDnodeOnline
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
int64_t
curMs
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
62f620fa
...
...
@@ -206,9 +206,8 @@ int32_t mndGetDnodeSize(SMnode *pMnode) {
return
sdbGetSize
(
pSdb
,
SDB_DNODE
);
}
bool
mndIsDnodeOnline
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
)
{
int64_t
ms
=
taosGetTimestampMs
();
int64_t
interval
=
ABS
(
pDnode
->
lastAccessTime
-
ms
);
bool
mndIsDnodeOnline
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
int64_t
curMs
)
{
int64_t
interval
=
ABS
(
pDnode
->
lastAccessTime
-
curMs
);
if
(
interval
>
3500
*
pMnode
->
cfg
.
statusInterval
)
{
if
(
pDnode
->
rebootTime
>
0
)
{
pDnode
->
offlineReason
=
DND_REASON_STATUS_MSG_TIMEOUT
;
...
...
@@ -313,33 +312,37 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
}
}
if
(
pStatus
->
sver
!=
pMnode
->
cfg
.
sver
)
{
if
(
pDnode
!=
NULL
)
{
pDnode
->
offlineReason
=
DND_REASON_VERSION_NOT_MATCH
;
}
mError
(
"dnode:%d, status msg version:%d not match cluster:%d"
,
pStatus
->
dnodeId
,
pStatus
->
sver
,
pMnode
->
cfg
.
sver
);
terrno
=
TSDB_CODE_MND_INVALID_MSG_VERSION
;
goto
PROCESS_STATUS_MSG_OVER
;
}
int64_t
curMs
=
taosGetTimestampMs
();
bool
online
=
mndIsDnodeOnline
(
pMnode
,
pDnode
,
curMs
);
bool
needCheckCfg
=
!
(
online
&&
pDnode
->
rebootTime
==
pStatus
->
rebootTime
);
if
(
pStatus
->
dnodeId
==
0
)
{
mDebug
(
"dnode:%d %s, first access, set clusterId %"
PRId64
,
pDnode
->
id
,
pDnode
->
ep
,
pMnode
->
clusterId
);
}
else
{
if
(
pStatus
->
clusterId
!=
pMnode
->
clusterId
)
{
if
(
needCheckCfg
)
{
if
(
pStatus
->
sver
!=
pMnode
->
cfg
.
sver
)
{
if
(
pDnode
!=
NULL
)
{
pDnode
->
offlineReason
=
DND_REASON_
CLUSTER_ID
_NOT_MATCH
;
pDnode
->
offlineReason
=
DND_REASON_
VERSION
_NOT_MATCH
;
}
mError
(
"dnode:%d, clusterId %"
PRId64
" not match exist %"
PRId64
,
pDnode
->
id
,
pStatus
->
clusterId
,
pMnode
->
clusterId
);
terrno
=
TSDB_CODE_MND_INVALID_CLUSTER_ID
;
mError
(
"dnode:%d, status msg version:%d not match cluster:%d"
,
pStatus
->
dnodeId
,
pStatus
->
sver
,
pMnode
->
cfg
.
sver
);
terrno
=
TSDB_CODE_MND_INVALID_MSG_VERSION
;
goto
PROCESS_STATUS_MSG_OVER
;
}
if
(
pStatus
->
dnodeId
==
0
)
{
mDebug
(
"dnode:%d %s, first access, set clusterId %"
PRId64
,
pDnode
->
id
,
pDnode
->
ep
,
pMnode
->
clusterId
);
}
else
{
pDnode
->
accessTimes
++
;
mTrace
(
"dnode:%d, status received, access times %d"
,
pDnode
->
id
,
pDnode
->
accessTimes
);
if
(
pStatus
->
clusterId
!=
pMnode
->
clusterId
)
{
if
(
pDnode
!=
NULL
)
{
pDnode
->
offlineReason
=
DND_REASON_CLUSTER_ID_NOT_MATCH
;
}
mError
(
"dnode:%d, clusterId %"
PRId64
" not match exist %"
PRId64
,
pDnode
->
id
,
pStatus
->
clusterId
,
pMnode
->
clusterId
);
terrno
=
TSDB_CODE_MND_INVALID_CLUSTER_ID
;
goto
PROCESS_STATUS_MSG_OVER
;
}
else
{
pDnode
->
accessTimes
++
;
mTrace
(
"dnode:%d, status received, access times %d"
,
pDnode
->
id
,
pDnode
->
accessTimes
);
}
}
}
if
(
/*pDnode->status == DND_STATUS_OFFLINE*/
1
)
{
// Verify whether the cluster parameters are consistent when status change from offline to ready
int32_t
ret
=
mndCheckClusterCfgPara
(
pMnode
,
&
pStatus
->
clusterCfg
);
if
(
0
!=
ret
)
{
...
...
@@ -350,28 +353,28 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
}
mInfo
(
"dnode:%d, from offline to online"
,
pDnode
->
id
);
}
pDnode
->
rebootTime
=
pStatus
->
rebootTime
;
pDnode
->
numOfCores
=
pStatus
->
numOfCores
;
pDnode
->
numOfSupportVnodes
=
pStatus
->
numOfSupportVnodes
;
pDnode
->
lastAccessTime
=
taosGetTimestampMs
();
int32_t
numOfEps
=
mndGetDnodeSize
(
pMnode
);
int32_t
contLen
=
sizeof
(
SStatusRsp
)
+
numOfEps
*
sizeof
(
SDnodeEp
);
SStatusRsp
*
pRsp
=
rpcMallocCont
(
contLen
);
if
(
pRsp
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
PROCESS_STATUS_MSG_OVER
;
}
pDnode
->
rebootTime
=
pStatus
->
rebootTime
;
pDnode
->
numOfCores
=
pStatus
->
numOfCores
;
pDnode
->
numOfSupportVnodes
=
pStatus
->
numOfSupportVnodes
;
pRsp
->
dnodeCfg
.
dnodeId
=
htonl
(
pDnode
->
id
);
pRsp
->
dnodeCfg
.
clusterId
=
htobe64
(
pMnode
->
clusterId
);
// mndGetDnodeData(pMnode, &pRsp->dnodeEps, numOfEps);
int32_t
numOfEps
=
mndGetDnodeSize
(
pMnode
);
int32_t
contLen
=
sizeof
(
SStatusRsp
)
+
numOfEps
*
sizeof
(
SDnodeEp
);
SStatusRsp
*
pRsp
=
rpcMallocCont
(
contLen
);
if
(
pRsp
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
PROCESS_STATUS_MSG_OVER
;
}
pRsp
->
dnodeCfg
.
dnodeId
=
htonl
(
pDnode
->
id
);
pRsp
->
dnodeCfg
.
clusterId
=
htobe64
(
pMnode
->
clusterId
);
mndGetDnodeData
(
pMnode
,
&
pRsp
->
dnodeEps
,
numOfEps
);
pMsg
->
contLen
=
contLen
;
pMsg
->
pCont
=
pRsp
;
pMsg
->
contLen
=
contLen
;
pMsg
->
pCont
=
pRsp
;
}
pDnode
->
lastAccessTime
=
curMs
;
code
=
0
;
PROCESS_STATUS_MSG_OVER:
...
...
@@ -682,11 +685,12 @@ static int32_t mndRetrieveDnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, i
int32_t
cols
=
0
;
SDnodeObj
*
pDnode
=
NULL
;
char
*
pWrite
;
int64_t
curMs
=
taosGetTimestampMs
();
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_DNODE
,
pShow
->
pIter
,
(
void
**
)
&
pDnode
);
if
(
pShow
->
pIter
==
NULL
)
break
;
bool
online
=
mndIsDnodeOnline
(
pMnode
,
pDnode
);
bool
online
=
mndIsDnodeOnline
(
pMnode
,
pDnode
,
curMs
);
cols
=
0
;
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
62f620fa
...
...
@@ -260,7 +260,8 @@ static SArray *mndBuildDnodesArray(SMnode *pMnode) {
pDnode
->
numOfVnodes
++
;
}
bool
online
=
mndIsDnodeOnline
(
pMnode
,
pDnode
);
int64_t
curMs
=
taosGetTimestampMs
();
bool
online
=
mndIsDnodeOnline
(
pMnode
,
pDnode
,
curMs
);
if
(
online
)
{
taosArrayPush
(
pArray
,
pDnode
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录