From 8aa04f8e5549c8c46ba0890675731f3964e70b18 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 13 Jul 2022 18:49:57 +0800 Subject: [PATCH] fix:error in tmq meta --- include/util/tencode.h | 4 ++-- source/common/src/tmsg.c | 6 ++++-- source/dnode/vnode/src/vnd/vnodeSvr.c | 10 +++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/util/tencode.h b/include/util/tencode.h index e318d4f240..ad642cd612 100644 --- a/include/util/tencode.h +++ b/include/util/tencode.h @@ -440,7 +440,7 @@ static FORCE_INLINE bool tDecodeIsEnd(SDecoder* pCoder) { return (pCoder->size = static FORCE_INLINE void* tEncoderMalloc(SEncoder* pCoder, int32_t size) { void* p = NULL; - SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + size); + SCoderMem* pMem = (SCoderMem*)taosMemoryCalloc(1, sizeof(*pMem) + size); if (pMem) { pMem->next = pCoder->mList; pCoder->mList = pMem; @@ -451,7 +451,7 @@ static FORCE_INLINE void* tEncoderMalloc(SEncoder* pCoder, int32_t size) { static FORCE_INLINE void* tDecoderMalloc(SDecoder* pCoder, int32_t size) { void* p = NULL; - SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + size); + SCoderMem* pMem = (SCoderMem*)taosMemoryCalloc(1, sizeof(*pMem) + size); if (pMem) { pMem->next = pCoder->mList; pCoder->mList = pMem; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 714a17df0d..9ebfa78b80 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -4984,8 +4984,10 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) { pReq->ctb.tagName = taosArrayInit(len, TSDB_COL_NAME_LEN); if(pReq->ctb.tagName == NULL) return -1; for (int32_t i = 0; i < len; i++){ - char *name = NULL; - if (tDecodeCStr(pCoder, &name) < 0) return -1; + char name[TSDB_COL_NAME_LEN] = {0}; + char *tmp = NULL; + if (tDecodeCStr(pCoder, &tmp) < 0) return -1; + strcpy(name, tmp); taosArrayPush(pReq->ctb.tagName, name); } } else if (pReq->type == TSDB_NORMAL_TABLE) { diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index d369475437..cca212a4e4 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -494,8 +494,6 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR taosArrayPush(rsp.pArray, &cRsp); } - tDecoderClear(&decoder); - tqUpdateTbUidList(pVnode->pTq, tbUids, true); tdUpdateTbUidList(pVnode->pSma, pStore); tdUidStoreFree(pStore); @@ -512,9 +510,12 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR } tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen); tEncodeSVCreateTbBatchRsp(&encoder, &rsp); - tEncoderClear(&encoder); _exit: + for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { + pCreateReq = req.pReqs + iReq; + taosArrayDestroy(pCreateReq->ctb.tagName); + } taosArrayDestroy(rsp.pArray); taosArrayDestroy(tbUids); tDecoderClear(&decoder); @@ -795,6 +796,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq if (tDecodeSVCreateTbReq(&decoder, &createTbReq) < 0) { pRsp->code = TSDB_CODE_INVALID_MSG; tDecoderClear(&decoder); + taosArrayDestroy(createTbReq.ctb.tagName); goto _exit; } @@ -802,6 +804,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) { submitBlkRsp.code = terrno; tDecoderClear(&decoder); + taosArrayDestroy(createTbReq.ctb.tagName); goto _exit; } } @@ -822,6 +825,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq vnodeDebugPrintSingleSubmitMsg(pVnode->pMeta, pBlock, &msgIter, "real uid"); #endif tDecoderClear(&decoder); + taosArrayDestroy(createTbReq.ctb.tagName); } else { submitBlkRsp.tblFName = taosMemoryMalloc(TSDB_TABLE_FNAME_LEN); sprintf(submitBlkRsp.tblFName, "%s.", pVnode->config.dbname); -- GitLab