From 06d94f6cd885dcc48982d96cb05c5729d46f61ae Mon Sep 17 00:00:00 2001 From: dmchen Date: Wed, 10 May 2023 17:16:04 +0800 Subject: [PATCH] to enterprise --- source/dnode/mnode/impl/src/mndDnode.c | 106 ------------------------- 1 file changed, 106 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 6172a7754e..e0934dbf43 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -596,112 +596,6 @@ _OVER: return code; } -static int32_t mndRestoreDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, int8_t restoreType) { - int32_t code = -1; - SSdbRaw *pRaw = NULL; - STrans *pTrans = NULL; - - pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "restore-dnode"); - if (pTrans == NULL) goto _OVER; - - mndTransSetSerial(pTrans); - - mInfo("trans:%d, used to restore dnode:%s", pTrans->id, pDnode->ep); - - if (mndTrancCheckConflict(pMnode, pTrans) != 0) goto _OVER; - - if(restoreType == RESTORE_TYPE__ALL || restoreType == RESTORE_TYPE__MNODE) - { - int32_t totalMnodes = sdbGetSize(pMnode->pSdb, SDB_MNODE); - if (totalMnodes == 2) { - mError("cant't restore mnode, since a mnode on it and replica is 2"); - terrno = TSDB_CODE_MNODE_ONLY_TWO_MNODE; - return -1; - } - - SMnodeObj *mnodeObj = mndAcquireMnode(pMnode, pDnode->id); - if(mnodeObj == NULL){ - mError("trans:%d, no mnode exist on dnode:%s", pTrans->id, pDnode->ep); - } - else - { - SMnodeObj newMnodeObj = {0}; - newMnodeObj.id = pDnode->id; - newMnodeObj.createdTime = taosGetTimestampMs(); - newMnodeObj.updateTime = newMnodeObj.createdTime; - newMnodeObj.role = TAOS_SYNC_ROLE_LEARNER; - newMnodeObj.lastIndex = pMnode->applied; - if (mndSetRestoreCreateMnodeRedoActions(pMnode, pTrans, pDnode, &newMnodeObj) != 0) goto _OVER; - - SMnodeObj mnodeLeaderObj = {0}; - mnodeLeaderObj.id = pDnode->id; - mnodeLeaderObj.createdTime = taosGetTimestampMs(); - mnodeLeaderObj.updateTime = mnodeLeaderObj.createdTime; - mnodeLeaderObj.role = TAOS_SYNC_ROLE_VOTER; - mnodeLeaderObj.lastIndex = pMnode->applied + 1; - if (mndSetRestoreAlterMnodeTypeRedoActions(pMnode, pTrans, pDnode, &mnodeLeaderObj) != 0) goto _OVER; - - if (mndSetCreateMnodeCommitLogs(pMnode, pTrans, &mnodeLeaderObj) != 0) goto _OVER; - - mndReleaseMnode(pMnode, mnodeObj); - } - } - - SSdb *pSdb = pMnode->pSdb; - void *pIter = NULL; - - if(restoreType == RESTORE_TYPE__ALL || restoreType == RESTORE_TYPE__VNODE){ - while (1) { - SVgObj *pVgroup = NULL; - pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); - if (pIter == NULL) break; - - if (mndVgroupInDnode(pVgroup, pDnode->id)) { - SDbObj *db = mndAcquireDb(pMnode, pVgroup->dbName); - if(db == NULL){ - sdbCancelFetch(pSdb, pIter); - sdbRelease(pSdb, pVgroup); - goto _OVER; - } - if (mndBuildRestoreAlterVgroupAction(pMnode, pTrans, db, pVgroup, pDnode) != 0) { - sdbCancelFetch(pSdb, pIter); - mndReleaseDb(pMnode, db); - sdbRelease(pSdb, pVgroup); - goto _OVER; - } - mndReleaseDb(pMnode, db); - } - - sdbRelease(pSdb, pVgroup); - } - } - - if(restoreType == RESTORE_TYPE__ALL || restoreType == RESTORE_TYPE__QNODE){ - pIter = NULL; - while (1) { - SQnodeObj *pQnode = NULL; - pIter = sdbFetch(pSdb, SDB_QNODE, pIter, (void **)&pQnode); - if (pIter == NULL) break; - - if (mndQnodeInDnode(pQnode, pDnode->id)) { - if (mndSetCreateQnodeCommitLogs(pTrans, pQnode) != 0) goto _OVER; - if (mndSetCreateQnodeRedoActions(pTrans, pDnode, pQnode) != 0) goto _OVER; - } - - sdbRelease(pSdb, pQnode); - } - } - - if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; - code = 0; - -_OVER: - - mndTransDrop(pTrans); - sdbFreeRaw(pRaw); - return code; -} - static int32_t mndProcessDnodeListReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; SSdb *pSdb = pMnode->pSdb; -- GitLab