From 0bb41e5bcaa5fc4a2574d0dc76d60e63362625ed Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 6 Sep 2019 12:18:18 +0800 Subject: [PATCH] Use assert in code locations that can cause file corruption and set global configuration items --- CMakeLists.txt | 1 - src/inc/tglobalcfg.h | 15 ++++++++------- src/system/src/vnodeFile.c | 8 ++++---- src/util/src/tglobalcfg.c | 29 ++++++++++++++++------------- src/util/src/tlog.c | 2 +- 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1eb30bb68..06048042a2 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,6 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") SET(TD_LINUX TRUE) ADD_DEFINITIONS(-DLINUX) - IF (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") ELSE () diff --git a/src/inc/tglobalcfg.h b/src/inc/tglobalcfg.h index 43bdce942c..222fbccb55 100644 --- a/src/inc/tglobalcfg.h +++ b/src/inc/tglobalcfg.h @@ -72,9 +72,10 @@ extern float tsNumOfThreadsPerCore; extern float tsRatioOfQueryThreads; extern char tsInternalIp[]; extern char tsServerIpStr[]; -extern int tsNumOfVnodesPerCore; -extern int tsNumOfTotalVnodes; +extern short tsNumOfVnodesPerCore; +extern short tsNumOfTotalVnodes; extern int tsShellsPerVnode; +extern short tsCheckHeaderFile; extern int tsSessionsPerVnode; extern int tsAverageCacheBlocks; @@ -84,11 +85,11 @@ extern int tsRowsInFileBlock; extern float tsFileBlockMinPercent; extern short tsNumOfBlocksPerMeter; -extern int tsCommitTime; // seconds -extern int tsCommitLog; -extern int tsAsyncLog; -extern int tsCompression; -extern int tsDaysPerFile; +extern short tsCommitTime; // seconds +extern short tsCommitLog; +extern short tsAsyncLog; +extern short tsCompression; +extern short tsDaysPerFile; extern int tsDaysToKeep; extern int tsReplications; diff --git a/src/system/src/vnodeFile.c b/src/system/src/vnodeFile.c index 69957a0b58..bde2187021 100644 --- a/src/system/src/vnodeFile.c +++ b/src/system/src/vnodeFile.c @@ -390,10 +390,10 @@ void vnodeCloseCommitFiles(SVnodeObj *pVnode) { int ret; // Check new if new header file is correct -#ifdef _CHECK_HEADER_FILE_ - assert(vnodeCheckNewHeaderFile(pVnode->nfd, pVnode) == 0); -#endif - + if (tsCheckHeaderFile != 0) { + assert(vnodeCheckNewHeaderFile(pVnode->nfd, pVnode) == 0); + } + close(pVnode->nfd); pVnode->nfd = 0; diff --git a/src/util/src/tglobalcfg.c b/src/util/src/tglobalcfg.c index 9dbf97e49e..f9ace3090f 100644 --- a/src/util/src/tglobalcfg.c +++ b/src/util/src/tglobalcfg.c @@ -70,8 +70,9 @@ float tsNumOfThreadsPerCore = 1.0; float tsRatioOfQueryThreads = 0.5; char tsInternalIp[TSDB_IPv4ADDR_LEN] = {0}; char tsServerIpStr[TSDB_IPv4ADDR_LEN] = "0.0.0.0"; -int tsNumOfVnodesPerCore = 8; -int tsNumOfTotalVnodes = 0; +short tsNumOfVnodesPerCore = 8; +short tsNumOfTotalVnodes = 0; +short tsCheckHeaderFile = 0; int tsSessionsPerVnode = 1000; int tsCacheBlockSize = 16384; // 256 columns @@ -81,10 +82,10 @@ int tsRowsInFileBlock = 4096; float tsFileBlockMinPercent = 0.05; short tsNumOfBlocksPerMeter = 100; -int tsCommitTime = 3600; // seconds -int tsCommitLog = 1; -int tsCompression = 2; -int tsDaysPerFile = 10; +short tsCommitTime = 3600; // seconds +short tsCommitLog = 1; +short tsCompression = 2; +short tsDaysPerFile = 10; int tsDaysToKeep = 3650; int tsMaxShellConns = 2000; @@ -418,10 +419,12 @@ void tsInitGlobalConfig() { TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT, 0, 10, 0, TSDB_CFG_UTYPE_NONE); tsInitConfigOption(cfg++, "ratioOfQueryThreads", &tsRatioOfQueryThreads, TSDB_CFG_VTYPE_FLOAT, TSDB_CFG_CTYPE_B_CONFIG, 0.1, 0.9, 0, TSDB_CFG_UTYPE_NONE); - tsInitConfigOption(cfg++, "numOfVnodesPerCore", &tsNumOfVnodesPerCore, TSDB_CFG_VTYPE_INT, + tsInitConfigOption(cfg++, "numOfVnodesPerCore", &tsNumOfVnodesPerCore, TSDB_CFG_VTYPE_SHORT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 1, 64, 0, TSDB_CFG_UTYPE_NONE); - tsInitConfigOption(cfg++, "numOfTotalVnodes", &tsNumOfTotalVnodes, TSDB_CFG_VTYPE_INT, TSDB_CFG_CTYPE_B_CONFIG, 0, + tsInitConfigOption(cfg++, "numOfTotalVnodes", &tsNumOfTotalVnodes, TSDB_CFG_VTYPE_SHORT, TSDB_CFG_CTYPE_B_CONFIG, 0, TSDB_MAX_VNODES, 0, TSDB_CFG_UTYPE_NONE); + tsInitConfigOption(cfg++, "checkHeaderFile", &tsCheckHeaderFile, TSDB_CFG_VTYPE_SHORT, + TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 0, 1, 0, TSDB_CFG_UTYPE_NONE); tsInitConfigOption(cfg++, "tables", &tsSessionsPerVnode, TSDB_CFG_VTYPE_INT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 4, 220000, 0, TSDB_CFG_UTYPE_NONE); tsInitConfigOption(cfg++, "cache", &tsCacheBlockSize, TSDB_CFG_VTYPE_INT, @@ -442,7 +445,7 @@ void tsInitGlobalConfig() { TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT, 100, 3000, 0, TSDB_CFG_UTYPE_MS); tsInitConfigOption(cfg++, "rpcMaxTime", &tsRpcMaxTime, TSDB_CFG_VTYPE_INT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT, 100, 7200, 0, TSDB_CFG_UTYPE_SECOND); - tsInitConfigOption(cfg++, "ctime", &tsCommitTime, TSDB_CFG_VTYPE_INT, + tsInitConfigOption(cfg++, "ctime", &tsCommitTime, TSDB_CFG_VTYPE_SHORT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 30, 40960, 0, TSDB_CFG_UTYPE_SECOND); tsInitConfigOption(cfg++, "statusInterval", &tsStatusInterval, TSDB_CFG_VTYPE_INT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 1, 10, 0, TSDB_CFG_UTYPE_SECOND); @@ -474,13 +477,13 @@ void tsInitGlobalConfig() { tsInitConfigOption(cfg++, "retryStreamCompDelay", &tsStreamCompRetryDelay, TSDB_CFG_VTYPE_INT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 10, 1000000000, 0, TSDB_CFG_UTYPE_MS); - tsInitConfigOption(cfg++, "clog", &tsCommitLog, TSDB_CFG_VTYPE_INT, + tsInitConfigOption(cfg++, "clog", &tsCommitLog, TSDB_CFG_VTYPE_SHORT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 0, 1, 0, TSDB_CFG_UTYPE_NONE); - tsInitConfigOption(cfg++, "comp", &tsCompression, TSDB_CFG_VTYPE_INT, + tsInitConfigOption(cfg++, "comp", &tsCompression, TSDB_CFG_VTYPE_SHORT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 0, 2, 0, TSDB_CFG_UTYPE_NONE); // database configs - tsInitConfigOption(cfg++, "days", &tsDaysPerFile, TSDB_CFG_VTYPE_INT, + tsInitConfigOption(cfg++, "days", &tsDaysPerFile, TSDB_CFG_VTYPE_SHORT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 1, 365, 0, TSDB_CFG_UTYPE_NONE); tsInitConfigOption(cfg++, "keep", &tsDaysToKeep, TSDB_CFG_VTYPE_INT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, 1, 365000, 0, TSDB_CFG_UTYPE_NONE); @@ -539,7 +542,7 @@ void tsInitGlobalConfig() { tsInitConfigOption(cfg++, "numOfLogLines", &tsNumOfLogLines, TSDB_CFG_VTYPE_INT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT, 10000, 2000000000, 0, TSDB_CFG_UTYPE_NONE); - tsInitConfigOption(cfg++, "asyncLog", &tsAsyncLog, TSDB_CFG_VTYPE_INT, + tsInitConfigOption(cfg++, "asyncLog", &tsAsyncLog, TSDB_CFG_VTYPE_SHORT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT, 0, 1, 0, TSDB_CFG_UTYPE_NONE); tsInitConfigOption(cfg++, "debugFlag", &debugFlag, TSDB_CFG_VTYPE_INT, diff --git a/src/util/src/tlog.c b/src/util/src/tlog.c index 397c17994d..e3a4a54786 100644 --- a/src/util/src/tlog.c +++ b/src/util/src/tlog.c @@ -53,7 +53,7 @@ typedef struct { } SLogBuff; int uDebugFlag = 131; // all the messages -int tsAsyncLog = 1; +short tsAsyncLog = 1; static SLogBuff *logHandle; static int taosLogFileNum = 1; -- GitLab