From ba5c3648db53504b6c1bf2b00e1f086a04c57d9d Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 22 Aug 2023 21:12:54 +0800 Subject: [PATCH 1/7] fix mem leak --- source/libs/stream/src/streamMeta.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index 71ec7617e3..8067b66e9c 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -641,6 +641,7 @@ void metaHbToMnode(void* param, void* tmrId) { tEncodeSize(tEncodeStreamHbMsg, &hbMsg, tlen, code); if (code < 0) { + taosArrayDestroy(hbMsg.pTaskStatus); qError("vgId:%d encode stream hb msg failed, code:%s", pMeta->vgId, tstrerror(code)); return; } @@ -648,6 +649,8 @@ void metaHbToMnode(void* param, void* tmrId) { void* buf = rpcMallocCont(tlen); if (buf == NULL) { qError("vgId:%d encode stream hb msg failed, code:%s", pMeta->vgId, tstrerror(TSDB_CODE_OUT_OF_MEMORY)); + + taosArrayDestroy(hbMsg.pTaskStatus); return; } @@ -656,6 +659,8 @@ void metaHbToMnode(void* param, void* tmrId) { if ((code = tEncodeStreamHbMsg(&encoder, &hbMsg)) < 0) { rpcFreeCont(buf); qError("vgId:%d encode stream hb msg failed, code:%s", pMeta->vgId, tstrerror(code)); + + taosArrayDestroy(hbMsg.pTaskStatus); return; } tEncoderClear(&encoder); From 5fe7563a1368be08d46260ded83f52fcb5403bf3 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 22 Aug 2023 21:13:02 +0800 Subject: [PATCH 2/7] fix mem leak --- source/libs/stream/src/streamMeta.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index 8067b66e9c..28f4c7b7d8 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -641,15 +641,14 @@ void metaHbToMnode(void* param, void* tmrId) { tEncodeSize(tEncodeStreamHbMsg, &hbMsg, tlen, code); if (code < 0) { - taosArrayDestroy(hbMsg.pTaskStatus); qError("vgId:%d encode stream hb msg failed, code:%s", pMeta->vgId, tstrerror(code)); + taosArrayDestroy(hbMsg.pTaskStatus); return; } void* buf = rpcMallocCont(tlen); if (buf == NULL) { qError("vgId:%d encode stream hb msg failed, code:%s", pMeta->vgId, tstrerror(TSDB_CODE_OUT_OF_MEMORY)); - taosArrayDestroy(hbMsg.pTaskStatus); return; } @@ -659,7 +658,6 @@ void metaHbToMnode(void* param, void* tmrId) { if ((code = tEncodeStreamHbMsg(&encoder, &hbMsg)) < 0) { rpcFreeCont(buf); qError("vgId:%d encode stream hb msg failed, code:%s", pMeta->vgId, tstrerror(code)); - taosArrayDestroy(hbMsg.pTaskStatus); return; } From 12b10dfc767e27ca733d818fa9362043419dc9c6 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 23 Aug 2023 09:08:37 +0800 Subject: [PATCH 3/7] fix mem leak --- source/libs/stream/src/streamMeta.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index 28f4c7b7d8..1284ce31b1 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -663,6 +663,8 @@ void metaHbToMnode(void* param, void* tmrId) { } tEncoderClear(&encoder); + taosArrayDestroy(hbMsg.pTaskStatus); + SRpcMsg msg = {0}; initRpcMsg(&msg, TDMT_MND_STREAM_HEARTBEAT, buf, tlen); msg.info.noResp = 1; From ab407c58b68292518ba52c805f6897fa77dfc1cd Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 23 Aug 2023 10:54:50 +0800 Subject: [PATCH 4/7] add log --- source/libs/stream/src/streamBackendRocksdb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index 1e26086cfa..94c859c669 100644 --- a/source/libs/stream/src/streamBackendRocksdb.c +++ b/source/libs/stream/src/streamBackendRocksdb.c @@ -443,7 +443,8 @@ int32_t rebuildDirFromCheckpoint(const char* path, int64_t chkpId, char** dst) { } } else { - qError("failed to start stream backend at %s, reason: %s", chkp, tstrerror(TAOS_SYSTEM_ERROR(errno))); + qError("failed to start stream backend at %s, reason: %s, restart from default state dir:%s", chkp, + tstrerror(TAOS_SYSTEM_ERROR(errno)), state); taosMkDir(state); } taosMemoryFree(chkp); From b1495a530d906c6937e2b039ed95ed4fa2780c97 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 23 Aug 2023 11:45:01 +0800 Subject: [PATCH 5/7] add log --- source/libs/transport/src/transCli.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 1ecc2e3506..4e019b52eb 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -12,8 +12,8 @@ * along with this program. If not, see . */ -#include "transComm.h" #include "tmisce.h" +#include "transComm.h" typedef struct { int32_t numOfConn; @@ -309,7 +309,6 @@ static void cliWalkCb(uv_handle_t* handle, void* arg); } \ } while (0) - static void* cliWorkThread(void* arg); static void cliReleaseUnfinishedMsg(SCliConn* conn) { @@ -1257,7 +1256,7 @@ static void cliHandleFastFail(SCliConn* pConn, int status) { SCliThrd* pThrd = pConn->hostThrd; STrans* pTransInst = pThrd->pTransInst; - if (status == -1) status = ENETUNREACH; + if (status == -1) status = UV_EADDRNOTAVAIL; if (pConn->pBatch == NULL) { SCliMsg* pMsg = transQueueGet(&pConn->cliMsgs, 0); From 8e9c59941aba2725cad129635f0267951f70b0fc Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 23 Aug 2023 11:48:57 +0800 Subject: [PATCH 6/7] fix mem leak --- tests/script/log | 103 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 tests/script/log diff --git a/tests/script/log b/tests/script/log new file mode 100644 index 0000000000..276333a1ae --- /dev/null +++ b/tests/script/log @@ -0,0 +1,103 @@ +------------------------------------------------------------------------ +Start TDengine Testing Case ... +BUILD_DIR: /root/yihao/work/TDengine/debug +SIM_DIR : /root/yihao/work/TDengine/sim +CODE_DIR : /root/yihao/work/TDengine/tests/script +CFG_DIR : /root/yihao/work/TDengine/sim/tsim/cfg +ASAN_DIR : /root/yihao/work/TDengine/sim/asan +------------------------------------------------------------------------ +ExcuteCmd: /root/yihao/work/TDengine/debug/build/bin/tsim -c /root/yihao/work/TDengine/sim/tsim/cfg -f tsim/stream/state0.sim +AsanDir: /root/yihao/work/TDengine/sim/asan/tsim.asan +08/18 17:00:43.118420 00438970 SIM simulator is running ... +Executing deploy.sh +SCRIPT_DIR: /root/yihao/work/TDengine/tests/script +------------ start dnode1 +nohup /root/yihao/work/TDengine/debug/build/bin/taosd -c /root/yihao/work/TDengine/sim/dnode1/cfg > /dev/null 2>&1 & +08/18 17:00:43.288417 00438970 SIM script:tsim/stream/state0.sim, sleep 50ms begin +08/18 17:00:43.338486 00438970 SIM script:tsim/stream/state0.sim, sleep 50ms finished +08/18 17:00:43.679227 00438970 SIM script:tsim/stream/state0.sim, =============== create database +08/18 17:00:45.450379 00438970 SIM script:tsim/stream/state0.sim, information_schema 23-08-18 17:00:43.491 NULL +08/18 17:00:45.454189 00438970 SIM script:tsim/stream/state0.sim, create stream streams1 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a); +08/18 17:00:45.610789 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:00:46.610955 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:00:46.611228 00438970 SIM script:tsim/stream/state0.sim, =====rows=0 +08/18 17:00:46.627080 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:00:47.627254 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:00:47.637364 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:00:48.637446 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:00:48.684845 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:00:49.685055 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:00:49.685390 00438970 SIM script:tsim/stream/state0.sim, =====rows=0 +08/18 17:00:49.712001 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:00:50.712137 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:00:50.713185 00438970 SIM script:tsim/stream/state0.sim, loop1 end +08/18 17:00:50.737435 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:00:51.737618 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:00:51.738003 00438970 SIM script:tsim/stream/state0.sim, =====data21=null +08/18 17:00:51.764834 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:00:52.764971 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:00:52.805578 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:00:53.805742 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:00:53.806044 00438970 SIM script:tsim/stream/state0.sim, =====data26=null +08/18 17:00:53.828622 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:00:54.828756 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:00:54.890423 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:00:55.890533 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:00:55.890839 00438970 SIM script:tsim/stream/state0.sim, =====data21=null +08/18 17:00:55.917818 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:00:56.918008 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:00:56.966614 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:00:57.966809 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:00:57.967085 00438970 SIM script:tsim/stream/state0.sim, ====loop4=rows=0 +08/18 17:00:57.993757 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:00:58.993936 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:00:58.994839 00438970 SIM script:tsim/stream/state0.sim, loop4 end +08/18 17:00:59.678915 00438970 SIM script:tsim/stream/state0.sim, information_schema 23-08-18 17:00:43.491 NULL +08/18 17:00:59.698124 00438970 SIM script:tsim/stream/state0.sim, create stream streams2 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a); +08/18 17:00:59.862389 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:01:00.862605 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:01:01.584856 00438970 SIM script:tsim/stream/state0.sim, create stream streams3 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt3 as select _wstart, count(*) c1, sum(b) c3 from t1 state_window(a); +08/18 17:01:01.778514 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:01:02.778699 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:01:09.536746 00438970 SIM script:tsim/stream/state0.sim, create stream if not exists streams4 trigger window_close IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt4 as select _wstart AS startts, min(c1),count(c1) from t1 state_window(c1); +08/18 17:01:09.789267 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:01:10.789450 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:01:10.863370 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:01:11.863556 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:01:11.909184 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:01:12.909288 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:01:12.936362 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:01:13.936494 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:01:15.301064 00438970 SIM script:tsim/stream/state0.sim, create stream streams0 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt as select _wstart c1, count(*) c2, max(a) c3 from tb state_window(a); +08/18 17:01:15.466754 00438970 SIM script:tsim/stream/state0.sim, data00:null +08/18 17:01:15.466768 00438970 SIM script:tsim/stream/state0.sim, data01:null +08/18 17:01:15.489373 00438970 SIM script:tsim/stream/state0.sim, data00:null +08/18 17:01:15.489392 00438970 SIM script:tsim/stream/state0.sim, data01:null +08/18 17:01:15.511826 00438970 SIM script:tsim/stream/state0.sim, data00:null +08/18 17:01:15.511841 00438970 SIM script:tsim/stream/state0.sim, data01:null +08/18 17:01:15.522397 00438970 SIM script:tsim/stream/state0.sim, data00:null +08/18 17:01:15.522416 00438970 SIM script:tsim/stream/state0.sim, data01:null +08/18 17:01:15.526939 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms begin +08/18 17:01:16.527119 00438970 SIM script:tsim/stream/state0.sim, sleep 1000ms finished +08/18 17:01:16.542936 00438970 SIM script:tsim/stream/state0.sim, state0 end +------------ stop dnode1 +try to kill by signal SIGINT +try to kill by signal SIGINT +try to kill by signal SIGINT +try to kill by signal SIGINT +08/18 17:01:20.674086 00438970 SIM script:tsim/stream/state0.sim, return cmd execute with:1 +08/18 17:01:20.674103 00438970 SIM script:tsim/stream/state0.sim, success +08/18 17:01:20.674165 00438970 SIM script:tsim/stream/state0.sim, background script num:0, stop them +08/18 17:01:20.674521 00438970 SIM ---------------------------------------------------------------------- +08/18 17:01:20.674528 00438970 SIM Simulation Test Done, 1 Passed: + +08/18 17:01:20.674534 00438970 SIM thread is stopped +08/18 17:01:20.674537 00438970 SIM execute result 0 +Execute result: 0 +Killing taosd processes +asan error_num: 0 +asan memory_leak: 0 +asan indirect_leak: 0 +asan runtime error: 0 +asan python error: 0 +no asan errors From 9d2d9aadddcc5c77641cb276d56211511561ceb9 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 23 Aug 2023 11:49:05 +0800 Subject: [PATCH 7/7] fix mem leak --- source/libs/transport/src/transCli.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 4e019b52eb..b02c8aad26 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -12,8 +12,10 @@ * along with this program. If not, see . */ -#include "tmisce.h" +// clang-format off #include "transComm.h" +#include "tmisce.h" +// clang-format on typedef struct { int32_t numOfConn;