Merge pull request #27702 from taosdata/fix/TD-31891-remove-void-mnode1

fix/TD-31891-remove-void-mnode1
This commit is contained in:
Hongze Cheng 2024-09-13 11:45:22 +08:00 committed by GitHub
commit ec2f2b68d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 73 additions and 24 deletions

View File

@ -268,7 +268,11 @@ int32_t mndAddCompactToTran(SMnode *pMnode, STrans *pTrans, SCompactObj *pCompac
sdbFreeRaw(pVgRaw); sdbFreeRaw(pVgRaw);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
if ((code = sdbSetRawStatus(pVgRaw, SDB_STATUS_READY)) != 0) {
sdbFreeRaw(pVgRaw);
TAOS_RETURN(code);
}
rsp->compactId = pCompact->compactId; rsp->compactId = pCompact->compactId;
@ -357,7 +361,10 @@ static void *mndBuildKillCompactReq(SMnode *pMnode, SVgObj *pVgroup, int32_t *pC
pHead->contLen = htonl(contLen); pHead->contLen = htonl(contLen);
pHead->vgId = htonl(pVgroup->vgId); pHead->vgId = htonl(pVgroup->vgId);
(void)tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req); if ((contLen = tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req)) < 0) {
terrno = contLen;
return NULL;
}
*pContLen = contLen; *pContLen = contLen;
return pReq; return pReq;
} }
@ -421,7 +428,10 @@ static int32_t mndKillCompact(SMnode *pMnode, SRpcMsg *pReq, SCompactObj *pCompa
mndTransDrop(pTrans); mndTransDrop(pTrans);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); if ((code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY)) != 0) {
mndTransDrop(pTrans);
TAOS_RETURN(code);
}
void *pIter = NULL; void *pIter = NULL;
while (1) { while (1) {
@ -614,7 +624,10 @@ void mndCompactSendProgressReq(SMnode *pMnode, SCompactObj *pCompact) {
pHead->contLen = htonl(contLen); pHead->contLen = htonl(contLen);
pHead->vgId = htonl(pDetail->vgId); pHead->vgId = htonl(pDetail->vgId);
(void)tSerializeSQueryCompactProgressReq((char *)pHead + sizeof(SMsgHead), contLen - sizeof(SMsgHead), &req); if (tSerializeSQueryCompactProgressReq((char *)pHead + sizeof(SMsgHead), contLen - sizeof(SMsgHead), &req) <= 0) {
sdbRelease(pMnode->pSdb, pDetail);
continue;
}
SRpcMsg rpcMsg = {.msgType = TDMT_VND_QUERY_COMPACT_PROGRESS, .contLen = contLen}; SRpcMsg rpcMsg = {.msgType = TDMT_VND_QUERY_COMPACT_PROGRESS, .contLen = contLen};
@ -719,7 +732,12 @@ static int32_t mndSaveCompactProgress(SMnode *pMnode, int32_t compactId) {
mndTransDrop(pTrans); mndTransDrop(pTrans);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); if ((code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY)) != 0) {
sdbCancelFetch(pMnode->pSdb, pIter);
sdbRelease(pMnode->pSdb, pDetail);
mndTransDrop(pTrans);
TAOS_RETURN(code);
}
} }
sdbRelease(pMnode->pSdb, pDetail); sdbRelease(pMnode->pSdb, pDetail);
@ -782,7 +800,12 @@ static int32_t mndSaveCompactProgress(SMnode *pMnode, int32_t compactId) {
mndTransDrop(pTrans); mndTransDrop(pTrans);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED); if ((code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED)) != 0) {
sdbCancelFetch(pMnode->pSdb, pIter);
sdbRelease(pMnode->pSdb, pDetail);
mndTransDrop(pTrans);
TAOS_RETURN(code);
}
mInfo("compact:%d, add drop compactdetail action", pDetail->compactDetailId); mInfo("compact:%d, add drop compactdetail action", pDetail->compactDetailId);
} }
@ -809,7 +832,11 @@ static int32_t mndSaveCompactProgress(SMnode *pMnode, int32_t compactId) {
mndTransDrop(pTrans); mndTransDrop(pTrans);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED); if ((code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED)) != 0) {
mError("compact:%d, trans:%d, failed to append commit log since %s", compactId, pTrans->id, terrstr());
mndTransDrop(pTrans);
TAOS_RETURN(code);
}
mInfo("compact:%d, add drop compact action", pCompact->compactId); mInfo("compact:%d, add drop compact action", pCompact->compactId);
} }

View File

@ -182,7 +182,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
goto _OVER; goto _OVER;
} }
TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pRaw), NULL, _OVER); TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pRaw), NULL, _OVER);
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY); TAOS_CHECK_GOTO(sdbSetRawStatus(pRaw, SDB_STATUS_READY), NULL, _OVER);
pRaw = NULL; pRaw = NULL;
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER); TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
@ -621,7 +621,10 @@ static int32_t mndUpdateDnodeObj(SMnode *pMnode, SDnodeObj *pDnode) {
TAOS_RETURN(terrno); TAOS_RETURN(terrno);
} }
(void)tSerializeSDnodeInfoReq(pReq, contLen, &infoReq); if ((contLen = tSerializeSDnodeInfoReq(pReq, contLen, &infoReq)) <= 0) {
code = contLen;
goto _exit;
}
SRpcMsg rpcMsg = {.msgType = TDMT_MND_UPDATE_DNODE_INFO, .pCont = pReq, .contLen = contLen}; SRpcMsg rpcMsg = {.msgType = TDMT_MND_UPDATE_DNODE_INFO, .pCont = pReq, .contLen = contLen};
TAOS_CHECK_EXIT(tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg)); TAOS_CHECK_EXIT(tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg));
@ -661,7 +664,7 @@ static int32_t mndProcessUpdateDnodeInfoReq(SRpcMsg *pReq) {
mError("trans:%d, failed to append commit log since %s", pTrans->id, tstrerror(code)); mError("trans:%d, failed to append commit log since %s", pTrans->id, tstrerror(code));
TAOS_CHECK_EXIT(code); TAOS_CHECK_EXIT(code);
} }
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); TAOS_CHECK_EXIT(sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY));
pCommitRaw = NULL; pCommitRaw = NULL;
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) { if ((code = mndTransPrepare(pMnode, pTrans)) != 0) {
@ -874,8 +877,12 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
int32_t contLen = tSerializeSStatusRsp(NULL, 0, &statusRsp); int32_t contLen = tSerializeSStatusRsp(NULL, 0, &statusRsp);
void *pHead = rpcMallocCont(contLen); void *pHead = rpcMallocCont(contLen);
(void)tSerializeSStatusRsp(pHead, contLen, &statusRsp); contLen = tSerializeSStatusRsp(pHead, contLen, &statusRsp);
taosArrayDestroy(statusRsp.pDnodeEps); taosArrayDestroy(statusRsp.pDnodeEps);
if (contLen < 0) {
code = contLen;
goto _OVER;
}
pReq->info.rspLen = contLen; pReq->info.rspLen = contLen;
pReq->info.rsp = pHead; pReq->info.rsp = pHead;
@ -888,8 +895,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
_OVER: _OVER:
mndReleaseDnode(pMnode, pDnode); mndReleaseDnode(pMnode, pDnode);
taosArrayDestroy(statusReq.pVloads); taosArrayDestroy(statusReq.pVloads);
(void)mndUpdClusterInfo(pReq); return mndUpdClusterInfo(pReq);
return code;
} }
static int32_t mndProcessNotifyReq(SRpcMsg *pReq) { static int32_t mndProcessNotifyReq(SRpcMsg *pReq) {
@ -955,7 +961,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC
goto _OVER; goto _OVER;
} }
TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pRaw), NULL, _OVER); TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pRaw), NULL, _OVER);
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY); TAOS_CHECK_GOTO(sdbSetRawStatus(pRaw, SDB_STATUS_READY), NULL, _OVER);
pRaw = NULL; pRaw = NULL;
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER); TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
@ -1010,7 +1016,10 @@ static int32_t mndProcessDnodeListReq(SRpcMsg *pReq) {
goto _OVER; goto _OVER;
} }
(void)tSerializeSDnodeListRsp(pRsp, rspLen, &rsp); if ((rspLen = tSerializeSDnodeListRsp(pRsp, rspLen, &rsp)) <= 0) {
code = rspLen;
goto _OVER;
}
pReq->info.rspLen = rspLen; pReq->info.rspLen = rspLen;
pReq->info.rsp = pRsp; pReq->info.rsp = pRsp;
@ -1151,7 +1160,10 @@ static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
goto _OVER; goto _OVER;
} }
(void)tSerializeSShowVariablesRsp(pRsp, rspLen, &rsp); if ((rspLen = tSerializeSShowVariablesRsp(pRsp, rspLen, &rsp)) <= 0) {
code = rspLen;
goto _OVER;
}
pReq->info.rspLen = rspLen; pReq->info.rspLen = rspLen;
pReq->info.rsp = pRsp; pReq->info.rsp = pRsp;
@ -1247,7 +1259,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
goto _OVER; goto _OVER;
} }
TAOS_CHECK_GOTO(mndTransAppendRedolog(pTrans, pRaw), NULL, _OVER); TAOS_CHECK_GOTO(mndTransAppendRedolog(pTrans, pRaw), NULL, _OVER);
(void)sdbSetRawStatus(pRaw, SDB_STATUS_DROPPING); TAOS_CHECK_GOTO(sdbSetRawStatus(pRaw, SDB_STATUS_DROPPING), NULL, _OVER);
pRaw = NULL; pRaw = NULL;
pRaw = mndDnodeActionEncode(pDnode); pRaw = mndDnodeActionEncode(pDnode);
@ -1257,7 +1269,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
goto _OVER; goto _OVER;
} }
TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pRaw), NULL, _OVER); TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pRaw), NULL, _OVER);
(void)sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED); TAOS_CHECK_GOTO(sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED), NULL, _OVER);
pRaw = NULL; pRaw = NULL;
if (pMObj != NULL) { if (pMObj != NULL) {
@ -1450,7 +1462,10 @@ static int32_t mndSendCfgDnodeReq(SMnode *pMnode, int32_t dnodeId, SDCfgDnodeReq
void *pBuf = rpcMallocCont(bufLen); void *pBuf = rpcMallocCont(bufLen);
if (pBuf != NULL) { if (pBuf != NULL) {
(void)tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq); if ((bufLen = tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq)) <= 0) {
code = bufLen;
return code;
}
mInfo("dnode:%d, send config req to dnode, config:%s value:%s", dnodeId, pDcfgReq->config, pDcfgReq->value); mInfo("dnode:%d, send config req to dnode, config:%s value:%s", dnodeId, pDcfgReq->config, pDcfgReq->value);
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen}; SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen};
code = tmsgSendReq(&epSet, &rpcMsg); code = tmsgSendReq(&epSet, &rpcMsg);
@ -1590,7 +1605,11 @@ static int32_t mndProcessCreateEncryptKeyReqImpl(SRpcMsg *pReq, int32_t dnodeId,
void *pBuf = rpcMallocCont(bufLen); void *pBuf = rpcMallocCont(bufLen);
if (pBuf != NULL) { if (pBuf != NULL) {
(void)tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq); if ((bufLen = tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq)) <= 0) {
code = bufLen;
sdbRelease(pSdb, pDnode);
goto _exit;
}
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CREATE_ENCRYPT_KEY, .pCont = pBuf, .contLen = bufLen}; SRpcMsg rpcMsg = {.msgType = TDMT_DND_CREATE_ENCRYPT_KEY, .pCont = pBuf, .contLen = bufLen};
if (0 == tmsgSendReq(&epSet, &rpcMsg)) { if (0 == tmsgSendReq(&epSet, &rpcMsg)) {
(void)atomic_add_fetch_16(&pMnode->encryptMgmt.nEncrypt, 1); (void)atomic_add_fetch_16(&pMnode->encryptMgmt.nEncrypt, 1);

View File

@ -375,7 +375,7 @@ static int32_t mndDropFunc(SMnode *pMnode, SRpcMsg *pReq, SFuncObj *pFunc) {
goto _OVER; goto _OVER;
} }
TAOS_CHECK_GOTO(mndTransAppendRedolog(pTrans, pRedoRaw), NULL, _OVER); TAOS_CHECK_GOTO(mndTransAppendRedolog(pTrans, pRedoRaw), NULL, _OVER);
(void)sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING); TAOS_CHECK_GOTO(sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING), NULL, _OVER);
SSdbRaw *pUndoRaw = mndFuncActionEncode(pFunc); SSdbRaw *pUndoRaw = mndFuncActionEncode(pFunc);
if (pUndoRaw == NULL) { if (pUndoRaw == NULL) {
@ -384,7 +384,7 @@ static int32_t mndDropFunc(SMnode *pMnode, SRpcMsg *pReq, SFuncObj *pFunc) {
goto _OVER; goto _OVER;
} }
TAOS_CHECK_GOTO(mndTransAppendUndolog(pTrans, pUndoRaw), NULL, _OVER); TAOS_CHECK_GOTO(mndTransAppendUndolog(pTrans, pUndoRaw), NULL, _OVER);
(void)sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY); TAOS_CHECK_GOTO(sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY), NULL, _OVER);
SSdbRaw *pCommitRaw = mndFuncActionEncode(pFunc); SSdbRaw *pCommitRaw = mndFuncActionEncode(pFunc);
if (pCommitRaw == NULL) { if (pCommitRaw == NULL) {
@ -393,7 +393,7 @@ static int32_t mndDropFunc(SMnode *pMnode, SRpcMsg *pReq, SFuncObj *pFunc) {
goto _OVER; goto _OVER;
} }
TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pCommitRaw), NULL, _OVER); TAOS_CHECK_GOTO(mndTransAppendCommitlog(pTrans, pCommitRaw), NULL, _OVER);
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED); TAOS_CHECK_GOTO(sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED), NULL, _OVER);
TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER); TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER);
@ -598,7 +598,10 @@ static int32_t mndProcessRetrieveFuncReq(SRpcMsg *pReq) {
goto RETRIEVE_FUNC_OVER; goto RETRIEVE_FUNC_OVER;
} }
(void)tSerializeSRetrieveFuncRsp(pRsp, contLen, &retrieveRsp); if ((contLen = tSerializeSRetrieveFuncRsp(pRsp, contLen, &retrieveRsp)) <= 0) {
code = contLen;
goto RETRIEVE_FUNC_OVER;
}
pReq->info.rsp = pRsp; pReq->info.rsp = pRsp;
pReq->info.rspLen = contLen; pReq->info.rspLen = contLen;