From bce692d8d1d697b86d07130e4c4547bce8264b72 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 3 Feb 2025 18:26:27 +0800 Subject: [PATCH] fix: benchUtil.c delayList free memory leak --- .../basic/json/TS-5846-Mixed-Query.json | 25 +++++++++ .../benchmark/basic/json/TS-5846-Query.json | 25 +++++++++ .../tools/taosdump/ws/taosdumpPrimaryKey.py | 2 +- tests/army/tools/taosdump/ws/taosdumpRetry.py | 2 +- tests/parallel_test/cases.task | 56 +++++++++---------- tools/taos-tools/src/benchUtil.c | 8 ++- 6 files changed, 87 insertions(+), 31 deletions(-) create mode 100644 tests/army/tools/benchmark/basic/json/TS-5846-Mixed-Query.json create mode 100644 tests/army/tools/benchmark/basic/json/TS-5846-Query.json diff --git a/tests/army/tools/benchmark/basic/json/TS-5846-Mixed-Query.json b/tests/army/tools/benchmark/basic/json/TS-5846-Mixed-Query.json new file mode 100644 index 0000000000..deda8fc6dd --- /dev/null +++ b/tests/army/tools/benchmark/basic/json/TS-5846-Mixed-Query.json @@ -0,0 +1,25 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "continue_if_fail": "yes", + "databases": "test", + "query_times": 10, + "query_mode": "taosc", + "specified_table_query": { + "threads": 2, + "mixed_query": "yes", + "sqls": [ + { + "sql": "select count(*) from test.meters" + }, + { + "sql": "select * from test.d0 limit 10" + } + ] + } +} \ No newline at end of file diff --git a/tests/army/tools/benchmark/basic/json/TS-5846-Query.json b/tests/army/tools/benchmark/basic/json/TS-5846-Query.json new file mode 100644 index 0000000000..000051a4d5 --- /dev/null +++ b/tests/army/tools/benchmark/basic/json/TS-5846-Query.json @@ -0,0 +1,25 @@ +{ + "filetype": "query", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "confirm_parameter_prompt": "no", + "continue_if_fail": "yes", + "databases": "test", + "query_times": 10, + "query_mode": "taosc", + "specified_table_query": { + "threads": 2, + "mixed_query": "no", + "sqls": [ + { + "sql": "select count(*) from test.meters" + }, + { + "sql": "select * from test.d0 limit 10" + } + ] + } +} \ No newline at end of file diff --git a/tests/army/tools/taosdump/ws/taosdumpPrimaryKey.py b/tests/army/tools/taosdump/ws/taosdumpPrimaryKey.py index c5980aa143..4477c4f881 100644 --- a/tests/army/tools/taosdump/ws/taosdumpPrimaryKey.py +++ b/tests/army/tools/taosdump/ws/taosdumpPrimaryKey.py @@ -157,7 +157,7 @@ class TDTestCase(TBase): # find taosdump, benchmark, tmpdir = self.findPrograme() - json = "./tools/taosdump/ws3/json/primaryKey.json" + json = "./tools/taosdump/ws/json/primaryKey.json" # insert data with taosBenchmark self.insertData(benchmark, json, db) diff --git a/tests/army/tools/taosdump/ws/taosdumpRetry.py b/tests/army/tools/taosdump/ws/taosdumpRetry.py index d137bb2a5b..621cc2da77 100644 --- a/tests/army/tools/taosdump/ws/taosdumpRetry.py +++ b/tests/army/tools/taosdump/ws/taosdumpRetry.py @@ -206,7 +206,7 @@ class TDTestCase(TBase): # find taosdump, benchmark, taosadapter, tmpdir = self.findPrograme() - json = "./tools/taosdump/ws3/json/retry.json" + json = "./tools/taosdump/ws/json/retry.json" # insert data with taosBenchmark self.insertData(benchmark, json, db) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index d34a931cd4..fa8c846c24 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -78,7 +78,7 @@ # # benchmark 66 cases -,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/rest_insert_alltypes_json.py +,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/rest_insert_alltypes_json.py -R ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/taosdemoTestQueryWithJson-mixed-query.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/stmt_sample_csv_json.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/taosdemoTestInsertWithJsonStmt-otherPara.py @@ -90,18 +90,18 @@ ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/stmt2_insert.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/stmt_offset_json.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/json_tag.py -,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/commandline-sml-rest.py +,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/commandline-sml-rest.py -R ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/taosc_auto_create_table_json.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/insert-json-csv.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/taosc_insert-table-creating-interval.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/insertMix.py -,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/taosc_insert-mix.py +,,n,army,python3 ./test.py -f tools/benchmark/basic/taosc_insert-mix.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/stream_function_test.py -,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/telnet_tcp.py +,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/telnet_tcp.py -R ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/stmt_sample_csv_json-subtable.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/from-to-continue.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/sml_json_alltypes-interlace.py -,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/commandline-retry.py +,,n,army,python3 ./test.py -f tools/benchmark/basic/commandline-retry.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/tmq_case.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/limit_offset_json.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/commandline-sml.py @@ -113,28 +113,28 @@ ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/bugs.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/taosc_sample_csv_json-subtable.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/query_json-with-error-sqlfile.py -,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/taosc_insert-retry-json-global.py +,,n,army,python3 ./test.py -f tools/benchmark/basic/taosc_insert-retry-json-global.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/from-to.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/exportCsv.py -,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/taosdemoTestQueryWithJson.py +,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/taosdemoTestQueryWithJson.py -R ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/commandline-partial-col-numpy.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/query_json-with-sqlfile.py -,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/query_json.py +,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/query_json.py -R ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/sml_json_alltypes.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/invalid_commandline.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/sml_json_insert_alltypes-same-min-max.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/default_json.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/taosc_sample_csv_json.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/stmt_sample_csv_json_doesnt_use_ts.py -,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/taosadapter_json.py +,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/taosadapter_json.py -R ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/demo.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/commandline-supplement-insert.py -,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/custom_col_tag.py +,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/custom_col_tag.py -R ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/stmt_auto_create_table_json.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/stmt_insert_alltypes_json.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/stmt_insert_alltypes-same-min-max.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/commandline-vgroups.py -,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/taosc_insert-retry-json-stb.py +,,n,army,python3 ./test.py -f tools/benchmark/basic/taosc_insert-retry-json-stb.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/sml_auto_create_table_json.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/sml_telnet_alltypes.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/stream-test.py @@ -143,7 +143,7 @@ ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/stt.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/basic/taosc_insert_alltypes_json-partial-col.py ,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/cloud/cloud-test.py -,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/ws/websocket.py +,,y,army,./pytest.sh python3 ./test.py -f tools/benchmark/ws/websocket.py -R # taosdump 46 cases ,,y,army,./pytest.sh python3 ./test.py -f tools/taosdump/native/taosdumpTest.py @@ -176,22 +176,22 @@ ,,y,army,./pytest.sh python3 ./test.py -f tools/taosdump/native/taosdumpTest2.py ,,y,army,./pytest.sh python3 ./test.py -f tools/taosdump/native/taosdumpTestTypeTinyInt.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeDouble.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeUnsignedBigInt.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpEscapedDb.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpPrimaryKey.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeJson.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeUnsignedSmallInt.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeUnsignedTinyInt.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeUnsignedInt.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeSmallInt.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeInt.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeBigInt.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeBinary.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeFloat.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeBool.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpRetry.py -,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeTinyInt.py +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeDouble.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeUnsignedBigInt.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpEscapedDb.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpPrimaryKey.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeJson.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeUnsignedSmallInt.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeUnsignedTinyInt.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeUnsignedInt.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeSmallInt.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeInt.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeBigInt.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeBinary.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeFloat.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeBool.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpRetry.py -R +,,n,army,python3 ./test.py -f tools/taosdump/ws/taosdumpTestTypeTinyInt.py -R # # system test diff --git a/tools/taos-tools/src/benchUtil.c b/tools/taos-tools/src/benchUtil.c index 900f0ded7a..ad59c4e37e 100644 --- a/tools/taos-tools/src/benchUtil.c +++ b/tools/taos-tools/src/benchUtil.c @@ -1110,17 +1110,23 @@ static int32_t benchArrayEnsureCap(BArray* pArray, size_t newCap) { void* benchArrayAddBatch(BArray* pArray, void* pData, int32_t elems, bool free) { if (pData == NULL || elems <=0) { + if (free) { + tmfree(pData); + } return NULL; } if (benchArrayEnsureCap(pArray, pArray->size + elems) != 0) { + if (free) { + tmfree(pData); + } return NULL; } void* dst = BARRAY_GET_ELEM(pArray, pArray->size); memcpy(dst, pData, pArray->elemSize * elems); if (free) { - tmfree(pData); // TODO remove this + tmfree(pData); } pArray->size += elems; return dst;