Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c1b3afa9
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
c1b3afa9
编写于
4月 09, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat[cluster]: create and drop mnode
上级
a0460538
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
121 addition
and
97 deletion
+121
-97
include/util/taoserror.h
include/util/taoserror.h
+3
-0
source/dnode/mgmt/inc/mmInt.h
source/dnode/mgmt/inc/mmInt.h
+1
-0
source/dnode/mgmt/mm/mmInt.c
source/dnode/mgmt/mm/mmInt.c
+4
-10
source/dnode/mgmt/mm/mmWorker.c
source/dnode/mgmt/mm/mmWorker.c
+14
-10
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+2
-1
source/dnode/mnode/impl/inc/mndMnode.h
source/dnode/mnode/impl/inc/mndMnode.h
+8
-6
source/dnode/mnode/impl/src/mndBnode.c
source/dnode/mnode/impl/src/mndBnode.c
+1
-1
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+1
-1
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+8
-0
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+69
-62
source/dnode/mnode/impl/src/mndQnode.c
source/dnode/mnode/impl/src/mndQnode.c
+2
-2
source/dnode/mnode/impl/src/mndSnode.c
source/dnode/mnode/impl/src/mndSnode.c
+1
-1
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+3
-2
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+1
-1
source/util/src/terror.c
source/util/src/terror.c
+3
-0
未找到文件。
include/util/taoserror.h
浏览文件 @
c1b3afa9
...
...
@@ -195,6 +195,9 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_SNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0355)
#define TSDB_CODE_MND_BNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0356)
#define TSDB_CODE_MND_BNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0357)
#define TSDB_CODE_MND_TOO_FEW_MNODES TAOS_DEF_ERROR_CODE(0, 0x0358)
#define TSDB_CODE_MND_MNODE_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0359)
#define TSDB_CODE_MND_CANT_DROP_MASTER TAOS_DEF_ERROR_CODE(0, 0x035A)
// mnode-acct
#define TSDB_CODE_MND_ACCT_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360)
...
...
source/dnode/mgmt/inc/mmInt.h
浏览文件 @
c1b3afa9
...
...
@@ -62,6 +62,7 @@ int32_t mmProcessSyncMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
int32_t
mmProcessReadMsg
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
);
int32_t
mmProcessQueryMsg
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
);
int32_t
mmProcessMonitorMsg
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
);
int32_t
mmPutMsgToQueryQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
);
int32_t
mmPutMsgToReadQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
);
int32_t
mmPutMsgToWriteQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
);
...
...
source/dnode/mgmt/mm/mmInt.c
浏览文件 @
c1b3afa9
...
...
@@ -48,15 +48,13 @@ static void mmInitOption(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) {
}
static
void
mmBuildOptionForDeploy
(
SMnodeMgmt
*
pMgmt
,
SMnodeOpt
*
pOption
)
{
SDnode
*
pDnode
=
pMgmt
->
pDnode
;
mmInitOption
(
pMgmt
,
pOption
);
pOption
->
replica
=
1
;
pOption
->
selfIndex
=
0
;
SReplica
*
pReplica
=
&
pOption
->
replicas
[
0
];
pReplica
->
id
=
1
;
pReplica
->
port
=
pDnode
->
serverPort
;
tstrncpy
(
pReplica
->
fqdn
,
pDnode
->
localFqdn
,
TSDB_FQDN_LEN
);
pReplica
->
port
=
p
Mgmt
->
p
Dnode
->
serverPort
;
tstrncpy
(
pReplica
->
fqdn
,
p
Mgmt
->
p
Dnode
->
localFqdn
,
TSDB_FQDN_LEN
);
pOption
->
deploy
=
true
;
pMgmt
->
selfIndex
=
pOption
->
selfIndex
;
...
...
@@ -151,12 +149,9 @@ static void mmCloseImp(SMnodeMgmt *pMgmt) {
int32_t
mmAlter
(
SMnodeMgmt
*
pMgmt
,
SDAlterMnodeReq
*
pReq
)
{
SMnodeOpt
option
=
{
0
};
if
(
pReq
!=
NULL
)
{
if
(
mmBuildOptionFromReq
(
pMgmt
,
&
option
,
pReq
)
!=
0
)
{
return
-
1
;
}
if
(
mmBuildOptionFromReq
(
pMgmt
,
&
option
,
pReq
)
!=
0
)
{
return
-
1
;
}
return
mndAlter
(
pMgmt
->
pMnode
,
&
option
);
}
...
...
@@ -240,4 +235,3 @@ void mmSetMgmtFp(SMgmtWrapper *pWrapper) {
pWrapper
->
name
=
"mnode"
;
pWrapper
->
fp
=
mgmtFp
;
}
source/dnode/mgmt/mm/mmWorker.c
浏览文件 @
c1b3afa9
...
...
@@ -16,6 +16,15 @@
#define _DEFAULT_SOURCE
#include "mmInt.h"
static
inline
void
mmSendRsp
(
SNodeMsg
*
pMsg
,
int32_t
code
)
{
SRpcMsg
rsp
=
{.
handle
=
pMsg
->
rpcMsg
.
handle
,
.
ahandle
=
pMsg
->
rpcMsg
.
ahandle
,
.
code
=
code
,
.
pCont
=
pMsg
->
pRsp
,
.
contLen
=
pMsg
->
rspLen
};
tmsgSendRsp
(
&
rsp
);
}
static
void
mmProcessQueue
(
SQueueInfo
*
pInfo
,
SNodeMsg
*
pMsg
)
{
SMnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
...
...
@@ -35,8 +44,7 @@ static void mmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
if
(
pRpc
->
msgType
&
1U
)
{
if
(
pRpc
->
handle
!=
NULL
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
if
(
code
!=
0
&&
terrno
!=
0
)
code
=
terrno
;
SRpcMsg
rsp
=
{.
handle
=
pRpc
->
handle
,
.
code
=
code
,
.
contLen
=
pMsg
->
rspLen
,
.
pCont
=
pMsg
->
pRsp
};
tmsgSendRsp
(
&
rsp
);
mmSendRsp
(
pMsg
,
code
);
}
}
...
...
@@ -48,7 +56,7 @@ static void mmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
static
void
mmProcessQueryQueue
(
SQueueInfo
*
pInfo
,
SNodeMsg
*
pMsg
)
{
SMnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
dTrace
(
"msg:%p, get from mnode
query queue"
,
pMsg
);
dTrace
(
"msg:%p, get from mnode
-
query queue"
,
pMsg
);
SRpcMsg
*
pRpc
=
&
pMsg
->
rpcMsg
;
int32_t
code
=
-
1
;
...
...
@@ -58,8 +66,7 @@ static void mmProcessQueryQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
if
(
pRpc
->
msgType
&
1U
)
{
if
(
pRpc
->
handle
!=
NULL
&&
code
!=
0
)
{
dError
(
"msg:%p, failed to process since %s"
,
pMsg
,
terrstr
());
SRpcMsg
rsp
=
{.
handle
=
pRpc
->
handle
,
.
code
=
code
,
.
ahandle
=
pRpc
->
ahandle
};
tmsgSendRsp
(
&
rsp
);
mmSendRsp
(
pMsg
,
code
);
}
}
...
...
@@ -98,11 +105,8 @@ int32_t mmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
}
int32_t
mmProcessMonitorMsg
(
SMgmtWrapper
*
pWrapper
,
SNodeMsg
*
pMsg
)
{
SMnodeMgmt
*
pMgmt
=
pWrapper
->
pMgmt
;
SSingleWorker
*
pWorker
=
&
pMgmt
->
monitorWorker
;
dTrace
(
"msg:%p, put into worker:%s"
,
pMsg
,
pWorker
->
name
);
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
SMnodeMgmt
*
pMgmt
=
pWrapper
->
pMgmt
;
mmPutMsgToWorker
(
&
pMgmt
->
monitorWorker
,
pMsg
);
return
0
;
}
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
c1b3afa9
...
...
@@ -100,6 +100,7 @@ typedef struct {
}
SGrantInfo
;
typedef
struct
SMnode
{
int32_t
selfId
;
int64_t
clusterId
;
int8_t
replica
;
int8_t
selfIndex
;
...
...
@@ -121,7 +122,7 @@ typedef struct SMnode {
SHashObj
*
infosMeta
;
SGrantInfo
grant
;
MndMsgFp
msgFp
[
TDMT_MAX
];
SMsgCb
msgCb
;
SMsgCb
msgCb
;
}
SMnode
;
void
mndSetMsgHandle
(
SMnode
*
pMnode
,
tmsg_t
msgType
,
MndMsgFp
fp
);
...
...
source/dnode/mnode/impl/inc/mndMnode.h
浏览文件 @
c1b3afa9
...
...
@@ -22,12 +22,14 @@
extern
"C"
{
#endif
int32_t
mndInitMnode
(
SMnode
*
pMnode
);
void
mndCleanupMnode
(
SMnode
*
pMnode
);
bool
mndIsMnode
(
SMnode
*
pMnode
,
int32_t
dnodeId
);
void
mndGetMnodeEpSet
(
SMnode
*
pMnode
,
SEpSet
*
pEpSet
);
char
*
mndGetRoleStr
(
int32_t
role
);
void
mndUpdateMnodeRole
(
SMnode
*
pMnode
);
int32_t
mndInitMnode
(
SMnode
*
pMnode
);
void
mndCleanupMnode
(
SMnode
*
pMnode
);
SMnodeObj
*
mndAcquireMnode
(
SMnode
*
pMnode
,
int32_t
mnodeId
);
void
mndReleaseMnode
(
SMnode
*
pMnode
,
SMnodeObj
*
pObj
);
bool
mndIsMnode
(
SMnode
*
pMnode
,
int32_t
dnodeId
);
void
mndGetMnodeEpSet
(
SMnode
*
pMnode
,
SEpSet
*
pEpSet
);
void
mndUpdateMnodeRole
(
SMnode
*
pMnode
);
const
char
*
mndGetRoleStr
(
int32_t
role
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndBnode.c
浏览文件 @
c1b3afa9
...
...
@@ -396,7 +396,7 @@ static int32_t mndProcessDropBnodeReq(SNodeMsg *pReq) {
mDebug
(
"bnode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
dropReq
.
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_
SDB_APP_ERROR
;
terrno
=
TSDB_CODE_
INVALID_MSG
;
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
c1b3afa9
...
...
@@ -1040,7 +1040,7 @@ static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) {
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
while
(
true
)
{
while
(
1
)
{
SVgObj
*
pVgroup
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
c1b3afa9
...
...
@@ -552,6 +552,7 @@ static int32_t mndProcessDropDnodeReq(SNodeMsg *pReq) {
int32_t
code
=
-
1
;
SUserObj
*
pUser
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
SMnodeObj
*
pMObj
=
NULL
;
SMDropMnodeReq
dropReq
=
{
0
};
if
(
tDeserializeSCreateDropMQSBNodeReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
dropReq
)
!=
0
)
{
...
...
@@ -572,6 +573,12 @@ static int32_t mndProcessDropDnodeReq(SNodeMsg *pReq) {
goto
DROP_DNODE_OVER
;
}
pMObj
=
mndAcquireMnode
(
pMnode
,
dropReq
.
dnodeId
);
if
(
pMObj
!=
NULL
)
{
terrno
=
TSDB_CODE_MND_MNODE_DEPLOYED
;
goto
DROP_DNODE_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
...
...
@@ -592,6 +599,7 @@ DROP_DNODE_OVER:
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseMnode
(
pMnode
,
pMObj
);
return
code
;
}
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
c1b3afa9
...
...
@@ -21,8 +21,8 @@
#include "mndTrans.h"
#include "mndUser.h"
#define
TSDB_
MNODE_VER_NUMBER 1
#define
TSDB_
MNODE_RESERVE_SIZE 64
#define MNODE_VER_NUMBER 1
#define MNODE_RESERVE_SIZE 64
static
int32_t
mndCreateDefaultMnode
(
SMnode
*
pMnode
);
static
SSdbRaw
*
mndMnodeActionEncode
(
SMnodeObj
*
pObj
);
...
...
@@ -64,21 +64,20 @@ int32_t mndInitMnode(SMnode *pMnode) {
void
mndCleanupMnode
(
SMnode
*
pMnode
)
{}
static
SMnodeObj
*
mndAcquireMnode
(
SMnode
*
pMnode
,
int32_t
mnodeId
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SMnodeObj
*
pObj
=
sdbAcquire
(
pSdb
,
SDB_MNODE
,
&
mnodeId
);
SMnodeObj
*
mndAcquireMnode
(
SMnode
*
pMnode
,
int32_t
mnodeId
)
{
SMnodeObj
*
pObj
=
sdbAcquire
(
pMnode
->
pSdb
,
SDB_MNODE
,
&
mnodeId
);
if
(
pObj
==
NULL
&&
terrno
==
TSDB_CODE_SDB_OBJ_NOT_THERE
)
{
terrno
=
TSDB_CODE_MND_MNODE_NOT_EXIST
;
}
return
pObj
;
}
static
void
mndReleaseMnode
(
SMnode
*
pMnode
,
SMnodeObj
*
pObj
)
{
void
mndReleaseMnode
(
SMnode
*
pMnode
,
SMnodeObj
*
pObj
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbRelease
(
pSdb
,
pObj
);
sdbRelease
(
p
Mnode
->
p
Sdb
,
pObj
);
}
char
*
mndGetRoleStr
(
int32_t
showType
)
{
c
onst
c
har
*
mndGetRoleStr
(
int32_t
showType
)
{
switch
(
showType
)
{
case
TAOS_SYNC_STATE_FOLLOWER
:
return
"unsynced"
;
...
...
@@ -130,18 +129,18 @@ static int32_t mndCreateDefaultMnode(SMnode *pMnode) {
static
SSdbRaw
*
mndMnodeActionEncode
(
SMnodeObj
*
pObj
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_MNODE
,
TSDB_MNODE_VER_NUMBER
,
sizeof
(
SMnodeObj
)
+
TSDB_
MNODE_RESERVE_SIZE
);
if
(
pRaw
==
NULL
)
goto
MNODE_ENCODE
_OVER
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_MNODE
,
MNODE_VER_NUMBER
,
sizeof
(
SMnodeObj
)
+
MNODE_RESERVE_SIZE
);
if
(
pRaw
==
NULL
)
goto
_OVER
;
int32_t
dataPos
=
0
;
SDB_SET_INT32
(
pRaw
,
dataPos
,
pObj
->
id
,
MNODE_ENCODE
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pObj
->
createdTime
,
MNODE_ENCODE
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pObj
->
updateTime
,
MNODE_ENCODE
_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_MNODE_RESERVE_SIZE
,
MNODE_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pObj
->
id
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pObj
->
createdTime
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pObj
->
updateTime
,
_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MNODE_RESERVE_SIZE
,
_OVER
)
terrno
=
0
;
MNODE_ENCODE
_OVER:
_OVER:
if
(
terrno
!=
0
)
{
mError
(
"mnode:%d, failed to encode to raw:%p since %s"
,
pObj
->
id
,
pRaw
,
terrstr
());
sdbFreeRaw
(
pRaw
);
...
...
@@ -158,26 +157,26 @@ static SSdbRow *mndMnodeActionDecode(SSdbRaw *pRaw) {
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
return
NULL
;
if
(
sver
!=
TSDB_
MNODE_VER_NUMBER
)
{
if
(
sver
!=
MNODE_VER_NUMBER
)
{
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
goto
MNODE_DECODE
_OVER
;
goto
_OVER
;
}
SSdbRow
*
pRow
=
sdbAllocRow
(
sizeof
(
SMnodeObj
));
if
(
pRow
==
NULL
)
goto
MNODE_DECODE
_OVER
;
if
(
pRow
==
NULL
)
goto
_OVER
;
SMnodeObj
*
pObj
=
sdbGetRowObj
(
pRow
);
if
(
pObj
==
NULL
)
goto
MNODE_DECODE
_OVER
;
if
(
pObj
==
NULL
)
goto
_OVER
;
int32_t
dataPos
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pObj
->
id
,
MNODE_DECODE
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pObj
->
createdTime
,
MNODE_DECODE
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pObj
->
updateTime
,
MNODE_DECODE
_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
TSDB_MNODE_RESERVE_SIZE
,
MNODE_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pObj
->
id
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pObj
->
createdTime
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pObj
->
updateTime
,
_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
MNODE_RESERVE_SIZE
,
_OVER
)
terrno
=
0
;
MNODE_DECODE
_OVER:
_OVER:
if
(
terrno
!=
0
)
{
mError
(
"mnode:%d, failed to decode from raw:%p since %s"
,
pObj
->
id
,
pRaw
,
terrstr
());
taosMemoryFreeClear
(
pRow
);
...
...
@@ -188,8 +187,6 @@ MNODE_DECODE_OVER:
return
pRow
;
}
static
void
mnodeResetMnode
(
SMnodeObj
*
pObj
)
{
pObj
->
role
=
TAOS_SYNC_STATE_FOLLOWER
;
}
static
int32_t
mndMnodeActionInsert
(
SSdb
*
pSdb
,
SMnodeObj
*
pObj
)
{
mTrace
(
"mnode:%d, perform insert action, row:%p"
,
pObj
->
id
,
pObj
);
pObj
->
pDnode
=
sdbAcquire
(
pSdb
,
SDB_DNODE
,
&
pObj
->
id
);
...
...
@@ -199,7 +196,7 @@ static int32_t mndMnodeActionInsert(SSdb *pSdb, SMnodeObj *pObj) {
return
-
1
;
}
mnodeResetMnode
(
pObj
)
;
pObj
->
role
=
TAOS_SYNC_STATE_FOLLOWER
;
return
0
;
}
...
...
@@ -233,7 +230,6 @@ bool mndIsMnode(SMnode *pMnode, int32_t dnodeId) {
void
mndGetMnodeEpSet
(
SMnode
*
pMnode
,
SEpSet
*
pEpSet
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
pEpSet
->
numOfEps
=
0
;
void
*
pIter
=
NULL
;
...
...
@@ -241,14 +237,15 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
SMnodeObj
*
pObj
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pObj
);
if
(
pIter
==
NULL
)
break
;
if
(
pObj
->
pDnode
==
NULL
)
break
;
if
(
pObj
->
role
==
TAOS_SYNC_STATE_LEADER
)
{
pEpSet
->
inUse
=
pEpSet
->
numOfEps
;
if
(
pObj
->
pDnode
==
NULL
)
{
mError
(
"mnode:%d, no corresponding dnode exists"
,
pObj
->
id
);
}
else
{
if
(
pObj
->
role
==
TAOS_SYNC_STATE_LEADER
)
{
pEpSet
->
inUse
=
pEpSet
->
numOfEps
;
}
addEpIntoEpSet
(
pEpSet
,
pObj
->
pDnode
->
fqdn
,
pObj
->
pDnode
->
port
);
sdbRelease
(
pSdb
,
pObj
);
}
addEpIntoEpSet
(
pEpSet
,
pObj
->
pDnode
->
fqdn
,
pObj
->
pDnode
->
port
);
sdbRelease
(
pSdb
,
pObj
);
}
}
...
...
@@ -364,18 +361,18 @@ static int32_t mndCreateMnode(SMnode *pMnode, SNodeMsg *pReq, SDnodeObj *pDnode,
mnodeObj
.
updateTime
=
mnodeObj
.
createdTime
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_TYPE_CREATE_MNODE
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
CREATE_MNODE
_OVER
;
if
(
pTrans
==
NULL
)
goto
_OVER
;
mDebug
(
"trans:%d, used to create mnode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
if
(
mndSetCreateMnodeRedoLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
goto
CREATE_MNODE
_OVER
;
if
(
mndSetCreateMnodeCommitLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
goto
CREATE_MNODE
_OVER
;
if
(
mndSetCreateMnodeRedoActions
(
pMnode
,
pTrans
,
pDnode
,
&
mnodeObj
)
!=
0
)
goto
CREATE_MNODE
_OVER
;
if
(
mndSetCreateMnodeRedoLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateMnodeCommitLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateMnodeRedoActions
(
pMnode
,
pTrans
,
pDnode
,
&
mnodeObj
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
CREATE_MNODE
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
CREATE_MNODE
_OVER:
_OVER:
mndTransDrop
(
pTrans
);
return
code
;
}
...
...
@@ -390,7 +387,7 @@ static int32_t mndProcessCreateMnodeReq(SNodeMsg *pReq) {
if
(
tDeserializeSCreateDropMQSBNodeReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
createReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
CREATE_MNODE
_OVER
;
goto
_OVER
;
}
mDebug
(
"mnode:%d, start to create"
,
createReq
.
dnodeId
);
...
...
@@ -398,31 +395,31 @@ static int32_t mndProcessCreateMnodeReq(SNodeMsg *pReq) {
pObj
=
mndAcquireMnode
(
pMnode
,
createReq
.
dnodeId
);
if
(
pObj
!=
NULL
)
{
terrno
=
TSDB_CODE_MND_MNODE_ALREADY_EXIST
;
goto
CREATE_MNODE
_OVER
;
goto
_OVER
;
}
else
if
(
terrno
!=
TSDB_CODE_MND_MNODE_NOT_EXIST
)
{
goto
CREATE_MNODE
_OVER
;
goto
_OVER
;
}
pDnode
=
mndAcquireDnode
(
pMnode
,
createReq
.
dnodeId
);
if
(
pDnode
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
goto
CREATE_MNODE
_OVER
;
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
CREATE_MNODE
_OVER
;
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
))
{
goto
CREATE_MNODE
_OVER
;
goto
_OVER
;
}
code
=
mndCreateMnode
(
pMnode
,
pReq
,
pDnode
,
&
createReq
);
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
CREATE_MNODE
_OVER:
_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"mnode:%d, failed to create since %s"
,
createReq
.
dnodeId
,
terrstr
());
}
...
...
@@ -531,18 +528,18 @@ static int32_t mndDropMnode(SMnode *pMnode, SNodeMsg *pReq, SMnodeObj *pObj) {
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_TYPE_DROP_MNODE
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
DROP_MNODE
_OVER
;
if
(
pTrans
==
NULL
)
goto
_OVER
;
mDebug
(
"trans:%d, used to drop mnode:%d"
,
pTrans
->
id
,
pObj
->
id
);
if
(
mndSetDropMnodeRedoLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
goto
DROP_MNODE
_OVER
;
if
(
mndSetDropMnodeCommitLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
goto
DROP_MNODE
_OVER
;
if
(
mndSetDropMnodeRedoActions
(
pMnode
,
pTrans
,
pObj
->
pDnode
,
pObj
)
!=
0
)
goto
DROP_MNODE
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
DROP_MNODE
_OVER
;
if
(
mndSetDropMnodeRedoLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropMnodeCommitLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropMnodeRedoActions
(
pMnode
,
pTrans
,
pObj
->
pDnode
,
pObj
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
DROP_MNODE
_OVER:
_OVER:
mndTransDrop
(
pTrans
);
return
code
;
}
...
...
@@ -556,35 +553,45 @@ static int32_t mndProcessDropMnodeReq(SNodeMsg *pReq) {
if
(
tDeserializeSCreateDropMQSBNodeReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
dropReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
DROP_MNODE
_OVER
;
goto
_OVER
;
}
mDebug
(
"mnode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
dropReq
.
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_
SDB_APP_ERROR
;
goto
DROP_MNODE
_OVER
;
terrno
=
TSDB_CODE_
INVALID_MSG
;
goto
_OVER
;
}
pObj
=
mndAcquireMnode
(
pMnode
,
dropReq
.
dnodeId
);
if
(
pObj
==
NULL
)
{
goto
DROP_MNODE_OVER
;
goto
_OVER
;
}
if
(
pMnode
->
selfId
==
dropReq
.
dnodeId
)
{
terrno
=
TSDB_CODE_MND_CANT_DROP_MASTER
;
goto
_OVER
;
}
if
(
sdbGetSize
(
pMnode
->
pSdb
,
SDB_MNODE
)
<=
1
)
{
terrno
=
TSDB_CODE_MND_TOO_FEW_MNODES
;
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
DROP_MNODE
_OVER
;
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
))
{
goto
DROP_MNODE
_OVER
;
goto
_OVER
;
}
code
=
mndDropMnode
(
pMnode
,
pReq
,
pObj
);
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
DROP_MNODE
_OVER:
_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"mnode:%d, failed to drop since %s"
,
dropReq
.
dnodeId
,
terrstr
());
}
...
...
@@ -687,7 +694,7 @@ static int32_t mndRetrieveMnodes(SNodeMsg *pReq, SShowObj *pShow, char *data, in
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
char
*
roles
=
mndGetRoleStr
(
pObj
->
role
);
c
onst
c
har
*
roles
=
mndGetRoleStr
(
pObj
->
role
);
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
roles
,
pShow
->
bytes
[
cols
]);
cols
++
;
...
...
source/dnode/mnode/impl/src/mndQnode.c
浏览文件 @
c1b3afa9
...
...
@@ -398,7 +398,7 @@ static int32_t mndProcessDropQnodeReq(SNodeMsg *pReq) {
mDebug
(
"qnode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
dropReq
.
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_
SDB_APP_ERROR
;
terrno
=
TSDB_CODE_
INVALID_MSG
;
goto
_OVER
;
}
...
...
@@ -453,7 +453,7 @@ static int32_t mndProcessQnodeListReq(SNodeMsg *pReq) {
goto
_OVER
;
}
while
(
true
)
{
while
(
1
)
{
void
*
pIter
=
sdbFetch
(
pSdb
,
SDB_QNODE
,
NULL
,
(
void
**
)
&
pObj
);
if
(
pIter
==
NULL
)
break
;
...
...
source/dnode/mnode/impl/src/mndSnode.c
浏览文件 @
c1b3afa9
...
...
@@ -406,7 +406,7 @@ static int32_t mndProcessDropSnodeReq(SNodeMsg *pReq) {
mDebug
(
"snode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
dropReq
.
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_
SDB_APP_ERROR
;
terrno
=
TSDB_CODE_
INVALID_MSG
;
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
c1b3afa9
...
...
@@ -105,7 +105,6 @@ static int32_t mndRestoreWal(SMnode *pMnode) {
if
(
walEndSnapshot
(
pWal
)
<
0
)
{
goto
WAL_RESTORE_OVER
;
}
}
code
=
0
;
...
...
@@ -129,7 +128,9 @@ int32_t mndInitSync(SMnode *pMnode) {
return
-
1
;
}
pMgmt
->
state
=
TAOS_SYNC_STATE_LEADER
;
if
(
pMnode
->
selfId
==
1
)
{
pMgmt
->
state
=
TAOS_SYNC_STATE_LEADER
;
}
pMgmt
->
pSyncNode
=
NULL
;
return
0
;
}
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
c1b3afa9
...
...
@@ -215,7 +215,6 @@ static int32_t mndInitSteps(SMnode *pMnode, bool deploy) {
}
else
{
if
(
mndAllocStep
(
pMnode
,
"mnode-sdb-read"
,
mndReadSdb
,
NULL
)
!=
0
)
return
-
1
;
}
// if (mndAllocStep(pMnode, "mnode-timer", mndInitTimer, NULL) != 0) return -1;
if
(
mndAllocStep
(
pMnode
,
"mnode-profile"
,
mndInitProfile
,
mndCleanupProfile
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-show"
,
mndInitShow
,
mndCleanupShow
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-query"
,
mndInitQuery
,
mndCleanupQuery
)
!=
0
)
return
-
1
;
...
...
@@ -272,6 +271,7 @@ static void mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
pMnode
->
selfIndex
=
pOption
->
selfIndex
;
memcpy
(
&
pMnode
->
replicas
,
pOption
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
pMnode
->
msgCb
=
pOption
->
msgCb
;
pMnode
->
selfId
=
pOption
->
replicas
[
pOption
->
selfIndex
].
id
;
}
SMnode
*
mndOpen
(
const
char
*
path
,
const
SMnodeOpt
*
pOption
)
{
...
...
source/util/src/terror.c
浏览文件 @
c1b3afa9
...
...
@@ -201,6 +201,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_SNODE_ALREADY_EXIST, "Snode already exists"
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_SNODE_NOT_EXIST
,
"Snode not there"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_BNODE_ALREADY_EXIST
,
"Bnode already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_BNODE_NOT_EXIST
,
"Bnode not there"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TOO_FEW_MNODES
,
"Too few mnodes"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_MNODE_DEPLOYED
,
"Mnode deployed in this dnode"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_CANT_DROP_MASTER
,
"Can't drop mnode which is master"
)
// mnode-acct
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_ACCT_ALREADY_EXIST
,
"Account already exists"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录