From 29fe08d10834166a17409e43afba5a903200a57c Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 6 Jan 2022 15:04:56 +0800 Subject: [PATCH] [td-11818] fix memory leak. --- source/client/test/clientTests.cpp | 42 +++++++++++++-------------- source/libs/scheduler/src/scheduler.c | 19 ++++++++---- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index cbd5689cc8..39b43d1602 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -281,18 +281,18 @@ TEST(testCase, use_db_test) { taos_close(pConn); } -TEST(testCase, create_table_Test) { - TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); - assert(pConn != NULL); - - TAOS_RES* pRes = taos_query(pConn, "use abc1"); - taos_free_result(pRes); - - pRes = taos_query(pConn, "create table tm0(ts timestamp, k int)"); - taos_free_result(pRes); - - taos_close(pConn); -} +//TEST(testCase, create_table_Test) { +// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); +// assert(pConn != NULL); +// +// TAOS_RES* pRes = taos_query(pConn, "use abc1"); +// taos_free_result(pRes); +// +// pRes = taos_query(pConn, "create table tm0(ts timestamp, k int)"); +// taos_free_result(pRes); +// +// taos_close(pConn); +//} //TEST(testCase, create_ctable_Test) { // TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); @@ -505,15 +505,15 @@ TEST(testCase, create_multiple_tables) { taos_free_result(pRes); - for(int32_t i = 0; i < 1000; ++i) { - char sql[512] = {0}; - snprintf(sql, tListLen(sql), "create table t_x_%d using st1 tags(2)", i); - TAOS_RES* pres = taos_query(pConn, sql); - if (taos_errno(pres) != 0) { - printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres)); - } - taos_free_result(pres); - } +// for(int32_t i = 0; i < 1000; ++i) { +// char sql[512] = {0}; +// snprintf(sql, tListLen(sql), "create table t_x_%d using st1 tags(2)", i); +// TAOS_RES* pres = taos_query(pConn, sql); +// if (taos_errno(pres) != 0) { +// printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres)); +// } +// taos_free_result(pres); +// } taos_close(pConn); } diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index b35823bc76..69df5dddee 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -591,7 +591,7 @@ int32_t schHandleCallback(void* param, const SDataBuf* pMsg, int32_t msgType, in schProcessRspMsg(*job, *task, msgType, pMsg->pData, pMsg->len, rspCode); -_return: +_return: tfree(param); SCH_RET(code); } @@ -823,8 +823,6 @@ int32_t schLaunchTask(SSchJob *job, SSchTask *task) { SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); } -// int32_t msgType = (plan->type == QUERY_TYPE_MODIFY)? TDMT_VND_SUBMIT : TDMT_VND_QUERY; - SCH_ERR_RET(schBuildAndSendMsg(job, task, plan->msgType)); SCH_ERR_RET(schPushTaskToExecList(job, task)); @@ -848,17 +846,26 @@ void schDropJobAllTasks(SSchJob *job) { void *pIter = taosHashIterate(job->succTasks, NULL); while (pIter) { SSchTask *task = *(SSchTask **)pIter; + + int32_t msgType = task->plan->msgType; + if (msgType == TDMT_VND_CREATE_TABLE || msgType == TDMT_VND_SUBMIT) { + break; + } + schBuildAndSendMsg(job, task, TDMT_VND_DROP_TASK); - pIter = taosHashIterate(job->succTasks, pIter); } pIter = taosHashIterate(job->failTasks, NULL); while (pIter) { SSchTask *task = *(SSchTask **)pIter; - + + int32_t msgType = task->plan->msgType; + if (msgType == TDMT_VND_CREATE_TABLE || msgType == TDMT_VND_SUBMIT) { + break; + } + schBuildAndSendMsg(job, task, TDMT_VND_DROP_TASK); - pIter = taosHashIterate(job->succTasks, pIter); } }