From ca0fb0877a994c95b4044765a5c531e5264228da Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 2 Jun 2023 17:22:08 +0800 Subject: [PATCH 1/3] fix: build warning --- src/benchQuery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/benchQuery.c b/src/benchQuery.c index 63816b81..05d1a05d 100644 --- a/src/benchQuery.c +++ b/src/benchQuery.c @@ -479,7 +479,7 @@ static int multi_thread_specified_table_query(uint16_t iface, char* dbName) { } // wait threads execute finished one by one - for (int j = 0; (j < nConcurrent && pids[j] > 0) ; j++) { + for (int j = 0; (j < nConcurrent && pids[j] != NULL) ; j++) { pthread_join(pids[j], NULL); threadInfo *pThreadInfo = infos + j; if (iface == REST_IFACE) { From 2d123416d90f2f876fc86e448bfea64474dd6aec Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 2 Jun 2023 18:14:18 +0800 Subject: [PATCH 2/3] fix: window build error and default per_req --- src/benchInsert.c | 4 +++- src/benchJsonOpt.c | 8 ++++---- src/benchQuery.c | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/benchInsert.c b/src/benchInsert.c index e565ea60..b5a4948e 100644 --- a/src/benchInsert.c +++ b/src/benchInsert.c @@ -977,6 +977,7 @@ static int startMultiThreadCreateChildTable( } int64_t b = ntables % threads; + int threadCnt = 0; for (uint32_t i = 0; (i < threads && !g_arguments->terminate); i++) { threadInfo *pThreadInfo = infos + i; pThreadInfo->threadID = i; @@ -1000,9 +1001,10 @@ static int startMultiThreadCreateChildTable( tableFrom = pThreadInfo->end_table_to + 1; pThreadInfo->tables_created = 0; pthread_create(pids + i, NULL, createTable, pThreadInfo); + threadCnt ++; } - for (int i = 0; (i < threads && pids[i] !=0); i++) { + for (int i = 0; i < threadCnt; i++) { pthread_join(pids[i], NULL); } diff --git a/src/benchJsonOpt.c b/src/benchJsonOpt.c index c48e6b28..86b7e7b9 100644 --- a/src/benchJsonOpt.c +++ b/src/benchJsonOpt.c @@ -1177,13 +1177,13 @@ static int getMetaFromInsertJsonFile(tools_cJSON *json) { if (numRecPerReq && numRecPerReq->type == tools_cJSON_Number) { g_arguments->reqPerReq = (uint32_t)numRecPerReq->valueint; if ((int32_t)g_arguments->reqPerReq <= 0) { - errorPrint(" num_of_records_per_req item in json config must over zero. current = %d\n", g_arguments->reqPerReq); - goto PARSE_OVER; + infoPrint("waring: num_of_records_per_req item in json config must over zero, current = %d. now reset to default. \n", g_arguments->reqPerReq); + g_arguments = DEFAULT_REQ_PER_REQ; } if (g_arguments->reqPerReq > 32768) { - errorPrint(" num_of_records_per_req item in json config need less than 32768. current = %d\n", g_arguments->reqPerReq); - goto PARSE_OVER; + infoPrint("warning: num_of_records_per_req item in json config need less than 32768. current = %d. now reset to default.\n", g_arguments->reqPerReq); + g_arguments = DEFAULT_REQ_PER_REQ; } } diff --git a/src/benchQuery.c b/src/benchQuery.c index 05d1a05d..3688dae8 100644 --- a/src/benchQuery.c +++ b/src/benchQuery.c @@ -446,6 +446,7 @@ static int multi_thread_specified_table_query(uint16_t iface, char* dbName) { SSQL *sql = benchArrayGet(g_queryInfo.specifiedQueryInfo.sqls, i); // create threads + int threadCnt = 0; for (int j = 0; j < nConcurrent; j++) { threadInfo *pThreadInfo = infos + j; pThreadInfo->threadID = i * nConcurrent + j; @@ -470,6 +471,7 @@ static int multi_thread_specified_table_query(uint16_t iface, char* dbName) { } pthread_create(pids + j, NULL, specifiedTableQuery, pThreadInfo); + threadCnt++; } // if failed, set termainte flag true like ctrl+c exit @@ -479,7 +481,7 @@ static int multi_thread_specified_table_query(uint16_t iface, char* dbName) { } // wait threads execute finished one by one - for (int j = 0; (j < nConcurrent && pids[j] != NULL) ; j++) { + for (int j = 0; j < threadCnt ; j++) { pthread_join(pids[j], NULL); threadInfo *pThreadInfo = infos + j; if (iface == REST_IFACE) { From c1c66c1419b56644639b9ceab3ddafebefb61787 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 2 Jun 2023 18:22:57 +0800 Subject: [PATCH 3/3] fix: build error --- src/benchJsonOpt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/benchJsonOpt.c b/src/benchJsonOpt.c index 86b7e7b9..c1365de0 100644 --- a/src/benchJsonOpt.c +++ b/src/benchJsonOpt.c @@ -1178,12 +1178,12 @@ static int getMetaFromInsertJsonFile(tools_cJSON *json) { g_arguments->reqPerReq = (uint32_t)numRecPerReq->valueint; if ((int32_t)g_arguments->reqPerReq <= 0) { infoPrint("waring: num_of_records_per_req item in json config must over zero, current = %d. now reset to default. \n", g_arguments->reqPerReq); - g_arguments = DEFAULT_REQ_PER_REQ; + g_arguments->reqPerReq = DEFAULT_REQ_PER_REQ; } if (g_arguments->reqPerReq > 32768) { infoPrint("warning: num_of_records_per_req item in json config need less than 32768. current = %d. now reset to default.\n", g_arguments->reqPerReq); - g_arguments = DEFAULT_REQ_PER_REQ; + g_arguments->reqPerReq = DEFAULT_REQ_PER_REQ; } }