serialize node msg
This commit is contained in:
parent
9b75a243d3
commit
34361b11a0
|
@ -872,15 +872,11 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
} SMCreateQnodeReq, SMDropQnodeReq, SDCreateQnodeReq, SDDropQnodeReq;
|
} SMCreateQnodeReq, SMDropQnodeReq, SDCreateQnodeReq, SDDropQnodeReq, SMCreateSnodeReq, SMDropSnodeReq,
|
||||||
|
SDCreateSnodeReq, SDDropSnodeReq, SMCreateBnodeReq, SMDropBnodeReq, SDCreateBnodeReq, SDDropBnodeReq;
|
||||||
|
|
||||||
typedef struct {
|
int32_t tSerializeSMCreateDropQSBNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq);
|
||||||
int32_t dnodeId;
|
int32_t tDeserializeSMCreateDropQSBNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq);
|
||||||
} SMCreateSnodeReq, SMDropSnodeReq, SDCreateSnodeReq, SDDropSnodeReq;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t dnodeId;
|
|
||||||
} SMCreateBnodeReq, SMDropBnodeReq, SDCreateBnodeReq, SDDropBnodeReq;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char sql[TSDB_SHOW_SQL_LEN];
|
char sql[TSDB_SHOW_SQL_LEN];
|
||||||
|
|
|
@ -823,3 +823,28 @@ int32_t tDeserializeSGetUserAuthRsp(void *buf, int32_t bufLen, SGetUserAuthRsp *
|
||||||
tCoderClear(&decoder);
|
tCoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tSerializeSMCreateDropQSBNodeReq(void *buf, int32_t bufLen, SMCreateQnodeReq *pReq) {
|
||||||
|
SCoder encoder = {0};
|
||||||
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
|
if (tStartEncode(&encoder) < 0) return -1;
|
||||||
|
if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1;
|
||||||
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tCoderClear(&encoder);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDeserializeSMCreateDropQSBNodeReq(void *buf, int32_t bufLen, SMCreateQnodeReq *pReq) {
|
||||||
|
SCoder decoder = {0};
|
||||||
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
if (tStartDecode(&decoder) < 0) return -1;
|
||||||
|
if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1;
|
||||||
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
tCoderClear(&decoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,10 @@ int32_t mndCheckCreateUserAuth(SUserObj *pOperUser);
|
||||||
int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SDbObj *pDb, SAlterUserReq *pAlter);
|
int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SDbObj *pDb, SAlterUserReq *pAlter);
|
||||||
int32_t mndCheckDropUserAuth(SUserObj *pOperUser);
|
int32_t mndCheckDropUserAuth(SUserObj *pOperUser);
|
||||||
|
|
||||||
|
int32_t mndCheckCreateNodeAuth(SUserObj *pOperUser);
|
||||||
|
int32_t mndCheckDropNodeAuth(SUserObj *pOperUser);
|
||||||
|
int32_t mndCheckAlterNodeAuth(SUserObj *pOperUser);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -109,4 +109,17 @@ int32_t mndCheckDropUserAuth(SUserObj *pOperUser) {
|
||||||
|
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t mndCheckCreateNodeAuth(SUserObj *pOperUser) {
|
||||||
|
if (pOperUser->superUser) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndCheckDropNodeAuth(SUserObj *pOperUser) { return mndCheckCreateNodeAuth(pOperUser); }
|
||||||
|
|
||||||
|
int32_t mndCheckAlterNodeAuth(SUserObj *pOperUser) { return mndCheckCreateNodeAuth(pOperUser); }
|
||||||
|
|
|
@ -15,9 +15,11 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndBnode.h"
|
#include "mndBnode.h"
|
||||||
|
#include "mndAuth.h"
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
|
#include "mndUser.h"
|
||||||
|
|
||||||
#define TSDB_BNODE_VER_NUMBER 1
|
#define TSDB_BNODE_VER_NUMBER 1
|
||||||
#define TSDB_BNODE_RESERVE_SIZE 64
|
#define TSDB_BNODE_RESERVE_SIZE 64
|
||||||
|
@ -257,40 +259,57 @@ CREATE_BNODE_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SMCreateBnodeReq *pCreate = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
|
SBnodeObj *pObj = NULL;
|
||||||
|
SDnodeObj *pDnode = NULL;
|
||||||
|
SUserObj *pUser = NULL;
|
||||||
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
|
||||||
pCreate->dnodeId = htonl(pCreate->dnodeId);
|
if (tDeserializeSMCreateDropQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &createReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto CREATE_BNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
mDebug("bnode:%d, start to create", pCreate->dnodeId);
|
mDebug("bnode:%d, start to create", createReq.dnodeId);
|
||||||
|
|
||||||
SBnodeObj *pObj = mndAcquireBnode(pMnode, pCreate->dnodeId);
|
pObj = mndAcquireBnode(pMnode, createReq.dnodeId);
|
||||||
if (pObj != NULL) {
|
if (pObj != NULL) {
|
||||||
mError("bnode:%d, bnode already exist", pObj->id);
|
|
||||||
terrno = TSDB_CODE_MND_BNODE_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_BNODE_ALREADY_EXIST;
|
||||||
mndReleaseBnode(pMnode, pObj);
|
goto CREATE_BNODE_OVER;
|
||||||
return -1;
|
|
||||||
} else if (terrno != TSDB_CODE_MND_BNODE_NOT_EXIST) {
|
} else if (terrno != TSDB_CODE_MND_BNODE_NOT_EXIST) {
|
||||||
mError("bnode:%d, failed to create bnode since %s", pCreate->dnodeId, terrstr());
|
goto CREATE_BNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pCreate->dnodeId);
|
pDnode = mndAcquireDnode(pMnode, createReq.dnodeId);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
mError("bnode:%d, dnode not exist", pCreate->dnodeId);
|
|
||||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||||
return -1;
|
goto CREATE_BNODE_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndCreateBnode(pMnode, pReq, pDnode, pCreate);
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
|
goto CREATE_BNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckDropNodeAuth(pUser)) {
|
||||||
|
goto CREATE_BNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndCreateBnode(pMnode, pReq, pDnode, &createReq);
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
CREATE_BNODE_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
|
mError("bnode:%d, failed to create since %s", createReq.dnodeId, terrstr());
|
||||||
|
}
|
||||||
|
|
||||||
|
mndReleaseBnode(pMnode, pObj);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
if (code != 0) {
|
return code;
|
||||||
mError("bnode:%d, failed to create since %s", pCreate->dnodeId, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSetDropBnodeRedoLogs(STrans *pTrans, SBnodeObj *pObj) {
|
static int32_t mndSetDropBnodeRedoLogs(STrans *pTrans, SBnodeObj *pObj) {
|
||||||
|
@ -352,33 +371,51 @@ DROP_BNODE_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessDropBnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessDropBnodeReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SMDropBnodeReq *pDrop = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
pDrop->dnodeId = htonl(pDrop->dnodeId);
|
SUserObj *pUser = NULL;
|
||||||
|
SBnodeObj *pObj = NULL;
|
||||||
|
SMDropBnodeReq dropReq = {0};
|
||||||
|
|
||||||
mDebug("bnode:%d, start to drop", pDrop->dnodeId);
|
if (tDeserializeSMCreateDropQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto DROP_BNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (pDrop->dnodeId <= 0) {
|
mDebug("bnode:%d, start to drop", dropReq.dnodeId);
|
||||||
|
|
||||||
|
if (dropReq.dnodeId <= 0) {
|
||||||
terrno = TSDB_CODE_SDB_APP_ERROR;
|
terrno = TSDB_CODE_SDB_APP_ERROR;
|
||||||
mError("bnode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
goto DROP_BNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SBnodeObj *pObj = mndAcquireBnode(pMnode, pDrop->dnodeId);
|
pObj = mndAcquireBnode(pMnode, dropReq.dnodeId);
|
||||||
if (pObj == NULL) {
|
if (pObj == NULL) {
|
||||||
mError("bnode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
goto DROP_BNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndDropBnode(pMnode, pReq, pObj);
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
if (code != 0) {
|
if (pUser == NULL) {
|
||||||
sdbRelease(pMnode->pSdb, pObj);
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
mError("bnode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
goto DROP_BNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbRelease(pMnode->pSdb, pObj);
|
if (mndCheckCreateNodeAuth(pUser)) {
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
goto DROP_BNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndDropBnode(pMnode, pReq, pObj);
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
DROP_BNODE_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
|
mError("bnode:%d, failed to drop since %s", dropReq.dnodeId, terrstr());
|
||||||
|
}
|
||||||
|
|
||||||
|
mndReleaseBnode(pMnode, pObj);
|
||||||
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateBnodeRsp(SMnodeMsg *pRsp) {
|
static int32_t mndProcessCreateBnodeRsp(SMnodeMsg *pRsp) {
|
||||||
|
|
|
@ -15,9 +15,11 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndQnode.h"
|
#include "mndQnode.h"
|
||||||
|
#include "mndAuth.h"
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
|
#include "mndUser.h"
|
||||||
|
|
||||||
#define TSDB_QNODE_VER_NUMBER 1
|
#define TSDB_QNODE_VER_NUMBER 1
|
||||||
#define TSDB_QNODE_RESERVE_SIZE 64
|
#define TSDB_QNODE_RESERVE_SIZE 64
|
||||||
|
@ -257,40 +259,58 @@ CREATE_QNODE_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SMCreateQnodeReq *pCreate = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
|
SQnodeObj *pObj = NULL;
|
||||||
|
SDnodeObj *pDnode = NULL;
|
||||||
|
SUserObj *pUser = NULL;
|
||||||
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
|
||||||
pCreate->dnodeId = htonl(pCreate->dnodeId);
|
if (tDeserializeSMCreateDropQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &createReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto CREATE_QNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
mDebug("qnode:%d, start to create", pCreate->dnodeId);
|
mDebug("qnode:%d, start to create", createReq.dnodeId);
|
||||||
|
|
||||||
SQnodeObj *pObj = mndAcquireQnode(pMnode, pCreate->dnodeId);
|
pObj = mndAcquireQnode(pMnode, createReq.dnodeId);
|
||||||
if (pObj != NULL) {
|
if (pObj != NULL) {
|
||||||
mError("qnode:%d, qnode already exist", pObj->id);
|
|
||||||
terrno = TSDB_CODE_MND_QNODE_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_QNODE_ALREADY_EXIST;
|
||||||
mndReleaseQnode(pMnode, pObj);
|
goto CREATE_QNODE_OVER;
|
||||||
return -1;
|
|
||||||
} else if (terrno != TSDB_CODE_MND_QNODE_NOT_EXIST) {
|
} else if (terrno != TSDB_CODE_MND_QNODE_NOT_EXIST) {
|
||||||
mError("qnode:%d, failed to create qnode since %s", pCreate->dnodeId, terrstr());
|
goto CREATE_QNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pCreate->dnodeId);
|
pDnode = mndAcquireDnode(pMnode, createReq.dnodeId);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
mError("qnode:%d, dnode not exist", pCreate->dnodeId);
|
|
||||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||||
|
goto CREATE_QNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
|
goto CREATE_QNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckDropNodeAuth(pUser)) {
|
||||||
|
goto CREATE_QNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndCreateQnode(pMnode, pReq, pDnode, &createReq);
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
CREATE_QNODE_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
|
mError("qnode:%d, failed to create since %s", createReq.dnodeId, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndCreateQnode(pMnode, pReq, pDnode, pCreate);
|
mndReleaseQnode(pMnode, pObj);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
if (code != 0) {
|
return code;
|
||||||
mError("qnode:%d, failed to create since %s", pCreate->dnodeId, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSetDropQnodeRedoLogs(STrans *pTrans, SQnodeObj *pObj) {
|
static int32_t mndSetDropQnodeRedoLogs(STrans *pTrans, SQnodeObj *pObj) {
|
||||||
|
@ -352,33 +372,52 @@ DROP_QNODE_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessDropQnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessDropQnodeReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SMDropQnodeReq *pDrop = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
pDrop->dnodeId = htonl(pDrop->dnodeId);
|
SUserObj *pUser = NULL;
|
||||||
|
SQnodeObj *pObj = NULL;
|
||||||
|
SMDropQnodeReq dropReq = {0};
|
||||||
|
|
||||||
mDebug("qnode:%d, start to drop", pDrop->dnodeId);
|
if (tDeserializeSMCreateDropQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto DROP_QNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (pDrop->dnodeId <= 0) {
|
mDebug("qnode:%d, start to drop", dropReq.dnodeId);
|
||||||
|
|
||||||
|
if (dropReq.dnodeId <= 0) {
|
||||||
terrno = TSDB_CODE_SDB_APP_ERROR;
|
terrno = TSDB_CODE_SDB_APP_ERROR;
|
||||||
mError("qnode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
goto DROP_QNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SQnodeObj *pObj = mndAcquireQnode(pMnode, pDrop->dnodeId);
|
pObj = mndAcquireQnode(pMnode, dropReq.dnodeId);
|
||||||
if (pObj == NULL) {
|
if (pObj == NULL) {
|
||||||
mError("qnode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
goto DROP_QNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndDropQnode(pMnode, pReq, pObj);
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
if (code != 0) {
|
if (pUser == NULL) {
|
||||||
sdbRelease(pMnode->pSdb, pObj);
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
|
goto DROP_QNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckCreateNodeAuth(pUser)) {
|
||||||
|
goto DROP_QNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndDropQnode(pMnode, pReq, pObj);
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
DROP_QNODE_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
mError("qnode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
mError("qnode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbRelease(pMnode->pSdb, pObj);
|
mndReleaseQnode(pMnode, pObj);
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateQnodeRsp(SMnodeMsg *pRsp) {
|
static int32_t mndProcessCreateQnodeRsp(SMnodeMsg *pRsp) {
|
||||||
|
|
|
@ -15,9 +15,11 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "mndSnode.h"
|
#include "mndSnode.h"
|
||||||
|
#include "mndAuth.h"
|
||||||
#include "mndDnode.h"
|
#include "mndDnode.h"
|
||||||
#include "mndShow.h"
|
#include "mndShow.h"
|
||||||
#include "mndTrans.h"
|
#include "mndTrans.h"
|
||||||
|
#include "mndUser.h"
|
||||||
|
|
||||||
#define TSDB_SNODE_VER_NUMBER 1
|
#define TSDB_SNODE_VER_NUMBER 1
|
||||||
#define TSDB_SNODE_RESERVE_SIZE 64
|
#define TSDB_SNODE_RESERVE_SIZE 64
|
||||||
|
@ -258,40 +260,58 @@ CREATE_SNODE_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SMCreateSnodeReq *pCreate = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
|
SSnodeObj *pObj = NULL;
|
||||||
|
SDnodeObj *pDnode = NULL;
|
||||||
|
SUserObj *pUser = NULL;
|
||||||
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
|
||||||
pCreate->dnodeId = htonl(pCreate->dnodeId);
|
if (tDeserializeSMCreateDropQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &createReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto CREATE_SNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
mDebug("snode:%d, start to create", pCreate->dnodeId);
|
mDebug("snode:%d, start to create", createReq.dnodeId);
|
||||||
|
|
||||||
SSnodeObj *pObj = mndAcquireSnode(pMnode, pCreate->dnodeId);
|
pObj = mndAcquireSnode(pMnode, createReq.dnodeId);
|
||||||
if (pObj != NULL) {
|
if (pObj != NULL) {
|
||||||
mError("snode:%d, snode already exist", pObj->id);
|
|
||||||
terrno = TSDB_CODE_MND_SNODE_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_SNODE_ALREADY_EXIST;
|
||||||
mndReleaseSnode(pMnode, pObj);
|
goto CREATE_SNODE_OVER;
|
||||||
return -1;
|
|
||||||
} else if (terrno != TSDB_CODE_MND_SNODE_NOT_EXIST) {
|
} else if (terrno != TSDB_CODE_MND_SNODE_NOT_EXIST) {
|
||||||
mError("snode:%d, failed to create snode since %s", pCreate->dnodeId, terrstr());
|
goto CREATE_SNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pCreate->dnodeId);
|
pDnode = mndAcquireDnode(pMnode, createReq.dnodeId);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
mError("snode:%d, dnode not exist", pCreate->dnodeId);
|
|
||||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||||
|
goto CREATE_SNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
|
if (pUser == NULL) {
|
||||||
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
|
goto CREATE_SNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckDropNodeAuth(pUser)) {
|
||||||
|
goto CREATE_SNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndCreateSnode(pMnode, pReq, pDnode, &createReq);
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
CREATE_SNODE_OVER:
|
||||||
|
if(code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
|
mError("snode:%d, failed to create since %s", createReq.dnodeId, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndCreateSnode(pMnode, pReq, pDnode, pCreate);
|
mndReleaseSnode(pMnode, pObj);
|
||||||
mndReleaseDnode(pMnode, pDnode);
|
mndReleaseDnode(pMnode, pDnode);
|
||||||
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
if (code != 0) {
|
return code;
|
||||||
mError("snode:%d, failed to create since %s", pCreate->dnodeId, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSetDropSnodeRedoLogs(STrans *pTrans, SSnodeObj *pObj) {
|
static int32_t mndSetDropSnodeRedoLogs(STrans *pTrans, SSnodeObj *pObj) {
|
||||||
|
@ -354,33 +374,52 @@ DROP_SNODE_OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessDropSnodeReq(SMnodeMsg *pReq) {
|
static int32_t mndProcessDropSnodeReq(SMnodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pMnode;
|
SMnode *pMnode = pReq->pMnode;
|
||||||
SMDropSnodeReq *pDrop = pReq->rpcMsg.pCont;
|
int32_t code = -1;
|
||||||
pDrop->dnodeId = htonl(pDrop->dnodeId);
|
SUserObj *pUser = NULL;
|
||||||
|
SSnodeObj *pObj = NULL;
|
||||||
|
SMDropSnodeReq dropReq = {0};
|
||||||
|
|
||||||
mDebug("snode:%d, start to drop", pDrop->dnodeId);
|
if (tDeserializeSMCreateDropQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) {
|
||||||
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto DROP_SNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
if (pDrop->dnodeId <= 0) {
|
mDebug("snode:%d, start to drop", dropReq.dnodeId);
|
||||||
|
|
||||||
|
if (dropReq.dnodeId <= 0) {
|
||||||
terrno = TSDB_CODE_SDB_APP_ERROR;
|
terrno = TSDB_CODE_SDB_APP_ERROR;
|
||||||
mError("snode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
goto DROP_SNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SSnodeObj *pObj = mndAcquireSnode(pMnode, pDrop->dnodeId);
|
pObj = mndAcquireSnode(pMnode, dropReq.dnodeId);
|
||||||
if (pObj == NULL) {
|
if (pObj == NULL) {
|
||||||
mError("snode:%d, failed to drop since %s", pDrop->dnodeId, terrstr());
|
goto DROP_SNODE_OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = mndDropSnode(pMnode, pReq, pObj);
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
if (code != 0) {
|
if (pUser == NULL) {
|
||||||
sdbRelease(pMnode->pSdb, pObj);
|
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||||
|
goto DROP_SNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndCheckCreateNodeAuth(pUser)) {
|
||||||
|
goto DROP_SNODE_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = mndDropSnode(pMnode, pReq, pObj);
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
|
|
||||||
|
DROP_SNODE_OVER:
|
||||||
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
mError("snode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
mError("snode:%d, failed to drop since %s", pMnode->dnodeId, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbRelease(pMnode->pSdb, pObj);
|
mndReleaseSnode(pMnode, pObj);
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
mndReleaseUser(pMnode, pUser);
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateSnodeRsp(SMnodeMsg *pRsp) {
|
static int32_t mndProcessCreateSnodeRsp(SMnodeMsg *pRsp) {
|
||||||
|
|
|
@ -52,10 +52,12 @@ TEST_F(MndTestBnode, 01_Show_Bnode) {
|
||||||
|
|
||||||
TEST_F(MndTestBnode, 02_Create_Bnode) {
|
TEST_F(MndTestBnode, 02_Create_Bnode) {
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -63,10 +65,12 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 1;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(1);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -83,10 +87,12 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 1;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(1);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -113,10 +119,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -135,10 +143,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMDropBnodeReq);
|
SMDropBnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -154,10 +164,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMDropBnodeReq);
|
SMDropBnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -168,10 +180,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
||||||
TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
||||||
{
|
{
|
||||||
// send message first, then dnode2 crash, result is returned, and rollback is started
|
// send message first, then dnode2 crash, result is returned, and rollback is started
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
server2.Stop();
|
server2.Stop();
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
|
@ -181,10 +195,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, bnode is creating
|
// continue send message, bnode is creating
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -193,10 +209,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, bnode is creating
|
// continue send message, bnode is creating
|
||||||
int32_t contLen = sizeof(SMDropBnodeReq);
|
SMDropBnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -212,10 +230,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
||||||
int32_t retryMax = 20;
|
int32_t retryMax = 20;
|
||||||
|
|
||||||
for (retry = 0; retry < retryMax; retry++) {
|
for (retry = 0; retry < retryMax; retry++) {
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -230,10 +250,12 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
|
||||||
TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
|
TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
|
||||||
{
|
{
|
||||||
// send message first, then dnode2 crash, result is returned, and rollback is started
|
// send message first, then dnode2 crash, result is returned, and rollback is started
|
||||||
int32_t contLen = sizeof(SMDropBnodeReq);
|
SMDropBnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
server2.Stop();
|
server2.Stop();
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||||
|
@ -243,10 +265,12 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, bnode is dropping
|
// continue send message, bnode is dropping
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -255,10 +279,12 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, bnode is dropping
|
// continue send message, bnode is dropping
|
||||||
int32_t contLen = sizeof(SMDropBnodeReq);
|
SMDropBnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -274,10 +300,12 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
|
||||||
int32_t retryMax = 20;
|
int32_t retryMax = 20;
|
||||||
|
|
||||||
for (retry = 0; retry < retryMax; retry++) {
|
for (retry = 0; retry < retryMax; retry++) {
|
||||||
int32_t contLen = sizeof(SMCreateBnodeReq);
|
SMCreateBnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
|
|
@ -52,10 +52,12 @@ TEST_F(MndTestQnode, 01_Show_Qnode) {
|
||||||
|
|
||||||
TEST_F(MndTestQnode, 02_Create_Qnode) {
|
TEST_F(MndTestQnode, 02_Create_Qnode) {
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -63,10 +65,12 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 1;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(1);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -83,10 +87,12 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 1;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(1);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -113,10 +119,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -135,10 +143,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMDropQnodeReq);
|
SMDropQnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -154,10 +164,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMDropQnodeReq);
|
SMDropQnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -168,10 +180,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
|
||||||
TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
||||||
{
|
{
|
||||||
// send message first, then dnode2 crash, result is returned, and rollback is started
|
// send message first, then dnode2 crash, result is returned, and rollback is started
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
server2.Stop();
|
server2.Stop();
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
|
@ -181,10 +195,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, qnode is creating
|
// continue send message, qnode is creating
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -193,10 +209,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, qnode is creating
|
// continue send message, qnode is creating
|
||||||
int32_t contLen = sizeof(SMDropQnodeReq);
|
SMDropQnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -212,10 +230,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
||||||
int32_t retryMax = 20;
|
int32_t retryMax = 20;
|
||||||
|
|
||||||
for (retry = 0; retry < retryMax; retry++) {
|
for (retry = 0; retry < retryMax; retry++) {
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -230,10 +250,12 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
|
||||||
TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
|
TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
|
||||||
{
|
{
|
||||||
// send message first, then dnode2 crash, result is returned, and rollback is started
|
// send message first, then dnode2 crash, result is returned, and rollback is started
|
||||||
int32_t contLen = sizeof(SMDropQnodeReq);
|
SMDropQnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
server2.Stop();
|
server2.Stop();
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||||
|
@ -243,11 +265,12 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, qnode is dropping
|
// continue send message, qnode is dropping
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
|
||||||
pReq->dnodeId = htonl(2);
|
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||||
|
@ -255,10 +278,12 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, qnode is dropping
|
// continue send message, qnode is dropping
|
||||||
int32_t contLen = sizeof(SMDropQnodeReq);
|
SMDropQnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -274,11 +299,12 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
|
||||||
int32_t retryMax = 20;
|
int32_t retryMax = 20;
|
||||||
|
|
||||||
for (retry = 0; retry < retryMax; retry++) {
|
for (retry = 0; retry < retryMax; retry++) {
|
||||||
int32_t contLen = sizeof(SMCreateQnodeReq);
|
SMCreateQnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen);
|
|
||||||
pReq->dnodeId = htonl(2);
|
|
||||||
|
|
||||||
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
if (pRsp->code == 0) break;
|
if (pRsp->code == 0) break;
|
||||||
|
|
|
@ -52,10 +52,12 @@ TEST_F(MndTestSnode, 01_Show_Snode) {
|
||||||
|
|
||||||
TEST_F(MndTestSnode, 02_Create_Snode) {
|
TEST_F(MndTestSnode, 02_Create_Snode) {
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -63,10 +65,12 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 1;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(1);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -83,10 +87,12 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 1;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(1);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -113,10 +119,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -135,10 +143,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMDropSnodeReq);
|
SMDropSnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -154,10 +164,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t contLen = sizeof(SMDropSnodeReq);
|
SMDropSnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -168,10 +180,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
|
||||||
TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
||||||
{
|
{
|
||||||
// send message first, then dnode2 crash, result is returned, and rollback is started
|
// send message first, then dnode2 crash, result is returned, and rollback is started
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
server2.Stop();
|
server2.Stop();
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
|
@ -181,10 +195,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, snode is creating
|
// continue send message, snode is creating
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -193,10 +209,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, snode is creating
|
// continue send message, snode is creating
|
||||||
int32_t contLen = sizeof(SMDropSnodeReq);
|
SMDropSnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -212,10 +230,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
||||||
int32_t retryMax = 20;
|
int32_t retryMax = 20;
|
||||||
|
|
||||||
for (retry = 0; retry < retryMax; retry++) {
|
for (retry = 0; retry < retryMax; retry++) {
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -230,10 +250,12 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
|
||||||
TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
|
TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
|
||||||
{
|
{
|
||||||
// send message first, then dnode2 crash, result is returned, and rollback is started
|
// send message first, then dnode2 crash, result is returned, and rollback is started
|
||||||
int32_t contLen = sizeof(SMDropSnodeReq);
|
SMDropSnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
server2.Stop();
|
server2.Stop();
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||||
|
@ -243,10 +265,12 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, snode is dropping
|
// continue send message, snode is dropping
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -255,10 +279,12 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
|
||||||
|
|
||||||
{
|
{
|
||||||
// continue send message, snode is dropping
|
// continue send message, snode is dropping
|
||||||
int32_t contLen = sizeof(SMDropSnodeReq);
|
SMDropSnodeReq dropReq = {0};
|
||||||
|
dropReq.dnodeId = 2;
|
||||||
|
|
||||||
SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &dropReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
@ -274,10 +300,12 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
|
||||||
int32_t retryMax = 20;
|
int32_t retryMax = 20;
|
||||||
|
|
||||||
for (retry = 0; retry < retryMax; retry++) {
|
for (retry = 0; retry < retryMax; retry++) {
|
||||||
int32_t contLen = sizeof(SMCreateSnodeReq);
|
SMCreateSnodeReq createReq = {0};
|
||||||
|
createReq.dnodeId = 2;
|
||||||
|
|
||||||
SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen);
|
int32_t contLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq);
|
||||||
pReq->dnodeId = htonl(2);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
tSerializeSMCreateDropQSBNodeReq(pReq, contLen, &createReq);
|
||||||
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
|
|
Loading…
Reference in New Issue