remove void at mnode 4

This commit is contained in:
xiao-77 2024-09-20 13:09:11 +08:00
parent 8f3f494282
commit faa1816245
2 changed files with 1019 additions and 840 deletions

View File

@ -285,8 +285,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
} }
epsetSort(pEpSet); epsetSort(pEpSet);
} }
}
static int32_t mndSetCreateMnodeRedoLogs(SMnode * pMnode, STrans * pTrans, SMnodeObj * pObj) { static int32_t mndSetCreateMnodeRedoLogs(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
int32_t code = 0; int32_t code = 0;
SSdbRaw *pRedoRaw = mndMnodeActionEncode(pObj); SSdbRaw *pRedoRaw = mndMnodeActionEncode(pObj);
if (pRedoRaw == NULL) { if (pRedoRaw == NULL) {
@ -297,9 +298,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
TAOS_CHECK_RETURN(mndTransAppendRedolog(pTrans, pRedoRaw)); TAOS_CHECK_RETURN(mndTransAppendRedolog(pTrans, pRedoRaw));
TAOS_CHECK_RETURN(sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING)); TAOS_CHECK_RETURN(sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING));
TAOS_RETURN(code); TAOS_RETURN(code);
} }
int32_t mndSetRestoreCreateMnodeRedoLogs(SMnode * pMnode, STrans * pTrans, SMnodeObj * pObj) { int32_t mndSetRestoreCreateMnodeRedoLogs(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
int32_t code = 0; int32_t code = 0;
SSdbRaw *pRedoRaw = mndMnodeActionEncode(pObj); SSdbRaw *pRedoRaw = mndMnodeActionEncode(pObj);
if (pRedoRaw == NULL) { if (pRedoRaw == NULL) {
@ -310,9 +311,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
TAOS_CHECK_RETURN(mndTransAppendRedolog(pTrans, pRedoRaw)); TAOS_CHECK_RETURN(mndTransAppendRedolog(pTrans, pRedoRaw));
TAOS_CHECK_RETURN(sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY)); TAOS_CHECK_RETURN(sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY));
TAOS_RETURN(code); TAOS_RETURN(code);
} }
static int32_t mndSetCreateMnodeUndoLogs(SMnode * pMnode, STrans * pTrans, SMnodeObj * pObj) { static int32_t mndSetCreateMnodeUndoLogs(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
int32_t code = 0; int32_t code = 0;
SSdbRaw *pUndoRaw = mndMnodeActionEncode(pObj); SSdbRaw *pUndoRaw = mndMnodeActionEncode(pObj);
if (pUndoRaw == NULL) { if (pUndoRaw == NULL) {
@ -323,9 +324,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
TAOS_CHECK_RETURN(mndTransAppendUndolog(pTrans, pUndoRaw)); TAOS_CHECK_RETURN(mndTransAppendUndolog(pTrans, pUndoRaw));
TAOS_CHECK_RETURN(sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED)); TAOS_CHECK_RETURN(sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED));
TAOS_RETURN(code); TAOS_RETURN(code);
} }
int32_t mndSetCreateMnodeCommitLogs(SMnode * pMnode, STrans * pTrans, SMnodeObj * pObj) { int32_t mndSetCreateMnodeCommitLogs(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
int32_t code = 0; int32_t code = 0;
SSdbRaw *pCommitRaw = mndMnodeActionEncode(pObj); SSdbRaw *pCommitRaw = mndMnodeActionEncode(pObj);
if (pCommitRaw == NULL) { if (pCommitRaw == NULL) {
@ -336,9 +337,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
TAOS_CHECK_RETURN(mndTransAppendCommitlog(pTrans, pCommitRaw)); TAOS_CHECK_RETURN(mndTransAppendCommitlog(pTrans, pCommitRaw));
TAOS_CHECK_RETURN(sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY)); TAOS_CHECK_RETURN(sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY));
TAOS_RETURN(code); TAOS_RETURN(code);
} }
static int32_t mndBuildCreateMnodeRedoAction(STrans * pTrans, SDCreateMnodeReq * pCreateReq, SEpSet * pCreateEpSet) { static int32_t mndBuildCreateMnodeRedoAction(STrans *pTrans, SDCreateMnodeReq *pCreateReq, SEpSet *pCreateEpSet) {
int32_t code = 0; int32_t code = 0;
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pCreateReq); int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pCreateReq);
void *pReq = taosMemoryMalloc(contLen); void *pReq = taosMemoryMalloc(contLen);
@ -361,10 +362,10 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
TAOS_RETURN(code); TAOS_RETURN(code);
} }
TAOS_RETURN(code); TAOS_RETURN(code);
} }
static int32_t mndBuildAlterMnodeTypeRedoAction(STrans * pTrans, SDAlterMnodeTypeReq * pAlterMnodeTypeReq, static int32_t mndBuildAlterMnodeTypeRedoAction(STrans *pTrans, SDAlterMnodeTypeReq *pAlterMnodeTypeReq,
SEpSet * pAlterMnodeTypeEpSet) { SEpSet *pAlterMnodeTypeEpSet) {
int32_t code = 0; int32_t code = 0;
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pAlterMnodeTypeReq); int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pAlterMnodeTypeReq);
void *pReq = taosMemoryMalloc(contLen); void *pReq = taosMemoryMalloc(contLen);
@ -388,9 +389,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
TAOS_RETURN(code); TAOS_RETURN(code);
} }
TAOS_RETURN(code); TAOS_RETURN(code);
} }
static int32_t mndBuildAlterMnodeRedoAction(STrans * pTrans, SDCreateMnodeReq * pAlterReq, SEpSet * pAlterEpSet) { static int32_t mndBuildAlterMnodeRedoAction(STrans *pTrans, SDCreateMnodeReq *pAlterReq, SEpSet *pAlterEpSet) {
int32_t code = 0; int32_t code = 0;
int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pAlterReq); int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pAlterReq);
void *pReq = taosMemoryMalloc(contLen); void *pReq = taosMemoryMalloc(contLen);
@ -413,9 +414,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
} }
TAOS_RETURN(code); TAOS_RETURN(code);
} }
static int32_t mndBuildDropMnodeRedoAction(STrans * pTrans, SDDropMnodeReq * pDropReq, SEpSet * pDroprEpSet) { static int32_t mndBuildDropMnodeRedoAction(STrans *pTrans, SDDropMnodeReq *pDropReq, SEpSet *pDroprEpSet) {
int32_t code = 0; int32_t code = 0;
int32_t contLen = tSerializeSCreateDropMQSNodeReq(NULL, 0, pDropReq); int32_t contLen = tSerializeSCreateDropMQSNodeReq(NULL, 0, pDropReq);
void *pReq = taosMemoryMalloc(contLen); void *pReq = taosMemoryMalloc(contLen);
@ -438,9 +439,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
TAOS_RETURN(code); TAOS_RETURN(code);
} }
TAOS_RETURN(code); TAOS_RETURN(code);
} }
static int32_t mndSetCreateMnodeRedoActions(SMnode * pMnode, STrans * pTrans, SDnodeObj * pDnode, SMnodeObj * pObj) { static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj) {
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
void *pIter = NULL; void *pIter = NULL;
int32_t numOfReplicas = 0; int32_t numOfReplicas = 0;
@ -484,9 +485,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
TAOS_CHECK_RETURN(mndBuildCreateMnodeRedoAction(pTrans, &createReq, &createEpset)); TAOS_CHECK_RETURN(mndBuildCreateMnodeRedoAction(pTrans, &createReq, &createEpset));
TAOS_RETURN(0); TAOS_RETURN(0);
} }
int32_t mndSetRestoreCreateMnodeRedoActions(SMnode * pMnode, STrans * pTrans, SDnodeObj * pDnode, SMnodeObj * pObj) { int32_t mndSetRestoreCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj) {
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
void *pIter = NULL; void *pIter = NULL;
SDCreateMnodeReq createReq = {0}; SDCreateMnodeReq createReq = {0};
@ -532,10 +533,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
TAOS_CHECK_RETURN(mndBuildCreateMnodeRedoAction(pTrans, &createReq, &createEpset)); TAOS_CHECK_RETURN(mndBuildCreateMnodeRedoAction(pTrans, &createReq, &createEpset));
TAOS_RETURN(0); TAOS_RETURN(0);
} }
static int32_t mndSetAlterMnodeTypeRedoActions(SMnode * pMnode, STrans * pTrans, SDnodeObj * pDnode, static int32_t mndSetAlterMnodeTypeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj) {
SMnodeObj * pObj) {
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
void *pIter = NULL; void *pIter = NULL;
SDAlterMnodeTypeReq alterReq = {0}; SDAlterMnodeTypeReq alterReq = {0};
@ -576,10 +576,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
TAOS_CHECK_RETURN(mndBuildAlterMnodeTypeRedoAction(pTrans, &alterReq, &createEpset)); TAOS_CHECK_RETURN(mndBuildAlterMnodeTypeRedoAction(pTrans, &alterReq, &createEpset));
TAOS_RETURN(0); TAOS_RETURN(0);
} }
int32_t mndSetRestoreAlterMnodeTypeRedoActions(SMnode * pMnode, STrans * pTrans, SDnodeObj * pDnode, int32_t mndSetRestoreAlterMnodeTypeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj) {
SMnodeObj * pObj) {
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
void *pIter = NULL; void *pIter = NULL;
SDAlterMnodeTypeReq alterReq = {0}; SDAlterMnodeTypeReq alterReq = {0};
@ -625,9 +624,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
TAOS_CHECK_RETURN(mndBuildAlterMnodeTypeRedoAction(pTrans, &alterReq, &createEpset)); TAOS_CHECK_RETURN(mndBuildAlterMnodeTypeRedoAction(pTrans, &alterReq, &createEpset));
TAOS_RETURN(0); TAOS_RETURN(0);
} }
static int32_t mndCreateMnode(SMnode * pMnode, SRpcMsg * pReq, SDnodeObj * pDnode, SMCreateMnodeReq * pCreate) { static int32_t mndCreateMnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SMCreateMnodeReq *pCreate) {
int32_t code = -1; int32_t code = -1;
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "create-mnode"); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "create-mnode");
@ -663,12 +662,12 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
code = 0; code = 0;
_OVER: _OVER:
mndTransDrop(pTrans); mndTransDrop(pTrans);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
static int32_t mndProcessCreateMnodeReq(SRpcMsg * pReq) { static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
SMnode *pMnode = pReq->info.node; SMnode *pMnode = pReq->info.node;
int32_t code = -1; int32_t code = -1;
SMnodeObj *pObj = NULL; SMnodeObj *pObj = NULL;
@ -712,7 +711,7 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
auditRecord(pReq, pMnode->clusterId, "createMnode", "", obj, createReq.sql, createReq.sqlLen); auditRecord(pReq, pMnode->clusterId, "createMnode", "", obj, createReq.sql, createReq.sqlLen);
_OVER: _OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
mError("mnode:%d, failed to create since %s", createReq.dnodeId, terrstr()); mError("mnode:%d, failed to create since %s", createReq.dnodeId, terrstr());
} }
@ -722,9 +721,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
tFreeSMCreateQnodeReq(&createReq); tFreeSMCreateQnodeReq(&createReq);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
static int32_t mndSetDropMnodeRedoLogs(SMnode * pMnode, STrans * pTrans, SMnodeObj * pObj) { static int32_t mndSetDropMnodeRedoLogs(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
int32_t code = 0; int32_t code = 0;
SSdbRaw *pRedoRaw = mndMnodeActionEncode(pObj); SSdbRaw *pRedoRaw = mndMnodeActionEncode(pObj);
if (pRedoRaw == NULL) { if (pRedoRaw == NULL) {
@ -735,9 +734,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
TAOS_CHECK_RETURN(mndTransAppendRedolog(pTrans, pRedoRaw)); TAOS_CHECK_RETURN(mndTransAppendRedolog(pTrans, pRedoRaw));
TAOS_CHECK_RETURN(sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING)); TAOS_CHECK_RETURN(sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING));
TAOS_RETURN(code); TAOS_RETURN(code);
} }
static int32_t mndSetDropMnodeCommitLogs(SMnode * pMnode, STrans * pTrans, SMnodeObj * pObj) { static int32_t mndSetDropMnodeCommitLogs(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj) {
int32_t code = 0; int32_t code = 0;
SSdbRaw *pCommitRaw = mndMnodeActionEncode(pObj); SSdbRaw *pCommitRaw = mndMnodeActionEncode(pObj);
if (pCommitRaw == NULL) { if (pCommitRaw == NULL) {
@ -748,9 +747,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
TAOS_CHECK_RETURN(mndTransAppendCommitlog(pTrans, pCommitRaw)); TAOS_CHECK_RETURN(mndTransAppendCommitlog(pTrans, pCommitRaw));
TAOS_CHECK_RETURN(sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED)); TAOS_CHECK_RETURN(sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED));
TAOS_RETURN(code); TAOS_RETURN(code);
} }
static int32_t mndSetDropMnodeRedoActions(SMnode * pMnode, STrans * pTrans, SDnodeObj * pDnode, SMnodeObj * pObj, static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj,
bool force) { bool force) {
int32_t code = 0; int32_t code = 0;
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
@ -786,17 +785,17 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
} }
TAOS_RETURN(code); TAOS_RETURN(code);
} }
int32_t mndSetDropMnodeInfoToTrans(SMnode * pMnode, STrans * pTrans, SMnodeObj * pObj, bool force) { int32_t mndSetDropMnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SMnodeObj *pObj, bool force) {
if (pObj == NULL) return 0; if (pObj == NULL) return 0;
pObj->lastIndex = pMnode->applied; pObj->lastIndex = pMnode->applied;
TAOS_CHECK_RETURN(mndSetDropMnodeRedoActions(pMnode, pTrans, pObj->pDnode, pObj, force)); TAOS_CHECK_RETURN(mndSetDropMnodeRedoActions(pMnode, pTrans, pObj->pDnode, pObj, force));
TAOS_CHECK_RETURN(mndSetDropMnodeCommitLogs(pMnode, pTrans, pObj)); TAOS_CHECK_RETURN(mndSetDropMnodeCommitLogs(pMnode, pTrans, pObj));
return 0; return 0;
} }
static int32_t mndDropMnode(SMnode * pMnode, SRpcMsg * pReq, SMnodeObj * pObj) { static int32_t mndDropMnode(SMnode *pMnode, SRpcMsg *pReq, SMnodeObj *pObj) {
int32_t code = -1; int32_t code = -1;
STrans *pTrans = NULL; STrans *pTrans = NULL;
@ -815,12 +814,12 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
code = 0; code = 0;
_OVER: _OVER:
mndTransDrop(pTrans); mndTransDrop(pTrans);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
static int32_t mndProcessDropMnodeReq(SRpcMsg * pReq) { static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) {
SMnode *pMnode = pReq->info.node; SMnode *pMnode = pReq->info.node;
int32_t code = -1; int32_t code = -1;
SMnodeObj *pObj = NULL; SMnodeObj *pObj = NULL;
@ -866,7 +865,7 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
auditRecord(pReq, pMnode->clusterId, "dropMnode", "", obj, dropReq.sql, dropReq.sqlLen); auditRecord(pReq, pMnode->clusterId, "dropMnode", "", obj, dropReq.sql, dropReq.sqlLen);
_OVER: _OVER:
if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) {
mError("mnode:%d, failed to drop since %s", dropReq.dnodeId, terrstr()); mError("mnode:%d, failed to drop since %s", dropReq.dnodeId, terrstr());
} }
@ -874,9 +873,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
mndReleaseMnode(pMnode, pObj); mndReleaseMnode(pMnode, pObj);
tFreeSMCreateQnodeReq(&dropReq); tFreeSMCreateQnodeReq(&dropReq);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
static int32_t mndRetrieveMnodes(SRpcMsg * pReq, SShowObj * pShow, SSDataBlock * pBlock, int32_t rows) { static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
SMnode *pMnode = pReq->info.node; SMnode *pMnode = pReq->info.node;
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
int32_t numOfRows = 0; int32_t numOfRows = 0;
@ -886,6 +885,7 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
ESdbStatus objStatus = 0; ESdbStatus objStatus = 0;
char *pWrite; char *pWrite;
int64_t curMs = taosGetTimestampMs(); int64_t curMs = taosGetTimestampMs();
int code = 0;
pSelfObj = sdbAcquire(pSdb, SDB_MNODE, &pMnode->selfDnodeId); pSelfObj = sdbAcquire(pSdb, SDB_MNODE, &pMnode->selfDnodeId);
if (pSelfObj == NULL) { if (pSelfObj == NULL) {
@ -969,17 +969,17 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
pShow->numOfRows += numOfRows; pShow->numOfRows += numOfRows;
_out: _out:
sdbRelease(pSdb, pSelfObj); sdbRelease(pSdb, pSelfObj);
return numOfRows; return numOfRows;
} }
static void mndCancelGetNextMnode(SMnode * pMnode, void *pIter) { static void mndCancelGetNextMnode(SMnode *pMnode, void *pIter) {
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
sdbCancelFetchByType(pSdb, pIter, SDB_MNODE); sdbCancelFetchByType(pSdb, pIter, SDB_MNODE);
} }
static int32_t mndProcessAlterMnodeReq(SRpcMsg * pReq) { static int32_t mndProcessAlterMnodeReq(SRpcMsg *pReq) {
#if 1 #if 1
return 0; return 0;
#else #else
@ -1037,15 +1037,16 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
TAOS_RETURN(code); TAOS_RETURN(code);
#endif #endif
} }
static void mndReloadSyncConfig(SMnode * pMnode) { static void mndReloadSyncConfig(SMnode *pMnode) {
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
SMnodeObj *pObj = NULL; SMnodeObj *pObj = NULL;
ESdbStatus objStatus = 0; ESdbStatus objStatus = 0;
void *pIter = NULL; void *pIter = NULL;
int32_t updatingMnodes = 0; int32_t updatingMnodes = 0;
int32_t readyMnodes = 0; int32_t readyMnodes = 0;
int32_t code = 0;
SSyncCfg cfg = { SSyncCfg cfg = {
.myIndex = -1, .myIndex = -1,
.lastIndex = 0, .lastIndex = 0,
@ -1132,4 +1133,4 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
mInfo("vgId:1, mnode sync reconfig success"); mInfo("vgId:1, mnode sync reconfig success");
} }
} }
} }

View File

@ -14,7 +14,6 @@
*/ */
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "mndVgroup.h"
#include "audit.h" #include "audit.h"
#include "mndArbGroup.h" #include "mndArbGroup.h"
#include "mndDb.h" #include "mndDb.h"
@ -27,6 +26,7 @@
#include "mndTopic.h" #include "mndTopic.h"
#include "mndTrans.h" #include "mndTrans.h"
#include "mndUser.h" #include "mndUser.h"
#include "mndVgroup.h"
#include "tmisce.h" #include "tmisce.h"
#define VGROUP_VER_NUMBER 1 #define VGROUP_VER_NUMBER 1
@ -320,6 +320,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
createReq.tsdbPageSize = pDb->cfg.tsdbPageSize; createReq.tsdbPageSize = pDb->cfg.tsdbPageSize;
createReq.changeVersion = ++(pVgroup->syncConfChangeVer); createReq.changeVersion = ++(pVgroup->syncConfChangeVer);
createReq.encryptAlgorithm = pDb->cfg.encryptAlgorithm; createReq.encryptAlgorithm = pDb->cfg.encryptAlgorithm;
int32_t code = 0;
for (int32_t v = 0; v < pVgroup->replica; ++v) { for (int32_t v = 0; v < pVgroup->replica; ++v) {
SReplica *pReplica = NULL; SReplica *pReplica = NULL;
@ -390,7 +391,13 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
return NULL; return NULL;
} }
(void)tSerializeSCreateVnodeReq(pReq, contLen, &createReq); code = tSerializeSCreateVnodeReq(pReq, contLen, &createReq);
if (code < 0) {
terrno = TSDB_CODE_APP_ERROR;
taosMemoryFree(pReq);
mError("vgId:%d, failed to serialize create vnode req,since %s", createReq.vgId, terrstr());
return NULL;
}
*pContLen = contLen; *pContLen = contLen;
return pReq; return pReq;
} }
@ -436,7 +443,12 @@ static void *mndBuildAlterVnodeConfigReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pV
pHead->contLen = htonl(contLen); pHead->contLen = htonl(contLen);
pHead->vgId = htonl(pVgroup->vgId); pHead->vgId = htonl(pVgroup->vgId);
(void)tSerializeSAlterVnodeConfigReq((char *)pReq + sizeof(SMsgHead), contLen, &alterReq); if (tSerializeSAlterVnodeConfigReq((char *)pReq + sizeof(SMsgHead), contLen, &alterReq) < 0) {
taosMemoryFree(pReq);
mError("vgId:%d, failed to serialize alter vnode config req,since %s", pVgroup->vgId, terrstr());
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
*pContLen = contLen; *pContLen = contLen;
return pReq; return pReq;
} }
@ -514,7 +526,12 @@ static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p
return NULL; return NULL;
} }
(void)tSerializeSAlterVnodeReplicaReq(pReq, contLen, &alterReq); if (tSerializeSAlterVnodeReplicaReq(pReq, contLen, &alterReq) < 0) {
mError("vgId:%d, failed to serialize alter vnode req,since %s", alterReq.vgId, terrstr());
taosMemoryFree(pReq);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
*pContLen = contLen; *pContLen = contLen;
return pReq; return pReq;
} }
@ -587,7 +604,12 @@ static void *mndBuildCheckLearnCatchupReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p
return NULL; return NULL;
} }
(void)tSerializeSAlterVnodeReplicaReq(pReq, contLen, &req); if (tSerializeSAlterVnodeReplicaReq(pReq, contLen, &req) < 0) {
mError("vgId:%d, failed to serialize alter vnode req,since %s", req.vgId, terrstr());
taosMemoryFree(pReq);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
*pContLen = contLen; *pContLen = contLen;
return pReq; return pReq;
} }
@ -611,7 +633,12 @@ static void *mndBuildDisableVnodeWriteReq(SMnode *pMnode, SDbObj *pDb, int32_t v
return NULL; return NULL;
} }
(void)tSerializeSDisableVnodeWriteReq(pReq, contLen, &disableReq); if (tSerializeSDisableVnodeWriteReq(pReq, contLen, &disableReq) < 0) {
mError("vgId:%d, failed to serialize disable vnode write req,since %s", vgId, terrstr());
taosMemoryFree(pReq);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
*pContLen = contLen; *pContLen = contLen;
return pReq; return pReq;
} }
@ -639,7 +666,12 @@ static void *mndBuildAlterVnodeHashRangeReq(SMnode *pMnode, int32_t srcVgId, SVg
return NULL; return NULL;
} }
(void)tSerializeSAlterVnodeHashRangeReq(pReq, contLen, &alterReq); if (tSerializeSAlterVnodeHashRangeReq(pReq, contLen, &alterReq) < 0) {
mError("vgId:%d, failed to serialize alter vnode hashrange req,since %s", srcVgId, terrstr());
taosMemoryFree(pReq);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
*pContLen = contLen; *pContLen = contLen;
return pReq; return pReq;
} }
@ -664,7 +696,12 @@ void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgOb
return NULL; return NULL;
} }
(void)tSerializeSDropVnodeReq(pReq, contLen, &dropReq); if (tSerializeSDropVnodeReq(pReq, contLen, &dropReq) < 0) {
mError("vgId:%d, failed to serialize drop vnode req,since %s", dropReq.vgId, terrstr());
taosMemoryFree(pReq);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
*pContLen = contLen; *pContLen = contLen;
return pReq; return pReq;
} }
@ -907,7 +944,9 @@ SEpSet mndGetVgroupEpset(SMnode *pMnode, const SVgObj *pVgroup) {
epset.inUse = epset.numOfEps; epset.inUse = epset.numOfEps;
} }
(void)addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); if (addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port) != 0) {
mWarn("vgId:%d, failed to add ep:%s:%d into epset", pVgroup->vgId, pDnode->fqdn, pDnode->port);
}
mndReleaseDnode(pMnode, pDnode); mndReleaseDnode(pMnode, pDnode);
} }
epsetSort(&epset); epsetSort(&epset);
@ -930,7 +969,9 @@ SEpSet mndGetVgroupEpsetById(SMnode *pMnode, int32_t vgId) {
epset.inUse = epset.numOfEps; epset.inUse = epset.numOfEps;
} }
(void)addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); if (addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port) != 0) {
mWarn("vgId:%d, failed to add ep:%s:%d into epset", pVgroup->vgId, pDnode->fqdn, pDnode->port);
}
mndReleaseDnode(pMnode, pDnode); mndReleaseDnode(pMnode, pDnode);
} }
@ -945,6 +986,7 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
SVgObj *pVgroup = NULL; SVgObj *pVgroup = NULL;
int32_t cols = 0; int32_t cols = 0;
int64_t curMs = taosGetTimestampMs(); int64_t curMs = taosGetTimestampMs();
int32_t code = 0;
SDbObj *pDb = NULL; SDbObj *pDb = NULL;
if (strlen(pShow->db) > 0) { if (strlen(pShow->db) > 0) {
@ -965,26 +1007,46 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
cols = 0; cols = 0;
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false);
if (code != 0) {
mError("vgId:%d, failed to set vgId, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
SName name = {0}; SName name = {0};
char db[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; char db[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
(void)tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT | T_NAME_DB); code = tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT | T_NAME_DB);
if (code != 0) {
mError("vgId:%d, failed to set dbName, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
(void)tNameGetDbName(&name, varDataVal(db)); (void)tNameGetDbName(&name, varDataVal(db));
varDataSetLen(db, strlen(varDataVal(db))); varDataSetLen(db, strlen(varDataVal(db)));
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
(void)colDataSetVal(pColInfo, numOfRows, (const char *)db, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)db, false);
if (code != 0) {
mError("vgId:%d, failed to set dbName, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfTables, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfTables, false);
if (code != 0) {
mError("vgId:%d, failed to set numOfTables, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
// default 3 replica, add 1 replica if move vnode // default 3 replica, add 1 replica if move vnode
for (int32_t i = 0; i < 4; ++i) { for (int32_t i = 0; i < 4; ++i) {
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
if (i < pVgroup->replica) { if (i < pVgroup->replica) {
int16_t dnodeId = (int16_t)pVgroup->vnodeGid[i].dnodeId; int16_t dnodeId = (int16_t)pVgroup->vnodeGid[i].dnodeId;
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&dnodeId, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)&dnodeId, false);
if (code != 0) {
mError("vgId:%d, failed to set dnodeId, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
bool exist = false; bool exist = false;
bool online = false; bool online = false;
@ -1038,7 +1100,11 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
STR_WITH_MAXSIZE_TO_VARSTR(buf1, role, pShow->pMeta->pSchemas[cols].bytes); STR_WITH_MAXSIZE_TO_VARSTR(buf1, role, pShow->pMeta->pSchemas[cols].bytes);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
(void)colDataSetVal(pColInfo, numOfRows, (const char *)buf1, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)buf1, false);
if (code != 0) {
mError("vgId:%d, failed to set role, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
} else { } else {
colDataSetNULL(pColInfo, numOfRows); colDataSetNULL(pColInfo, numOfRows);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
@ -1048,21 +1114,25 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
int32_t cacheUsage = (int32_t)pVgroup->cacheUsage; int32_t cacheUsage = (int32_t)pVgroup->cacheUsage;
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&cacheUsage, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)&cacheUsage, false);
if (code != 0) {
mError("vgId:%d, failed to set cacheUsage, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfCachedTables, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfCachedTables, false);
if (code != 0) {
mError("vgId:%d, failed to set numOfCachedTables, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->isTsma, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->isTsma, false);
if (code != 0) {
// pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); mError("vgId:%d, failed to set isTsma, since %s", pVgroup->vgId, tstrerror(code));
// if (pDb == NULL || pDb->compactStartTime <= 0) { return code;
// colDataSetNULL(pColInfo, numOfRows); }
// } else {
// (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pDb->compactStartTime, false);
// }
numOfRows++; numOfRows++;
sdbRelease(pSdb, pVgroup); sdbRelease(pSdb, pVgroup);
} }
@ -1147,6 +1217,7 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
SVgObj *pVgroup = NULL; SVgObj *pVgroup = NULL;
int32_t cols = 0; int32_t cols = 0;
int64_t curMs = taosGetTimestampMs(); int64_t curMs = taosGetTimestampMs();
int32_t code = 0;
while (numOfRows < rows - TSDB_MAX_REPLICA) { while (numOfRows < rows - TSDB_MAX_REPLICA) {
pShow->pIter = sdbFetch(pSdb, SDB_VGROUP, pShow->pIter, (void **)&pVgroup); pShow->pIter = sdbFetch(pSdb, SDB_VGROUP, pShow->pIter, (void **)&pVgroup);
@ -1158,10 +1229,17 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
cols = 0; cols = 0;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->dnodeId, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->dnodeId, false);
if (code != 0) {
mError("vgId:%d, failed to set dnodeId, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false);
if (code != 0) {
mError("vgId:%d, failed to set vgId, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
// db_name // db_name
const char *dbname = mndGetDbStr(pVgroup->dbName); const char *dbname = mndGetDbStr(pVgroup->dbName);
@ -1172,7 +1250,11 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
STR_WITH_MAXSIZE_TO_VARSTR(b1, "NULL", TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE); STR_WITH_MAXSIZE_TO_VARSTR(b1, "NULL", TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE);
} }
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
(void)colDataSetVal(pColInfo, numOfRows, (const char *)b1, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)b1, false);
if (code != 0) {
mError("vgId:%d, failed to set dbName, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
// dnode is online? // dnode is online?
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pGid->dnodeId); SDnodeObj *pDnode = mndAcquireDnode(pMnode, pGid->dnodeId);
@ -1186,18 +1268,34 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
ESyncState syncState = (isDnodeOnline) ? pGid->syncState : TAOS_SYNC_STATE_OFFLINE; ESyncState syncState = (isDnodeOnline) ? pGid->syncState : TAOS_SYNC_STATE_OFFLINE;
STR_TO_VARSTR(buf, syncStr(syncState)); STR_TO_VARSTR(buf, syncStr(syncState));
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
(void)colDataSetVal(pColInfo, numOfRows, (const char *)buf, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)buf, false);
if (code != 0) {
mError("vgId:%d, failed to set syncState, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
int64_t roleTimeMs = (isDnodeOnline) ? pGid->roleTimeMs : 0; int64_t roleTimeMs = (isDnodeOnline) ? pGid->roleTimeMs : 0;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&roleTimeMs, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)&roleTimeMs, false);
if (code != 0) {
mError("vgId:%d, failed to set roleTimeMs, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
int64_t startTimeMs = (isDnodeOnline) ? pGid->startTimeMs : 0; int64_t startTimeMs = (isDnodeOnline) ? pGid->startTimeMs : 0;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&startTimeMs, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)&startTimeMs, false);
if (code != 0) {
mError("vgId:%d, failed to set startTimeMs, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->syncRestore, false); code = colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->syncRestore, false);
if (code != 0) {
mError("vgId:%d, failed to set syncRestore, since %s", pVgroup->vgId, tstrerror(code));
return code;
}
numOfRows++; numOfRows++;
sdbRelease(pSdb, pDnode); sdbRelease(pSdb, pDnode);
@ -1270,8 +1368,10 @@ static int32_t mndAddVnodeToVgroup(SMnode *pMnode, STrans *pTrans, SVgObj *pVgro
sdbFreeRaw(pVgRaw); sdbFreeRaw(pVgRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status since %s at line:%d", pVgroup->vgId, tstrerror(code), __LINE__);
}
TAOS_RETURN(code); TAOS_RETURN(code);
} }
@ -1332,7 +1432,10 @@ _OVER:
sdbFreeRaw(pVgRaw); sdbFreeRaw(pVgRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status since %s at line:%d", pVgroup->vgId, tstrerror(code), __LINE__);
}
TAOS_RETURN(code); TAOS_RETURN(code);
} }
@ -1568,6 +1671,10 @@ int32_t mndAddNewVgPrepareAction(SMnode *pMnode, STrans *pTrans, SVgObj *pVg) {
TAOS_CHECK_GOTO(mndTransAppendPrepareLog(pTrans, pRaw), NULL, _err); TAOS_CHECK_GOTO(mndTransAppendPrepareLog(pTrans, pRaw), NULL, _err);
(void)sdbSetRawStatus(pRaw, SDB_STATUS_CREATING); (void)sdbSetRawStatus(pRaw, SDB_STATUS_CREATING);
if (code != 0) {
mError("vgId:%d, failed to set raw status since %s at line:%d", pVg->vgId, tstrerror(code), __LINE__);
TAOS_RETURN(code);
}
pRaw = NULL; pRaw = NULL;
TAOS_RETURN(code); TAOS_RETURN(code);
@ -1824,7 +1931,11 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
sdbFreeRaw(pRaw); sdbFreeRaw(pRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status since %s at line:%d", newVg.vgId, tstrerror(code), __LINE__);
return code;
}
} }
TAOS_CHECK_RETURN(mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true)); TAOS_CHECK_RETURN(mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true));
@ -1850,7 +1961,6 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
sdbFreeRaw(pRaw); sdbFreeRaw(pRaw);
return -1; return -1;
} }
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
} }
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1; if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1;
@ -1880,7 +1990,11 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
sdbFreeRaw(pRaw); sdbFreeRaw(pRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status since %s at line:%d", newVg.vgId, tstrerror(code), __LINE__);
return code;
}
} }
for (int32_t i = 0; i < newVg.replica; ++i) { for (int32_t i = 0; i < newVg.replica; ++i) {
@ -1930,7 +2044,11 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
sdbFreeRaw(pRaw); sdbFreeRaw(pRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status since %s at line:%d", newVg.vgId, tstrerror(code), __LINE__);
return code;
}
} }
mInfo("vgId:%d, vgroup info after move, replica:%d", newVg.vgId, newVg.replica); mInfo("vgId:%d, vgroup info after move, replica:%d", newVg.vgId, newVg.replica);
@ -2005,7 +2123,11 @@ static int32_t mndAddIncVgroupReplicaToTrans(SMnode *pMnode, STrans *pTrans, SDb
sdbFreeRaw(pVgRaw); sdbFreeRaw(pVgRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status since %s at line:%d", pVgroup->vgId, tstrerror(code), __LINE__);
TAOS_RETURN(code);
}
// learner // learner
for (int32_t i = 0; i < pVgroup->replica - 1; ++i) { for (int32_t i = 0; i < pVgroup->replica - 1; ++i) {
@ -2057,7 +2179,11 @@ static int32_t mndAddDecVgroupReplicaFromTrans(SMnode *pMnode, STrans *pTrans, S
sdbFreeRaw(pVgRaw); sdbFreeRaw(pVgRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status since %s at line:%d", pVgroup->vgId, tstrerror(code), __LINE__);
TAOS_RETURN(code);
}
TAOS_CHECK_RETURN(mndAddDropVnodeAction(pMnode, pTrans, pDb, pVgroup, &delGid, true)); TAOS_CHECK_RETURN(mndAddDropVnodeAction(pMnode, pTrans, pDb, pVgroup, &delGid, true));
for (int32_t i = 0; i < pVgroup->replica; ++i) { for (int32_t i = 0; i < pVgroup->replica; ++i) {
@ -2171,7 +2297,11 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb,
sdbFreeRaw(pRaw); sdbFreeRaw(pRaw);
goto _OVER; goto _OVER;
} }
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status since %s at line:%d", newVg.vgId, tstrerror(code), __LINE__);
goto _OVER;
}
} }
mInfo("vgId:%d, vgroup info after redistribute, replica:%d", newVg.vgId, newVg.replica); mInfo("vgId:%d, vgroup info after redistribute, replica:%d", newVg.vgId, newVg.replica);
@ -2452,7 +2582,11 @@ static void *mndBuildSForceBecomeFollowerReq(SMnode *pMnode, SVgObj *pVgroup, in
pHead->contLen = htonl(contLen); pHead->contLen = htonl(contLen);
pHead->vgId = htonl(pVgroup->vgId); pHead->vgId = htonl(pVgroup->vgId);
(void)tSerializeSForceBecomeFollowerReq((char *)pReq + sizeof(SMsgHead), contLen, &balanceReq); if (tSerializeSForceBecomeFollowerReq((char *)pReq + sizeof(SMsgHead), contLen, &balanceReq) < 0) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
taosMemoryFree(pReq);
return NULL;
}
*pContLen = contLen; *pContLen = contLen;
return pReq; return pReq;
} }
@ -2693,7 +2827,11 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb
sdbFreeRaw(pVgRaw); sdbFreeRaw(pVgRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status since %s at line:%d", pNewVgroup->vgId, tstrerror(code), __LINE__);
TAOS_RETURN(code);
}
} }
TAOS_RETURN(code); TAOS_RETURN(code);
@ -2776,7 +2914,12 @@ int32_t mndBuildRaftAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pO
sdbFreeRaw(pVgRaw); sdbFreeRaw(pVgRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status to ready, error:%s, line:%d", newVgroup.vgId, tstrerror(code),
__LINE__);
TAOS_RETURN(code);
}
} else if (newVgroup.replica == 3 && pNewDb->cfg.replications == 1) { } else if (newVgroup.replica == 3 && pNewDb->cfg.replications == 1) {
mInfo("db:%s, vgId:%d, will remove 2 vnodes, vn:0 dnode:%d vn:1 dnode:%d vn:2 dnode:%d", pVgroup->dbName, mInfo("db:%s, vgId:%d, will remove 2 vnodes, vn:0 dnode:%d vn:1 dnode:%d vn:2 dnode:%d", pVgroup->dbName,
pVgroup->vgId, pVgroup->vnodeGid[0].dnodeId, pVgroup->vnodeGid[1].dnodeId, pVgroup->vnodeGid[2].dnodeId); pVgroup->vgId, pVgroup->vnodeGid[0].dnodeId, pVgroup->vnodeGid[1].dnodeId, pVgroup->vnodeGid[2].dnodeId);
@ -2801,7 +2944,12 @@ int32_t mndBuildRaftAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pO
sdbFreeRaw(pVgRaw); sdbFreeRaw(pVgRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status to ready, error:%s, line:%d", newVgroup.vgId, tstrerror(code),
__LINE__);
TAOS_RETURN(code);
}
SVnodeGid del2 = {0}; SVnodeGid del2 = {0};
TAOS_CHECK_RETURN(mndRemoveVnodeFromVgroupWithoutSave(pMnode, pTrans, &newVgroup, pArray, &del2)); TAOS_CHECK_RETURN(mndRemoveVnodeFromVgroupWithoutSave(pMnode, pTrans, &newVgroup, pArray, &del2));
@ -2823,7 +2971,12 @@ int32_t mndBuildRaftAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pO
sdbFreeRaw(pVgRaw); sdbFreeRaw(pVgRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status to ready, error:%s, line:%d", newVgroup.vgId, tstrerror(code),
__LINE__);
TAOS_RETURN(code);
}
} else { } else {
return -1; return -1;
} }
@ -2841,7 +2994,12 @@ int32_t mndBuildRaftAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pO
sdbFreeRaw(pVgRaw); sdbFreeRaw(pVgRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status to ready, error:%s, line:%d", newVgroup.vgId, tstrerror(code),
__LINE__);
TAOS_RETURN(code);
}
} }
TAOS_RETURN(code); TAOS_RETURN(code);
@ -2917,7 +3075,11 @@ int32_t mndBuildRestoreAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj
sdbFreeRaw(pVgRaw); sdbFreeRaw(pVgRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status to ready, error:%s, line:%d", newVgroup.vgId, tstrerror(code), __LINE__);
TAOS_RETURN(code);
}
TAOS_RETURN(code); TAOS_RETURN(code);
} }
@ -2938,7 +3100,11 @@ static int32_t mndAddVgStatusAction(STrans *pTrans, SVgObj *pVg, ESdbStatus vgSt
goto _err; goto _err;
} }
if ((code = appendActionCb(pTrans, pRaw)) != 0) goto _err; if ((code = appendActionCb(pTrans, pRaw)) != 0) goto _err;
(void)sdbSetRawStatus(pRaw, vgStatus); code = sdbSetRawStatus(pRaw, vgStatus);
if (code != 0) {
mError("vgId:%d, failed to set raw status to ready, error:%s, line:%d", pVg->vgId, tstrerror(code), __LINE__);
goto _err;
}
pRaw = NULL; pRaw = NULL;
TAOS_RETURN(code); TAOS_RETURN(code);
_err: _err:
@ -2956,7 +3122,11 @@ static int32_t mndAddDbStatusAction(STrans *pTrans, SDbObj *pDb, ESdbStatus dbSt
goto _err; goto _err;
} }
if ((code = appendActionCb(pTrans, pRaw)) != 0) goto _err; if ((code = appendActionCb(pTrans, pRaw)) != 0) goto _err;
(void)sdbSetRawStatus(pRaw, dbStatus); code = sdbSetRawStatus(pRaw, dbStatus);
if (code != 0) {
mError("db:%s, failed to set raw status to ready, error:%s, line:%d", pDb->name, tstrerror(code), __LINE__);
goto _err;
}
pRaw = NULL; pRaw = NULL;
TAOS_RETURN(code); TAOS_RETURN(code);
_err: _err:
@ -3165,7 +3335,11 @@ static int32_t mndSetBalanceVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SD
sdbFreeRaw(pRaw); sdbFreeRaw(pRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY); code = sdbSetRawStatus(pRaw, SDB_STATUS_READY);
if (code != 0) {
mError("vgId:%d, failed to set raw status to ready, error:%s, line:%d", newVg.vgId, tstrerror(code), __LINE__);
TAOS_RETURN(code);
}
} }
mInfo("vgId:%d, vgroup info after balance, replica:%d", newVg.vgId, newVg.replica); mInfo("vgId:%d, vgroup info after balance, replica:%d", newVg.vgId, newVg.replica);
@ -3391,7 +3565,11 @@ static void *mndBuildCompactVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgrou
pHead->contLen = htonl(contLen); pHead->contLen = htonl(contLen);
pHead->vgId = htonl(pVgroup->vgId); pHead->vgId = htonl(pVgroup->vgId);
(void)tSerializeSCompactVnodeReq((char *)pReq + sizeof(SMsgHead), contLen, &compactReq); if (tSerializeSCompactVnodeReq((char *)pReq + sizeof(SMsgHead), contLen, &compactReq) < 0) {
taosMemoryFree(pReq);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
*pContLen = contLen; *pContLen = contLen;
return pReq; return pReq;
} }