From 93c61f82c9270d338082c71bc7daf08bcfaf4cfc Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 10 Feb 2023 19:24:26 +0800 Subject: [PATCH] fix mem leak --- source/dnode/mnode/impl/src/mndIndex.c | 16 +++++++++++----- tests/script/tsim/tagindex/add_index.sim | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndIndex.c b/source/dnode/mnode/impl/src/mndIndex.c index e63b25b686..d59e6db0da 100644 --- a/source/dnode/mnode/impl/src/mndIndex.c +++ b/source/dnode/mnode/impl/src/mndIndex.c @@ -277,7 +277,7 @@ static SSdbRow *mndIdxActionDecode(SSdbRaw *pRaw) { _OVER: if (terrno != 0) { - taosMemoryFreeClear(pRow); + sdbFreeRaw(pRaw); return NULL; } @@ -780,15 +780,16 @@ int32_t mndAddIndexImpl(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *pSt if (mndSetUpdateIdxStbCommitLogs(pMnode, pTrans, pStb, &newStb, pIdx->colName, 1) != 0) goto _OVER; if (mndSetCreateIdxRedoActions(pMnode, pTrans, pDb, &newStb, pIdx) != 0) goto _OVER; - // if (mndSetAlterStbRedoLogs(pMnode, pTrans, pDb, pStb) != 0) goto _OVER; - // if (mndSetAlterStbCommitLogs(pMnode, pTrans, pDb, pStb) != 0) goto _OVER; - // if (mndSetAlterStbRedoActions2(pMnode, pTrans, pDb, pStb, sql, len) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; - return code; + code = 0; _OVER: // mndDestoryIdxObj(pIdx); + if (newStb.pTags != NULL) { + taosMemoryFree(newStb.pTags); + taosMemoryFree(newStb.pColumns); + } mndTransDrop(pTrans); return code; } @@ -872,6 +873,11 @@ 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); + } + mndTransDrop(pTrans); mndReleaseStb(pMnode, pStb); return code; diff --git a/tests/script/tsim/tagindex/add_index.sim b/tests/script/tsim/tagindex/add_index.sim index 4e883ef150..c60176c324 100644 --- a/tests/script/tsim/tagindex/add_index.sim +++ b/tests/script/tsim/tagindex/add_index.sim @@ -7,7 +7,7 @@ print ======== step0 $dbPrefix = ta_3_db $tbPrefix = ta_3_tb $mtPrefix = ta_3_mt -$tbNum = 100 +$tbNum = 10 $rowNum = 20 $totalNum = 200