From d123d8001f7808d510852b2796a433fab6ddb403 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 22 Sep 2020 11:19:45 +0800 Subject: [PATCH] TD-1415 --- src/vnode/src/vnodeWrite.c | 11 ++++++++-- tests/test/c/CMakeLists.txt | 12 +++++------ tests/test/c/createNormalTable.c | 35 ++++++++++++++++++++++++-------- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 1a9b05ed34..0c310439bb 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -130,8 +130,15 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe int code = TSDB_CODE_SUCCESS; STableCfg *pCfg = tsdbCreateTableCfgFromMsg((SMDCreateTableMsg *)pCont); - if (pCfg == NULL) return terrno; - if (tsdbCreateTable(pVnode->tsdb, pCfg) < 0) code = terrno; + if (pCfg == NULL) { + ASSERT(terrno != 0); + return terrno; + } + + if (tsdbCreateTable(pVnode->tsdb, pCfg) < 0) { + code = terrno; + ASSERT(code != 0); + } tsdbClearTableCfg(pCfg); return code; diff --git a/tests/test/c/CMakeLists.txt b/tests/test/c/CMakeLists.txt index ffab39d41c..c75316de81 100644 --- a/tests/test/c/CMakeLists.txt +++ b/tests/test/c/CMakeLists.txt @@ -31,16 +31,16 @@ IF (TD_LINUX) #add_executable(createTablePerformance createTablePerformance.c) #target_link_libraries(createTablePerformance taos_static tutil common pthread) - #add_executable(createNormalTable createNormalTable.c) - #target_link_libraries(createNormalTable taos_static tutil common pthread) + add_executable(createNormalTable createNormalTable.c) + target_link_libraries(createNormalTable taos_static tutil common pthread) #add_executable(queryPerformance queryPerformance.c) #target_link_libraries(queryPerformance taos_static tutil common pthread) - add_executable(httpTest httpTest.c) - target_link_libraries(httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) + #add_executable(httpTest httpTest.c) + #target_link_libraries(httpTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) - add_executable(cacheTest cacheTest.c) - target_link_libraries(cacheTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) + #add_executable(cacheTest cacheTest.c) + #target_link_libraries(cacheTest taos_static tutil common pthread mnode monitor http tsdb twal vnode cJson lz4) ENDIF() diff --git a/tests/test/c/createNormalTable.c b/tests/test/c/createNormalTable.c index 18a648b9e1..60253e2add 100644 --- a/tests/test/c/createNormalTable.c +++ b/tests/test/c/createNormalTable.c @@ -50,7 +50,9 @@ void createDbAndSTable(); int main(int argc, char *argv[]) { shellParseArgument(argc, argv); taos_init(); - createDbAndSTable(); + if (replica != 0) { + createDbAndSTable(); + } pPrint("%d threads are spawned to create table", numOfThreads); @@ -134,14 +136,31 @@ void *threadFunc(void *param) { int64_t startMs = taosGetTimestampMs(); - for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { - sprintf(qstr, "create table %s%d (ts timestamp, i int)", stableName, t); - TAOS_RES *pSql = taos_query(con, qstr); - code = taos_errno(pSql); - if (code != 0) { - pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + if (replica != 0) { + for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { + sprintf(qstr, "create table %s%d (ts timestamp, i int)", stableName, t); + TAOS_RES *pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + } + taos_free_result(pSql); + } + } else { + for (int32_t t = pInfo->tableBeginIndex; t < pInfo->tableEndIndex; ++t) { + sprintf(qstr, "insert into %s%d values(now, 1)", stableName, t); + TAOS_RES *pSql = taos_query(con, qstr); + code = taos_errno(pSql); + if (code != 0) { + if (code != TSDB_CODE_MND_INVALID_TABLE_NAME) { + pError("failed to create table %s%d, reason:%s", stableName, t, tstrerror(code)); + } + if (code == TSDB_CODE_VND_INVALID_VGROUP_ID) { + exit(0); + } + } + taos_free_result(pSql); } - taos_free_result(pSql); } float createTableSpeed = 0; -- GitLab