From 44401b6b909734aecd28539d831a1904e3076a4e Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Tue, 18 Oct 2022 10:58:33 +0800 Subject: [PATCH] fix: memory leak --- source/client/src/clientTmq.c | 7 ++++++- source/dnode/vnode/src/tq/tqSink.c | 2 +- tests/system-test/7-tmq/tmqAutoCreateTbl.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 8f94d88b1c..838b851d6d 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -455,7 +455,10 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT return -1; } void* buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len); - if (buf == NULL) return -1; + if (buf == NULL) { + taosMemoryFree(pOffset); + return -1; + } ((SMsgHead*)buf)->vgId = htonl(pVg->vgId); void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); @@ -468,6 +471,7 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT // build param SMqCommitCbParam* pParam = taosMemoryCalloc(1, sizeof(SMqCommitCbParam)); if (pParam == NULL) { + taosMemoryFree(pOffset); taosMemoryFree(buf); return -1; } @@ -477,6 +481,7 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT // build send info SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (pMsgSendInfo == NULL) { + taosMemoryFree(pOffset); taosMemoryFree(buf); taosMemoryFree(pParam); return -1; diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index 9bdcf04e89..ab195b1eb3 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -436,7 +436,7 @@ void tqTableSink1(SStreamTask* pTask, void* vnode, int64_t ver, void* data) { } if (mr.me.ctbEntry.suid != suid) { tqError("vgId:%d, failed to write into %s, since suid mismatch, expect suid: %ld, actual suid %ld", - TD_VID(pVnode), ctbName, suid, mr.me.ctbEntry); + TD_VID(pVnode), ctbName, suid, mr.me.ctbEntry.suid); metaReaderClear(&mr); taosMemoryFree(ctbName); continue; diff --git a/tests/system-test/7-tmq/tmqAutoCreateTbl.py b/tests/system-test/7-tmq/tmqAutoCreateTbl.py index 587472ed82..ce2cad4b14 100644 --- a/tests/system-test/7-tmq/tmqAutoCreateTbl.py +++ b/tests/system-test/7-tmq/tmqAutoCreateTbl.py @@ -160,7 +160,7 @@ class TDTestCase: 'rowsPerTbl': 1000, 'batchNum': 1000, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 - 'pollDelay': 5, + 'pollDelay': 20, 'showMsg': 1, 'showRow': 1, 'snapshot': 0}