Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1b59ce04
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
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看板
提交
1b59ce04
编写于
10月 12, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1671
上级
f7656ec7
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
66 addition
and
56 deletion
+66
-56
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+10
-30
src/dnode/src/dnodeModule.c
src/dnode/src/dnodeModule.c
+5
-2
src/inc/dnode.h
src/inc/dnode.h
+1
-1
src/inc/mnode.h
src/inc/mnode.h
+1
-1
src/inc/taosmsg.h
src/inc/taosmsg.h
+1
-0
src/mnode/src/mnodeMain.c
src/mnode/src/mnodeMain.c
+1
-1
src/mnode/src/mnodeMnode.c
src/mnode/src/mnodeMnode.c
+21
-4
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+25
-16
tests/script/unique/mnode/mgmt21.sim
tests/script/unique/mnode/mgmt21.sim
+1
-1
未找到文件。
src/dnode/src/dnodeMgmt.c
浏览文件 @
1b59ce04
...
...
@@ -459,18 +459,24 @@ static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) {
static
int32_t
dnodeProcessCreateMnodeMsg
(
SRpcMsg
*
pMsg
)
{
SMDCreateMnodeMsg
*
pCfg
=
pMsg
->
pCont
;
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
if
(
pCfg
->
dnodeId
!=
dnodeGetDnodeId
())
{
dError
(
"dnodeId:%d in create mnode msg is not equal with saved dnodeId:%d"
,
pCfg
->
dnodeId
,
dnodeGetDnodeId
());
dError
(
"dnodeId:%d
,
in create mnode msg is not equal with saved dnodeId:%d"
,
pCfg
->
dnodeId
,
dnodeGetDnodeId
());
return
TSDB_CODE_MND_DNODE_ID_NOT_CONFIGURED
;
}
if
(
strcmp
(
pCfg
->
dnodeEp
,
tsLocalEp
)
!=
0
)
{
dError
(
"dnodeEp:%s in create mnode msg is not equal with saved dnodeEp:%s"
,
pCfg
->
dnodeEp
,
tsLocalEp
);
dError
(
"dnodeEp:%s
,
in create mnode msg is not equal with saved dnodeEp:%s"
,
pCfg
->
dnodeEp
,
tsLocalEp
);
return
TSDB_CODE_MND_DNODE_EP_NOT_CONFIGURED
;
}
dDebug
(
"dnodeId:%d, create mnode msg is received"
,
pCfg
->
dnodeId
);
dnodeStartMnode
();
dDebug
(
"dnodeId:%d, create mnode msg is received from mnodes, numOfMnodes:%d"
,
pCfg
->
dnodeId
,
pCfg
->
mnodes
.
nodeNum
);
for
(
int
i
=
0
;
i
<
pCfg
->
mnodes
.
nodeNum
;
++
i
)
{
pCfg
->
mnodes
.
nodeInfos
[
i
].
nodeId
=
htonl
(
pCfg
->
mnodes
.
nodeInfos
[
i
].
nodeId
);
dDebug
(
"mnode index:%d, mnode:%d:%s"
,
i
,
pCfg
->
mnodes
.
nodeInfos
[
i
].
nodeId
,
pCfg
->
mnodes
.
nodeInfos
[
i
].
nodeEp
);
}
dnodeStartMnode
(
&
pCfg
->
mnodes
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -485,31 +491,6 @@ void dnodeUpdateMnodeEpSetForPeer(SRpcEpSet *pEpSet) {
for
(
int
i
=
0
;
i
<
pEpSet
->
numOfEps
;
++
i
)
{
pEpSet
->
port
[
i
]
-=
TSDB_PORT_DNODEDNODE
;
dInfo
(
"mnode index:%d %s:%u"
,
i
,
pEpSet
->
fqdn
[
i
],
pEpSet
->
port
[
i
]);
#if 0
if (!mnodeIsRunning()) {
if (strcmp(pEpSet->fqdn[i], tsLocalFqdn) == 0 && pEpSet->port[i] == tsServerPort) {
dInfo("mnode index:%d %s:%u self should work as mnode", i, pEpSet->fqdn[i], pEpSet->port[i]);
bool find = false;
for (int i = 0; i < tsDMnodeInfos.nodeNum; ++i) {
if (tsDMnodeInfos.nodeInfos[i].nodeId == dnodeGetDnodeId()) {
dInfo("localEp found in mnode infos");
find = true;
break;
}
}
if (!find) {
dInfo("localEp not found in mnode infos, will set into mnode infos");
tstrncpy(tsDMnodeInfos.nodeInfos[tsDMnodeInfos.nodeNum].nodeEp, tsLocalEp, TSDB_EP_LEN);
tsDMnodeInfos.nodeInfos[tsDMnodeInfos.nodeNum].nodeId = dnodeGetDnodeId();
tsDMnodeInfos.nodeNum++;
}
dnodeStartMnode();
}
}
#endif
}
tsDMnodeEpSet
=
*
pEpSet
;
...
...
@@ -598,7 +579,6 @@ static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes) {
}
dnodeSaveMnodeInfos
();
sdbUpdateSync
();
}
static
bool
dnodeReadMnodeInfos
()
{
...
...
src/dnode/src/dnodeModule.c
浏览文件 @
1b59ce04
...
...
@@ -146,7 +146,9 @@ void dnodeProcessModuleStatus(uint32_t moduleStatus) {
}
}
bool
dnodeStartMnode
()
{
bool
dnodeStartMnode
(
void
*
pMnodes
)
{
SDMMnodeInfos
*
mnodes
=
pMnodes
;
if
(
tsModuleStatus
&
(
1
<<
TSDB_MOD_MNODE
))
{
dDebug
(
"mnode module is already started, module status:%d"
,
tsModuleStatus
);
return
false
;
...
...
@@ -156,6 +158,7 @@ bool dnodeStartMnode() {
dInfo
(
"start mnode module, module status:%d, new status:%d"
,
tsModuleStatus
,
moduleStatus
);
dnodeProcessModuleStatus
(
moduleStatus
);
sdbUpdateSync
();
sdbUpdateSync
(
mnodes
);
return
true
;
}
src/inc/dnode.h
浏览文件 @
1b59ce04
...
...
@@ -43,7 +43,7 @@ void dnodeGetMnodeEpSetForPeer(void *epSet);
void
dnodeGetMnodeEpSetForShell
(
void
*
epSet
);
void
*
dnodeGetMnodeInfos
();
int32_t
dnodeGetDnodeId
();
bool
dnodeStartMnode
();
bool
dnodeStartMnode
(
void
*
pModes
);
void
dnodeAddClientRspHandle
(
uint8_t
msgType
,
void
(
*
fp
)(
SRpcMsg
*
rpcMsg
));
void
dnodeSendMsgToDnode
(
SRpcEpSet
*
epSet
,
SRpcMsg
*
rpcMsg
);
...
...
src/inc/mnode.h
浏览文件 @
1b59ce04
...
...
@@ -60,7 +60,7 @@ int32_t mnodeInitSystem();
int32_t
mnodeStartSystem
();
void
mnodeCleanupSystem
();
void
mnodeStopSystem
();
void
sdbUpdateSync
();
void
sdbUpdateSync
(
void
*
pMnodes
);
bool
mnodeIsRunning
();
int32_t
mnodeProcessRead
(
SMnodeMsg
*
pMsg
);
int32_t
mnodeProcessWrite
(
SMnodeMsg
*
pMsg
);
...
...
src/inc/taosmsg.h
浏览文件 @
1b59ce04
...
...
@@ -722,6 +722,7 @@ typedef struct {
typedef
struct
{
int32_t
dnodeId
;
char
dnodeEp
[
TSDB_EP_LEN
];
// end point, hostname:port
SDMMnodeInfos
mnodes
;
}
SMDCreateMnodeMsg
;
typedef
struct
{
...
...
src/mnode/src/mnodeMain.c
浏览文件 @
1b59ce04
...
...
@@ -109,7 +109,7 @@ int32_t mnodeStartSystem() {
mInfo
(
"mnode is initialized successfully"
);
sdbUpdateSync
();
sdbUpdateSync
(
NULL
);
return
0
;
}
...
...
src/mnode/src/mnodeMnode.c
浏览文件 @
1b59ce04
...
...
@@ -276,8 +276,20 @@ static int32_t mnodeSendCreateMnodeMsg(int32_t dnodeId, char *dnodeEp) {
if
(
pCreate
==
NULL
)
{
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
else
{
pCreate
->
dnodeId
=
dnodeId
;
pCreate
->
dnodeId
=
htonl
(
dnodeId
)
;
tstrncpy
(
pCreate
->
dnodeEp
,
dnodeEp
,
sizeof
(
pCreate
->
dnodeEp
));
pCreate
->
mnodes
=
tsMnodeInfos
;
bool
found
=
false
;
for
(
int
i
=
0
;
i
<
pCreate
->
mnodes
.
nodeNum
;
++
i
)
{
if
(
pCreate
->
mnodes
.
nodeInfos
[
i
].
nodeId
==
htonl
(
dnodeId
))
{
found
=
true
;
}
}
if
(
!
found
)
{
pCreate
->
mnodes
.
nodeInfos
[
pCreate
->
mnodes
.
nodeNum
].
nodeId
=
htonl
(
dnodeId
);
tstrncpy
(
pCreate
->
mnodes
.
nodeInfos
[
pCreate
->
mnodes
.
nodeNum
].
nodeEp
,
dnodeEp
,
sizeof
(
pCreate
->
dnodeEp
));
pCreate
->
mnodes
.
nodeNum
++
;
}
}
SRpcMsg
rpcMsg
=
{
0
};
...
...
@@ -291,6 +303,8 @@ static int32_t mnodeSendCreateMnodeMsg(int32_t dnodeId, char *dnodeEp) {
if
(
rpcRsp
.
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"dnode:%d, failed to send create mnode msg, ep:%s reason:%s"
,
dnodeId
,
dnodeEp
,
tstrerror
(
rpcRsp
.
code
));
}
else
{
mDebug
(
"dnode:%d, create mnode msg is disposed, mnode is created in dnode"
,
dnodeId
);
}
rpcFreeCont
(
rpcRsp
.
pCont
);
...
...
@@ -301,8 +315,9 @@ static int32_t mnodeCreateMnodeCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"failed to create mnode, reason:%s"
,
tstrerror
(
code
));
}
else
{
mDebug
(
"mnode is created"
);
mDebug
(
"mnode is created
successfully
"
);
mnodeUpdateMnodeEpSet
();
sdbUpdateSync
(
NULL
);
}
return
code
;
...
...
@@ -314,9 +329,9 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
pMnode
->
createdTime
=
taosGetTimestampMs
();
SSdbOper
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsMnodeSdb
,
.
pObj
=
pMnode
,
.
pObj
=
pMnode
,
.
writeCb
=
mnodeCreateMnodeCb
};
...
...
@@ -346,6 +361,7 @@ void mnodeDropMnodeLocal(int32_t dnodeId) {
}
mnodeUpdateMnodeEpSet
();
sdbUpdateSync
(
NULL
);
}
int32_t
mnodeDropMnode
(
int32_t
dnodeId
)
{
...
...
@@ -365,6 +381,7 @@ int32_t mnodeDropMnode(int32_t dnodeId) {
sdbDecRef
(
tsMnodeSdb
,
pMnode
);
mnodeUpdateMnodeEpSet
();
sdbUpdateSync
(
NULL
);
return
code
;
}
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
1b59ce04
...
...
@@ -297,27 +297,19 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) {
taosFreeQitem
(
pOper
);
}
void
sdbUpdateSync
()
{
void
sdbUpdateSync
(
void
*
pMnodes
)
{
SDMMnodeInfos
*
mnodes
=
pMnodes
;
if
(
!
mnodeIsRunning
())
{
mDebug
(
"mnode not start yet, update sync
info
later"
);
mDebug
(
"mnode not start yet, update sync
config
later"
);
return
;
}
mDebug
(
"update sync
info in sdb"
);
mDebug
(
"update sync
config in sync module, mnodes:%p"
,
pMnodes
);
SSyncCfg
syncCfg
=
{
0
};
int32_t
index
=
0
;
SDMMnodeInfos
*
mnodes
=
dnodeGetMnodeInfos
();
for
(
int32_t
i
=
0
;
i
<
mnodes
->
nodeNum
;
++
i
)
{
SDMMnodeInfo
*
node
=
&
mnodes
->
nodeInfos
[
i
];
syncCfg
.
nodeInfo
[
i
].
nodeId
=
node
->
nodeId
;
taosGetFqdnPortFromEp
(
node
->
nodeEp
,
syncCfg
.
nodeInfo
[
i
].
nodeFqdn
,
&
syncCfg
.
nodeInfo
[
i
].
nodePort
);
syncCfg
.
nodeInfo
[
i
].
nodePort
+=
TSDB_PORT_SYNC
;
index
++
;
}
if
(
index
==
0
)
{
if
(
mnodes
==
NULL
)
{
void
*
pIter
=
NULL
;
while
(
1
)
{
SMnodeObj
*
pMnode
=
NULL
;
...
...
@@ -337,9 +329,19 @@ void sdbUpdateSync() {
mnodeDecMnodeRef
(
pMnode
);
}
sdbFreeIter
(
pIter
);
syncCfg
.
replica
=
index
;
mDebug
(
"mnodes info not input, use infos in sdb, numOfMnodes:%d"
,
syncCfg
.
replica
);
}
else
{
for
(
index
=
0
;
index
<
mnodes
->
nodeNum
;
++
index
)
{
SDMMnodeInfo
*
node
=
&
mnodes
->
nodeInfos
[
index
];
syncCfg
.
nodeInfo
[
index
].
nodeId
=
node
->
nodeId
;
taosGetFqdnPortFromEp
(
node
->
nodeEp
,
syncCfg
.
nodeInfo
[
index
].
nodeFqdn
,
&
syncCfg
.
nodeInfo
[
index
].
nodePort
);
syncCfg
.
nodeInfo
[
index
].
nodePort
+=
TSDB_PORT_SYNC
;
}
syncCfg
.
replica
=
index
;
mDebug
(
"mnodes info input, numOfMnodes:%d"
,
syncCfg
.
replica
);
}
syncCfg
.
replica
=
index
;
syncCfg
.
quorum
=
(
syncCfg
.
replica
==
1
)
?
1
:
2
;
bool
hasThisDnode
=
false
;
...
...
@@ -350,8 +352,15 @@ void sdbUpdateSync() {
}
}
if
(
!
hasThisDnode
)
return
;
if
(
memcmp
(
&
syncCfg
,
&
tsSdbObj
.
cfg
,
sizeof
(
SSyncCfg
))
==
0
)
return
;
if
(
!
hasThisDnode
)
{
sdbError
(
"update sync config, this dnode not exist"
);
return
;
}
if
(
memcmp
(
&
syncCfg
,
&
tsSdbObj
.
cfg
,
sizeof
(
SSyncCfg
))
==
0
)
{
sdbDebug
(
"update sync config, info not changed"
);
return
;
}
sdbInfo
(
"work as mnode, replica:%d"
,
syncCfg
.
replica
);
for
(
int32_t
i
=
0
;
i
<
syncCfg
.
replica
;
++
i
)
{
...
...
tests/script/unique/mnode/mgmt21.sim
浏览文件 @
1b59ce04
...
...
@@ -25,7 +25,7 @@ sql create dnode $hostname2
$x = 0
show2:
$x = $x + 1
sleep
4
000
sleep
2
000
if $x == 5 then
return -1
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录