From 90697d04401f470247a681911c50d65de06ad634 Mon Sep 17 00:00:00 2001 From: dengyihao Date: Mon, 15 Jun 2020 01:55:39 +0800 Subject: [PATCH 1/9] bugfix TD-690 --- src/client/src/tscSQLParser.c | 8 ++++++++ src/query/inc/sql.y | 14 +++++++++++--- src/query/src/qparserImpl.c | 12 ++++++++++-- src/query/src/sql.c | 22 +++++++++++++++------- 4 files changed, 44 insertions(+), 12 deletions(-) mode change 100644 => 100755 src/query/src/sql.c diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 494540290b..788d53e00a 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -752,6 +752,10 @@ static bool validateTableColumnInfo(tFieldList* pFieldList, SSqlCmd* pCmd) { int32_t nLen = 0; for (int32_t i = 0; i < pFieldList->nField; ++i) { + if (pFieldList->p[i].bytes == 0) { + invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg5); + return false; + } nLen += pFieldList->p[i].bytes; } @@ -808,6 +812,10 @@ static bool validateTagParams(tFieldList* pTagsList, tFieldList* pFieldList, SSq int32_t nLen = 0; for (int32_t i = 0; i < pTagsList->nField; ++i) { + if (pTagsList->p[i].bytes == 0) { + invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7); + return false; + } nLen += pTagsList->p[i].bytes; } diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 4a20502e4e..b4ea1254b7 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -251,12 +251,20 @@ alter_db_optr(Y) ::= alter_db_optr(Z) comp(X). { Y = Z; Y.compressionLeve alter_db_optr(Y) ::= alter_db_optr(Z) wal(X). { Y = Z; Y.walLevel = strtol(X.z, NULL, 10); } %type typename {TAOS_FIELD} -typename(A) ::= ids(X). { tSQLSetColumnType (&A, &X); } +typename(A) ::= ids(X). { + X.type = 0; + tSQLSetColumnType (&A, &X); +} //define binary type, e.g., binary(10), nchar(10) typename(A) ::= ids(X) LP signed(Y) RP. { - X.type = -Y; // negative value of name length - tSQLSetColumnType(&A, &X); + if (Y <= 0) { + X.type = 0; + tSQLSetColumnType(&A, &X); + } else { + X.type = -Y; // negative value of name length + tSQLSetColumnType(&A, &X); + } } %type signed {int64_t} diff --git a/src/query/src/qparserImpl.c b/src/query/src/qparserImpl.c index 87add1e69e..928b9eb873 100644 --- a/src/query/src/qparserImpl.c +++ b/src/query/src/qparserImpl.c @@ -497,10 +497,18 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SSQLToken *type) { * number of bytes in UCS-4 format, which is 4 times larger than the * number of characters */ - pField->bytes = -(int32_t)type->type * TSDB_NCHAR_SIZE + LENGTH_SIZE_OF_STR; + if (type->type == 0) { + pField->bytes = 0; + } else { + pField->bytes = -(int32_t)type->type * TSDB_NCHAR_SIZE + LENGTH_SIZE_OF_STR; + } } else if (i == TSDB_DATA_TYPE_BINARY) { /* for binary, the TOKENTYPE is the length of binary */ - pField->bytes = -(int32_t) type->type + LENGTH_SIZE_OF_STR; + if (type->type == 0) { + pField->bytes = 0; + } else { + pField->bytes = -(int32_t) type->type + LENGTH_SIZE_OF_STR; + } } break; } diff --git a/src/query/src/sql.c b/src/query/src/sql.c old mode 100644 new mode 100755 index 545cef4082..e75802a98f --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -25,17 +25,17 @@ #include /************ Begin %include sections from the grammar ************************/ -#include -#include +#include #include #include +#include +#include +#include "tutil.h" #include "qsqlparser.h" #include "tstoken.h" -#include "tutil.h" #include "tvariant.h" #include "ttokendef.h" #include "qsqltype.h" - /**************** End of %include directives **********************************/ /* These constants specify the various numeric values for terminal symbols ** in a format understandable to "makeheaders". This section is blank unless @@ -2262,13 +2262,21 @@ static void yy_reduce( { setDefaultCreateDbOption(&yymsp[1].minor.yy374);} break; case 102: /* typename ::= ids */ -{ tSQLSetColumnType (&yylhsminor.yy325, &yymsp[0].minor.yy0); } +{ + yymsp[0].minor.yy0.type = 0; + tSQLSetColumnType (&yylhsminor.yy325, &yymsp[0].minor.yy0); +} yymsp[0].minor.yy325 = yylhsminor.yy325; break; case 103: /* typename ::= ids LP signed RP */ { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy279; // negative value of name length - tSQLSetColumnType(&yylhsminor.yy325, &yymsp[-3].minor.yy0); + if (yymsp[-1].minor.yy279 <= 0) { + yymsp[-3].minor.yy0.type = 0; + tSQLSetColumnType(&yylhsminor.yy325, &yymsp[-3].minor.yy0); + } else { + yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy279; // negative value of name length + tSQLSetColumnType(&yylhsminor.yy325, &yymsp[-3].minor.yy0); + } } yymsp[-3].minor.yy325 = yylhsminor.yy325; break; From 124c2ecdc18c11143795d2ee48ac13e3c1f755a0 Mon Sep 17 00:00:00 2001 From: dengyihao Date: Mon, 15 Jun 2020 01:57:02 +0800 Subject: [PATCH 2/9] bugfix TD-690 --- src/query/src/sql.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/query/src/sql.c diff --git a/src/query/src/sql.c b/src/query/src/sql.c old mode 100755 new mode 100644 From a61552783544ca3c1f6c70392475a1e30b31a51c Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Thu, 18 Jun 2020 10:03:33 +0000 Subject: [PATCH 3/9] free ID in the last step --- src/rpc/src/rpcMain.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 365857a14e..71e1651ce1 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -576,11 +576,12 @@ static void rpcReleaseConn(SRpcConn *pConn) { taosHashRemove(pRpc->hash, hashstr, size); rpcFreeMsg(pConn->pRspMsg); // it may have a response msg saved, but not request msg } - - taosFreeId(pRpc->idPool, pConn->sid); + + int sid = pConn->sid; int64_t lockedBy = pConn->lockedBy; memset(pConn, 0, sizeof(SRpcConn)); pConn->lockedBy = lockedBy; + taosFreeId(pRpc->idPool, sid); tTrace("%s, rpc connection is released", pConn->info); } From ff16a84d59490dce236ede2de66acf81071ca139 Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Thu, 18 Jun 2020 10:07:06 +0000 Subject: [PATCH 4/9] add comments --- src/rpc/src/rpcMain.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 71e1651ce1..4a28cb4ff4 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -577,6 +577,7 @@ static void rpcReleaseConn(SRpcConn *pConn) { rpcFreeMsg(pConn->pRspMsg); // it may have a response msg saved, but not request msg } + // lockedBy can not be reset, since it maybe hold by a thread int sid = pConn->sid; int64_t lockedBy = pConn->lockedBy; memset(pConn, 0, sizeof(SRpcConn)); From 8a0ae7af4c9f3ad32e707b3ada6060b544b01592 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 18 Jun 2020 18:16:18 +0800 Subject: [PATCH 5/9] scripts --- tests/script/jenkins/simple.txt | 55 +++++++++++---------------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/tests/script/jenkins/simple.txt b/tests/script/jenkins/simple.txt index 55d139a91c..0ee98aa1f9 100644 --- a/tests/script/jenkins/simple.txt +++ b/tests/script/jenkins/simple.txt @@ -1,13 +1,14 @@ cd ../../../debug; cmake .. cd ../../../debug; make -#unsupport ./test.sh -f general/alter/cached_schema_after_alter.sim -#unsupport ./test.sh -f general/alter/count.sim -#unsupport ./test.sh -f general/alter/import.sim -#unsupport ./test.sh -f general/alter/insert1.sim -#unsupport ./test.sh -f general/alter/insert2.sim -#unsupport ./test.sh -f general/alter/metrics.sim -#unsupport ./test.sh -f general/alter/table.sim + +#./test.sh -f general/alter/cached_schema_after_alter.sim +./test.sh -f general/alter/count.sim +./test.sh -f general/alter/import.sim +#./test.sh -f general/alter/insert1.sim +./test.sh -f general/alter/insert2.sim +./test.sh -f general/alter/metrics.sim +./test.sh -f general/alter/table.sim ./test.sh -f general/cache/new_metrics.sim ./test.sh -f general/cache/restart_metrics.sim @@ -52,8 +53,7 @@ cd ../../../debug; make ./test.sh -f general/db/basic3.sim ./test.sh -f general/db/basic4.sim ./test.sh -f general/db/basic5.sim -./test.sh -f general/db/delete_reuse1.sim -./test.sh -f general/db/delete_writing1.sim +./test.sh -f general/db/delete_writing2.sim ./test.sh -f general/db/delete.sim ./test.sh -f general/db/len.sim ./test.sh -f general/db/repeat.sim @@ -96,7 +96,7 @@ cd ../../../debug; make ./test.sh -f general/insert/query_multi_file.sim ./test.sh -f general/insert/tcp.sim -#./test.sh -f general/parser/alter.sim +./test.sh -f general/parser/alter.sim ./test.sh -f general/parser/alter1.sim ./test.sh -f general/parser/alter_stable.sim ./test.sh -f general/parser/auto_create_tb.sim @@ -113,10 +113,10 @@ cd ../../../debug; make ./test.sh -f general/parser/import_commit3.sim ./test.sh -f general/parser/insert_tb.sim ./test.sh -f general/parser/first_last.sim -#unsupport ./test.sh -f general/parser/import_file.sim +#./test.sh -f general/parser/import_file.sim ./test.sh -f general/parser/lastrow.sim ./test.sh -f general/parser/nchar.sim -#unsupport ./test.sh -f general/parser/null_char.sim +./test.sh -f general/parser/null_char.sim ./test.sh -f general/parser/single_row_in_tb.sim ./test.sh -f general/parser/select_from_cache_disk.sim ./test.sh -f general/parser/mixed_blocks.sim @@ -143,10 +143,6 @@ cd ../../../debug; make ./test.sh -f general/parser/join_multivnode.sim ./test.sh -f general/parser/binary_escapeCharacter.sim ./test.sh -f general/parser/bug.sim -#unsupport ./test.sh -f general/parser/stream_on_sys.sim -#unsupport ./test.sh -f general/parser/stream.sim -#unsupport ./test.sh -f general/parser/repeatAlter.sim -#unsupport ./test.sh -f general/parser/repeatStream.sim ./test.sh -f general/stable/disk.sim ./test.sh -f general/stable/dnode3.sim @@ -155,21 +151,6 @@ cd ../../../debug; make ./test.sh -f general/stable/values.sim ./test.sh -f general/stable/vnode3.sim -#./test.sh -f general/stream/metrics_1.sim -#./test.sh -f general/stream/metrics_del.sim -#./test.sh -f general/stream/metrics_n.sim -#./test.sh -f general/stream/metrics_replica1_vnoden.sim -#./test.sh -f general/stream/new_stream.sim -#./test.sh -f general/stream/restart_stream.sim -#./test.sh -f general/stream/stream_1.sim -#./test.sh -f general/stream/stream_2.sim -#./test.sh -f general/stream/stream_3.sim -#./test.sh -f general/stream/stream_restart.sim -#./test.sh -f general/stream/table_1.sim -#./test.sh -f general/stream/table_del.sim -#./test.sh -f general/stream/table_n.sim -#./test.sh -f general/stream/table_replica1_vnoden.sim - ./test.sh -f general/table/autocreate.sim ./test.sh -f general/table/basic1.sim ./test.sh -f general/table/basic2.sim @@ -183,7 +164,7 @@ cd ../../../debug; make ./test.sh -f general/table/column2.sim ./test.sh -f general/table/date.sim ./test.sh -f general/table/db.table.sim -./test.sh -f general/table/delete_reuse1.sim +./test.sh -f general/table/delete_writing.sim ./test.sh -f general/table/describe.sim ./test.sh -f general/table/double.sim ./test.sh -f general/table/fill.sim @@ -200,25 +181,25 @@ cd ../../../debug; make ./test.sh -f general/tag/4.sim ./test.sh -f general/tag/5.sim ./test.sh -f general/tag/6.sim -#unsupport ./test.sh -f general/tag/add.sim +./test.sh -f general/tag/add.sim ./test.sh -f general/tag/bigint.sim ./test.sh -f general/tag/binary_binary.sim ./test.sh -f general/tag/binary.sim ./test.sh -f general/tag/bool_binary.sim ./test.sh -f general/tag/bool_int.sim ./test.sh -f general/tag/bool.sim -#unsupport ./test.sh -f general/tag/change.sim +./test.sh -f general/tag/change.sim ./test.sh -f general/tag/column.sim -#unsupport ./test.sh -f general/tag/commit.sim +#./test.sh -f general/tag/commit.sim ./test.sh -f general/tag/create.sim -#unsupport ./test.sh -f general/tag/delete.sim +./test.sh -f general/tag/delete.sim ./test.sh -f general/tag/double.sim ./test.sh -f general/tag/filter.sim ./test.sh -f general/tag/float.sim ./test.sh -f general/tag/int_binary.sim ./test.sh -f general/tag/int_float.sim ./test.sh -f general/tag/int.sim -#unsupport ./test.sh -f general/tag/set.sim +./test.sh -f general/tag/set.sim ./test.sh -f general/tag/smallint.sim ./test.sh -f general/tag/tinyint.sim From e8607b3bcfc3c8b690c9966eb1999a0510551c1e Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 18 Jun 2020 18:17:08 +0800 Subject: [PATCH 6/9] change SIGINT to SIGKILL to make dnode5 be killed. --- tests/script/unique/cluster/balance2.sim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/script/unique/cluster/balance2.sim b/tests/script/unique/cluster/balance2.sim index bb27a2aadb..0b3e1374ec 100644 --- a/tests/script/unique/cluster/balance2.sim +++ b/tests/script/unique/cluster/balance2.sim @@ -425,7 +425,7 @@ system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGKILL system sh/exec.sh -n dnode6 -s stop -x SIGINT system sh/exec.sh -n dnode7 -s stop -x SIGINT system sh/exec.sh -n dnode8 -s stop -x SIGINT From 430e060acfb4ec8419099bac5624d5199dbaba67 Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Thu, 18 Jun 2020 18:32:17 +0800 Subject: [PATCH 7/9] implement format check for log and fix all format issues --- src/client/src/TSDBJNIConnector.c | 2 +- src/client/src/tscServer.c | 4 +-- src/client/src/tscSub.c | 2 +- src/client/src/tscSubquery.c | 16 +++++----- src/client/src/tscUtil.c | 2 +- src/mnode/src/mnodeTable.c | 8 ++--- src/mnode/src/mnodeVgroup.c | 2 +- src/plugins/http/src/httpContext.c | 2 +- src/plugins/http/src/httpJson.c | 2 +- src/plugins/http/src/httpSession.c | 2 +- src/plugins/monitor/src/monitorMain.c | 2 +- src/query/src/qExecutor.c | 46 +++++++++++++-------------- src/rpc/src/rpcMain.c | 2 +- src/rpc/src/rpcTcp.c | 2 +- src/tsdb/src/tsdbMain.c | 20 ++++++------ src/tsdb/src/tsdbMeta.c | 10 +++--- src/tsdb/src/tsdbRead.c | 14 ++++---- src/util/inc/tlog.h | 14 ++++++-- src/util/src/tkvstore.c | 12 +++---- src/util/src/tlog.c | 4 +-- src/vnode/src/vnodeMain.c | 4 +-- src/vnode/src/vnodeRead.c | 2 +- tests/test/c/importPerTable.c | 8 ++--- tests/test/c/insertPerRow.c | 8 ++--- tests/test/c/insertPerTable.c | 10 +++--- 25 files changed, 105 insertions(+), 95 deletions(-) diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index dc44c8ea26..9530bc26b4 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -583,7 +583,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_subscribeImp(JNI } JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_consumeImp(JNIEnv *env, jobject jobj, jlong sub) { - jniTrace("jobj:%p, in TSDBJNIConnector_consumeImp, sub:%" PRId64, jobj, sub); + jniTrace("jobj:%p, in TSDBJNIConnector_consumeImp, sub:%lld", jobj, sub); jniGetGlobalMethod(env); TAOS_SUB *tsub = (TAOS_SUB *)sub; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index da807b1964..b509dd3364 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -272,7 +272,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) { if (pRes->code != TSDB_CODE_TSC_QUERY_CANCELLED) { pRes->code = (rpcMsg->code != TSDB_CODE_SUCCESS) ? rpcMsg->code : TSDB_CODE_RPC_NETWORK_UNAVAIL; } else { - tscTrace("%p query is cancelled, code:%d", pSql, tstrerror(pRes->code)); + tscTrace("%p query is cancelled, code:%s", pSql, tstrerror(pRes->code)); } if (pRes->code == TSDB_CODE_SUCCESS) { @@ -2180,7 +2180,7 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) { } pRes->row = 0; - tscTrace("%p numOfRows:%d, offset:%d, complete:%d", pSql, pRes->numOfRows, pRes->offset, pRes->completed); + tscTrace("%p numOfRows:%" PRId64 ", offset:%" PRId64 ", complete:%d", pSql, pRes->numOfRows, pRes->offset, pRes->completed); return 0; } diff --git a/src/client/src/tscSub.c b/src/client/src/tscSub.c index 15dc58a713..bbde276c3b 100644 --- a/src/client/src/tscSub.c +++ b/src/client/src/tscSub.c @@ -291,7 +291,7 @@ static int tscLoadSubscriptionProgress(SSub* pSub) { fclose(fp); taosArraySort(progress, tscCompareSubscriptionProgress); - tscTrace("subscription progress loaded, %z tables: %s", taosArrayGetSize(progress), pSub->topic); + tscTrace("subscription progress loaded, %zu tables: %s", taosArrayGetSize(progress), pSub->topic); return 1; } diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index b0a66701c5..42a5d1d09b 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -354,7 +354,7 @@ static int32_t tscLaunchSecondPhaseSubqueries(SSqlObj* pSql) { } size_t numOfCols = taosArrayGetSize(pNewQueryInfo->colList); - tscTrace("%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%z, colList:%z, fieldsInfo:%d, name:%s", + tscTrace("%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%zu, colList:%zu, fieldsInfo:%d, name:%s", pSql, pNew, 0, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, taosArrayGetSize(pNewQueryInfo->exprList), numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, pTableMetaInfo->name); } @@ -551,7 +551,7 @@ static void issueTSCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj* tscTrace( "%p subquery:%p tableIndex:%d, vgroupIndex:%d, numOfVgroups:%d, type:%d, ts_comp query to retrieve timestamps, " - "numOfExpr:%z, colList:%z, numOfOutputFields:%d, name:%s", + "numOfExpr:%zu, colList:%zu, numOfOutputFields:%d, name:%s", pParent, pSql, 0, pTableMetaInfo->vgroupIndex, pTableMetaInfo->vgroupList->numOfVgroups, pQueryInfo->type, tscSqlExprNumOfExprs(pQueryInfo), numOfCols, pQueryInfo->fieldsInfo.numOfOutput, pTableMetaInfo->name); @@ -809,7 +809,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow pTableMetaInfo->vgroupIndex += 1; assert(pTableMetaInfo->vgroupIndex < totalVgroups); - tscTrace("%p results from vgroup index:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%d", + tscTrace("%p results from vgroup index:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%" PRId64, pSql, pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pRes->numOfClauseTotal); @@ -1245,7 +1245,7 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter tscTrace( "%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, transfer to tid_tag query to retrieve (tableId, tags), " - "exprInfo:%z, colList:%z, fieldsInfo:%d, tagIndex:%d, name:%s", + "exprInfo:%zu, colList:%zu, fieldsInfo:%d, tagIndex:%d, name:%s", pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo), numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, index.columnIndex, pNewQueryInfo->pTableMetaInfo[0]->name); } else { @@ -1280,7 +1280,7 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter tscTrace( "%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%u, transfer to ts_comp query to retrieve timestamps, " - "exprInfo:%z, colList:%z, fieldsInfo:%d, name:%s", + "exprInfo:%zu, colList:%zu, fieldsInfo:%d, name:%s", pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo), numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, pNewQueryInfo->pTableMetaInfo[0]->name); } @@ -1647,7 +1647,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p // all sub-queries are returned, start to local merge process pDesc->pColumnModel->capacity = trsupport->pExtMemBuffer[idx]->numOfElemsPerPage; - tscTrace("%p retrieve from %d vnodes completed.final NumOfRows:%d,start to build loser tree", pPObj, + tscTrace("%p retrieve from %d vnodes completed.final NumOfRows:%" PRId64 ",start to build loser tree", pPObj, pState->numOfTotal, pState->numOfRetrievedRows); SQueryInfo *pPQueryInfo = tscGetQueryInfoDetail(&pPObj->cmd, 0); @@ -1869,7 +1869,7 @@ static void multiVnodeInsertMerge(void* param, TAOS_RES* tres, int numOfRows) { return; } - tscTrace("%p Async insertion completed, total inserted:%d", pParentObj, pParentObj->res.numOfRows); + tscTrace("%p Async insertion completed, total inserted:%" PRId64, pParentObj, pParentObj->res.numOfRows); tfree(pState); tfree(pSupporter); @@ -2049,7 +2049,7 @@ static void transferNcharData(SSqlObj *pSql, int32_t columnIndex, TAOS_FIELD *pF pRes->tsrow[columnIndex] = pRes->buffer[columnIndex]; pRes->length[columnIndex] = length; } else { - tscError("%p charset:%s to %s. val:%ls convert failed.", pSql, DEFAULT_UNICODE_ENCODEC, tsCharset, pRes->tsrow[columnIndex]); + tscError("%p charset:%s to %s. val:%s convert failed.", pSql, DEFAULT_UNICODE_ENCODEC, tsCharset, (char*)pRes->tsrow[columnIndex]); pRes->tsrow[columnIndex] = NULL; pRes->length[columnIndex] = 0; } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index e65c9a8bdf..cbf1aa12be 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1835,7 +1835,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { assert(pFinalInfo->vgroupList != NULL); } - + if (cmd == TSDB_SQL_SELECT) { size_t size = taosArrayGetSize(pNewQueryInfo->colList); diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index d5d9cbe207..6eb9e07dd4 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -1061,7 +1061,7 @@ static int32_t mnodeAddSuperTableColumn(SMnodeMsg *pMsg, SSchema schema[], int32 SDbObj *pDb = pMsg->pDb; SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable; if (ncols <= 0) { - mError("app:%p:%p, stable:%s, add column, ncols:%d <= 0", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId); + mError("app:%p:%p, stable:%s, add column, ncols:%d <= 0", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId, ncols); return TSDB_CODE_MND_APP_ERROR; } @@ -1689,7 +1689,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) { } if (pMsg->pTable == NULL) { - mError("app:%p:%p, table:%s, object not found, retry:%d reason:%s", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId, + mError("app:%p:%p, table:%s, object not found, retry:%d reason:%s", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId, pMsg->retry, tstrerror(terrno)); return terrno; } else { @@ -1758,7 +1758,7 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3 SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable; SDbObj *pDb = pMsg->pDb; if (ncols <= 0) { - mError("app:%p:%p, ctable:%s, add column, ncols:%d <= 0", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId); + mError("app:%p:%p, ctable:%s, add column, ncols:%d <= 0", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId, ncols); return TSDB_CODE_MND_APP_ERROR; } @@ -2023,7 +2023,7 @@ static void mnodeDropAllChildTablesInStable(SSuperTableObj *pStable) { int32_t numOfTables = 0; SChildTableObj *pTable = NULL; - mPrint("stable:%s, all child tables will dropped from sdb", pStable->info.tableId, numOfTables); + mPrint("stable:%s, all child tables(%d) will dropped from sdb", pStable->info.tableId, numOfTables); while (1) { pIter = mnodeGetNextChildTable(pIter, &pTable); diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index ff09af7611..43b47764b9 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -739,7 +739,7 @@ static int32_t mnodeProcessVnodeCfgMsg(SMnodeMsg *pMsg) { SDnodeObj *pDnode = mnodeGetDnode(pCfg->dnodeId); if (pDnode == NULL) { - mTrace("dnode:%s, invalid dnode", taosIpStr(pCfg->dnodeId), pCfg->vgId); + mTrace("dnode:%s, vgId:%d, invalid dnode", taosIpStr(pCfg->dnodeId), pCfg->vgId); return TSDB_CODE_MND_VGROUP_NOT_EXIST; } mnodeDecDnodeRef(pDnode); diff --git a/src/plugins/http/src/httpContext.c b/src/plugins/http/src/httpContext.c index 981492681a..a9082be708 100644 --- a/src/plugins/http/src/httpContext.c +++ b/src/plugins/http/src/httpContext.c @@ -70,7 +70,7 @@ bool httpInitContexts() { void httpCleanupContexts() { if (tsHttpServer.contextCache != NULL) { SCacheObj *cache = tsHttpServer.contextCache; - httpPrint("context cache is cleanuping, size:%d", taosHashGetSize(cache->pHashTable)); + httpPrint("context cache is cleanuping, size:%zu", taosHashGetSize(cache->pHashTable)); taosCacheCleanup(tsHttpServer.contextCache); tsHttpServer.contextCache = NULL; } diff --git a/src/plugins/http/src/httpJson.c b/src/plugins/http/src/httpJson.c index 76cc90c48f..901b930774 100644 --- a/src/plugins/http/src/httpJson.c +++ b/src/plugins/http/src/httpJson.c @@ -139,7 +139,7 @@ int httpWriteJsonBufBody(JsonBuf* buf, bool isTheLast) { return 0; // there is no data to dump. } } else { - httpError("context:%p, fd:%d, ip:%s, failed to compress data, chunkSize:%d, last:%d, error:%d, response:\n%s", + httpError("context:%p, fd:%d, ip:%s, failed to compress data, chunkSize:%" PRIu64 ", last:%d, error:%d, response:\n%s", buf->pContext, buf->pContext->fd, buf->pContext->ipstr, srcLen, isTheLast, ret, buf->buf); return 0; } diff --git a/src/plugins/http/src/httpSession.c b/src/plugins/http/src/httpSession.c index c1e33706d5..e0fc708fa5 100644 --- a/src/plugins/http/src/httpSession.c +++ b/src/plugins/http/src/httpSession.c @@ -108,7 +108,7 @@ static void httpDestroySession(void *data) { void httpCleanUpSessions() { if (tsHttpServer.sessionCache != NULL) { SCacheObj *cache = tsHttpServer.sessionCache; - httpPrint("session cache is cleanuping, size:%d", taosHashGetSize(cache->pHashTable)); + httpPrint("session cache is cleanuping, size:%zu", taosHashGetSize(cache->pHashTable)); taosCacheCleanup(tsHttpServer.sessionCache); tsHttpServer.sessionCache = NULL; } diff --git a/src/plugins/monitor/src/monitorMain.c b/src/plugins/monitor/src/monitorMain.c index 735c77ae21..ea7916026c 100644 --- a/src/plugins/monitor/src/monitorMain.c +++ b/src/plugins/monitor/src/monitorMain.c @@ -208,7 +208,7 @@ static void monitorInitDatabase() { static void monitorInitDatabaseCb(void *param, TAOS_RES *result, int32_t code) { if (-code == TSDB_CODE_MND_TABLE_ALREADY_EXIST || -code == TSDB_CODE_MND_DB_ALREADY_EXIST || code >= 0) { - monitorTrace("monitor:%p, sql success, reason:%d, %s", tsMonitorConn.conn, tstrerror(code), tsMonitorConn.sql); + monitorTrace("monitor:%p, sql success, reason:%s, %s", tsMonitorConn.conn, tstrerror(code), tsMonitorConn.sql); if (tsMonitorConn.cmdIndex == MONITOR_CMD_CREATE_TB_LOG) { monitorPrint("dnode:%s is started", tsLocalEp); } diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 0a25ae3397..9f7a9dace4 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -273,7 +273,7 @@ static bool limitResults(SQueryRuntimeEnv* pRuntimeEnv) { if ((pQuery->limit.limit > 0) && (pQuery->rec.total + pQuery->rec.rows > pQuery->limit.limit)) { pQuery->rec.rows = pQuery->limit.limit - pQuery->rec.total; - qTrace("QInfo:%p discard remain data due to result limitation, limit:%"PRId64", current return:%d, total:%"PRId64, + qTrace("QInfo:%p discard remain data due to result limitation, limit:%"PRId64", current return:%" PRId64 ", total:%"PRId64, pQInfo, pQuery->limit.limit, pQuery->rec.rows, pQuery->rec.total + pQuery->rec.rows); assert(pQuery->rec.rows >= 0); setQueryStatus(pQuery, QUERY_COMPLETED); @@ -2060,7 +2060,7 @@ static void ensureOutputBufferSimple(SQueryRuntimeEnv* pRuntimeEnv, int32_t capa pRuntimeEnv->pCtx[i].aOutputBuf = pQuery->sdata[i]->data; } - qTrace("QInfo:%p realloc output buffer to inc output buffer from: %d rows to:%d rows", GET_QINFO_ADDR(pRuntimeEnv), + qTrace("QInfo:%p realloc output buffer to inc output buffer from: %" PRId64 " rows to:%d rows", GET_QINFO_ADDR(pRuntimeEnv), pQuery->rec.capacity, capacity); pQuery->rec.capacity = capacity; @@ -2096,7 +2096,7 @@ static void ensureOutputBuffer(SQueryRuntimeEnv* pRuntimeEnv, SDataBlockInfo* pB } } - qTrace("QInfo:%p realloc output buffer, new size: %d rows, old:%d, remain:%d", GET_QINFO_ADDR(pRuntimeEnv), + qTrace("QInfo:%p realloc output buffer, new size: %d rows, old:%" PRId64 ", remain:%" PRId64, GET_QINFO_ADDR(pRuntimeEnv), newSize, pRec->capacity, newSize - pRec->rows); pRec->capacity = newSize; @@ -2270,8 +2270,8 @@ void setTagVal(SQueryRuntimeEnv *pRuntimeEnv, STableId* pTableId, void *tsdb) { } doSetTagValueInParam(tsdb, pTableId, pExprInfo->base.arg->argValue.i64, &pRuntimeEnv->pCtx[0].tag, type, bytes); - qTrace("QInfo:%p set tag value for join comparison, colId:%d, val:%"PRId64, pQInfo, pExprInfo->base.arg->argValue.i64, - pRuntimeEnv->pCtx[0].tag) + qTrace("QInfo:%p set tag value for join comparison, colId:%" PRId64 ", val:%"PRId64, pQInfo, pExprInfo->base.arg->argValue.i64, + pRuntimeEnv->pCtx[0].tag.i64Key) } } } @@ -2494,7 +2494,7 @@ int32_t mergeIntoGroupResult(SQInfo *pQInfo) { qTrace("QInfo:%p no result in group %d, continue", pQInfo, pQInfo->groupIndex - 1); } - qTrace("QInfo:%p merge res data into group, index:%d, total group:%d, elapsed time:%lldms", pQInfo, + qTrace("QInfo:%p merge res data into group, index:%d, total group:%d, elapsed time:%" PRId64 "ms", pQInfo, pQInfo->groupIndex - 1, numOfGroups, taosGetTimestampMs() - st); return TSDB_CODE_SUCCESS; @@ -2952,7 +2952,7 @@ void skipResults(SQueryRuntimeEnv *pRuntimeEnv) { } if (pQuery->rec.rows <= pQuery->limit.offset) { - qTrace("QInfo:%p skip rows:%d, new offset:%" PRIu64, GET_QINFO_ADDR(pRuntimeEnv), pQuery->rec.rows, + qTrace("QInfo:%p skip rows:%" PRId64 ", new offset:%" PRIu64, GET_QINFO_ADDR(pRuntimeEnv), pQuery->rec.rows, pQuery->limit.offset - pQuery->rec.rows); pQuery->limit.offset -= pQuery->rec.rows; @@ -3696,7 +3696,7 @@ int32_t doFillGapsInResults(SQueryRuntimeEnv* pRuntimeEnv, tFilePage **pDst, int } if (pQuery->limit.offset < ret) { - qTrace("QInfo:%p initial numOfRows:%d, generate filled result:%d rows, offset:%d. Discard due to offset, remain:%d, new offset:%d", + qTrace("QInfo:%p initial numOfRows:%d, generate filled result:%d rows, offset:%" PRId64 ". Discard due to offset, remain:%" PRId64 ", new offset:%d", pQInfo, pFillInfo->numOfRows, ret, pQuery->limit.offset, ret - pQuery->limit.offset, 0); ret -= pQuery->limit.offset; @@ -3710,8 +3710,8 @@ int32_t doFillGapsInResults(SQueryRuntimeEnv* pRuntimeEnv, tFilePage **pDst, int pQuery->limit.offset = 0; return ret; } else { - qTrace("QInfo:%p initial numOfRows:%d, generate filled result:%d rows, offset:%d. Discard due to offset, " - "remain:%d, new offset:%d", pQInfo, pFillInfo->numOfRows, ret, pQuery->limit.offset, 0, + qTrace("QInfo:%p initial numOfRows:%d, generate filled result:%d rows, offset:%" PRId64 ". Discard due to offset, " + "remain:%d, new offset:%" PRId64, pQInfo, pFillInfo->numOfRows, ret, pQuery->limit.offset, 0, pQuery->limit.offset - ret); pQuery->limit.offset -= ret; @@ -4259,7 +4259,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) { while (pQInfo->groupIndex < numOfGroups) { SArray* group = taosArrayGetP(pQInfo->groupInfo.pGroupList, pQInfo->groupIndex); - qTrace("QInfo:%p last_row query on group:%d, total group:%u, current group:%p", pQInfo, pQInfo->groupIndex, + qTrace("QInfo:%p last_row query on group:%d, total group:%zu, current group:%p", pQInfo, pQInfo->groupIndex, numOfGroups, group); STsdbQueryCond cond = { @@ -4324,7 +4324,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) { while (pQInfo->groupIndex < numOfGroups) { SArray* group = taosArrayGetP(pQInfo->groupInfo.pGroupList, pQInfo->groupIndex); - qTrace("QInfo:%p group by normal columns group:%d, total group:%d", pQInfo, pQInfo->groupIndex, numOfGroups); + qTrace("QInfo:%p group by normal columns group:%d, total group:%zu", pQInfo, pQInfo->groupIndex, numOfGroups); STsdbQueryCond cond = { .twindow = pQuery->window, @@ -4510,7 +4510,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) { } qTrace( - "QInfo %p numOfTables:%"PRIu64", index:%d, numOfGroups:%d, %"PRId64" points returned, total:%"PRId64", offset:%" PRId64, + "QInfo %p numOfTables:%"PRIu64", index:%d, numOfGroups:%zu, %"PRId64" points returned, total:%"PRId64", offset:%" PRId64, pQInfo, pQInfo->groupInfo.numOfTables, pQInfo->tableIndex, numOfGroups, pQuery->rec.rows, pQuery->rec.total, pQuery->limit.offset); } @@ -4606,7 +4606,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) { // do check all qualified data blocks int64_t el = scanMultiTableDataBlocks(pQInfo); - qTrace("QInfo:%p master scan completed, elapsed time: %lldms, reverse scan start", pQInfo, el); + qTrace("QInfo:%p master scan completed, elapsed time: %" PRId64 "ms, reverse scan start", pQInfo, el); // query error occurred or query is killed, abort current execution if (pQInfo->code != TSDB_CODE_SUCCESS || isQueryKilled(pQInfo)) { @@ -4621,7 +4621,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) { doSaveContext(pQInfo); el = scanMultiTableDataBlocks(pQInfo); - qTrace("QInfo:%p reversed scan completed, elapsed time: %lldms", pQInfo, el); + qTrace("QInfo:%p reversed scan completed, elapsed time: %" PRId64 "ms", pQInfo, el); doRestoreContext(pQInfo); } else { @@ -4648,7 +4648,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) { } // handle the limitation of output buffer - qTrace("QInfo:%p points returned:%d, total:%d", pQInfo, pQuery->rec.rows, pQuery->rec.total + pQuery->rec.rows); + qTrace("QInfo:%p points returned:%" PRId64 ", total:%" PRId64, pQInfo, pQuery->rec.rows, pQuery->rec.total + pQuery->rec.rows); } /* @@ -4720,8 +4720,8 @@ static void tableMultiOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) break; } - qTrace("QInfo:%p vid:%d sid:%d id:%s, skip current result, offset:%" PRId64 ", next qrange:%" PRId64 "-%" PRId64, - pQInfo, pQuery->limit.offset, pQuery->current->lastKey); + qTrace("QInfo:%p skip current result, offset:%" PRId64 ", next qrange:%" PRId64 "-%" PRId64, + pQInfo, pQuery->limit.offset, pQuery->current->lastKey, pQuery->current->win.ekey); resetCtxOutputBuf(pRuntimeEnv); } @@ -4849,7 +4849,7 @@ static void tableQueryImpl(SQInfo *pQInfo) { limitResults(pRuntimeEnv); } - qTrace("QInfo:%p current:%d returned, total:%d", pQInfo, pQuery->rec.rows, pQuery->rec.total); + qTrace("QInfo:%p current:%" PRId64 " returned, total:%" PRId64, pQInfo, pQuery->rec.rows, pQuery->rec.total); return; } @@ -4931,7 +4931,7 @@ static void stableQueryImpl(SQInfo *pQInfo) { pQInfo->runtimeEnv.summary.elapsedTime += (taosGetTimestampUs() - st); if (pQuery->rec.rows == 0) { - qTrace("QInfo:%p over, %d tables queried, %"PRId64" rows are returned", pQInfo, pQInfo->groupInfo.numOfTables, pQuery->rec.total); + qTrace("QInfo:%p over, %zu tables queried, %"PRId64" rows are returned", pQInfo, pQInfo->groupInfo.numOfTables, pQuery->rec.total); } } @@ -5233,7 +5233,7 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, } static int32_t buildAirthmeticExprFromMsg(SExprInfo *pArithExprInfo, SQueryTableMsg *pQueryMsg) { - qTrace("qmsg:%p create arithmetic expr from binary string", pQueryMsg, pArithExprInfo->base.arg[0].argValue.pz); + qTrace("qmsg:%p create arithmetic expr from binary string: %s", pQueryMsg, pArithExprInfo->base.arg[0].argValue.pz); tExprNode* pExprNode = NULL; TRY(32) { @@ -5853,7 +5853,7 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) { } pQuery->rec.total += pQuery->rec.rows; - qTrace("QInfo:%p current numOfRes rows:%d, total:%d", pQInfo, pQuery->rec.rows, pQuery->rec.total); + qTrace("QInfo:%p current numOfRes rows:%" PRId64 ", total:%" PRId64, pQInfo, pQuery->rec.rows, pQuery->rec.total); if (pQuery->limit.limit > 0 && pQuery->limit.limit == pQuery->rec.total) { qTrace("QInfo:%p results limitation reached, limitation:%"PRId64, pQInfo, pQuery->limit.limit); @@ -5939,7 +5939,7 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi SArray* p = taosArrayClone(pTableIdList); taosArrayPush(groupInfo.pGroupList, &p); - qTrace("qmsg:%p query on %d tables in one group from client", pQueryMsg, groupInfo.numOfTables); + qTrace("qmsg:%p query on %zu tables in one group from client", pQueryMsg, groupInfo.numOfTables); } } else { assert(0); diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 4a28cb4ff4..3e89cf76a5 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -696,7 +696,7 @@ static SRpcConn *rpcGetConnObj(SRpcInfo *pRpc, int sid, SRecvInfo *pRecv) { if (pConn) { if (pConn->linkUid != pHead->linkUid) { terrno = TSDB_CODE_RPC_MISMATCHED_LINK_ID; - tError("%s %p %p, linkUid:0x%x is not matched with received:0x%x", pRpc->label, pConn, pHead->ahandle, pConn->linkUid, pHead->linkUid); + tError("%s %p %p, linkUid:0x%x is not matched with received:0x%x", pRpc->label, pConn, (void*)pHead->ahandle, pConn->linkUid, pHead->linkUid); pConn = NULL; } } diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index 0ca73c1b40..674d560952 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -299,7 +299,7 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void * return NULL; } - tTrace("%s TCP client is initialized, ip:%s:%hu", label, ip, port); + tTrace("%s TCP client is initialized, ip:%u:%hu", label, ip, port); return pThreadObj; } diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 5526ad0d6e..181cda118f 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -420,7 +420,7 @@ int tsdbUpdateTagValue(TsdbRepoT *repo, SUpdateTableTagValMsg *pMsg) { if (pTable->type != TSDB_CHILD_TABLE) { tsdbError("vgId:%d failed to update tag value of table %s since its type is %d", pRepo->config.tsdbId, - varDataVal(pTable->name), pTable->type); + pTable->name->data, pTable->type); return TSDB_CODE_TDB_INVALID_TABLE_TYPE; } @@ -450,7 +450,7 @@ int tsdbUpdateTagValue(TsdbRepoT *repo, SUpdateTableTagValMsg *pMsg) { tsdbError( "vgId:%d failed to update tag value of table %s since version out of date, client tag version:%d server tag " "version:%d", - pRepo->config.tsdbId, varDataVal(pTable->name), tversion, schemaVersion(pTable->tagSchema)); + pRepo->config.tsdbId, pTable->name->data, tversion, schemaVersion(pTable->tagSchema)); return TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE; } if (schemaColAt(pTagSchema, DEFAULT_TAG_INDEX_COLUMN)->colId == htons(pMsg->colId)) { @@ -945,7 +945,7 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable pTable->mem->numOfRows = tSkipListGetSize(pTable->mem->pData); tsdbTrace("vgId:%d, tid:%d, uid:%" PRId64 ", table:%s a row is inserted to table! key:%" PRId64, pRepo->config.tsdbId, - pTable->tableId.tid, pTable->tableId.uid, varDataVal(pTable->name), dataRowKey(row)); + pTable->tableId.tid, pTable->tableId.uid, pTable->name->data, dataRowKey(row)); return 0; } @@ -958,7 +958,7 @@ static int32_t tsdbInsertDataToTable(TsdbRepoT *repo, SSubmitBlk *pBlock, TSKEY STableId tableId = {.uid = pBlock->uid, .tid = pBlock->tid}; STable *pTable = tsdbIsValidTableToInsert(pRepo->tsdbMeta, tableId); if (pTable == NULL) { - tsdbError("vgId:%d, failed to get table for insert, uid:" PRIu64 ", tid:%d", pRepo->config.tsdbId, pBlock->uid, + tsdbError("vgId:%d, failed to get table for insert, uid:%" PRIu64 ", tid:%d", pRepo->config.tsdbId, pBlock->uid, pBlock->tid); return TSDB_CODE_TDB_INVALID_TABLE_ID; } @@ -970,7 +970,7 @@ static int32_t tsdbInsertDataToTable(TsdbRepoT *repo, SSubmitBlk *pBlock, TSKEY int16_t nversion = schemaVersion(pSchema); if (tversion > nversion) { tsdbTrace("vgId:%d table:%s tid:%d server schema version %d is older than clien version %d, try to config.", - pRepo->config.tsdbId, varDataVal(pTable->name), pTable->tableId.tid, nversion, tversion); + pRepo->config.tsdbId, pTable->name->data, pTable->tableId.tid, nversion, tversion); void *msg = (*pRepo->appH.configFunc)(pRepo->config.tsdbId, pTable->tableId.tid); if (msg == NULL) { return terrno; @@ -993,7 +993,7 @@ static int32_t tsdbInsertDataToTable(TsdbRepoT *repo, SSubmitBlk *pBlock, TSKEY } else { if (tsdbGetTableSchemaByVersion(pMeta, pTable, tversion) == NULL) { tsdbError("vgId:%d table:%s tid:%d invalid schema version %d from client", pRepo->config.tsdbId, - varDataVal(pTable->name), pTable->tableId.tid, tversion); + pTable->name->data, pTable->tableId.tid, tversion); return TSDB_CODE_TDB_TABLE_SCHEMA_VERSION; } } @@ -1007,9 +1007,9 @@ static int32_t tsdbInsertDataToTable(TsdbRepoT *repo, SSubmitBlk *pBlock, TSKEY tsdbInitSubmitBlkIter(pBlock, &blkIter); while ((row = tsdbGetSubmitBlkNext(&blkIter)) != NULL) { if (dataRowKey(row) < minKey || dataRowKey(row) > maxKey) { - tsdbError("vgId:%d, table:%s, tid:%d, talbe uid:%ld timestamp is out of range. now:" PRId64 ", maxKey:" PRId64 - ", minKey:" PRId64, - pRepo->config.tsdbId, varDataVal(pTable->name), pTable->tableId.tid, pTable->tableId.uid, now, minKey, maxKey); + tsdbError("vgId:%d, table:%s, tid:%d, talbe uid:%ld timestamp is out of range. now:%" PRId64 ", maxKey:%" PRId64 + ", minKey:%" PRId64, + pRepo->config.tsdbId, pTable->name->data, pTable->tableId.tid, pTable->tableId.uid, now, minKey, maxKey); return TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE; } @@ -1279,7 +1279,7 @@ static int tsdbHasDataToCommit(SSkipListIterator **iters, int nIters, TSKEY minK static void tsdbAlterCompression(STsdbRepo *pRepo, int8_t compression) { int8_t oldCompRession = pRepo->config.compression; pRepo->config.compression = compression; - tsdbTrace("vgId:%d, tsdb compression is changed from %d to %d", oldCompRession, compression); + tsdbTrace("tsdb compression is changed from %d to %d", oldCompRession, compression); } static void tsdbAlterKeep(STsdbRepo *pRepo, int32_t keep) { diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 1f31f18ce1..7612567411 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -451,7 +451,7 @@ int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg) { STable *pTable = tsdbGetTableByUid(pMeta, pCfg->tableId.uid); if (pTable != NULL) { - tsdbError("vgId:%d table %s already exists, tid %d uid %" PRId64, pRepo->config.tsdbId, varDataVal(pTable->name), + tsdbError("vgId:%d table %s already exists, tid %d uid %" PRId64, pRepo->config.tsdbId, pTable->name->data, pTable->tableId.tid, pTable->tableId.uid); return TSDB_CODE_TDB_TABLE_ALREADY_EXIST; } @@ -485,11 +485,11 @@ int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg) { // Register to meta if (newSuper) { tsdbAddTableToMeta(pMeta, super, true); - tsdbTrace("vgId:%d, super table %s is created! uid:%" PRId64, pRepo->config.tsdbId, varDataVal(super->name), + tsdbTrace("vgId:%d, super table %s is created! uid:%" PRId64, pRepo->config.tsdbId, super->name->data, super->tableId.uid); } tsdbAddTableToMeta(pMeta, table, true); - tsdbTrace("vgId:%d, table %s is created! tid:%d, uid:%" PRId64, pRepo->config.tsdbId, varDataVal(table->name), + tsdbTrace("vgId:%d, table %s is created! tid:%d, uid:%" PRId64, pRepo->config.tsdbId, table->name->data, table->tableId.tid, table->tableId.uid); // Write to meta file @@ -595,7 +595,7 @@ int tsdbDropTable(TsdbRepoT *repo, STableId tableId) { STable *pTable = tsdbGetTableByUid(pMeta, tableId.uid); if (pTable == NULL) { - tsdbError("vgId:%d, failed to drop table since table not exists! tid:%d, uid:" PRId64, pRepo->config.tsdbId, + tsdbError("vgId:%d, failed to drop table since table not exists! tid:%d, uid:%" PRId64, pRepo->config.tsdbId, tableId.tid, tableId.uid); return -1; } @@ -604,7 +604,7 @@ int tsdbDropTable(TsdbRepoT *repo, STableId tableId) { pRepo->appH.cqDropFunc(pTable->cqhandle); } - tsdbTrace("vgId:%d, table %s is dropped! tid:%d, uid:%" PRId64, pRepo->config.tsdbId, varDataVal(pTable->name), + tsdbTrace("vgId:%d, table %s is dropped! tid:%d, uid:%" PRId64, pRepo->config.tsdbId, pTable->name->data, tableId.tid, tableId.uid); if (tsdbRemoveTableFromMeta(pMeta, pTable, true) < 0) return -1; diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 732e8e9008..9ac47ef22b 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -195,7 +195,7 @@ TsdbQueryHandleT* tsdbQueryTables(TsdbRepoT* tsdb, STsdbQueryCond* pCond, STable } } - tsdbTrace("%p total numOfTable:%d in query", pQueryHandle, taosArrayGetSize(pQueryHandle->pTableCheckInfo)); + tsdbTrace("%p total numOfTable:%zu in query", pQueryHandle, taosArrayGetSize(pQueryHandle->pTableCheckInfo)); tsdbInitDataBlockLoadInfo(&pQueryHandle->dataBlockLoadInfo); tsdbInitCompBlockLoadInfo(&pQueryHandle->compBlockLoadInfo); @@ -1095,7 +1095,7 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* cur->rows = numOfRows; cur->pos = pos; - tsdbTrace("%p uid:%" PRIu64",tid:%d data block created, brange:%"PRIu64"-%"PRIu64" %p", pQueryHandle, cur->win.skey, + tsdbTrace("%p uid:%" PRIu64",tid:%d data block created, brange:%"PRIu64"-%"PRIu64" rows:%d, %p", pQueryHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, cur->win.skey, cur->win.ekey, cur->rows, pQueryHandle->qinfo); } @@ -1195,7 +1195,7 @@ static int32_t dataBlockOrderCompar(const void* pLeft, const void* pRight, void* if (pLeftBlockInfoEx->compBlock->offset == pRightBlockInfoEx->compBlock->offset && pLeftBlockInfoEx->compBlock->last == pRightBlockInfoEx->compBlock->last) { // todo add more information - tsdbError("error in header file, two block with same offset:%p", pLeftBlockInfoEx->compBlock->offset); + tsdbError("error in header file, two block with same offset:%" PRId64, (int64_t)pLeftBlockInfoEx->compBlock->offset); } return pLeftBlockInfoEx->compBlock->offset > pRightBlockInfoEx->compBlock->offset ? 1 : -1; @@ -2020,7 +2020,7 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC } taosArrayPush(pTableGroup, &sa); - tsdbTrace("all %d tables belong to one group", size); + tsdbTrace("all %zu tables belong to one group", size); } else { STableGroupSupporter *pSupp = (STableGroupSupporter *) calloc(1, sizeof(STableGroupSupporter)); pSupp->tsdbMeta = tsdbGetMeta(tsdb); @@ -2125,7 +2125,7 @@ int32_t tsdbQuerySTableByTagCond(TsdbRepoT* tsdb, uint64_t uid, const char* pTag if (pTable->type != TSDB_SUPER_TABLE) { tsdbError("%p query normal tag not allowed, uid:%" PRIu64 ", tid:%d, name:%s", tsdb, uid, pTable->tableId.tid, - pTable->name); + pTable->name->data); return TSDB_CODE_COM_OPS_NOT_SUPPORT; //basically, this error is caused by invalid sql issued by client } @@ -2140,7 +2140,7 @@ int32_t tsdbQuerySTableByTagCond(TsdbRepoT* tsdb, uint64_t uid, const char* pTag pGroupInfo->numOfTables = taosArrayGetSize(res); pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols, tsdb); - tsdbTrace("%p no table name/tag condition, all tables belong to one group, numOfTables:%d", tsdb, pGroupInfo->numOfTables); + tsdbTrace("%p no table name/tag condition, all tables belong to one group, numOfTables:%zu", tsdb, pGroupInfo->numOfTables); } else { // todo add error } @@ -2184,7 +2184,7 @@ int32_t tsdbQuerySTableByTagCond(TsdbRepoT* tsdb, uint64_t uid, const char* pTag pGroupInfo->numOfTables = taosArrayGetSize(res); pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols, tsdb); - tsdbTrace("%p stable tid:%d, uid:%"PRIu64" query, numOfTables:%d, belong to %d groups", tsdb, pTable->tableId.tid, + tsdbTrace("%p stable tid:%d, uid:%"PRIu64" query, numOfTables:%zu, belong to %zu groups", tsdb, pTable->tableId.tid, pTable->tableId.uid, pGroupInfo->numOfTables, taosArrayGetSize(pGroupInfo->pGroupList)); taosArrayDestroy(res); diff --git a/src/util/inc/tlog.h b/src/util/inc/tlog.h index 284ea924b0..4e063c17bb 100644 --- a/src/util/inc/tlog.h +++ b/src/util/inc/tlog.h @@ -32,8 +32,18 @@ int32_t taosInitLog(char *logName, int32_t numOfLogLines, int32_t maxFiles); void taosCloseLog(); void taosResetLog(); -void taosPrintLog(const char *const flags, int32_t dflag, const char *const format, ...); -void taosPrintLongString(const char *const flags, int32_t dflag, const char *const format, ...); +void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) +#ifdef __GNUC__ + __attribute__((format(printf, 3, 4))) +#endif +; + +void taosPrintLongString(const char * flags, int32_t dflag, const char *format, ...) +#ifdef __GNUC__ + __attribute__((format(printf, 3, 4))) +#endif +; + void taosDumpData(unsigned char *msg, int32_t len); #ifdef __cplusplus diff --git a/src/util/src/tkvstore.c b/src/util/src/tkvstore.c index cf5228c072..07da337bc1 100644 --- a/src/util/src/tkvstore.c +++ b/src/util/src/tkvstore.c @@ -117,7 +117,7 @@ SKVStore *tdOpenKVStore(char *fname, iterFunc iFunc, afterFunc aFunc, void *appH if (tdLoadKVStoreHeader(pStore->sfd, pStore->fsnap, &info) < 0) goto _err; if (ftruncate(pStore->fd, info.size) < 0) { - uError("failed to truncate %s to " PRId64 " size since %s", pStore->fname, info.size, strerror(errno)); + uError("failed to truncate %s to %" PRId64 " size since %s", pStore->fname, info.size, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); goto _err; } @@ -245,7 +245,7 @@ int tdDropKVStoreRecord(SKVStore *pStore, uint64_t uid) { SKVRecord *pRecord = taosHashGet(pStore->map, &uid, sizeof(uid)); if (pRecord == NULL) { - uError("failed to drop KV store record with key " PRIu64 " since not find", uid); + uError("failed to drop KV store record with key %" PRIu64 " since not find", uid); return -1; } @@ -256,7 +256,7 @@ int tdDropKVStoreRecord(SKVStore *pStore, uint64_t uid) { void *pBuf = tdEncodeKVRecord(buf, &rInfo); if (twrite(pStore->fd, buf, POINTER_DISTANCE(pBuf, buf)) < POINTER_DISTANCE(pBuf, buf)) { - uError("failed to write %d bytes to file %s since %s", POINTER_DISTANCE(pBuf, buf), pStore->fname, strerror(errno)); + uError("failed to write %" PRId64 " bytes to file %s since %s", POINTER_DISTANCE(pBuf, buf), pStore->fname, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); return -1; } @@ -456,7 +456,7 @@ static int tdRestoreKVStore(SKVStore *pStore) { ssize_t tsize = tread(pStore->fd, tbuf, sizeof(SKVRecord)); if (tsize == 0) break; if (tsize < sizeof(SKVRecord)) { - uError("failed to read %d bytes from file %s since %s", sizeof(SKVRecord), pStore->fname, strerror(errno)); + uError("failed to read %zu bytes from file %s since %s", sizeof(SKVRecord), pStore->fname, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); goto _err; } @@ -514,13 +514,13 @@ static int tdRestoreKVStore(SKVStore *pStore) { } if (tread(pStore->fd, buf, pRecord->size) < pRecord->size) { - uError("failed to read %d bytes from file %s since %s", pRecord->size, pStore->fname, strerror(errno)); + uError("failed to read %" PRId64 " bytes from file %s since %s", pRecord->size, pStore->fname, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); goto _err; } if (!taosCheckChecksumWhole((uint8_t *)buf, pRecord->size)) { - uError("file %s has checksum error, offset " PRId64 " size %d", pStore->fname, pRecord->offset, pRecord->size); + uError("file %s has checksum error, offset %" PRId64 " size %" PRId64, pStore->fname, pRecord->offset, pRecord->size); terrno = TSDB_CODE_COM_FILE_CORRUPTED; goto _err; } diff --git a/src/util/src/tlog.c b/src/util/src/tlog.c index 39ec89daf4..f5129c96c0 100644 --- a/src/util/src/tlog.c +++ b/src/util/src/tlog.c @@ -309,7 +309,7 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) { return 0; } -void taosPrintLog(const char *const flags, int32_t dflag, const char *const format, ...) { +void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) { if (tsTotalLogDirGB != 0 && tsAvailLogDirGB < tsMinimalLogDirGB) { printf("server disk:%s space remain %.3f GB, total %.1f GB, stop print log.\n", tsLogDir, tsAvailLogDirGB, tsTotalLogDirGB); fflush(stdout); @@ -396,7 +396,7 @@ void taosDumpData(unsigned char *msg, int32_t len) { return; } -void taosPrintLongString(const char *const flags, int32_t dflag, const char *const format, ...) { +void taosPrintLongString(const char *flags, int32_t dflag, const char *format, ...) { if (tsTotalLogDirGB != 0 && tsAvailLogDirGB < tsMinimalLogDirGB) { printf("server disk:%s space remain %.3f GB, total %.1f GB, stop write log.\n", tsLogDir, tsAvailLogDirGB, tsTotalLogDirGB); fflush(stdout); diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index ff0b12d446..8987b82b51 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -439,7 +439,7 @@ void vnodeSetAccess(SDMVgroupAccess *pAccess, int32_t numOfVnodes) { if (pVnode != NULL) { pVnode->accessState = pAccess[i].accessState; if (pVnode->accessState != TSDB_VN_ALL_ACCCESS) { - vTrace("vgId:%d, access state is set to %d", pAccess[i].vgId) + vTrace("vgId:%d, access state is set to %d", pAccess[i].vgId, pVnode->accessState) } vnodeRelease(pVnode); } @@ -734,7 +734,7 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) { cJSON *quorum = cJSON_GetObjectItem(root, "quorum"); if (!quorum || quorum->type != cJSON_Number) { - vError("failed to read vnode cfg, quorum not found", pVnode->vgId); + vError("vgId: %d, failed to read vnode cfg, quorum not found", pVnode->vgId); goto PARSE_OVER; } pVnode->syncCfg.quorum = (int8_t)quorum->valueint; diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c index f9dcd5e6e0..91c6d28e22 100644 --- a/src/vnode/src/vnodeRead.c +++ b/src/vnode/src/vnodeRead.c @@ -86,7 +86,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) { killQueryMsg->free = htons(killQueryMsg->free); killQueryMsg->qhandle = htobe64(killQueryMsg->qhandle); - vWarn("QInfo:%p connection %p broken, kill query", killQueryMsg->qhandle, pReadMsg->rpcMsg.handle); + vWarn("QInfo:%p connection %p broken, kill query", (void*)killQueryMsg->qhandle, pReadMsg->rpcMsg.handle); assert(pReadMsg->rpcMsg.contLen > 0 && killQueryMsg->free == 1); // this message arrived here by means of the query message, so release the vnode is necessary diff --git a/tests/test/c/importPerTable.c b/tests/test/c/importPerTable.c index 15b3fc2572..407a818fa5 100644 --- a/tests/test/c/importPerTable.c +++ b/tests/test/c/importPerTable.c @@ -110,7 +110,7 @@ void createDbAndTable() { for (int64_t t = 0; t < totalTables; ++t) { sprintf(qstr, "create table if not exists %s%ld using %s tags(%ld)", stableName, t, stableName, t); if (taos_query(con, qstr)) { - pError("failed to create table %s%d, reason:%s", stableName, t, taos_errstr(con)); + pError("failed to create table %s%" PRId64 ", reason:%s", stableName, t, taos_errstr(con)); exit(0); } } @@ -141,7 +141,7 @@ void insertData() { gettimeofday(&systemTime, NULL); st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; - pPrint("%d threads are spawned to import data", numOfThreads); + pPrint("%" PRId64 " threads are spawned to import data", numOfThreads); pthread_attr_t thattr; pthread_attr_init(&thattr); @@ -323,8 +323,8 @@ void shellParseArgument(int argc, char *argv[]) { pPrint("%spointsPerTable:%" PRId64 "%s", GREEN, pointsPerTable, NC); pPrint("%snumOfThreads:%" PRId64 "%s", GREEN, numOfThreads, NC); pPrint("%snumOfTablesPerThread:%" PRId64 "%s", GREEN, numOfTablesPerThread, NC); - pPrint("%scache:%" PRId64 "%s", GREEN, cache, NC); - pPrint("%stables:%" PRId64 "%s", GREEN, tables, NC); + pPrint("%scache:%d%s", GREEN, cache, NC); + pPrint("%stables:%d%s", GREEN, tables, NC); pPrint("%sdbName:%s%s", GREEN, dbName, NC); pPrint("%stableName:%s%s", GREEN, stableName, NC); pPrint("%sstart to run%s", GREEN, NC); diff --git a/tests/test/c/insertPerRow.c b/tests/test/c/insertPerRow.c index 906956b998..7a97b21e0a 100644 --- a/tests/test/c/insertPerRow.c +++ b/tests/test/c/insertPerRow.c @@ -119,7 +119,7 @@ void insertData() { gettimeofday(&systemTime, NULL); st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; - pPrint("%d threads are spawned to insert data", numOfThreads); + pPrint("%" PRId64 " threads are spawned to insert data", numOfThreads); pthread_attr_t thattr; pthread_attr_init(&thattr); @@ -202,7 +202,7 @@ void *syncTest(void *param) { 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, taos_errstr(con)); + pError("failed to create table %s%" PRId64 ", reason:%s", stableName, t, taos_errstr(con)); exit(0); } taos_free_result(pSql); @@ -348,8 +348,8 @@ void shellParseArgument(int argc, char *argv[]) { pPrint("%spointsPerTable:%" PRId64 "%s", GREEN, pointsPerTable, NC); pPrint("%snumOfThreads:%" PRId64 "%s", GREEN, numOfThreads, NC); pPrint("%snumOfTablesPerThread:%" PRId64 "%s", GREEN, numOfTablesPerThread, NC); - pPrint("%scache:%" PRId64 "%s", GREEN, cache, NC); - pPrint("%stables:%" PRId64 "%s", GREEN, tables, NC); + pPrint("%scache:%" PRId32 "%s", GREEN, cache, NC); + pPrint("%stables:%" PRId32 "%s", GREEN, tables, NC); pPrint("%sdbName:%s%s", GREEN, dbName, NC); pPrint("%stableName:%s%s", GREEN, stableName, NC); pPrint("%sstart to run%s", GREEN, NC); diff --git a/tests/test/c/insertPerTable.c b/tests/test/c/insertPerTable.c index af92927a9e..00e1256686 100644 --- a/tests/test/c/insertPerTable.c +++ b/tests/test/c/insertPerTable.c @@ -121,7 +121,7 @@ void createDbAndTable() { pSql = taos_query(con, qstr); code = taos_errno(pSql); if (code != 0) { - pError("failed to create table %s%d, reason:%s", stableName, t, taos_errstr(con)); + pError("failed to create table %s%" PRId64 ", reason:%s", stableName, t, taos_errstr(con)); exit(0); } taos_stop_query(pSql); @@ -158,10 +158,10 @@ void insertData() { st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; if (rowsPerTable <= 0) { - pPrint("not insert data for rowsPerTable is :%d", rowsPerTable); + pPrint("not insert data for rowsPerTable is :%" PRId64, rowsPerTable); exit(0); } else { - pPrint("%d threads are spawned to insert data", numOfThreads); + pPrint("%" PRId64 " threads are spawned to insert data", numOfThreads); } pthread_attr_t thattr; @@ -348,8 +348,8 @@ void shellParseArgument(int argc, char *argv[]) { pPrint("%spointsPerTable:%" PRId64 "%s", GREEN, pointsPerTable, NC); pPrint("%snumOfThreads:%" PRId64 "%s", GREEN, numOfThreads, NC); pPrint("%snumOfTablesPerThread:%" PRId64 "%s", GREEN, numOfTablesPerThread, NC); - pPrint("%scache:%" PRId64 "%s", GREEN, cache, NC); - pPrint("%stables:%" PRId64 "%s", GREEN, tables, NC); + pPrint("%scache:%" PRId32 "%s", GREEN, cache, NC); + pPrint("%stables:%" PRId32 "%s", GREEN, tables, NC); pPrint("%sdbName:%s%s", GREEN, dbName, NC); pPrint("%stableName:%s%s", GREEN, stableName, NC); pPrint("%sstart to run%s", GREEN, NC); From 5a2542f84adeae2dbfd02dc1b9caa045eb6258af Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 18 Jun 2020 16:11:28 +0000 Subject: [PATCH 8/9] [TD-543] coverity scan --- src/mnode/src/mnodeDb.c | 4 +++- src/mnode/src/mnodeDnode.c | 12 ++++++++---- src/mnode/src/mnodeShow.c | 2 +- src/mnode/src/mnodeTable.c | 29 +++++++++++++++++------------ src/mnode/src/mnodeUser.c | 4 ++-- src/mnode/src/mnodeVgroup.c | 12 ++++++++---- 6 files changed, 39 insertions(+), 24 deletions(-) diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 5cb0096e8d..081fe28954 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -960,6 +960,8 @@ static int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg) { } static int32_t mnodeDropDb(SMnodeMsg *pMsg) { + if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR; + SDbObj *pDb = pMsg->pDb; mPrint("db:%s, drop db from sdb", pDb->name); @@ -973,7 +975,7 @@ static int32_t mnodeDropDb(SMnodeMsg *pMsg) { int32_t code = sdbDeleteRow(&oper); if (code == TSDB_CODE_SUCCESS) { mLPrint("db:%s, is dropped by %s", pDb->name, mnodeGetUserFromMsg(pMsg)); - if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; + code = TSDB_CODE_MND_ACTION_IN_PROGRESS; } return code; diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index 21de887488..bd95b0cc51 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -90,11 +90,12 @@ static int32_t mnodeDnodeActionDelete(SSdbOper *pOper) { static int32_t mnodeDnodeActionUpdate(SSdbOper *pOper) { SDnodeObj *pDnode = pOper->pObj; SDnodeObj *pSaved = mnodeGetDnode(pDnode->dnodeId); - if (pDnode != pSaved && pDnode != NULL && pSaved != NULL) { + if (pSaved != NULL && pDnode != pSaved) { memcpy(pSaved, pDnode, pOper->rowSize); free(pDnode); + mnodeDecDnodeRef(pSaved); } - mnodeDecDnodeRef(pSaved); + return TSDB_CODE_SUCCESS; } @@ -120,8 +121,10 @@ static int32_t mnodeDnodeActionRestored() { mPrint("dnode first deploy, create dnode:%s", tsLocalEp); mnodeCreateDnode(tsLocalEp, NULL); SDnodeObj *pDnode = mnodeGetDnodeByEp(tsLocalEp); - mnodeAddMnode(pDnode->dnodeId); - mnodeDecDnodeRef(pDnode); + if (pDnode != NULL) { + mnodeAddMnode(pDnode->dnodeId); + mnodeDecDnodeRef(pDnode); + } } return TSDB_CODE_SUCCESS; @@ -371,6 +374,7 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { bool ret = mnodeCheckClusterCfgPara(&(pStatus->clusterCfg)); if (false == ret) { mnodeDecDnodeRef(pDnode); + rpcFreeCont(pRsp); mError("dnode %s cluster cfg parameters inconsistent", pStatus->dnodeEp); return TSDB_CODE_MND_CLUSTER_CFG_INCONSISTENT; } diff --git a/src/mnode/src/mnodeShow.c b/src/mnode/src/mnodeShow.c index 0ff4da42c5..fb283eb61d 100644 --- a/src/mnode/src/mnodeShow.c +++ b/src/mnode/src/mnodeShow.c @@ -122,7 +122,7 @@ static int32_t mnodeProcessShowMsg(SMnodeMsg *pMsg) { SShowObj *pShow = (SShowObj *) calloc(1, showObjSize); pShow->type = pShowMsg->type; pShow->payloadLen = htons(pShowMsg->payloadLen); - strcpy(pShow->db, pShowMsg->db); + tstrncpy(pShow->db, pShowMsg->db, TSDB_DB_NAME_LEN); memcpy(pShow->payload, pShowMsg->payload, pShow->payloadLen); pShow = mnodePutShowObj(pShow, showObjSize); diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 6eb9e07dd4..7019cc942c 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -443,7 +443,7 @@ static int32_t mnodeSuperTableActionDelete(SSdbOper *pOper) { static int32_t mnodeSuperTableActionUpdate(SSdbOper *pOper) { SSuperTableObj *pNew = pOper->pObj; SSuperTableObj *pTable = mnodeGetSuperTable(pNew->info.tableId); - if (pTable != pNew) { + if (pTable != NULL && pTable != pNew) { void *oldTableId = pTable->info.tableId; void *oldSchema = pTable->schema; void *oldVgHash = pTable->vgHash; @@ -457,8 +457,10 @@ static int32_t mnodeSuperTableActionUpdate(SSdbOper *pOper) { free(pNew); free(oldTableId); free(oldSchema); + + mnodeDecTableRef(pTable); } - mnodeDecTableRef(pTable); + return TSDB_CODE_SUCCESS; } @@ -779,6 +781,8 @@ static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *pMsg) { } static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) { + if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR; + SCMCreateTableMsg *pCreate = pMsg->rpcMsg.pCont; SSuperTableObj * pStable = calloc(1, sizeof(SSuperTableObj)); if (pStable == NULL) { @@ -830,13 +834,15 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) { } else { mLPrint("app:%p:%p, table:%s, is created, tags:%d fields:%d", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId, pStable->numOfTags, pStable->numOfColumns); - if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; + code = TSDB_CODE_MND_ACTION_IN_PROGRESS; } return code; } static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) { + if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR; + SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable; if (pStable->numOfTables != 0) { SHashMutableIterator *pIter = taosHashCreateIter(pStable->vgHash); @@ -873,7 +879,7 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) { int32_t code = sdbDeleteRow(&oper); if (code == TSDB_CODE_SUCCESS) { mLPrint("stable:%s, is dropped from sdb, result:%s", pStable->info.tableId, tstrerror(code)); - if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; + code = TSDB_CODE_MND_ACTION_IN_PROGRESS; } return code; @@ -1418,7 +1424,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) { SDnodeObj *pDnode = pVgroup->vnodeGid[vn].pDnode; if (pDnode == NULL) break; - strncpy(pVgroupInfo->vgroups[vgSize].ipAddr[vn].fqdn, pDnode->dnodeFqdn, tListLen(pDnode->dnodeFqdn)); + tstrncpy(pVgroupInfo->vgroups[vgSize].ipAddr[vn].fqdn, pDnode->dnodeFqdn, TSDB_FQDN_LEN); pVgroupInfo->vgroups[vgSize].ipAddr[vn].port = htons(pDnode->dnodePort); pVgroupInfo->vgroups[vgSize].numOfIps++; @@ -1462,10 +1468,10 @@ static void *mnodeBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableO int32_t contLen = 0; if (pTable->info.type == TSDB_CHILD_TABLE) { totalCols = pTable->superTable->numOfColumns + pTable->superTable->numOfTags; - contLen = sizeof(SMDCreateTableMsg) + totalCols * sizeof(SSchema) + tagDataLen + pTable->sqlLen; + contLen = sizeof(SMDCreateTableMsg) + totalCols * sizeof(SSchema) + pTable->sqlLen; if (pMsg != NULL) { pTagData = (STagData *)pMsg->schema; - tagDataLen = ntohl(pTagData->dataLen); + tagDataLen = htonl(pTagData->dataLen); contLen += tagDataLen; } } else { @@ -1714,7 +1720,7 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) { return TSDB_CODE_MND_OUT_OF_MEMORY; } - strcpy(pDrop->tableId, pTable->info.tableId); + tstrncpy(pDrop->tableId, pTable->info.tableId, TSDB_TABLE_ID_LEN); pDrop->vgId = htonl(pTable->vgId); pDrop->contLen = htonl(sizeof(SMDDropTableMsg)); pDrop->sid = htonl(pTable->sid); @@ -1873,7 +1879,7 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) { pMeta->sid = htonl(pTable->sid); pMeta->precision = pDb->cfg.precision; pMeta->tableType = pTable->info.type; - strncpy(pMeta->tableId, pTable->info.tableId, strlen(pTable->info.tableId)); + tstrncpy(pMeta->tableId, pTable->info.tableId, TSDB_TABLE_ID_LEN); if (pTable->info.type == TSDB_CHILD_TABLE) { pMeta->sversion = htons(pTable->superTable->sversion); @@ -1916,7 +1922,7 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) { SCMTableInfoMsg *pInfo = pMsg->rpcMsg.pCont; STagData *pTag = (STagData *)pInfo->tags; - int32_t contLen = sizeof(SCMCreateTableMsg) + offsetof(STagData, data) + ntohl(pTag->dataLen); + int32_t contLen = sizeof(SCMCreateTableMsg) + offsetof(STagData, data) + htonl(pTag->dataLen); SCMCreateTableMsg *pCreateMsg = rpcMallocCont(contLen); if (pCreateMsg == NULL) { mError("app:%p:%p, table:%s, failed to create table while get meta info, no enough memory", pMsg->rpcMsg.ahandle, @@ -2380,8 +2386,7 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) { if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pAlter->tableId); if (pMsg->pTable == NULL) { - mError("app:%p:%p, table:%s, failed to alter table, table not exist", pMsg->rpcMsg.ahandle, pMsg, - pMsg->pTable->tableId); + mError("app:%p:%p, table:%s, failed to alter table, table not exist", pMsg->rpcMsg.ahandle, pMsg, pAlter->tableId); return TSDB_CODE_MND_INVALID_TABLE_NAME; } diff --git a/src/mnode/src/mnodeUser.c b/src/mnode/src/mnodeUser.c index eb79d6acb6..07de4cf641 100644 --- a/src/mnode/src/mnodeUser.c +++ b/src/mnode/src/mnodeUser.c @@ -216,7 +216,7 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) { } pUser = calloc(1, sizeof(SUserObj)); - strcpy(pUser->user, name); + tstrncpy(pUser->user, name, TSDB_USER_LEN); taosEncryptPass((uint8_t*) pass, strlen(pass), pUser->pass); strcpy(pUser->acct, pAcct->user); pUser->createdTime = taosGetTimestampMs(); @@ -368,7 +368,7 @@ SUserObj *mnodeGetUserFromConn(void *pConn) { char *mnodeGetUserFromMsg(void *pMsg) { SMnodeMsg *pMnodeMsg = pMsg; - if (pMnodeMsg != NULL &&pMnodeMsg->pUser != NULL) { + if (pMnodeMsg != NULL && pMnodeMsg->pUser != NULL) { return pMnodeMsg->pUser->user; } else { return "system"; diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 43b47764b9..8df28aeec6 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -133,7 +133,7 @@ static void mnodeVgroupUpdateIdPool(SVgObj *pVgroup) { taosUpdateIdPool(pVgroup->idPool, pDb->cfg.maxTables); int32_t size = sizeof(SChildTableObj *) * pDb->cfg.maxTables; pVgroup->tableList = (SChildTableObj **)realloc(pVgroup->tableList, size); - memset(pVgroup->tableList + oldTables, 0, (pDb->cfg.maxTables - oldTables) * sizeof(SChildTableObj **)); + memset(pVgroup->tableList + oldTables, 0, (pDb->cfg.maxTables - oldTables) * sizeof(SChildTableObj *)); } } } @@ -252,7 +252,9 @@ void mnodeUpdateVgroup(SVgObj *pVgroup) { .pObj = pVgroup }; - sdbUpdateRow(&oper); + if (sdbUpdateRow(&oper) != TSDB_CODE_SUCCESS) { + mError("vgId:%d, failed to update vgroup", pVgroup->vgId); + } mnodeSendCreateVgroupMsg(pVgroup, NULL); } @@ -323,8 +325,10 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) { } int32_t mnodeCreateVgroup(SMnodeMsg *pMsg, SDbObj *pDb) { + if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR; + SVgObj *pVgroup = (SVgObj *)calloc(1, sizeof(SVgObj)); - strcpy(pVgroup->dbName, pDb->name); + tstrncpy(pVgroup->dbName, pDb->name, TSDB_DB_NAME_LEN); pVgroup->numOfVnodes = pDb->cfg.replications; pVgroup->createdTime = taosGetTimestampMs(); pVgroup->accessState = TSDB_VN_ALL_ACCCESS; @@ -350,7 +354,7 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg, SDbObj *pDb) { pMsg->pVgroup = NULL; tfree(pVgroup); } else { - if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; + code = TSDB_CODE_MND_ACTION_IN_PROGRESS; } return code; From 894fc1eddbcfbada964375e26c84ef128f1956b7 Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Fri, 19 Jun 2020 01:08:26 +0000 Subject: [PATCH 9/9] reference count --- src/rpc/src/rpcMain.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 3e89cf76a5..69db734588 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -108,7 +108,7 @@ typedef struct SRpcConn { uint16_t outTranId; // outgoing transcation ID uint16_t inTranId; // transcation ID for incoming msg uint8_t outType; // message type for outgoing request - char inType; // message type for incoming request + uint8_t inType; // message type for incoming request void *chandle; // handle passed by TCP/UDP connection layer void *ahandle; // handle provided by upper app layter int retry; // number of retry for sending request @@ -394,6 +394,8 @@ void rpcSendResponse(const SRpcMsg *pRsp) { if ( pConn->inType == 0 || pConn->user[0] == 0 ) { tTrace("%s, connection is already released, rsp wont be sent", pConn->info); rpcUnlockConn(pConn); + rpcFreeCont(pMsg->pCont); + rpcDecRef(pRpc); return; } @@ -885,6 +887,7 @@ static void rpcReportBrokenLinkToServer(SRpcConn *pConn) { SRpcInfo *pRpc = pConn->pRpc; // if there are pending request, notify the app + rpcAddRef(pRpc); tTrace("%s, notify the server app, connection is gone", pConn->info); SRpcMsg rpcMsg;