From a8b0452080e86524f4ecb3c9ef9558391f2e9ee9 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sun, 12 Feb 2023 10:30:36 +0800 Subject: [PATCH] fix mem leak --- source/dnode/mnode/impl/src/mndIndex.c | 19 ++++++++----------- source/dnode/mnode/impl/src/mndSma.c | 1 - 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndIndex.c b/source/dnode/mnode/impl/src/mndIndex.c index d59e6db0da..2423ed9c0e 100644 --- a/source/dnode/mnode/impl/src/mndIndex.c +++ b/source/dnode/mnode/impl/src/mndIndex.c @@ -277,11 +277,11 @@ static SSdbRow *mndIdxActionDecode(SSdbRaw *pRaw) { _OVER: if (terrno != 0) { - sdbFreeRaw(pRaw); + sdbFreeRaw(pRow); return NULL; } - mTrace("sma:%s, decode from raw:%p, row:%p", pIdx->name, pRaw, pIdx); + mTrace("idx:%s, decode from raw:%p, row:%p", pIdx->name, pRaw, pIdx); return pRow; } @@ -291,12 +291,12 @@ static int32_t mndIdxActionInsert(SSdb *pSdb, SIdxObj *pIdx) { } static int32_t mndIdxActionDelete(SSdb *pSdb, SIdxObj *pIdx) { - mTrace("sma:%s, perform delete action, row:%p", pIdx->name, pIdx); + mTrace("idx:%s, perform delete action, row:%p", pIdx->name, pIdx); return 0; } static int32_t mndIdxActionUpdate(SSdb *pSdb, SIdxObj *pOld, SIdxObj *pNew) { - mTrace("sma:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew); + mTrace("idx:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew); return 0; } @@ -873,10 +873,8 @@ static int32_t mndDropIdx(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SIdxObj *p code = 0; _OVER: - if (newObj.pTags != NULL) { - taosMemoryFree(newObj.pTags); - taosMemoryFree(newObj.pColumns); - } + taosMemoryFree(newObj.pTags); + taosMemoryFree(newObj.pColumns); mndTransDrop(pTrans); mndReleaseStb(pMnode, pStb); @@ -898,8 +896,6 @@ int32_t mndProcessDropTagIdxReq(SRpcMsg *pReq) { if (mndAcquireGlobalIdx(pMnode, req.name, SDB_IDX, &idx) == 0) { pIdx = idx.pIdx; } - - pIdx = mndAcquireIdx(pMnode, req.name); if (pIdx == NULL) { if (req.igNotExists) { mInfo("idx:%s, not exist, ignore not exist is set", req.name); @@ -923,12 +919,13 @@ int32_t mndProcessDropTagIdxReq(SRpcMsg *pReq) { code = mndDropIdx(pMnode, pReq, pDb, pIdx); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; - return code; _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { mError("idx:%s, failed to drop since %s", req.name, terrstr()); } + mndReleaseIdx(pMnode, pIdx); + mndReleaseDb(pMnode, pDb); return code; } static int32_t mndProcessGetIdxReq(SRpcMsg *pReq) { diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index e87457e33f..8408506b8c 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -63,7 +63,6 @@ static int32_t mndProcessDropIdxReq(SRpcMsg *pReq) { if (terrno == TSDB_CODE_MND_SMA_NOT_EXIST) { terrno = 0; ret = mndProcessDropTagIdxReq(pReq); - } else { } return ret; } -- GitLab