From 66408607499c56e818e10b877d1a93ef8b0366b0 Mon Sep 17 00:00:00 2001 From: dmchen Date: Wed, 28 Aug 2024 07:54:24 +0000 Subject: [PATCH] fix/TD-31686-remove-void-arrayput-mnode --- source/dnode/mnode/impl/src/mndArbGroup.c | 8 ++++-- source/dnode/mnode/impl/src/mndCompact.c | 4 ++- source/dnode/mnode/impl/src/mndConsumer.c | 16 +++++++++-- source/dnode/mnode/impl/src/mndDb.c | 20 ++++++++++--- source/dnode/mnode/impl/src/mndDnode.c | 15 ++++++++-- source/dnode/mnode/impl/src/mndMain.c | 16 ++++++++--- source/dnode/mnode/impl/src/mndProfile.c | 29 +++++++++++++------ source/dnode/mnode/impl/src/mndQnode.c | 7 ++++- source/dnode/mnode/impl/src/mndStb.c | 34 ++++++++++++++++++----- source/dnode/mnode/impl/src/mndTopic.c | 4 ++- source/dnode/mnode/impl/src/mndTrans.c | 4 ++- 11 files changed, 123 insertions(+), 34 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndArbGroup.c b/source/dnode/mnode/impl/src/mndArbGroup.c index 23434e5ee3..2411a58a6c 100644 --- a/source/dnode/mnode/impl/src/mndArbGroup.c +++ b/source/dnode/mnode/impl/src/mndArbGroup.c @@ -407,7 +407,9 @@ static int32_t mndProcessArbHbTimer(SRpcMsg *pReq) { (void)taosHashPut(pDnodeHash, &dnodeId, sizeof(int32_t), &hbMembers, POINTER_BYTES); } SVArbHbReqMember reqMember = {.vgId = pArbGroup->vgId, .hbSeq = pMember->state.nextHbSeq++}; - (void)taosArrayPush(hbMembers, &reqMember); + if (taosArrayPush(hbMembers, &reqMember) == NULL) { + mError("dnodeId:%d, failed to push hb member, but conitnue next at this timer round", dnodeId); + } } (void)taosThreadMutexUnlock(&pArbGroup->mutex); @@ -998,7 +1000,9 @@ static int32_t mndUpdateArbHeartBeat(SMnode *pMnode, int32_t dnodeId, SArray *me bool updateToken = mndUpdateArbGroupByHeartBeat(pGroup, pRspMember, nowMs, dnodeId, &newGroup); if (updateToken) { - (void)taosArrayPush(pUpdateArray, &newGroup); + if (taosArrayPush(pUpdateArray, &newGroup) == NULL) { + mError("failed to push newGroup to updateArray, but continue at this hearbear"); + } } sdbRelease(pMnode->pSdb, pGroup); diff --git a/source/dnode/mnode/impl/src/mndCompact.c b/source/dnode/mnode/impl/src/mndCompact.c index aae3a262f4..b8073885fd 100644 --- a/source/dnode/mnode/impl/src/mndCompact.c +++ b/source/dnode/mnode/impl/src/mndCompact.c @@ -826,7 +826,9 @@ void mndCompactPullup(SMnode *pMnode) { SCompactObj *pCompact = NULL; pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT, pIter, (void **)&pCompact); if (pIter == NULL) break; - (void)taosArrayPush(pArray, &pCompact->compactId); + if (taosArrayPush(pArray, &pCompact->compactId) == NULL) { + mError("failed to push compact id:%d into array, but continue pull up", pCompact->compactId); + } sdbRelease(pSdb, pCompact); } diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 65617ddf31..1d0dbd1c44 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -334,9 +334,21 @@ static int32_t addEpSetInfo(SMnode *pMnode, SMqConsumerObj *pConsumer, int32_t e } } SMqSubVgEp vgEp = {.epSet = pVgEp->epSet, .vgId = pVgEp->vgId, .offset = -1}; - (void)taosArrayPush(topicEp.vgs, &vgEp); + if (taosArrayPush(topicEp.vgs, &vgEp) == NULL) { + taosArrayDestroy(topicEp.vgs); + taosRUnLockLatch(&pConsumer->lock); + taosRUnLockLatch(&pSub->lock); + mndReleaseSubscribe(pMnode, pSub); + return TSDB_CODE_OUT_OF_MEMORY; + } + } + if (taosArrayPush(rsp->topics, &topicEp) == NULL) { + taosArrayDestroy(topicEp.vgs); + taosRUnLockLatch(&pConsumer->lock); + taosRUnLockLatch(&pSub->lock); + mndReleaseSubscribe(pMnode, pSub); + return TSDB_CODE_OUT_OF_MEMORY; } - (void)taosArrayPush(rsp->topics, &topicEp); taosRUnLockLatch(&pSub->lock); mndReleaseSubscribe(pMnode, pSub); } diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 9b83fa8a1d..0ee265dd74 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1710,7 +1710,9 @@ void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) { } } vindex++; - (void)taosArrayPush(pVgList, &vgInfo); + if (taosArrayPush(pVgList, &vgInfo) == NULL) { + mError("db:%s, failed to push vgInfo to array, vgId:%d, but continue next", pDb->name, vgInfo.vgId); + } } sdbRelease(pSdb, pVgroup); @@ -1856,7 +1858,10 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs, rsp.useDbRsp->vgNum = taosArrayGetSize(rsp.useDbRsp->pVgroupInfos); - (void)taosArrayPush(batchRsp.pArray, &rsp); + if (taosArrayPush(batchRsp.pArray, &rsp) == NULL) { + if (terrno != 0) code = terrno; + return code; + } continue; } @@ -1868,7 +1873,10 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs, (void)memcpy(rsp.useDbRsp->db, pDbCacheInfo->dbFName, TSDB_DB_FNAME_LEN); rsp.useDbRsp->uid = pDbCacheInfo->dbId; rsp.useDbRsp->vgVersion = -1; - (void)taosArrayPush(batchRsp.pArray, &rsp); + if (taosArrayPush(batchRsp.pArray, &rsp) == NULL) { + if (terrno != 0) code = terrno; + return code; + } continue; } @@ -1940,7 +1948,11 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs, rsp.useDbRsp->hashSuffix = pDb->cfg.hashSuffix; } - (void)taosArrayPush(batchRsp.pArray, &rsp); + if (taosArrayPush(batchRsp.pArray, &rsp) == NULL) { + mndReleaseDb(pMnode, pDb); + if (terrno != 0) code = terrno; + return code; + } mndReleaseDb(pMnode, pDb); } diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 974beeccb6..ffd8e16468 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -430,7 +430,9 @@ static void mndGetDnodeEps(SMnode *pMnode, SArray *pDnodeEps) { if (mndIsMnode(pMnode, pDnode->id)) { dnodeEp.isMnode = 1; } - (void)taosArrayPush(pDnodeEps, &dnodeEp); + if (taosArrayPush(pDnodeEps, &dnodeEp) == NULL) { + mError("failed to put ep into array, but continue at this call"); + } } } @@ -991,7 +993,12 @@ static int32_t mndProcessDnodeListReq(SRpcMsg *pReq) { tstrncpy(epSet.eps[0].fqdn, pObj->fqdn, TSDB_FQDN_LEN); epSet.eps[0].port = pObj->port; - (void)taosArrayPush(rsp.dnodeList, &epSet); + if (taosArrayPush(rsp.dnodeList, &epSet) == NULL) { + if (terrno != 0) code = terrno; + sdbRelease(pSdb, pObj); + sdbCancelFetch(pSdb, pIter); + goto _OVER; + } sdbRelease(pSdb, pObj); } @@ -1845,7 +1852,9 @@ SArray *mndGetAllDnodeFqdns(SMnode *pMnode) { if (pIter == NULL) break; char *fqdn = taosStrdup(pObj->fqdn); - (void)taosArrayPush(fqdns, &fqdn); + if (taosArrayPush(fqdns, &fqdn) == NULL) { + mError("failed to fqdn into array, but continue at this time"); + } sdbRelease(pSdb, pObj); } return fqdns; diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 9b80370fd4..aa03fbf2d9 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -991,7 +991,9 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr } else { tstrncpy(desc.status, "offline", sizeof(desc.status)); } - (void)taosArrayPush(pClusterInfo->dnodes, &desc); + if (taosArrayPush(pClusterInfo->dnodes, &desc) == NULL) { + mError("failed put dnode into array, but continue at this monitor report") + } sdbRelease(pSdb, pObj); } @@ -1017,7 +1019,9 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr tstrncpy(desc.role, syncStr(pObj->syncState), sizeof(desc.role)); desc.syncState = pObj->syncState; } - (void)taosArrayPush(pClusterInfo->mnodes, &desc); + if (taosArrayPush(pClusterInfo->mnodes, &desc) == NULL) { + mError("failed to put mnode into array, but continue at this monitor report"); + } sdbRelease(pSdb, pObj); } @@ -1057,7 +1061,9 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr pClusterInfo->vnodes_total++; } - (void)taosArrayPush(pVgroupInfo->vgroups, &desc); + if (taosArrayPush(pVgroupInfo->vgroups, &desc) == NULL) { + mError("failed to put vgroup into array, but continue at this monitor report") + } sdbRelease(pSdb, pVgroup); } @@ -1078,7 +1084,9 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr (void)tNameFromString(&name2, pStb->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); tstrncpy(desc.stb_name, tNameGetTableName(&name2), TSDB_TABLE_NAME_LEN); - (void)taosArrayPush(pStbInfo->stbs, &desc); + if (taosArrayPush(pStbInfo->stbs, &desc) == NULL) { + mError("failed to put stb into array, but continue at this monitor report"); + } sdbRelease(pSdb, pStb); } diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 875ad562d2..7e78a03918 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -546,8 +546,9 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb int32_t kvNum = taosHashGetSize(pHbReq->info); if (NULL == pHbReq->info || kvNum <= 0) { - // TODO return value - (void)taosArrayPush(pBatchRsp->rsps, &hbRsp); + if (taosArrayPush(pBatchRsp->rsps, &hbRsp) == NULL) { + mError("failed to put rsp into array, but continue at this heartbeat"); + } return TSDB_CODE_SUCCESS; } @@ -597,7 +598,9 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb pObj->ipWhiteListVer); if (rspMsg && rspLen > 0) { SKv kv1 = {.key = HEARTBEAT_KEY_USER_AUTHINFO, .valueLen = rspLen, .value = rspMsg}; - (void)taosArrayPush(hbRsp.info, &kv1); + if (taosArrayPush(hbRsp.info, &kv1) == NULL) { + mError("failed to put kv into array, but continue at this heartbeat"); + } } break; } @@ -607,7 +610,9 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb (void)mndValidateDbInfo(pMnode, kv->value, kv->valueLen / sizeof(SDbCacheInfo), &rspMsg, &rspLen); if (rspMsg && rspLen > 0) { SKv kv1 = {.key = HEARTBEAT_KEY_DBINFO, .valueLen = rspLen, .value = rspMsg}; - (void)taosArrayPush(hbRsp.info, &kv1); + if (taosArrayPush(hbRsp.info, &kv1) == NULL) { + mError("failed to put kv into array, but continue at this heartbeat"); + } } break; } @@ -617,7 +622,9 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb (void)mndValidateStbInfo(pMnode, kv->value, kv->valueLen / sizeof(SSTableVersion), &rspMsg, &rspLen); if (rspMsg && rspLen > 0) { SKv kv1 = {.key = HEARTBEAT_KEY_STBINFO, .valueLen = rspLen, .value = rspMsg}; - (void)taosArrayPush(hbRsp.info, &kv1); + if (taosArrayPush(hbRsp.info, &kv1) == NULL) { + mError("failed to put kv into array, but continue at this heartbeat"); + } } break; } @@ -635,7 +642,9 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb (void)mndValidateViewInfo(pMnode, kv->value, kv->valueLen / sizeof(SViewVersion), &rspMsg, &rspLen); if (rspMsg && rspLen > 0) { SKv kv1 = {.key = HEARTBEAT_KEY_VIEWINFO, .valueLen = rspLen, .value = rspMsg}; - (void)taosArrayPush(hbRsp.info, &kv1); + if (taosArrayPush(hbRsp.info, &kv1) == NULL) { + mError("failed to put kv into array, but continue at this heartbeat"); + } } break; } @@ -646,7 +655,9 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb (void)mndValidateTSMAInfo(pMnode, kv->value, kv->valueLen / sizeof(STSMAVersion), &rspMsg, &rspLen); if (rspMsg && rspLen > 0) { SKv kv = {.key = HEARTBEAT_KEY_TSMA, .valueLen = rspLen, .value = rspMsg}; - (void)taosArrayPush(hbRsp.info, &kv); + if (taosArrayPush(hbRsp.info, &kv) == NULL) { + mError("failed to put kv into array, but continue at this heartbeat"); + } } break; } @@ -706,7 +717,9 @@ static int32_t mndProcessHeartBeatReq(SRpcMsg *pReq) { } else if (pHbReq->connKey.connType == CONN_TYPE__TMQ) { SClientHbRsp *pRsp = mndMqHbBuildRsp(pMnode, pHbReq); if (pRsp != NULL) { - (void)taosArrayPush(batchRsp.rsps, pRsp); + if (taosArrayPush(batchRsp.rsps, pRsp) == NULL) { + mError("failed to put kv into array, but continue at this heartbeat"); + } taosMemoryFree(pRsp); } } diff --git a/source/dnode/mnode/impl/src/mndQnode.c b/source/dnode/mnode/impl/src/mndQnode.c index 2e352915d8..8210b94b57 100644 --- a/source/dnode/mnode/impl/src/mndQnode.c +++ b/source/dnode/mnode/impl/src/mndQnode.c @@ -498,7 +498,12 @@ int32_t mndCreateQnodeList(SMnode *pMnode, SArray **pList, int32_t limit) { nodeLoad.addr.epSet.eps[0].port = pObj->pDnode->port; nodeLoad.load = QNODE_LOAD_VALUE(pObj); - (void)taosArrayPush(qnodeList, &nodeLoad); + if (taosArrayPush(qnodeList, &nodeLoad) == NULL) { + sdbRelease(pSdb, pObj); + sdbCancelFetch(pSdb, pIter); + if (terrno != 0) code = terrno; + return code; + } numOfRows++; sdbRelease(pSdb, pObj); diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 9a1804ce6a..6384451d86 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -278,7 +278,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { for (int32_t i = 0; i < pStb->numOfFuncs; ++i) { char funcName[TSDB_FUNC_NAME_LEN] = {0}; SDB_GET_BINARY(pRaw, dataPos, funcName, TSDB_FUNC_NAME_LEN, _OVER) - (void)taosArrayPush(pStb->pFuncs, funcName); + if (taosArrayPush(pStb->pFuncs, funcName) == NULL) goto _OVER; } if (pStb->commentLen > 0) { @@ -3069,7 +3069,10 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t tstrncpy(metaRsp.dbFName, pStbVersion->dbFName, sizeof(metaRsp.dbFName)); tstrncpy(metaRsp.tbName, pStbVersion->stbName, sizeof(metaRsp.tbName)); tstrncpy(metaRsp.stbName, pStbVersion->stbName, sizeof(metaRsp.stbName)); - (void)taosArrayPush(hbRsp.pMetaRsp, &metaRsp); + if (taosArrayPush(hbRsp.pMetaRsp, &metaRsp) == NULL) { + code = terrno; + return code; + } continue; } @@ -3082,11 +3085,17 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t tstrncpy(metaRsp.dbFName, pStbVersion->dbFName, sizeof(metaRsp.dbFName)); tstrncpy(metaRsp.tbName, pStbVersion->stbName, sizeof(metaRsp.tbName)); tstrncpy(metaRsp.stbName, pStbVersion->stbName, sizeof(metaRsp.stbName)); - (void)taosArrayPush(hbRsp.pMetaRsp, &metaRsp); + if (taosArrayPush(hbRsp.pMetaRsp, &metaRsp) == NULL) { + code = terrno; + return code; + } continue; } - (void)taosArrayPush(hbRsp.pMetaRsp, &metaRsp); + if (taosArrayPush(hbRsp.pMetaRsp, &metaRsp) == NULL) { + code = terrno; + return code; + } } if (sma) { @@ -3110,7 +3119,10 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t strcpy(indexRsp.dbFName, pStbVersion->dbFName); strcpy(indexRsp.tbName, pStbVersion->stbName); - (void)taosArrayPush(hbRsp.pIndexRsp, &indexRsp); + if (taosArrayPush(hbRsp.pIndexRsp, &indexRsp) == NULL) { + code = terrno; + return code; + } } } @@ -4313,7 +4325,12 @@ static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode *pMnode, SMndDropTbsWith } else { info.dbInfo = *pDbInfo; } - (void)taosArrayPush(pInfos->pTsmaInfos, &info); + if (taosArrayPush(pInfos->pTsmaInfos, &info) == NULL) { + code = terrno; + sdbCancelFetch(pMnode->pSdb, pIter); + sdbRelease(pMnode->pSdb, pSma); + goto _end; + } } sdbRelease(pMnode->pSdb, pSma); } @@ -4333,7 +4350,10 @@ static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode *pMnode, SMndDropTbsWith taosGetTbHashVal(buf, len, pInfo->dbInfo.hashMethod, pInfo->dbInfo.hashPrefix, pInfo->dbInfo.hashSuffix); const SVgroupInfo *pVgInfo = taosArraySearch(pInfo->dbInfo.dbVgInfos, &hashVal, vgHashValCmp, TD_EQ); void *p = taosStrdup(buf + strlen(pInfo->tsmaResTbDbFName) + TSDB_NAME_DELIMITER_LEN); - (void)taosArrayPush(pCtx->pResTbNames, &p); + if (taosArrayPush(pCtx->pResTbNames, &p) == NULL) { + code = terrno; + goto _end; + } TAOS_CHECK_GOTO(mndDropTbAdd(pMnode, pCtx->pVgMap, pVgInfo, p, pInfo->suid, true), NULL, _end); } } diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index dcac86a7d4..9e06f3b0f2 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -270,7 +270,9 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { } int16_t colId; SDB_GET_INT16(pRaw, dataPos, &colId, TOPIC_DECODE_OVER); - (void)taosArrayPush(pTopic->ntbColIds, &colId); + if (taosArrayPush(pTopic->ntbColIds, &colId) == NULL) { + goto TOPIC_DECODE_OVER; + } } SDB_GET_INT64(pRaw, dataPos, &pTopic->ctbStbUid, TOPIC_DECODE_OVER); diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index ab236007a1..a9f9d1022a 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -1905,7 +1905,9 @@ void mndTransPullup(SMnode *pMnode) { STrans *pTrans = NULL; pIter = sdbFetch(pMnode->pSdb, SDB_TRANS, pIter, (void **)&pTrans); if (pIter == NULL) break; - (void)taosArrayPush(pArray, &pTrans->id); + if (taosArrayPush(pArray, &pTrans->id) == NULL) { + mError("failed to put trans into array, trans:%d, but pull up will continute", pTrans->id); + } sdbRelease(pSdb, pTrans); }