diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 97955c0c49..0446ca7dee 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -4267,7 +4267,8 @@ typedef struct { void* rawData; }; }; - void* data; //for free, only effected if type is data or metadata. raw data not effected + void* data; //for free in client, only effected if type is data or metadata. raw data not effected + bool blockDataElementFree; // if true, free blockDataElement in blockData,(true in server, false in client) } SMqDataRsp; diff --git a/source/common/src/msg/tmsg.c b/source/common/src/msg/tmsg.c index fbf721993b..75791ed0ce 100644 --- a/source/common/src/msg/tmsg.c +++ b/source/common/src/msg/tmsg.c @@ -11451,6 +11451,8 @@ int32_t tDecodeMqDataRspCommon(SDecoder *pDecoder, SMqDataRsp *pRsp) { if (taosArrayPush(pRsp->blockData, &data) == NULL) { TAOS_CHECK_EXIT(terrno); } + pRsp->blockDataElementFree = false; + int32_t len = bLen; if (taosArrayPush(pRsp->blockDataLen, &len) == NULL) { TAOS_CHECK_EXIT(terrno); @@ -11510,7 +11512,11 @@ _exit: static void tDeleteMqDataRspCommon(SMqDataRsp *pRsp) { taosArrayDestroy(pRsp->blockDataLen); pRsp->blockDataLen = NULL; - taosArrayDestroy(pRsp->blockData); + if (pRsp->blockDataElementFree){ + taosArrayDestroyP(pRsp->blockData) + } else { + taosArrayDestroy(pRsp->blockData); + } pRsp->blockData = NULL; taosArrayDestroyP(pRsp->blockSchema, (FDelete)tDeleteSchemaWrapper); pRsp->blockSchema = NULL; diff --git a/source/dnode/vnode/src/tq/tqScan.c b/source/dnode/vnode/src/tq/tqScan.c index 0de5803881..ead040b7a5 100644 --- a/source/dnode/vnode/src/tq/tqScan.c +++ b/source/dnode/vnode/src/tq/tqScan.c @@ -62,7 +62,7 @@ static int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, actualLen += sizeof(SRetrieveTableRspForTmq); TSDB_CHECK_NULL(taosArrayPush(pRsp->blockDataLen, &actualLen), code, lino, END, terrno); TSDB_CHECK_NULL(taosArrayPush(pRsp->blockData, &buf), code, lino, END, terrno); - + pRsp->blockDataElementFree = true; buf = NULL; END: if (code != 0){