From a5b1ba1b9353e3afbabef973912f6607ea4b4dca Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 6 May 2020 23:45:48 +0800 Subject: [PATCH 01/41] fix compile error for Ubuntu 20.04 [TD-210] --- src/client/src/tscLocal.c | 6 ++++-- src/client/src/tscSQLParser.c | 4 ++-- src/kit/taosdemo/taosdemo.c | 2 +- src/mnode/src/mgmtDb.c | 6 ++++-- src/mnode/src/mgmtDnode.c | 2 +- src/mnode/src/mgmtUser.c | 11 +++++++---- src/mnode/src/mgmtVgroup.c | 5 +++-- src/os/linux/CMakeLists.txt | 2 ++ src/os/linux/inc/os.h | 8 +------- src/os/linux/inc/tsysctl.h | 30 ++++++++++++++++++++++++++++++ src/os/linux/src/linuxSysPara.c | 1 + tests/tsim/src/simExe.c | 7 ++++--- 12 files changed, 60 insertions(+), 24 deletions(-) create mode 100644 src/os/linux/inc/tsysctl.h diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index 600ef88344..5ae226a577 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -156,7 +156,8 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) { pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 3); if (i >= tscGetNumOfColumns(pMeta) && tscGetNumOfTags(pMeta) != 0) { char* output = pRes->data + tscFieldInfoGetOffset(pQueryInfo, 3) * totalNumOfRows + pField->bytes * i; - STR_WITH_SIZE_TO_VARSTR(output, "TAG", 3); + const char *src = "TAG"; + STR_WITH_SIZE_TO_VARSTR(output, src, strlen(src)); } } @@ -191,7 +192,8 @@ static int32_t tscSetValueToResObj(SSqlObj *pSql, int32_t rowLen) { // tag value pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, 3); char *target = pRes->data + tscFieldInfoGetOffset(pQueryInfo, 3) * totalNumOfRows + pField->bytes * i; - STR_WITH_SIZE_TO_VARSTR(target, "TAG", 3); + const char *src = "TAG"; + STR_WITH_SIZE_TO_VARSTR(target, src, strlen(src)); pTagValue += pSchema[i].bytes; } diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 12032725c3..b33220fb81 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2222,14 +2222,14 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { char* portStr = strtok(NULL, &delim); if (!validateIpAddress(ipStr, strlen(ipStr))) { - memset(pCmd->payload, 0, tListLen(pCmd->payload)); + memset(pCmd->payload, 0, strlen(pCmd->payload)); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } uint16_t port = (uint16_t)strtol(portStr, NULL, 10); if (port <= 0 || port > 65535) { - memset(pCmd->payload, 0, tListLen(pCmd->payload)); + memset(pCmd->payload, 0, strlen(pCmd->payload)); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 937c8d177d..33b76cea2d 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -634,7 +634,7 @@ void *readMetric(void *sarg) { fprintf(fp, "Querying On %d records:\n", totalData); for (int j = 0; j < n; j++) { - char condition[BUFFER_SIZE] = "\0"; + char condition[BUFFER_SIZE - 30] = "\0"; char tempS[BUFFER_SIZE] = "\0"; int m = 10 < num_of_tables ? 10 : num_of_tables; diff --git a/src/mnode/src/mgmtDb.c b/src/mnode/src/mgmtDb.c index 9eb8b8dce1..4fd3df1775 100644 --- a/src/mnode/src/mgmtDb.c +++ b/src/mnode/src/mgmtDb.c @@ -677,9 +677,11 @@ static int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void * pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; if (pDb->status == TSDB_DB_STATUS_READY) { - STR_WITH_SIZE_TO_VARSTR(pWrite, "ready", 5); + const char *src = "ready"; + STR_WITH_SIZE_TO_VARSTR(pWrite, src, strlen(src)); } else { - STR_WITH_SIZE_TO_VARSTR(pWrite, "dropping", 8); + const char *src = "dropping"; + STR_WITH_SIZE_TO_VARSTR(pWrite, src, strlen(src)); } cols++; diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index bb98e1c3e6..9bb48b7e95 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -225,7 +225,7 @@ void mgmtProcessCfgDnodeMsg(SQueuedMsg *pMsg) { if (pCmCfgDnode->ep[0] == 0) { strcpy(pCmCfgDnode->ep, tsLocalEp); } else { - strcpy(pCmCfgDnode->ep, pCmCfgDnode->ep); + // TODO temporary disabled for compiling: strcpy(pCmCfgDnode->ep, pCmCfgDnode->ep); } if (strcmp(pMsg->pUser->user, "root") != 0) { diff --git a/src/mnode/src/mgmtUser.c b/src/mnode/src/mgmtUser.c index b4dd58cb3b..1dd572ed9d 100644 --- a/src/mnode/src/mgmtUser.c +++ b/src/mnode/src/mgmtUser.c @@ -309,11 +309,14 @@ static int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; if (pUser->superAuth) { - STR_WITH_SIZE_TO_VARSTR(pWrite, "super", 5); + const char *src = "super"; + STR_WITH_SIZE_TO_VARSTR(pWrite, src, strlen(src)); } else if (pUser->writeAuth) { - STR_WITH_SIZE_TO_VARSTR(pWrite, "writable", 8); + const char *src = "writable"; + STR_WITH_SIZE_TO_VARSTR(pWrite, src, strlen(src)); } else { - STR_WITH_SIZE_TO_VARSTR(pWrite, "readable", 8); + const char *src = "readable"; + STR_WITH_SIZE_TO_VARSTR(pWrite, src, strlen(src)); } cols++; @@ -525,4 +528,4 @@ void mgmtDropAllUsers(SAcctObj *pAcct) { } mTrace("acct:%s, all users:%d is dropped from sdb", pAcct->user, numOfUsers); -} \ No newline at end of file +} diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index f83268e760..e6fad58b71 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -495,11 +495,12 @@ int32_t mgmtRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pCo cols++; } else { pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - STR_WITH_SIZE_TO_VARSTR(pWrite, "NULL", 4); + const char *src = "NULL"; + STR_WITH_SIZE_TO_VARSTR(pWrite, src, strlen(src)); cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - STR_WITH_SIZE_TO_VARSTR(pWrite, "NULL", 4); + STR_WITH_SIZE_TO_VARSTR(pWrite, src, strlen(src)); cols++; } } diff --git a/src/os/linux/CMakeLists.txt b/src/os/linux/CMakeLists.txt index 83d717f905..7be4a13f25 100644 --- a/src/os/linux/CMakeLists.txt +++ b/src/os/linux/CMakeLists.txt @@ -12,3 +12,5 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) ADD_LIBRARY(os ${SRC}) TARGET_LINK_LIBRARIES(os m rt) ENDIF () + +SET_SOURCE_FILES_PROPERTIES(src/linuxSysPara.c PROPERTIES COMPILE_FLAGS -w) diff --git a/src/os/linux/inc/os.h b/src/os/linux/inc/os.h index 27a8363050..cab899753d 100644 --- a/src/os/linux/inc/os.h +++ b/src/os/linux/inc/os.h @@ -23,13 +23,6 @@ extern "C" { #include #include -#ifndef _ALPINE - #include - #include -#else - #include -#endif - #include #include #include @@ -82,6 +75,7 @@ extern "C" { #include #include #include +#include #define taosCloseSocket(x) \ { \ diff --git a/src/os/linux/inc/tsysctl.h b/src/os/linux/inc/tsysctl.h new file mode 100644 index 0000000000..559d5653ee --- /dev/null +++ b/src/os/linux/inc/tsysctl.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_TSYSCTL_H +#define TDENGINE_TSYSCTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ALPINE + #include + #include +#else + #include +#endif + +#endif diff --git a/src/os/linux/src/linuxSysPara.c b/src/os/linux/src/linuxSysPara.c index f43ed44a4b..55d1e198e1 100644 --- a/src/os/linux/src/linuxSysPara.c +++ b/src/os/linux/src/linuxSysPara.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "os.h" +#include "tsysctl.h" #include "tconfig.h" #include "tglobal.h" #include "tulog.h" diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index d0d798343a..a93d1bb262 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -119,7 +119,7 @@ char *simGetVariable(SScript *script, char *varName, int varLen) { int simExecuteExpression(SScript *script, char *exp) { char *op1, *op2, *var1, *var2, *var3, *rest; int op1Len, op2Len, var1Len, var2Len, var3Len, val0, val1; - char t0[512], t1[512], t2[512], t3[512]; + char t0[512], t1[512], t2[512], t3[1024]; int result; rest = paGetToken(exp, &var1, &var1Len); @@ -310,14 +310,15 @@ void simStoreSystemContentResult(SScript *script, char *filename) { bool simExecuteSystemContentCmd(SScript *script, char *option) { char buf[4096] = {0}; + char buf1[4096 + 512] = {0}; char filename[400] = {0}; sprintf(filename, "%s/%s.tmp", tsScriptDir, script->fileName); sprintf(buf, "cd %s; ", tsScriptDir); simVisuallizeOption(script, option, buf + strlen(buf)); - sprintf(buf, "%s > %s 2>/dev/null", buf, filename); + sprintf(buf1, "%s > %s 2>/dev/null", buf, filename); - sprintf(script->system_exit_code, "%d", system(buf)); + sprintf(script->system_exit_code, "%d", system(buf1)); simStoreSystemContentResult(script, filename); script->linePos++; From 47fa4ac4587fb602fe8f2f93bb466f3be64b56d4 Mon Sep 17 00:00:00 2001 From: liu0x54 Date: Thu, 7 May 2020 06:00:58 +0000 Subject: [PATCH 02/41] [TD-228] fix python connector to support binary interface change --- src/connector/python/linux/python2/taos/cinterface.py | 5 ++++- src/connector/python/windows/python2/taos/cinterface.py | 5 ++++- src/connector/python/windows/python3/taos/cinterface.py | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/connector/python/linux/python2/taos/cinterface.py b/src/connector/python/linux/python2/taos/cinterface.py index d9460efb21..055c4a16df 100644 --- a/src/connector/python/linux/python2/taos/cinterface.py +++ b/src/connector/python/linux/python2/taos/cinterface.py @@ -146,6 +146,7 @@ class CTaosInterface(object): libtaos.taos_errstr.restype = ctypes.c_char_p libtaos.taos_subscribe.restype = ctypes.c_void_p libtaos.taos_consume.restype = ctypes.c_void_p + libtaos.taos_fetch_lengths.restype = ctypes.c_void_p def __init__(self, config=None): ''' @@ -314,6 +315,8 @@ class CTaosInterface(object): isMicro = (CTaosInterface.libtaos.taos_result_precision(result) == FieldType.C_TIMESTAMP_MICRO) blocks = [None] * len(fields) + fieldL = CTaosInterface.libtaos.taos_fetch_lengths(result) + fieldLen = [ele for ele in ctypes.cast(fieldL, ctypes.POINTER(ctypes.c_int))[:len(fields)]] for i in range(len(fields)): data = ctypes.cast(pblock, ctypes.POINTER(ctypes.c_void_p))[i] if data == None: @@ -323,7 +326,7 @@ class CTaosInterface(object): if fields[i]['type'] not in _CONVERT_FUNC: raise DatabaseError("Invalid data type returned from database") - blocks[i] = _CONVERT_FUNC[fields[i]['type']](data, num_of_rows, fields[i]['bytes'], isMicro) + blocks[i] = _CONVERT_FUNC[fields[i]['type']](data, num_of_rows, fieldLen[i], isMicro) return blocks, abs(num_of_rows) diff --git a/src/connector/python/windows/python2/taos/cinterface.py b/src/connector/python/windows/python2/taos/cinterface.py index a18d372db2..f5d35fefd9 100644 --- a/src/connector/python/windows/python2/taos/cinterface.py +++ b/src/connector/python/windows/python2/taos/cinterface.py @@ -146,6 +146,7 @@ class CTaosInterface(object): libtaos.taos_errstr.restype = ctypes.c_char_p libtaos.taos_subscribe.restype = ctypes.c_void_p libtaos.taos_consume.restype = ctypes.c_void_p + libtaos.taos_fetch_lengths.restype = ctypes.c_void_p def __init__(self, config=None): ''' @@ -314,6 +315,8 @@ class CTaosInterface(object): isMicro = (CTaosInterface.libtaos.taos_result_precision(result) == FieldType.C_TIMESTAMP_MICRO) blocks = [None] * len(fields) + fieldL = CTaosInterface.libtaos.taos_fetch_lengths(result) + fieldLen = [ele for ele in ctypes.cast(fieldL, ctypes.POINTER(ctypes.c_int))[:len(fields)]] for i in range(len(fields)): data = ctypes.cast(pblock, ctypes.POINTER(ctypes.c_void_p))[i] if data == None: @@ -323,7 +326,7 @@ class CTaosInterface(object): if fields[i]['type'] not in _CONVERT_FUNC: raise DatabaseError("Invalid data type returned from database") - blocks[i] = _CONVERT_FUNC[fields[i]['type']](data, num_of_rows, fields[i]['bytes'], isMicro) + blocks[i] = _CONVERT_FUNC[fields[i]['type']](data, num_of_rows, fieldLen[i], isMicro) return blocks, abs(num_of_rows) diff --git a/src/connector/python/windows/python3/taos/cinterface.py b/src/connector/python/windows/python3/taos/cinterface.py index cbcf2d884e..4f9dd78755 100644 --- a/src/connector/python/windows/python3/taos/cinterface.py +++ b/src/connector/python/windows/python3/taos/cinterface.py @@ -146,6 +146,7 @@ class CTaosInterface(object): libtaos.taos_errstr.restype = ctypes.c_char_p libtaos.taos_subscribe.restype = ctypes.c_void_p libtaos.taos_consume.restype = ctypes.c_void_p + libtaos.taos_fetch_lengths.restype = ctypes.c_void_p def __init__(self, config=None): ''' @@ -314,6 +315,8 @@ class CTaosInterface(object): isMicro = (CTaosInterface.libtaos.taos_result_precision(result) == FieldType.C_TIMESTAMP_MICRO) blocks = [None] * len(fields) + fieldL = CTaosInterface.libtaos.taos_fetch_lengths(result) + fieldLen = [ele for ele in ctypes.cast(fieldL, ctypes.POINTER(ctypes.c_int))[:len(fields)]] for i in range(len(fields)): data = ctypes.cast(pblock, ctypes.POINTER(ctypes.c_void_p))[i] if data == None: @@ -323,7 +326,7 @@ class CTaosInterface(object): if fields[i]['type'] not in _CONVERT_FUNC: raise DatabaseError("Invalid data type returned from database") - blocks[i] = _CONVERT_FUNC[fields[i]['type']](data, num_of_rows, fields[i]['bytes'], isMicro) + blocks[i] = _CONVERT_FUNC[fields[i]['type']](data, num_of_rows, fieldLen[i], isMicro) return blocks, abs(num_of_rows) From af7e3ffa29d2b8ef7e6f732edb3ad87fb9b53929 Mon Sep 17 00:00:00 2001 From: liu0x54 Date: Thu, 7 May 2020 15:03:33 +0000 Subject: [PATCH 03/41] [TD-228] fix python connector to support binary interface change --- src/plugins/http/src/gcJson.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/http/src/gcJson.c b/src/plugins/http/src/gcJson.c index 09990c123e..98069f434d 100644 --- a/src/plugins/http/src/gcJson.c +++ b/src/plugins/http/src/gcJson.c @@ -121,6 +121,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, for (int k = 0; k < numOfRows; ++k) { TAOS_ROW row = taos_fetch_row(result); + int32_t* length = taos_fetch_lengths(result); // for group by if (groupFields != -1) { @@ -150,7 +151,11 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, break; case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: - len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%s", fields[i].name, (char *)row[i]); + if (row[i]!= NULL){ + len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:", fields[i].name); + memcpy(target + len, (char *) row[i], length[i]); + len = strlen(target); + } break; default: len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%s", fields[i].name, "-"); From 002b7ea5fbd1facbb8417464cd1628c49ec333d8 Mon Sep 17 00:00:00 2001 From: liu0x54 Date: Fri, 8 May 2020 01:25:01 +0000 Subject: [PATCH 04/41] [TD-228] fix python connector to support binary interface change --- src/plugins/http/src/gcJson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/http/src/gcJson.c b/src/plugins/http/src/gcJson.c index 98069f434d..544a11b5fc 100644 --- a/src/plugins/http/src/gcJson.c +++ b/src/plugins/http/src/gcJson.c @@ -125,7 +125,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, // for group by if (groupFields != -1) { - char target[HTTP_GC_TARGET_SIZE]; + char target[HTTP_GC_TARGET_SIZE] = {0}; int len; len = snprintf(target,HTTP_GC_TARGET_SIZE,"%s{",aliasBuffer); for (int i = dataFields + 1; i Date: Fri, 8 May 2020 10:10:28 +0800 Subject: [PATCH 05/41] add part of tsdb log --- src/tsdb/src/tsdbMain.c | 57 +++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 3f41a3c5fe..8d570911a9 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -90,6 +90,7 @@ void tsdbFreeCfg(STsdbCfg *pCfg) { int32_t tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg, void *limiter /* TODO */) { if (mkdir(rootDir, 0755) != 0) { + tsdbError("id %d: failed to create rootDir! rootDir %s, reason %s", pCfg->tsdbId, rootDir, strerror(errno)); if (errno == EACCES) { return TSDB_CODE_NO_DISK_PERMISSIONS; } else if (errno == ENOSPC) { @@ -611,14 +612,20 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) { if (pCfg->precision == -1) { pCfg->precision = TSDB_DEFAULT_PRECISION; } else { - if (!IS_VALID_PRECISION(pCfg->precision)) return -1; + if (!IS_VALID_PRECISION(pCfg->precision)) { + tsdbError("id %d: invalid precision configuration! precision %d", pCfg->tsdbId, pCfg->precision); + return -1; + } } // Check compression if (pCfg->compression == -1) { pCfg->compression = TSDB_DEFAULT_COMPRESSION; } else { - if (!IS_VALID_COMPRESSION(pCfg->compression)) return -1; + if (!IS_VALID_COMPRESSION(pCfg->compression)) { + tsdbError("id %d: invalid compression configuration! compression %d", pCfg->tsdbId, pCfg->precision); + return -1; + } } // Check tsdbId @@ -628,29 +635,49 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) { if (pCfg->maxTables == -1) { pCfg->maxTables = TSDB_DEFAULT_TABLES; } else { - if (pCfg->maxTables < TSDB_MIN_TABLES || pCfg->maxTables > TSDB_MAX_TABLES) return -1; + if (pCfg->maxTables < TSDB_MIN_TABLES || pCfg->maxTables > TSDB_MAX_TABLES) { + tsdbError("id %d: invalid maxTables configuration! maxTables %d TSDB_MIN_TABLES %d TSDB_MAX_TABLES %d", + pCfg->tsdbId, pCfg->maxTables, TSDB_MIN_TABLES, TSDB_MAX_TABLES); + return -1; + } } // Check daysPerFile if (pCfg->daysPerFile == -1) { pCfg->daysPerFile = TSDB_DEFAULT_DAYS_PER_FILE; } else { - if (pCfg->daysPerFile < TSDB_MIN_DAYS_PER_FILE || pCfg->daysPerFile > TSDB_MAX_DAYS_PER_FILE) return -1; + if (pCfg->daysPerFile < TSDB_MIN_DAYS_PER_FILE || pCfg->daysPerFile > TSDB_MAX_DAYS_PER_FILE) { + tsdbError( + "id %d: invalid daysPerFile configuration! daysPerFile %d TSDB_MIN_DAYS_PER_FILE %d TSDB_MAX_DAYS_PER_FILE " + "%d", + pCfg->tsdbId, pCfg->daysPerFile, TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE); + return -1; + } } // Check minRowsPerFileBlock and maxRowsPerFileBlock if (pCfg->minRowsPerFileBlock == -1) { pCfg->minRowsPerFileBlock = TSDB_DEFAULT_MIN_ROW_FBLOCK; } else { - if (pCfg->minRowsPerFileBlock < TSDB_MIN_MIN_ROW_FBLOCK || pCfg->minRowsPerFileBlock > TSDB_MAX_MIN_ROW_FBLOCK) + if (pCfg->minRowsPerFileBlock < TSDB_MIN_MIN_ROW_FBLOCK || pCfg->minRowsPerFileBlock > TSDB_MAX_MIN_ROW_FBLOCK) { + tsdbError( + "id %d: invalid minRowsPerFileBlock configuration! minRowsPerFileBlock %d TSDB_MIN_MIN_ROW_FBLOCK %d " + "TSDB_MAX_MIN_ROW_FBLOCK %d", + pCfg->tsdbId, pCfg->minRowsPerFileBlock, TSDB_MIN_MIN_ROW_FBLOCK, TSDB_MAX_MIN_ROW_FBLOCK); return -1; + } } if (pCfg->maxRowsPerFileBlock == -1) { pCfg->maxRowsPerFileBlock = TSDB_DEFAULT_MAX_ROW_FBLOCK; } else { - if (pCfg->maxRowsPerFileBlock < TSDB_MIN_MAX_ROW_FBLOCK || pCfg->maxRowsPerFileBlock > TSDB_MAX_MAX_ROW_FBLOCK) + if (pCfg->maxRowsPerFileBlock < TSDB_MIN_MAX_ROW_FBLOCK || pCfg->maxRowsPerFileBlock > TSDB_MAX_MAX_ROW_FBLOCK) { + tsdbError( + "id %d: invalid maxRowsPerFileBlock configuration! maxRowsPerFileBlock %d TSDB_MIN_MAX_ROW_FBLOCK %d " + "TSDB_MAX_MAX_ROW_FBLOCK %d", + pCfg->tsdbId, pCfg->maxRowsPerFileBlock, TSDB_MIN_MIN_ROW_FBLOCK, TSDB_MAX_MIN_ROW_FBLOCK); return -1; + } } if (pCfg->minRowsPerFileBlock > pCfg->maxRowsPerFileBlock) return -1; @@ -659,7 +686,13 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) { if (pCfg->keep == -1) { pCfg->keep = TSDB_DEFAULT_KEEP; } else { - if (pCfg->keep < TSDB_MIN_KEEP || pCfg->keep > TSDB_MAX_KEEP) return -1; + if (pCfg->keep < TSDB_MIN_KEEP || pCfg->keep > TSDB_MAX_KEEP) { + tsdbError( + "id %d: invalid keep configuration! keep %d TSDB_MIN_KEEP %d " + "TSDB_MAX_KEEP %d", + pCfg->tsdbId, pCfg->keep, TSDB_MIN_KEEP, TSDB_MAX_KEEP); + return -1; + } } return 0; @@ -716,15 +749,22 @@ static int32_t tsdbGetDataDirName(STsdbRepo *pRepo, char *fname) { } static int32_t tsdbSetRepoEnv(STsdbRepo *pRepo) { + STsdbCfg *pCfg = &pRepo->config; if (tsdbSaveConfig(pRepo) < 0) return -1; char dirName[128] = "\0"; if (tsdbGetDataDirName(pRepo, dirName) < 0) return -1; if (mkdir(dirName, 0755) < 0) { + tsdbError("id %d: failed to create repository directory! reason %s", pRepo->config.tsdbId, strerror(errno)); return -1; } + tsdbError( + "id %d: set up tsdb environment succeed! cacheBlockSize %d, totalBlocks %d, maxTables %d, daysPerFile %d, keep " + "%d, minRowsPerFileBlock %d, maxRowsPerFileBlock %d, precision %d, compression%d", + pRepo->config.tsdbId, pCfg->cacheBlockSize, pCfg->totalBlocks, pCfg->maxTables, pCfg->daysPerFile, pCfg->keep, + pCfg->minRowsPerFileBlock, pCfg->maxRowsPerFileBlock, pCfg->precision, pCfg->compression); return 0; } @@ -811,7 +851,8 @@ 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("failed to get table for insert, uid:%" PRIu64 ", tid:%d", tableId.uid, tableId.tid); + tsdbError("id %d: failed to get table for insert, uid:%" PRIu64 ", tid:%d", pRepo->config.tsdbId, pBlock->uid, + pBlock->tid); return TSDB_CODE_INVALID_TABLE_ID; } From 6a70b5d19a2dbad18279284e672ea12648c10940 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 8 May 2020 15:55:28 +0800 Subject: [PATCH 06/41] add general/parser test case to 2.0 [TD-253] --- tests/script/basicSuite.sim | 1 + .../general/parser/auto_create_tb_drop_tb.sim | 2 +- tests/script/general/parser/create_db.sim | 14 +- tests/script/general/parser/first_last.sim | 2 +- tests/script/general/parser/mixed_blocks.sim | 2 +- tests/script/general/parser/slimit.sim | 4 +- tests/script/general/parser/slimit1.sim | 2 +- .../general/parser/slimit_alter_tags.sim | 2 +- tests/script/general/parser/testSuite.sim | 178 ++++++++++-------- tests/script/general/parser/timestamp.sim | 2 +- 10 files changed, 115 insertions(+), 94 deletions(-) diff --git a/tests/script/basicSuite.sim b/tests/script/basicSuite.sim index df15c7ebbb..973a88f553 100644 --- a/tests/script/basicSuite.sim +++ b/tests/script/basicSuite.sim @@ -42,4 +42,5 @@ run general/compute/diff.sim run general/compute/null.sim # run general/compute/diff2.sim +run general/parse/testSuite.sim ################################## diff --git a/tests/script/general/parser/auto_create_tb_drop_tb.sim b/tests/script/general/parser/auto_create_tb_drop_tb.sim index 23cad7137e..aa14d2fdfb 100644 --- a/tests/script/general/parser/auto_create_tb_drop_tb.sim +++ b/tests/script/general/parser/auto_create_tb_drop_tb.sim @@ -22,7 +22,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db rows 200 cache 2048 maxTables 4 +sql create database $db maxrows 200 cache 2048 maxTables 4 print ====== create tables sql use $db diff --git a/tests/script/general/parser/create_db.sim b/tests/script/general/parser/create_db.sim index 6e11f9d25b..8048770198 100644 --- a/tests/script/general/parser/create_db.sim +++ b/tests/script/general/parser/create_db.sim @@ -108,10 +108,10 @@ $cache = 4096 # 4 kb $ablocks = 100 $tblocks = 32 # max=512, automatically trimmed when exceeding $ctime = 36000 # 10 hours -$clog = 0 # max=32, automatically trimmed when exceeding +$wal = 0 # valid value is 0, 1, 2 $comp = 1 # max=32, automatically trimmed when exceeding -sql create database $db replica $replica days $days keep $keep rows $rows_db cache $cache ablocks $ablocks tblocks $tblocks ctime $ctime clog $clog comp $comp +sql create database $db replica $replica days $days keep $keep maxrows $rows_db cache $cache ablocks $ablocks tblocks $tblocks ctime $ctime wal $wal comp $comp sql show databases if $rows != 1 then return -1 @@ -156,8 +156,8 @@ sql_error create database $db keep 0 #sql_error create database $db keep 3651 # rows [200, 10000] -sql_error create database $db rows 199 -#sql_error create database $db rows 10001 +sql_error create database $db maxrows 199 +#sql_error create database $db maxrows 10001 # cache [100, 10485760] sql_error create database $db cache 99 @@ -175,9 +175,9 @@ sql_error create database $db ablocks -1 sql_error create database $db ctime 29 sql_error create database $db ctime 40961 -# clog {0, 1} -sql_error create database $db clog -1 -#sql_error create database $db clog 2 +# wal {0, 1} +sql_error create database $db wal -1 +#sql_error create database $db wal 2 # comp {0, 1, 2} sql_error create database $db comp -1 diff --git a/tests/script/general/parser/first_last.sim b/tests/script/general/parser/first_last.sim index 8bede7573a..b67764dc9b 100644 --- a/tests/script/general/parser/first_last.sim +++ b/tests/script/general/parser/first_last.sim @@ -21,7 +21,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db rows 400 cache 4096 maxTables 4 +sql create database $db maxrows 400 cache 4096 maxTables 4 sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) diff --git a/tests/script/general/parser/mixed_blocks.sim b/tests/script/general/parser/mixed_blocks.sim index 37ba1a8900..77838774df 100644 --- a/tests/script/general/parser/mixed_blocks.sim +++ b/tests/script/general/parser/mixed_blocks.sim @@ -22,7 +22,7 @@ sql drop database if exists $db $paramRows = 200 $rowNum = $paramRows * 4 $rowNum = $rowNum / 5 -sql create database $db rows $paramRows maxTables 4 +sql create database $db maxrows $paramRows maxTables 4 print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 bool, c6 binary(10), c7 nchar(10)) tags(t1 int) diff --git a/tests/script/general/parser/slimit.sim b/tests/script/general/parser/slimit.sim index 234e31d261..017e8d4d2e 100644 --- a/tests/script/general/parser/slimit.sim +++ b/tests/script/general/parser/slimit.sim @@ -22,7 +22,7 @@ $db = $dbPrefix . $i $stb = $stbPrefix . $i sql drop database if exists $db -sql create database $db rows 200 cache 1024 tblocks 200 maxTables 4 +sql create database $db maxrows 200 cache 1024 tblocks 200 maxTables 4 print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 binary(15), t2 int, t3 bigint, t4 nchar(10), t5 double, t6 bool) @@ -64,7 +64,7 @@ print ====== $db tables created $db = $dbPrefix . 1 sql drop database if exists $db -sql create database $db rows 200 cache 1024 +sql create database $db maxrows 200 cache 1024 sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 binary(15), t2 int, t3 bigint, t4 nchar(10), t5 double, t6 bool) diff --git a/tests/script/general/parser/slimit1.sim b/tests/script/general/parser/slimit1.sim index 7020cc8bb7..3dbe9f0a06 100644 --- a/tests/script/general/parser/slimit1.sim +++ b/tests/script/general/parser/slimit1.sim @@ -18,7 +18,7 @@ $delta = 600000 $db = $dbPrefix sql drop database if exists $db -sql create database $db rows 200 +sql create database $db maxrows 200 sql use $db sql create table stb (ts timestamp, c1 int, c2 bigint, c3 double) tags(t1 int, t2 int) diff --git a/tests/script/general/parser/slimit_alter_tags.sim b/tests/script/general/parser/slimit_alter_tags.sim index 630855260c..5c62482802 100644 --- a/tests/script/general/parser/slimit_alter_tags.sim +++ b/tests/script/general/parser/slimit_alter_tags.sim @@ -18,7 +18,7 @@ $delta = 600000 $db = $dbPrefix sql drop database if exists $db -sql create database $db rows 200 +sql create database $db maxrows 200 sql use $db sql create table stb (ts timestamp, c1 int, c2 bigint, c3 double) tags(t1 int, t2 int) diff --git a/tests/script/general/parser/testSuite.sim b/tests/script/general/parser/testSuite.sim index d1228f5820..aaf8979337 100644 --- a/tests/script/general/parser/testSuite.sim +++ b/tests/script/general/parser/testSuite.sim @@ -1,93 +1,113 @@ -#run general/parser/alter.sim -#sleep 2000 -#run general/parser/alter1.sim -#sleep 2000 -#run general/parser/alter_stable.sim -#sleep 2000 -#run general/parser/auto_create_tb.sim -#sleep 2000 -#run general/parser/auto_create_tb_drop_tb.sim +# run general/parser/alter.sim +# sleep 2000 +# run general/parser/alter1.sim +# sleep 2000 +# run general/parser/alter_stable.sim +# sleep 2000 +# run general/parser/auto_create_tb.sim +# sleep 2000 +# run general/parser/auto_create_tb_drop_tb.sim +# sleep 2000 +run general/parser/binary_escapeCharacter.sim +sleep 2000 +run general/parser/bug.sim sleep 2000 run general/parser/col_arithmetic_operation.sim sleep 2000 -run general/parser/columnValue.sim +run general/parser/columnValue_bigint.sim sleep 2000 -run general/parser/commit.sim -run general/parser/create_db.sim +run general/parser/columnValue_bool.sim sleep 2000 -run general/parser/create_mt.sim +run general/parser/columnValue_double.sim sleep 2000 -run general/parser/create_tb.sim +run general/parser/columnValue_float.sim sleep 2000 -run general/parser/dbtbnameValidate.sim -sleep 2000 -run general/parser/fill.sim -sleep 2000 -run general/parser/fill_stb.sim -sleep 2000 -run general/parser/first_last.sim -sleep 2000 -run general/parser/import_commit1.sim -sleep 2000 -run general/parser/import_commit2.sim -sleep 2000 -run general/parser/import_commit3.sim -sleep 2000 -run general/parser/import_file.sim -sleep 2000 -run general/parser/insert_tb.sim -sleep 2000 -run general/parser/tags_dynamically_specifiy.sim -sleep 2000 -run general/parser/interp.sim -run general/parser/lastrow.sim -sleep 2000 -run general/parser/limit.sim -sleep 2000 -run general/parser/limit1.sim -sleep 2000 -run general/parser/limit1_tblocks100.sim -sleep 2000 -run general/parser/limit2.sim -sleep 2000 -run general/parser/mixed_blocks.sim -sleep 2000 -run general/parser/nchar.sim -sleep 2000 -run general/parser/null_char.sim -sleep 2000 -run general/parser/selectResNum.sim -sleep 2000 -run general/parser/select_across_vnodes.sim +run general/parser/columnValue_int.sim sleep 2000 + +# sleep 2000 +# run general/parser/col_arithmetic_operation.sim +# sleep 2000 +# run general/parser/columnValue.sim +# sleep 2000 +# run general/parser/commit.sim +# run general/parser/create_db.sim +# sleep 2000 +# run general/parser/create_mt.sim +# sleep 2000 +# run general/parser/create_tb.sim +# sleep 2000 +# run general/parser/dbtbnameValidate.sim +# sleep 2000 +# run general/parser/fill.sim +# sleep 2000 +# run general/parser/fill_stb.sim +# sleep 2000 +# run general/parser/first_last.sim +# sleep 2000 +# run general/parser/import_commit1.sim +# sleep 2000 +# run general/parser/import_commit2.sim +# sleep 2000 +# run general/parser/import_commit3.sim +# sleep 2000 +# run general/parser/import_file.sim +# sleep 2000 +# run general/parser/insert_tb.sim +# sleep 2000 +# run general/parser/tags_dynamically_specifiy.sim +# sleep 2000 +# run general/parser/interp.sim +# run general/parser/lastrow.sim +# sleep 2000 +# run general/parser/limit.sim +# sleep 2000 +# run general/parser/limit1.sim +# sleep 2000 +# run general/parser/limit1_tblocks100.sim +# sleep 2000 +# run general/parser/limit2.sim +# sleep 2000 +# run general/parser/mixed_blocks.sim +# sleep 2000 +# run general/parser/nchar.sim +# sleep 2000 +# run general/parser/null_char.sim +# sleep 2000 +# run general/parser/selectResNum.sim +# sleep 2000 +# run general/parser/select_across_vnodes.sim +# sleep 2000 run general/parser/select_from_cache_disk.sim sleep 2000 -run general/parser/set_tag_vals.sim -sleep 2000 -run general/parser/single_row_in_tb.sim -sleep 2000 -run general/parser/slimit.sim -sleep 2000 +# run general/parser/set_tag_vals.sim +# sleep 2000 +# run general/parser/single_row_in_tb.sim +# sleep 2000 +# run general/parser/slimit.sim +# sleep 2000 run general/parser/slimit1.sim sleep 2000 -run general/parser/slimit_alter_tags.sim +run general/parser/slimit1_query.sim sleep 2000 -run general/parser/stream_on_sys.sim -sleep 2000 -run general/parser/stream.sim -sleep 2000 -run general/parser/tbnameIn.sim -sleep 2000 -run general/parser/where.sim -sleep 2000 -#run general/parser/repeatAlter.sim -sleep 2000 -#run general/parser/repeatStream.sim -sleep 2000 -run general/parser/join.sim -run general/parser/join_multivnode.sim -run general/parser/projection_limit_offset.sim -sleep 2000 -run general/parser/select_with_tags.sim -run general/parser/groupby.sim +# run general/parser/slimit_alter_tags.sim +# sleep 2000 +# run general/parser/stream_on_sys.sim +# sleep 2000 +# run general/parser/stream.sim +# sleep 2000 +# run general/parser/tbnameIn.sim +# sleep 2000 +# run general/parser/where.sim +# sleep 2000 +# #run general/parser/repeatAlter.sim +# sleep 2000 +# #run general/parser/repeatStream.sim +# sleep 2000 +# run general/parser/join.sim +# run general/parser/join_multivnode.sim +# run general/parser/projection_limit_offset.sim +# sleep 2000 +# run general/parser/select_with_tags.sim +# run general/parser/groupby.sim diff --git a/tests/script/general/parser/timestamp.sim b/tests/script/general/parser/timestamp.sim index 9a1c793909..fbe0f24a47 100644 --- a/tests/script/general/parser/timestamp.sim +++ b/tests/script/general/parser/timestamp.sim @@ -21,7 +21,7 @@ $db = $dbPrefix . $i $stb = $stbPrefix . $i sql drop database if exists $db -sql create database $db rows 200 cache 1024 tblocks 200 maxTables 4 +sql create database $db maxrows 200 cache 1024 tblocks 200 maxTables 4 print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 timestamp, c2 int) tags(t1 binary(20)) From c4e7acc3c01f42e51252ed896d0dc036952052c7 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 8 May 2020 13:17:10 +0800 Subject: [PATCH 07/41] add general/field/*.sim to 2.0 [TD-252] --- tests/script/basicSuite.sim | 2 ++ tests/script/general/field/testSuite.sim | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/script/basicSuite.sim b/tests/script/basicSuite.sim index df15c7ebbb..7ab8803ae8 100644 --- a/tests/script/basicSuite.sim +++ b/tests/script/basicSuite.sim @@ -42,4 +42,6 @@ run general/compute/diff.sim run general/compute/null.sim # run general/compute/diff2.sim +run general/field/testSuite.sim + ################################## diff --git a/tests/script/general/field/testSuite.sim b/tests/script/general/field/testSuite.sim index 9b58c77e92..d12f0ebbd4 100644 --- a/tests/script/general/field/testSuite.sim +++ b/tests/script/general/field/testSuite.sim @@ -1,4 +1,4 @@ -run general/field/single.sim +# run general/field/single.sim run general/field/bool.sim run general/field/smallint.sim run general/field/tinyint.sim @@ -6,9 +6,9 @@ run general/field/int.sim run general/field/bigint.sim run general/field/float.sim run general/field/double.sim -run general/field/binary.sim -run general/field/2.sim -run general/field/3.sim -run general/field/4.sim -run general/field/5.sim -run general/field/6.sim \ No newline at end of file +# run general/field/binary.sim +# run general/field/2.sim +# run general/field/3.sim +# run general/field/4.sim +# run general/field/5.sim +# run general/field/6.sim From c3bcd6fe1aad06c57b79417efdd3a20609bd1b32 Mon Sep 17 00:00:00 2001 From: liu0x54 Date: Fri, 8 May 2020 09:44:16 +0000 Subject: [PATCH 08/41] [TD251]fix python connector to process NCHAR --- src/connector/python/linux/python2/taos/cinterface.py | 2 +- src/connector/python/linux/python3/taos/cinterface.py | 2 +- src/connector/python/windows/python2/taos/cinterface.py | 2 +- src/connector/python/windows/python3/taos/cinterface.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/connector/python/linux/python2/taos/cinterface.py b/src/connector/python/linux/python2/taos/cinterface.py index d9460efb21..6d792fa92f 100644 --- a/src/connector/python/linux/python2/taos/cinterface.py +++ b/src/connector/python/linux/python2/taos/cinterface.py @@ -96,7 +96,7 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) + res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: diff --git a/src/connector/python/linux/python3/taos/cinterface.py b/src/connector/python/linux/python3/taos/cinterface.py index 6ef54f1ba5..49dd5d00e3 100644 --- a/src/connector/python/linux/python3/taos/cinterface.py +++ b/src/connector/python/linux/python3/taos/cinterface.py @@ -96,7 +96,7 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) + res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: diff --git a/src/connector/python/windows/python2/taos/cinterface.py b/src/connector/python/windows/python2/taos/cinterface.py index a18d372db2..a62ac2801c 100644 --- a/src/connector/python/windows/python2/taos/cinterface.py +++ b/src/connector/python/windows/python2/taos/cinterface.py @@ -96,7 +96,7 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) + res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: diff --git a/src/connector/python/windows/python3/taos/cinterface.py b/src/connector/python/windows/python3/taos/cinterface.py index cbcf2d884e..4d009f0be0 100644 --- a/src/connector/python/windows/python3/taos/cinterface.py +++ b/src/connector/python/windows/python3/taos/cinterface.py @@ -96,7 +96,7 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) + res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: From ccd0e00031e743bc4717f43199123eb9e84b4090 Mon Sep 17 00:00:00 2001 From: hzcheng Date: Fri, 8 May 2020 18:17:01 +0800 Subject: [PATCH 09/41] fix #1844 --- src/tsdb/inc/tsdbMain.h | 1 + src/tsdb/src/tsdbMeta.c | 76 +++++++++++++++++++++++++---------------- 2 files changed, 48 insertions(+), 29 deletions(-) diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h index a681c865c9..278463f0d2 100644 --- a/src/tsdb/inc/tsdbMain.h +++ b/src/tsdb/inc/tsdbMain.h @@ -95,6 +95,7 @@ typedef struct STable { void * streamHandler; // TODO TSKEY lastKey; // lastkey inserted in this table, initialized as 0, TODO: make a structure struct STable *next; // TODO: remove the next + struct STable *prev; } STable; #define TSDB_GET_TABLE_LAST_KEY(pTable) ((pTable)->lastKey) diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 63ccb538ed..a351245220 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -13,10 +13,10 @@ static int tsdbFreeTable(STable *pTable); static int32_t tsdbCheckTableCfg(STableCfg *pCfg); static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx); -static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable); static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable); static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable); static int tsdbEstimateTableEncodeSize(STable *pTable); +static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable); /** * Encode a TSDB table object as a binary content @@ -375,21 +375,9 @@ int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId) { STable *pTable = tsdbGetTableByUid(pMeta, tableId.uid); if (pTable == NULL) return -1; - if (pTable->type == TSDB_SUPER_TABLE) { - // TODO: implement drop super table - return -1; - } else { - pMeta->tables[pTable->tableId.tid] = NULL; - pMeta->nTables--; - assert(pMeta->nTables >= 0); - if (pTable->type == TSDB_CHILD_TABLE) { - tsdbRemoveTableFromIndex(pMeta, pTable); - } - - tsdbFreeTable(pTable); - } - + if (tsdbRemoveTableFromMeta(pMeta, pTable) < 0) return -1; return 0; + } // int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable) { @@ -445,10 +433,12 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx) { if (pMeta->superList == NULL) { pMeta->superList = pTable; pTable->next = NULL; + pTable->prev = NULL; } else { - STable *pTemp = pMeta->superList; + pTable->next = pMeta->superList; + pTable->prev = NULL; + pTable->next->prev = pTable; pMeta->superList = pTable; - pTable->next = pTemp; } } else { // add non-super table to the array @@ -467,22 +457,50 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx) { if (bytes > pMeta->maxRowBytes) pMeta->maxRowBytes = bytes; } - return tsdbAddTableIntoMap(pMeta, pTable); -} - -// static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable) { -// // TODO -// return 0; -// } - -static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable) { - // TODO: add the table to the map - int64_t uid = pTable->tableId.uid; - if (taosHashPut(pMeta->map, (char *)(&uid), sizeof(uid), (void *)(&pTable), sizeof(pTable)) < 0) { + if (taosHashPut(pMeta->map, (char *)(&pTable->tableId.uid), sizeof(pTable->tableId.uid), (void *)(&pTable), sizeof(pTable)) < 0) { return -1; } return 0; } + +static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable) { + if (pTable->type == TSDB_SUPER_TABLE) { + SSkipListIterator *pIter = tSkipListCreateIter(pTable->pIndex); + while (tSkipListIterNext(pIter)) { + STable *tTable = *(STable **)SL_GET_NODE_DATA(tSkipListIterGet(pIter)); + ASSERT(tTable != NULL && tTable->type == TSDB_CHILD_TABLE); + + pMeta->tables[tTable->tableId.tid] = NULL; + taosHashRemove(pMeta->map, (char *)(&(pTable->tableId.uid)), sizeof(pTable->tableId.uid)); + pMeta->nTables--; + tsdbFreeTable(tTable); + } + + tSkipListDestroyIter(pIter); + + // TODO: Remove the table from the list + if (pTable->prev != NULL) { + pTable->prev->next = pTable->next; + if (pTable->next != NULL) { + pTable->next->prev = pTable->prev; + } + } else { + pMeta->superList = pTable->next; + } + } else { + pMeta->tables[pTable->tableId.tid] = NULL; + if (pTable->type == TSDB_CHILD_TABLE) { + tsdbRemoveTableFromIndex(pMeta, pTable); + } + + pMeta->nTables--; + } + + tsdbFreeTable(pTable); + taosHashRemove(pMeta->map, (char *)(&(pTable->tableId.uid)), sizeof(pTable->tableId.uid)); + return 0; +} + static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable) { assert(pTable->type == TSDB_CHILD_TABLE && pTable != NULL); STable* pSTable = tsdbGetTableByUid(pMeta, pTable->superUid); From 5127b9a135ff6f521be3709ef241da9b40b57da8 Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 8 May 2020 19:05:03 +0800 Subject: [PATCH 10/41] fix bug while alter table --- src/mnode/src/mgmtTable.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index 9bd2cde2dc..e9fdee7a0f 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -828,10 +828,10 @@ static void mgmtProcessDropSuperTableMsg(SQueuedMsg *pMsg) { } static int32_t mgmtFindSuperTableTagIndex(SSuperTableObj *pStable, const char *tagName) { - for (int32_t i = 0; i < pStable->numOfTags; i++) { - SSchema *schema = (SSchema *)(pStable->schema + (pStable->numOfColumns + i) * sizeof(SSchema)); - if (strcasecmp(tagName, schema->name) == 0) { - return i; + SSchema *schema = (SSchema *) pStable->schema; + for (int32_t tag = 0; tag < pStable->numOfTags; tag++) { + if (strcasecmp(schema[pStable->numOfColumns + tag].name, tagName) == 0) { + return tag; } } From 36e26330f530ab97d1889f59c99eadc102e87894 Mon Sep 17 00:00:00 2001 From: liu0x54 Date: Fri, 8 May 2020 11:24:39 +0000 Subject: [PATCH 11/41] [TD251]fix python connector to process NCHAR --- src/connector/python/linux/python2/taos/cinterface.py | 3 ++- src/connector/python/linux/python3/taos/cinterface.py | 3 ++- src/connector/python/windows/python2/taos/cinterface.py | 3 ++- src/connector/python/windows/python3/taos/cinterface.py | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/connector/python/linux/python2/taos/cinterface.py b/src/connector/python/linux/python2/taos/cinterface.py index 6d792fa92f..98a2103c09 100644 --- a/src/connector/python/linux/python2/taos/cinterface.py +++ b/src/connector/python/linux/python2/taos/cinterface.py @@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) + tmpstr = ctypes.c_char_p(data) + res.append( tmpstr.value.decode() ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: diff --git a/src/connector/python/linux/python3/taos/cinterface.py b/src/connector/python/linux/python3/taos/cinterface.py index 49dd5d00e3..d516aad5a7 100644 --- a/src/connector/python/linux/python3/taos/cinterface.py +++ b/src/connector/python/linux/python3/taos/cinterface.py @@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) + tmpstr = ctypes.c_char_p(data) + res.append( tmpstr.value.decode() ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: diff --git a/src/connector/python/windows/python2/taos/cinterface.py b/src/connector/python/windows/python2/taos/cinterface.py index a62ac2801c..28130d5cb3 100644 --- a/src/connector/python/windows/python2/taos/cinterface.py +++ b/src/connector/python/windows/python2/taos/cinterface.py @@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) + tmpstr = ctypes.c_char_p(data) + res.append( tmpstr.value.decode() ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: diff --git a/src/connector/python/windows/python3/taos/cinterface.py b/src/connector/python/windows/python3/taos/cinterface.py index 4d009f0be0..f683537661 100644 --- a/src/connector/python/windows/python3/taos/cinterface.py +++ b/src/connector/python/windows/python3/taos/cinterface.py @@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) + tmpstr = ctypes.c_char_p(data) + res.append( tmpstr.value.decode() ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: From 599711dd6ba4c5fefae816f41f4c39db112373cf Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Fri, 8 May 2020 12:32:50 +0000 Subject: [PATCH 12/41] port in redirect message shall be htons --- src/dnode/src/dnodeVRead.c | 2 ++ src/rpc/src/rpcMain.c | 28 +++++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/dnode/src/dnodeVRead.c b/src/dnode/src/dnodeVRead.c index ff211bf1b2..aaf71838bf 100644 --- a/src/dnode/src/dnodeVRead.c +++ b/src/dnode/src/dnodeVRead.c @@ -81,6 +81,8 @@ void dnodeCleanupRead() { } taosCloseQset(readQset); + free(readPool.readWorker); + dPrint("dnode read is closed"); } diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 39d773f6a2..cdd2d732e1 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -226,17 +226,6 @@ void *rpcOpen(const SRpcInit *pInit) { pRpc->cfp = pInit->cfp; pRpc->afp = pInit->afp; - pRpc->tcphandle = (*taosInitConn[pRpc->connType|RPC_CONN_TCP])(0, pRpc->localPort, pRpc->label, - pRpc->numOfThreads, rpcProcessMsgFromPeer, pRpc); - pRpc->udphandle = (*taosInitConn[pRpc->connType])(0, pRpc->localPort, pRpc->label, - pRpc->numOfThreads, rpcProcessMsgFromPeer, pRpc); - - if (pRpc->tcphandle == NULL || pRpc->udphandle == NULL) { - tError("%s failed to init network, port:%d", pRpc->label, pRpc->localPort); - rpcClose(pRpc); - return NULL; - } - size_t size = sizeof(SRpcConn) * pRpc->sessions; pRpc->connList = (SRpcConn *)calloc(1, size); if (pRpc->connList == NULL) { @@ -277,6 +266,17 @@ void *rpcOpen(const SRpcInit *pInit) { pthread_mutex_init(&pRpc->mutex, NULL); + pRpc->tcphandle = (*taosInitConn[pRpc->connType|RPC_CONN_TCP])(0, pRpc->localPort, pRpc->label, + pRpc->numOfThreads, rpcProcessMsgFromPeer, pRpc); + pRpc->udphandle = (*taosInitConn[pRpc->connType])(0, pRpc->localPort, pRpc->label, + pRpc->numOfThreads, rpcProcessMsgFromPeer, pRpc); + + if (pRpc->tcphandle == NULL || pRpc->udphandle == NULL) { + tError("%s failed to init network, port:%d", pRpc->label, pRpc->localPort); + rpcClose(pRpc); + return NULL; + } + tTrace("%s RPC is openned, numOfThreads:%d", pRpc->label, pRpc->numOfThreads); return pRpc; @@ -869,9 +869,9 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) { pConn = rpcProcessMsgHead(pRpc, pRecv); if (pHead->msgType < TSDB_MSG_TYPE_CM_HEARTBEAT || (rpcDebugFlag & 16)) { - tTrace("%s %p, %s received from 0x%x:%hu, parse code:0x%x len:%d sig:0x%08x:0x%08x:%d", + tTrace("%s %p, %s received from 0x%x:%hu, parse code:0x%x len:%d sig:0x%08x:0x%08x:%d code:0x%x", pRpc->label, pConn, taosMsg[pHead->msgType], pRecv->ip, pRecv->port, terrno, - pRecv->msgLen, pHead->sourceId, pHead->destId, pHead->tranId, pHead->port); + pRecv->msgLen, pHead->sourceId, pHead->destId, pHead->tranId, pHead->code); } int32_t code = terrno; @@ -939,6 +939,8 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) { pContext->numOfTry = 0; memcpy(&pContext->ipSet, pHead->content, sizeof(pContext->ipSet)); tTrace("%s %p, redirect is received, numOfIps:%d", pRpc->label, pConn, pContext->ipSet.numOfIps); + for (int i=0; iipSet.numOfIps; ++i) + pContext->ipSet.port[i] = htons(pContext->ipSet.port[i]); rpcSendReqToServer(pRpc, pContext); } else if (pHead->code == TSDB_CODE_NOT_READY) { pContext->code = pHead->code; From b8c6d6c0314d2c79512eff73aa9442327a3183da Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 8 May 2020 22:05:02 +0800 Subject: [PATCH 13/41] failed to get bandwidth --- src/mnode/inc/{mgmtLog.h => mgmtInt.h} | 36 ++++++-------------------- src/mnode/src/mgmtAcct.c | 2 +- src/mnode/src/mgmtBalance.c | 2 +- src/mnode/src/mgmtDb.c | 2 +- src/mnode/src/mgmtDnode.c | 2 +- src/mnode/src/mgmtGrant.c | 2 +- src/mnode/src/mgmtMain.c | 2 +- src/mnode/src/mgmtMnode.c | 2 +- src/mnode/src/mgmtProfile.c | 2 +- src/mnode/src/mgmtSdb.c | 2 +- src/mnode/src/mgmtServer.c | 2 +- src/mnode/src/mgmtShell.c | 2 +- src/mnode/src/mgmtTable.c | 2 +- src/mnode/src/mgmtUser.c | 2 +- src/mnode/src/mgmtVgroup.c | 2 +- src/os/linux/src/linuxSysPara.c | 11 +++++--- src/plugins/monitor/src/monitorMain.c | 8 +++--- 17 files changed, 34 insertions(+), 49 deletions(-) rename src/mnode/inc/{mgmtLog.h => mgmtInt.h} (53%) diff --git a/src/mnode/inc/mgmtLog.h b/src/mnode/inc/mgmtInt.h similarity index 53% rename from src/mnode/inc/mgmtLog.h rename to src/mnode/inc/mgmtInt.h index a99fa22593..17553ade72 100644 --- a/src/mnode/inc/mgmtLog.h +++ b/src/mnode/inc/mgmtInt.h @@ -27,39 +27,19 @@ extern int32_t mdebugFlag; extern int32_t sdbDebugFlag; // mnode log function -#define mError(...) \ - if (mdebugFlag & DEBUG_ERROR) { \ - taosPrintLog("ERROR MND ", 255, __VA_ARGS__); \ - } -#define mWarn(...) \ - if (mdebugFlag & DEBUG_WARN) { \ - taosPrintLog("WARN MND ", mdebugFlag, __VA_ARGS__); \ - } -#define mTrace(...) \ - if (mdebugFlag & DEBUG_TRACE) { \ - taosPrintLog("MND ", mdebugFlag, __VA_ARGS__); \ - } -#define mPrint(...) \ - { taosPrintLog("MND ", 255, __VA_ARGS__); } +#define mError(...) if (mdebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MND ", 255, __VA_ARGS__); } +#define mWarn(...) if (mdebugFlag & DEBUG_WARN) { taosPrintLog("WARN MND ", mdebugFlag, __VA_ARGS__); } +#define mTrace(...) if (mdebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mdebugFlag, __VA_ARGS__); } +#define mPrint(...) { taosPrintLog("MND ", 255, __VA_ARGS__); } #define mLError(...) monitorSaveLog(2, __VA_ARGS__); mError(__VA_ARGS__) #define mLWarn(...) monitorSaveLog(1, __VA_ARGS__); mWarn(__VA_ARGS__) #define mLPrint(...) monitorSaveLog(0, __VA_ARGS__); mPrint(__VA_ARGS__) -#define sdbError(...) \ - if (sdbDebugFlag & DEBUG_ERROR) { \ - taosPrintLog("ERROR MND-SDB ", 255, __VA_ARGS__); \ - } -#define sdbWarn(...) \ - if (sdbDebugFlag & DEBUG_WARN) { \ - taosPrintLog("WARN MND-SDB ", sdbDebugFlag, __VA_ARGS__); \ - } -#define sdbTrace(...) \ - if (sdbDebugFlag & DEBUG_TRACE) { \ - taosPrintLog("MND-SDB ", sdbDebugFlag, __VA_ARGS__); \ - } -#define sdbPrint(...) \ - { taosPrintLog("MND-SDB ", 255, __VA_ARGS__); } +#define sdbError(...) if (sdbDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MND-SDB ", 255, __VA_ARGS__); } +#define sdbWarn(...) if (sdbDebugFlag & DEBUG_WARN) { taosPrintLog("WARN MND-SDB ", sdbDebugFlag, __VA_ARGS__); } +#define sdbTrace(...) if (sdbDebugFlag & DEBUG_TRACE) { taosPrintLog("MND-SDB ", sdbDebugFlag, __VA_ARGS__);} +#define sdbPrint(...) { taosPrintLog("MND-SDB ", 255, __VA_ARGS__); } #define sdbLError(...) monitorSaveLog(2, __VA_ARGS__); sdbError(__VA_ARGS__) #define sdbLWarn(...) monitorSaveLog(1, __VA_ARGS__); sdbWarn(__VA_ARGS__) diff --git a/src/mnode/src/mgmtAcct.c b/src/mnode/src/mgmtAcct.c index 9b7815af12..1cacec96ee 100644 --- a/src/mnode/src/mgmtAcct.c +++ b/src/mnode/src/mgmtAcct.c @@ -20,7 +20,7 @@ #include "tutil.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtAcct.h" #include "mgmtDb.h" #include "mgmtSdb.h" diff --git a/src/mnode/src/mgmtBalance.c b/src/mnode/src/mgmtBalance.c index d16a06fc5c..ff5b4008bb 100644 --- a/src/mnode/src/mgmtBalance.c +++ b/src/mnode/src/mgmtBalance.c @@ -19,7 +19,7 @@ #include "tbalance.h" #include "tglobal.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtMnode.h" #include "mgmtDnode.h" #include "mgmtVgroup.h" diff --git a/src/mnode/src/mgmtDb.c b/src/mnode/src/mgmtDb.c index 5cee1f30cd..8c6a80eb61 100644 --- a/src/mnode/src/mgmtDb.c +++ b/src/mnode/src/mgmtDb.c @@ -25,7 +25,7 @@ #include "tbalance.h" #include "tdataformat.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtAcct.h" #include "mgmtDb.h" #include "mgmtDnode.h" diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index 030123b804..a170aa2d02 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -27,7 +27,7 @@ #include "tdataformat.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtDnode.h" #include "mgmtMnode.h" #include "mgmtSdb.h" diff --git a/src/mnode/src/mgmtGrant.c b/src/mnode/src/mgmtGrant.c index 449799ef95..f44b47e20c 100644 --- a/src/mnode/src/mgmtGrant.c +++ b/src/mnode/src/mgmtGrant.c @@ -18,7 +18,7 @@ #include "os.h" #include "taoserror.h" #include "tgrant.h" -#include "mgmtLog.h" +#include "mgmtInt.h" int32_t grantInit() { return TSDB_CODE_SUCCESS; } void grantCleanUp() {} diff --git a/src/mnode/src/mgmtMain.c b/src/mnode/src/mgmtMain.c index aa95381df3..37edddec10 100644 --- a/src/mnode/src/mgmtMain.c +++ b/src/mnode/src/mgmtMain.c @@ -23,7 +23,7 @@ #include "tglobal.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtServer.h" #include "mgmtAcct.h" #include "mgmtDnode.h" diff --git a/src/mnode/src/mgmtMnode.c b/src/mnode/src/mgmtMnode.c index f28e286f79..a78e5574c0 100644 --- a/src/mnode/src/mgmtMnode.c +++ b/src/mnode/src/mgmtMnode.c @@ -24,7 +24,7 @@ #include "tsocket.h" #include "tdataformat.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtMnode.h" #include "mgmtDnode.h" #include "mgmtSdb.h" diff --git a/src/mnode/src/mgmtProfile.c b/src/mnode/src/mgmtProfile.c index 77871f037b..64ac8ed710 100644 --- a/src/mnode/src/mgmtProfile.c +++ b/src/mnode/src/mgmtProfile.c @@ -19,7 +19,7 @@ #include "taoserror.h" #include "tutil.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtAcct.h" #include "mgmtDnode.h" #include "mgmtDb.h" diff --git a/src/mnode/src/mgmtSdb.c b/src/mnode/src/mgmtSdb.c index fe25699b5f..d2a5287f13 100644 --- a/src/mnode/src/mgmtSdb.c +++ b/src/mnode/src/mgmtSdb.c @@ -27,7 +27,7 @@ #include "hashstr.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtMnode.h" #include "mgmtSdb.h" diff --git a/src/mnode/src/mgmtServer.c b/src/mnode/src/mgmtServer.c index 2fa6e68f65..a6b4362cbf 100644 --- a/src/mnode/src/mgmtServer.c +++ b/src/mnode/src/mgmtServer.c @@ -25,7 +25,7 @@ #include "tglobal.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtDb.h" #include "mgmtMnode.h" #include "mgmtProfile.h" diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index 7264c85027..3cb0225b97 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -26,7 +26,7 @@ #include "tcache.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtAcct.h" #include "mgmtDb.h" #include "mgmtDnode.h" diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index e9fdee7a0f..2225e08f58 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -26,7 +26,7 @@ #include "tglobal.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtAcct.h" #include "mgmtDb.h" #include "mgmtDnode.h" diff --git a/src/mnode/src/mgmtUser.c b/src/mnode/src/mgmtUser.c index ecd3c217ca..b0e58a5052 100644 --- a/src/mnode/src/mgmtUser.c +++ b/src/mnode/src/mgmtUser.c @@ -23,7 +23,7 @@ #include "tdataformat.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtAcct.h" #include "mgmtMnode.h" #include "mgmtSdb.h" diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index 6be2a73444..cbe235a26a 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -26,7 +26,7 @@ #include "dnode.h" #include "tdataformat.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtDb.h" #include "mgmtDnode.h" #include "mgmtMnode.h" diff --git a/src/os/linux/src/linuxSysPara.c b/src/os/linux/src/linuxSysPara.c index f43ed44a4b..6bab418385 100644 --- a/src/os/linux/src/linuxSysPara.c +++ b/src/os/linux/src/linuxSysPara.c @@ -356,10 +356,15 @@ static bool taosGetCardName(char *ip, char *name) { break; } - if (strcmp(host, ip) == 0) { - strcpy(name, ifa->ifa_name); - ret = true; + if (strcmp(host, "127.0.0.1") == 0) { + continue; } + + // TODO: the ip not config + // if (strcmp(host, ip) == 0) { + strcpy(name, ifa->ifa_name); + ret = true; + // } } freeifaddrs(ifaddr); diff --git a/src/plugins/monitor/src/monitorMain.c b/src/plugins/monitor/src/monitorMain.c index 7836dbae85..35787d1dfe 100644 --- a/src/plugins/monitor/src/monitorMain.c +++ b/src/plugins/monitor/src/monitorMain.c @@ -43,7 +43,7 @@ { taosPrintLog("MON ", 255, __VA_ARGS__); } #define SQL_LENGTH 1024 -#define LOG_LEN_STR 80 +#define LOG_LEN_STR 100 #define IP_LEN_STR 18 #define CHECK_INTERVAL 1000 @@ -148,8 +148,8 @@ static void dnodeBuildMonitorSql(char *sql, int32_t cmd) { if (cmd == MONITOR_CMD_CREATE_DB) { snprintf(sql, SQL_LENGTH, - "create database if not exists %s replica 1 days 10 keep 30 cache 2 " - "blocks 2 maxtables 32 precision 'us'", + "create database if not exists %s replica 1 days 10 keep 30 cache 1 " + "blocks 2 maxtables 16 precision 'us'", tsMonitorDbName); } else if (cmd == MONITOR_CMD_CREATE_MT_DN) { snprintf(sql, SQL_LENGTH, @@ -407,7 +407,7 @@ void monitorSaveLog(int32_t level, const char *const format, ...) { if (tsMonitorConn.state != MONITOR_STATE_INITIALIZED) return; - int32_t len = snprintf(sql, (size_t)max_length, "import into %s.log values(%" PRId64 ", %d,'", tsMonitorDbName, + int32_t len = snprintf(sql, (size_t)max_length, "insert into %s.log values(%" PRId64 ", %d,'", tsMonitorDbName, taosGetTimestampUs(), level); va_start(argpointer, format); From 36a2e334dbe0ae612779fdc64830849e13228044 Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 8 May 2020 22:05:45 +0800 Subject: [PATCH 14/41] set max redirect times --- src/rpc/src/rpcMain.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index cdd2d732e1..685b0f2b86 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -934,8 +934,15 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) { // for UDP, port may be changed by server, the port in ipSet shall be used for cache rpcAddConnIntoCache(pRpc->pCache, pConn, pConn->peerFqdn, pContext->ipSet.port[pContext->ipSet.inUse], pConn->connType); + if (pHead->code == TSDB_CODE_REDIRECT) { + pContext->redirect++; + if (pContext->redirect > TSDB_MAX_REPLICA) { + pHead->code = TSDB_CODE_NETWORK_UNAVAIL; + tWarn("%s %p, too many redirects, quit", pRpc->label, pConn); + } + } + if (pHead->code == TSDB_CODE_REDIRECT) { - pContext->redirect = 1; pContext->numOfTry = 0; memcpy(&pContext->ipSet, pHead->content, sizeof(pContext->ipSet)); tTrace("%s %p, redirect is received, numOfIps:%d", pRpc->label, pConn, pContext->ipSet.numOfIps); From 15d6f34de7ddd149f032b6125e6b367e108551f8 Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 8 May 2020 22:06:10 +0800 Subject: [PATCH 15/41] scripts --- tests/script/jenkins/basic.txt | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 1a9862e4ed..44fc24e107 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -102,6 +102,66 @@ cd ../../../debug; make #./test.sh -f general/metrics/vnode3.sim #parser + +# ./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 +# ./test.sh -f general/parser/auto_create_tb_drop_tb.sim +./test.sh -f general/parser/binary_escapeCharacter.sim +./test.sh -f general/parser/bug.sim +./test.sh -f general/parser/col_arithmetic_operation.sim +./test.sh -f general/parser/columnValue_bigint.sim +./test.sh -f general/parser/columnValue_bool.sim +./test.sh -f general/parser/columnValue_double.sim +./test.sh -f general/parser/columnValue_float.sim +./test.sh -f general/parser/columnValue_int.sim +# ./test.sh -f general/parser/col_arithmetic_operation.sim +# ./test.sh -f general/parser/columnValue.sim +# ./test.sh -f general/parser/commit.sim +# ./test.sh -f general/parser/create_db.sim +# ./test.sh -f general/parser/create_mt.sim +# ./test.sh -f general/parser/create_tb.sim +# ./test.sh -f general/parser/dbtbnameValidate.sim +# ./test.sh -f general/parser/fill.sim +# ./test.sh -f general/parser/fill_stb.sim +# ./test.sh -f general/parser/first_last.sim +# ./test.sh -f general/parser/import_commit1.sim +# ./test.sh -f general/parser/import_commit2.sim +# ./test.sh -f general/parser/import_commit3.sim +# ./test.sh -f general/parser/import_file.sim +# ./test.sh -f general/parser/insert_tb.sim +# ./test.sh -f general/parser/tags_dynamically_specifiy.sim +# ./test.sh -f general/parser/interp.sim +# ./test.sh -f general/parser/lastrow.sim +# ./test.sh -f general/parser/limit.sim +# ./test.sh -f general/parser/limit1.sim +# ./test.sh -f general/parser/limit1_tblocks100.sim +# ./test.sh -f general/parser/limit2.sim +# ./test.sh -f general/parser/mixed_blocks.sim +# ./test.sh -f general/parser/nchar.sim +# ./test.sh -f general/parser/null_char.sim +# ./test.sh -f general/parser/selectResNum.sim +# ./test.sh -f general/parser/select_across_vnodes.sim +./test.sh -f general/parser/select_from_cache_disk.sim +# ./test.sh -f general/parser/set_tag_vals.sim +# ./test.sh -f general/parser/single_row_in_tb.sim +# ./test.sh -f general/parser/slimit.sim +./test.sh -f general/parser/slimit1.sim +./test.sh -f general/parser/slimit1_query.sim +# ./test.sh -f general/parser/slimit_alter_tags.sim +# ./test.sh -f general/parser/stream_on_sys.sim +# ./test.sh -f general/parser/stream.sim +# ./test.sh -f general/parser/tbnameIn.sim +# ./test.sh -f general/parser/where.sim +# #./test.sh -f general/parser/repeatAlter.sim +# #./test.sh -f general/parser/repeatStream.sim +# ./test.sh -f general/parser/join.sim +# ./test.sh -f general/parser/join_multivnode.sim +# ./test.sh -f general/parser/projection_limit_offset.sim +# ./test.sh -f general/parser/select_with_tags.sim +# ./test.sh -f general/parser/groupby.sim + #stream ./test.sh -f general/table/autocreate.sim From 6383fc6fdfa0cd827477966200b9dbe626c78894 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Sat, 9 May 2020 01:09:04 +0800 Subject: [PATCH 16/41] add more cases to smoketest.sh --- tests/pytest/fulltest.sh | 1 + tests/pytest/smoketest.sh | 126 +++++++++++++++++++++++++++++++++++--- 2 files changed, 117 insertions(+), 10 deletions(-) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index cff6db2028..249245c762 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -9,6 +9,7 @@ python3 ./test.py $1 -f insert/smallint.py python3 ./test.py $1 -f insert/tinyint.py python3 ./test.py $1 -f insert/date.py python3 ./test.py $1 -f insert/binary.py +python3 ./test.py $1 -f insert/nchar.py python3 ./test.py $1 -f table/column_name.py python3 ./test.py $1 -f table/column_num.py diff --git a/tests/pytest/smoketest.sh b/tests/pytest/smoketest.sh index af597fb6c5..37af5f3f42 100755 --- a/tests/pytest/smoketest.sh +++ b/tests/pytest/smoketest.sh @@ -23,6 +23,15 @@ sleep 1 python3 ./test.py $1 -f insert/tinyint.py python3 ./test.py -s $1 sleep 1 +python3 ./test.py $1 -f insert/binary.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f insert/date.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f insert/nchar.py +python3 ./test.py -s $1 +sleep 1 python3 ./test.py $1 -f table/column_name.py python3 ./test.py -s $1 @@ -34,33 +43,130 @@ python3 ./test.py $1 -f table/db_table.py python3 ./test.py -s $1 sleep 1 -python3 ./test.py $1 -f import_merge/importDataLastTO.py +python3 ./test.py $1 -f import_merge/importDataLastTO.py python3 ./test.py -s $1 sleep 1 -python3 ./test.py $1 -f import_merge/importDataLastT.py +python3 ./test.py $1 -f import_merge/importDataLastT.py python3 ./test.py -s $1 sleep 1 -python3 ./test.py $1 -f import_merge/importDataTO.py +python3 ./test.py $1 -f import_merge/importDataTO.py python3 ./test.py -s $1 sleep 1 -python3 ./test.py $1 -f import_merge/importDataT.py +python3 ./test.py $1 -f import_merge/importDataT.py python3 ./test.py -s $1 sleep 1 -python3 ./test.py $1 -f import_merge/importHeadOverlap.py +python3 ./test.py $1 -f import_merge/importHeadOverlap.py python3 ./test.py -s $1 sleep 1 -python3 ./test.py $1 -f import_merge/importHeadPartOverlap.py +python3 ./test.py $1 -f import_merge/importHeadPartOverlap.py python3 ./test.py -s $1 sleep 1 -python3 ./test.py $1 -f import_merge/importHORestart.py +python3 ./test.py $1 -f import_merge/importHORestart.py python3 ./test.py -s $1 sleep 1 -python3 ./test.py $1 -f import_merge/importHPORestart.py +python3 ./test.py $1 -f import_merge/importHPORestart.py python3 ./test.py -s $1 sleep 1 -python3 ./test.py $1 -f import_merge/importHRestart.py +python3 ./test.py $1 -f import_merge/importHRestart.py python3 ./test.py -s $1 sleep 1 -python3 ./test.py $1 -f import_merge/importLastSub.py +python3 ./test.py $1 -f import_merge/importLastSub.py +python3 ./test.py -s $1 +sleep 1 + +python3 ./test.py $1 -f import_merge/importBlock1HO.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock1HPO.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock1H.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock1S.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock1Sub.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock1TO.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock1TPO.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock1T.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock2HO.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock2HPO.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock2H.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock2S.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock2Sub.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock2TO.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock2TPO.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlock2T.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importBlockbetween.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importCacheFileSub.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importCacheFileTO.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importCacheFileT.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importDataLastSub.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importHead.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importLastTO.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importLastT.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importSpan.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importSRestart.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importSubRestart.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importTailOverlap.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importTail.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importTORestart.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importTPORestart.py +python3 ./test.py -s $1 +sleep 1 +python3 ./test.py $1 -f import_merge/importTRestart.py python3 ./test.py -s $1 sleep 1 From 118144968ae3dabcb23d335f87d87e92fcc0c011 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Sat, 9 May 2020 01:13:56 +0800 Subject: [PATCH 17/41] add insert/nchar.py --- tests/pytest/insert/nchar.py | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/pytest/insert/nchar.py diff --git a/tests/pytest/insert/nchar.py b/tests/pytest/insert/nchar.py new file mode 100644 index 0000000000..d61a44844d --- /dev/null +++ b/tests/pytest/insert/nchar.py @@ -0,0 +1,44 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * + + +class TDTestCase: + def init(self, conn): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + tdSql.prepare() + + tdSql.execute('create table tb (ts timestamp, col nchar(10))') + tdSql.execute("insert into tb values (now, 'taosdata')") + tdSql.query("select * from tb") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 'taosdata') + tdSql.execute("insert into tb values (now, '涛思数据')") + tdSql.query("select * from tb") + tdSql.checkRows(2) + tdSql.checkData(1, 1, '涛思数据') + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) From 1445c34196d5c04d0bdd035e42073659a54700eb Mon Sep 17 00:00:00 2001 From: liu0x54 Date: Sat, 9 May 2020 02:05:25 +0000 Subject: [PATCH 18/41] [TD-228] fix rest API to support binary interface change --- src/plugins/http/src/restJson.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/http/src/restJson.c b/src/plugins/http/src/restJson.c index 9277d7d045..2d9c31935c 100644 --- a/src/plugins/http/src/restJson.c +++ b/src/plugins/http/src/restJson.c @@ -94,6 +94,7 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, for (int k = 0; k < numOfRows; ++k) { TAOS_ROW row = taos_fetch_row(result); + int32_t* length = taos_fetch_lengths(result); // data row array begin httpJsonItemToken(jsonBuf); @@ -129,7 +130,7 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, break; case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: - httpJsonStringForTransMean(jsonBuf, row[i], fields[i].bytes); + httpJsonStringForTransMean(jsonBuf, row[i], length[i]); break; case TSDB_DATA_TYPE_TIMESTAMP: if (timestampFormat == REST_TIMESTAMP_FMT_LOCAL_STRING) { From b175e7cdf2c320cfa7c9def5972df767cf089cae Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 9 May 2020 11:20:19 +0800 Subject: [PATCH 19/41] rname dnode table name in log database --- src/plugins/monitor/src/monitorMain.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/monitor/src/monitorMain.c b/src/plugins/monitor/src/monitorMain.c index 35787d1dfe..76b322d01b 100644 --- a/src/plugins/monitor/src/monitorMain.c +++ b/src/plugins/monitor/src/monitorMain.c @@ -160,11 +160,11 @@ static void dnodeBuildMonitorSql(char *sql, int32_t cmd) { ", band_speed float" ", io_read float, io_write float" ", req_http int, req_select int, req_insert int" - ") tags (ipaddr binary(%d))", + ") tags (dnodeid int, fqdn binary(%d))", tsMonitorDbName, TSDB_FQDN_LEN + 1); } else if (cmd == MONITOR_CMD_CREATE_TB_DN) { - snprintf(sql, SQL_LENGTH, "create table if not exists %s.dn_%s using %s.dn tags('%s')", tsMonitorDbName, - tsMonitorConn.ep, tsMonitorDbName, tsLocalEp); + snprintf(sql, SQL_LENGTH, "create table if not exists %s.dn%d using %s.dn tags(%d, '%s')", tsMonitorDbName, + dnodeGetDnodeId(), tsMonitorDbName, dnodeGetDnodeId(), tsLocalEp); } else if (cmd == MONITOR_CMD_CREATE_MT_ACCT) { snprintf(sql, SQL_LENGTH, "create table if not exists %s.acct(ts timestamp " @@ -347,7 +347,7 @@ static void monitorSaveSystemInfo() { int64_t ts = taosGetTimestampUs(); char * sql = tsMonitorConn.sql; - int32_t pos = snprintf(sql, SQL_LENGTH, "insert into %s.dn_%s values(%" PRId64, tsMonitorDbName, tsMonitorConn.ep, ts); + int32_t pos = snprintf(sql, SQL_LENGTH, "insert into %s.dn%d values(%" PRId64, tsMonitorDbName, dnodeGetDnodeId(), ts); pos += monitorBuildCpuSql(sql + pos); pos += monitorBuildMemorySql(sql + pos); From 269d15c485a911d6213532b8de0dd2642a985ca2 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Sat, 9 May 2020 11:25:27 +0800 Subject: [PATCH 20/41] fixup: change default charset to UTF-8 --- tests/pytest/util/dnodes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 51eed3d25a..2532cec702 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -69,7 +69,7 @@ class TDSimClient: self.cfg("numOfLogLines", "100000000") self.cfg("numOfThreadsPerCore", "2.0") self.cfg("locale", "en_US.UTF-8") - self.cfg("charset", "GBK") + self.cfg("charset", "UTF-8") self.cfg("asyncLog", "0") self.cfg("anyIp", "0") self.cfg("sdbDebugFlag", "135") From b7e4b7eefdebf9f20a84e1e62708fe27c5caac02 Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 9 May 2020 13:48:18 +0800 Subject: [PATCH 21/41] invalid read while sync --- src/mnode/src/mgmtMain.c | 21 ++++++++++----------- src/mnode/src/mgmtShell.c | 15 ++++++++++----- tests/script/unique/mnode/mgmt22.sim | 13 +++++++++---- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/mnode/src/mgmtMain.c b/src/mnode/src/mgmtMain.c index 37edddec10..434552980f 100644 --- a/src/mnode/src/mgmtMain.c +++ b/src/mnode/src/mgmtMain.c @@ -55,11 +55,6 @@ int32_t mgmtStartSystem() { return -1; } - if (grantInit() < 0) { - mError("failed to init grant"); - return -1; - } - if (mgmtInitUsers() < 0) { mError("failed to init users"); return -1; @@ -99,6 +94,11 @@ int32_t mgmtStartSystem() { mError("failed to init balance") } + if (grantInit() < 0) { + mError("failed to init grant"); + return -1; + } + if (mgmtInitServer() < 0) { return -1; } @@ -132,19 +132,18 @@ int32_t mgmtInitSystem() { void mgmtCleanUpSystem() { mPrint("starting to clean up mgmt"); - grantCleanUp(); - mgmtCleanupMnodes(); - balanceCleanUp(); mgmtCleanUpShell(); mgmtCleanupServer(); - mgmtCleanUpAccts(); + grantCleanUp(); + balanceCleanUp(); + sdbCleanUp(); + mgmtCleanupMnodes(); mgmtCleanUpTables(); mgmtCleanUpVgroups(); mgmtCleanUpDbs(); mgmtCleanupDnodes(); mgmtCleanUpUsers(); - sdbCleanUp(); - taosTmrCleanUp(tsMgmtTmr); + mgmtCleanUpAccts(); tsMgmtIsRunning = false; mPrint("mgmt is cleaned up"); } diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index 3cb0225b97..c869e752d3 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -66,21 +66,26 @@ int32_t mgmtInitShell() { tsMgmtTmr = taosTmrInit((tsMaxShellConns) * 3, 200, 3600000, "MND"); tsMgmtTranQhandle = taosInitScheduler(tsMaxShellConns, 1, "mnodeT"); - tsQhandleCache = taosCacheInit(tsMgmtTmr, 2); + tsQhandleCache = taosCacheInit(tsMgmtTmr, 10); return 0; } void mgmtCleanUpShell() { - if (tsMgmtTranQhandle) { - taosCleanUpScheduler(tsMgmtTranQhandle); - tsMgmtTranQhandle = NULL; + if (tsMgmtTmr != NULL){ + taosTmrCleanUp(tsMgmtTmr); + tsMgmtTmr = NULL; } - if (tsQhandleCache) { + if (tsQhandleCache != NULL) { taosCacheCleanup(tsQhandleCache); tsQhandleCache = NULL; } + + if (tsMgmtTranQhandle != NULL) { + taosCleanUpScheduler(tsMgmtTranQhandle); + tsMgmtTranQhandle = NULL; + } } void mgmtAddShellMsgHandle(uint8_t showType, void (*fp)(SQueuedMsg *queuedMsg)) { diff --git a/tests/script/unique/mnode/mgmt22.sim b/tests/script/unique/mnode/mgmt22.sim index ae3c386122..50692524cf 100644 --- a/tests/script/unique/mnode/mgmt22.sim +++ b/tests/script/unique/mnode/mgmt22.sim @@ -8,7 +8,8 @@ system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2 print ============== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec_up.sh -n dnode1 -s start -t +sleep 3000 sql connect sql show mnodes @@ -19,7 +20,7 @@ if $data2_1 != master then endi print ============== step2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start -t sql create dnode $hostname2 $x = 0 @@ -44,8 +45,12 @@ print ============== step3 sql_error drop dnode $hostname1 -x error1 print should not drop master +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +return + print ============== step4 -system sh/exec_up.sh -n dnode1 -s stop +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT sql_error show mnodes print error of no master @@ -78,7 +83,7 @@ if $data2_2 != slave then endi print ============== step7 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec_up.sh -n dnode3 -s start -t sql create dnode $hostname3 sleep 5000 From 29a514314b77dff067fcb119ed0092ec81e84789 Mon Sep 17 00:00:00 2001 From: liuyq-617 <183030384@qq.com> Date: Sat, 9 May 2020 13:51:56 +0800 Subject: [PATCH 22/41] change describe log.dn --- tests/examples/JDBC/springbootdemo/readme.md | 2 +- .../springbootdemo/src/main/resources/application.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/examples/JDBC/springbootdemo/readme.md b/tests/examples/JDBC/springbootdemo/readme.md index 64aabedcdc..ac3bb44ef9 100644 --- a/tests/examples/JDBC/springbootdemo/readme.md +++ b/tests/examples/JDBC/springbootdemo/readme.md @@ -14,7 +14,7 @@ spring.datasource.druid.max-active=5 # max wait time for get connection, ms spring.datasource.druid.max-wait=60000 -spring.datasource.druid.validation-query=describe log.dn +spring.datasource.druid.validation-query=select server_status(); spring.datasource.druid.validation-query-timeout=5000 spring.datasource.druid.test-on-borrow=false spring.datasource.druid.test-on-return=false diff --git a/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties b/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties index dc77e144f0..926559a90c 100644 --- a/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties +++ b/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties @@ -10,7 +10,7 @@ spring.datasource.druid.max-active=5 # max wait time for get connection, ms spring.datasource.druid.max-wait=60000 -spring.datasource.druid.validation-query=describe log.dn +spring.datasource.druid.validation-query=select server_status(); spring.datasource.druid.validation-query-timeout=5000 spring.datasource.druid.test-on-borrow=false spring.datasource.druid.test-on-return=false @@ -23,4 +23,4 @@ spring.datasource.druid.max-evictable-idle-time-millis=900000 #mybatis mybatis.mapper-locations=classpath:mapper/*.xml -logging.level.com.taosdata.jdbc.springbootdemo.dao=debug \ No newline at end of file +logging.level.com.taosdata.jdbc.springbootdemo.dao=debug From 3a9a9ed1d204bfe5a4d968a4c21c56a2bd8c1a24 Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 9 May 2020 13:54:10 +0800 Subject: [PATCH 23/41] crash while print log --- src/client/src/tscSubquery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 020a1b3606..d3a81adca6 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -1436,7 +1436,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO return; } else { // reach the maximum retry count, abort atomic_val_compare_exchange_32(&pState->code, TSDB_CODE_SUCCESS, numOfRows); - tscError("%p sub:%p retrieve failed,code:%s,orderOfSub:%d failed.no more retry,set global code:%d", pPObj, pSql, + tscError("%p sub:%p retrieve failed,code:%d,orderOfSub:%d failed.no more retry,set global code:%d", pPObj, pSql, numOfRows, subqueryIndex, tstrerror(pState->code)); } } From b69e67bd7fc189ae8fad56b2cd11454a7335e8db Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 9 May 2020 13:58:16 +0800 Subject: [PATCH 24/41] scripts --- tests/script/unique/db/replica_add12.sim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/script/unique/db/replica_add12.sim b/tests/script/unique/db/replica_add12.sim index 5d1ec79450..b0de807fca 100644 --- a/tests/script/unique/db/replica_add12.sim +++ b/tests/script/unique/db/replica_add12.sim @@ -73,9 +73,9 @@ endi sleep 2000 sql show dnodes -print dnode1 ==> openVnodes: $data3_1 -print dnode2 ==> openVnodes: $data3_2 -print dnode3 ==> openVnodes: $data3_3 +print dnode1 ==> openVnodes: $data2_1 +print dnode2 ==> openVnodes: $data2_2 +print dnode3 ==> openVnodes: $data2_3 if $data2_1 != 0 then return -1 @@ -99,9 +99,9 @@ sleep 10000 print ======== step3 sql show dnodes -print dnode1 ==> openVnodes: $data3_1 -print dnode2 ==> openVnodes: $data3_2 -print dnode3 ==> openVnodes: $data3_3 +print dnode1 ==> openVnodes: $data2_1 +print dnode2 ==> openVnodes: $data2_2 +print dnode3 ==> openVnodes: $data2_3 if $data2_1 != 0 then return -1 From 1ebaa4e27a947d870c67ec6b76c01993faf4a93a Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 9 May 2020 17:06:09 +0800 Subject: [PATCH 25/41] fix bug while alter dnode --- src/client/src/tscSQLParser.c | 5 +++-- src/client/src/tscServer.c | 23 ++++++++--------------- src/common/src/tglobal.c | 21 +++++++++++++++++---- src/dnode/src/dnodeShell.c | 1 - src/inc/taosmsg.h | 4 ---- src/mnode/src/mgmtDnode.c | 2 +- src/mnode/src/mgmtMain.c | 2 +- src/mnode/src/mgmtSdb.c | 14 +++++++++++--- tests/script/jenkins/basic.txt | 14 +++++++------- tests/script/sh/deploy.sh | 1 + 10 files changed, 49 insertions(+), 38 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index cd5dd6355a..c0ee6f9d89 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -370,10 +370,11 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } - char* pMsg = pCmd->payload + tsRpcHeadSize; - pMsg += sizeof(SMgmtHead); + char* pMsg = pCmd->payload; SCMCfgDnodeMsg* pCfg = (SCMCfgDnodeMsg*)pMsg; + pDCL->a[0].n = strdequote(pDCL->a[0].z); + strncpy(pCfg->ep, pDCL->a[0].z, pDCL->a[0].n); strncpy(pCfg->config, pDCL->a[1].z, pDCL->a[1].n); diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 35e2250dd8..119a84e964 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1005,13 +1005,7 @@ int32_t tscBuildUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int32_t tscBuildCfgDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SSqlCmd *pCmd = &pSql->cmd; pCmd->payloadLen = sizeof(SCMCfgDnodeMsg); - - if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) { - tscError("%p failed to malloc for query msg", pSql); - return TSDB_CODE_CLI_OUT_OF_MEMORY; - } - - pCmd->msgType = TSDB_MSG_TYPE_MD_CONFIG_DNODE; + pCmd->msgType = TSDB_MSG_TYPE_CM_CONFIG_DNODE; return TSDB_CODE_SUCCESS; } @@ -1189,7 +1183,7 @@ int32_t tscBuildKillMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) { SSqlCmd *pCmd = &(pSql->cmd); - int32_t size = minMsgSize() + sizeof(SMgmtHead) + sizeof(SCMCreateTableMsg); + int32_t size = minMsgSize() + sizeof(SCMCreateTableMsg); SCreateTableSQL *pCreateTableInfo = pInfo->pCreateTableInfo; if (pCreateTableInfo->type == TSQL_CREATE_TABLE_FROM_STABLE) { @@ -1277,7 +1271,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int tscEstimateAlterTableMsgLength(SSqlCmd *pCmd) { SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0); - return minMsgSize() + sizeof(SMgmtHead) + sizeof(SCMAlterTableMsg) + sizeof(SSchema) * tscNumOfFields(pQueryInfo) + + return minMsgSize() + sizeof(SCMAlterTableMsg) + sizeof(SSchema) * tscNumOfFields(pQueryInfo) + TSDB_EXTRA_PAYLOAD_SIZE; } @@ -1534,6 +1528,7 @@ int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) { * no used 4B **/ int tscBuildMultiMeterMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) { +#if 0 SSqlCmd *pCmd = &pSql->cmd; // copy payload content to temp buff @@ -1566,6 +1561,8 @@ int tscBuildMultiMeterMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pCmd->payloadLen); return pCmd->payloadLen; +#endif + return 0; } //static UNUSED_FUNC int32_t tscEstimateMetricMetaMsgSize(SSqlCmd *pCmd) { @@ -1765,7 +1762,7 @@ int tscEstimateHeartBeatMsgLength(SSqlObj *pSql) { int size = 0; STscObj *pObj = pSql->pTscObj; - size += tsRpcHeadSize + sizeof(SMgmtHead); + size += tsRpcHeadSize; size += sizeof(SQqueryList); SSqlObj *tpSql = pObj->sqlList; @@ -1801,13 +1798,9 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) { return -1; } - pMsg = pCmd->payload + tsRpcHeadSize; + pMsg = pCmd->payload; pStart = pMsg; - SMgmtHead *pMgmt = (SMgmtHead *)pMsg; - strcpy(pMgmt->db, pObj->db); - pMsg += sizeof(SMgmtHead); - pMsg = tscBuildQueryStreamDesc(pMsg, pObj); pthread_mutex_unlock(&pObj->mutex); diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 9828906532..991c1b403b 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -204,10 +204,19 @@ static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT; void taosSetAllDebugFlag() { for (int32_t i = 0; i < tsGlobalConfigNum; ++i) { - SGlobalCfg *cfg = &tsGlobalConfig[i]; - if ((cfg->cfgType & TSDB_CFG_CTYPE_B_LOG) && cfg->cfgType == TAOS_CFG_VTYPE_INT32) { - *((int32_t*)cfg->ptr) = debugFlag; - } + mdebugFlag = debugFlag; + sdbDebugFlag = debugFlag; + dDebugFlag = debugFlag; + vDebugFlag = debugFlag; + cdebugFlag = debugFlag; + jnidebugFlag = debugFlag; + odbcdebugFlag = debugFlag; + httpDebugFlag = debugFlag; + monitorDebugFlag = debugFlag; + rpcDebugFlag = debugFlag; + uDebugFlag = debugFlag; + sDebugFlag = debugFlag; + //qdebugFlag = debugFlag; } uPrint("all debug flag are set to %d", debugFlag); } @@ -1189,6 +1198,10 @@ void taosInitGlobalCfg() { } bool taosCheckGlobalCfg() { + if (debugFlag == 135 || debugFlag == 199) { + taosSetAllDebugFlag(); + } + taosGetFqdn(tsLocalEp); sprintf(tsLocalEp + strlen(tsLocalEp), ":%d", tsServerPort); uPrint("localEp is %s", tsLocalEp); diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index 8ca3aa12e1..cf6b5e38ab 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -137,7 +137,6 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg) { } } - static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey) { return TSDB_CODE_SUCCESS; } diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index fec14bd938..c359ede22e 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -317,10 +317,6 @@ typedef struct { int8_t flag; } SCMCreateUserMsg, SCMAlterUserMsg; -typedef struct { - char db[TSDB_TABLE_ID_LEN + 1]; -} SMgmtHead; - typedef struct { int32_t contLen; int32_t vgId; diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index a170aa2d02..54a9e53cd9 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -252,7 +252,7 @@ void mgmtProcessCfgDnodeMsg(SQueuedMsg *pMsg) { } static void mgmtProcessCfgDnodeMsgRsp(SRpcMsg *rpcMsg) { - mPrint("cfg vnode rsp is received, result:%s", tstrerror(rpcMsg->code)); + mPrint("cfg dnode rsp is received"); } void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg) { diff --git a/src/mnode/src/mgmtMain.c b/src/mnode/src/mgmtMain.c index 434552980f..2a8e139eec 100644 --- a/src/mnode/src/mgmtMain.c +++ b/src/mnode/src/mgmtMain.c @@ -132,6 +132,7 @@ int32_t mgmtInitSystem() { void mgmtCleanUpSystem() { mPrint("starting to clean up mgmt"); + tsMgmtIsRunning = false; mgmtCleanUpShell(); mgmtCleanupServer(); grantCleanUp(); @@ -144,7 +145,6 @@ void mgmtCleanUpSystem() { mgmtCleanupDnodes(); mgmtCleanUpUsers(); mgmtCleanUpAccts(); - tsMgmtIsRunning = false; mPrint("mgmt is cleaned up"); } diff --git a/src/mnode/src/mgmtSdb.c b/src/mnode/src/mgmtSdb.c index d2a5287f13..4a18c5e285 100644 --- a/src/mnode/src/mgmtSdb.c +++ b/src/mnode/src/mgmtSdb.c @@ -323,11 +323,19 @@ void sdbCleanUp() { if (tsSdbObj.status != SDB_STATUS_SERVING) return; tsSdbObj.status = SDB_STATUS_CLOSING; - syncStop(tsSdbObj.sync); - walClose(tsSdbObj.wal); + + if (tsSdbObj.sync) { + syncStop(tsSdbObj.sync); + tsSdbObj.sync = NULL; + } + + if (tsSdbObj.wal) { + walClose(tsSdbObj.wal); + tsSdbObj.wal = NULL; + } + sem_destroy(&tsSdbObj.sem); pthread_mutex_destroy(&tsSdbObj.mutex); - memset(&tsSdbObj, 0, sizeof(tsSdbObj)); } void sdbIncRef(void *handle, void *pRow) { diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 44fc24e107..1858211c50 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -27,21 +27,21 @@ cd ../../../debug; make ./test.sh -f general/compress/compress2.sim ./test.sh -f general/compress/uncompress.sim -#./test.sh -f general/compute/avg.sim +./test.sh -f general/compute/avg.sim ./test.sh -f general/compute/bottom.sim -#./test.sh -f general/compute/count.sim +./test.sh -f general/compute/count.sim ./test.sh -f general/compute/diff.sim #./test.sh -f general/compute/diff2.sim -#./test.sh -f general/compute/first.sim +./test.sh -f general/compute/first.sim #./test.sh -f general/compute/interval.sim #./test.sh -f general/compute/last.sim #./test.sh -f general/compute/leastsquare.sim -#./test.sh -f general/compute/max.sim -#./test.sh -f general/compute/min.sim +./test.sh -f general/compute/max.sim +./test.sh -f general/compute/min.sim ./test.sh -f general/compute/null.sim ./test.sh -f general/compute/percentile.sim ./test.sh -f general/compute/stddev.sim -#./test.sh -f general/compute/sum.sim +./test.sh -f general/compute/sum.sim ./test.sh -f general/compute/top.sim ./test.sh -f general/db/basic.sim @@ -109,7 +109,7 @@ cd ../../../debug; make # ./test.sh -f general/parser/auto_create_tb.sim # ./test.sh -f general/parser/auto_create_tb_drop_tb.sim ./test.sh -f general/parser/binary_escapeCharacter.sim -./test.sh -f general/parser/bug.sim +#./test.sh -f general/parser/bug.sim ./test.sh -f general/parser/col_arithmetic_operation.sim ./test.sh -f general/parser/columnValue_bigint.sim ./test.sh -f general/parser/columnValue_bool.sim diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index bfbba3a012..5587e3bb8c 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -108,6 +108,7 @@ echo "udebugFlag 131" >> $TAOS_CFG echo "jnidebugFlag 131" >> $TAOS_CFG echo "sdebugFlag 135" >> $TAOS_CFG echo "monitor 0" >> $TAOS_CFG +echo "monitorInterval 1" >> $TAOS_CFG echo "http 0" >> $TAOS_CFG echo "numOfThreadsPerCore 2.0" >> $TAOS_CFG echo "defaultPass taosdata" >> $TAOS_CFG From 08a816fc2d77ddb4dbc34520296b0119b8d45cee Mon Sep 17 00:00:00 2001 From: chang Date: Sat, 9 May 2020 18:10:11 +0800 Subject: [PATCH 26/41] feat: add user test case --- tests/pytest/account/__init__.py | 0 tests/pytest/account/account_create.py | 41 +++++++++++++++++ tests/pytest/account/account_del.py | 52 +++++++++++++++++++++ tests/pytest/fulltest.sh | 4 ++ tests/pytest/user/__init__.py | 0 tests/pytest/user/pass_len.py | 63 ++++++++++++++++++++++++++ tests/pytest/user/user_create.py | 54 ++++++++++++++++++++++ 7 files changed, 214 insertions(+) create mode 100644 tests/pytest/account/__init__.py create mode 100644 tests/pytest/account/account_create.py create mode 100644 tests/pytest/account/account_del.py create mode 100644 tests/pytest/user/__init__.py create mode 100644 tests/pytest/user/pass_len.py create mode 100644 tests/pytest/user/user_create.py diff --git a/tests/pytest/account/__init__.py b/tests/pytest/account/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/pytest/account/account_create.py b/tests/pytest/account/account_create.py new file mode 100644 index 0000000000..24bcc8df2f --- /dev/null +++ b/tests/pytest/account/account_create.py @@ -0,0 +1,41 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + try: + tdSql.execute("create account a&cc PASS 'pass123'") + except Exception as e: + print("create account a&cc PASS 'pass123'") + return + + tdLog.exit("drop built-in user is error.") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/account/account_del.py b/tests/pytest/account/account_del.py new file mode 100644 index 0000000000..43690c6e37 --- /dev/null +++ b/tests/pytest/account/account_del.py @@ -0,0 +1,52 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + print("==========step1") + print("drop built-in account") + try: + tdSql.execute("drop account root") + except Exception as e: + if len(e.args) > 0 and 'no rights' != e.args[0]: + tdLog.exit(e) + + print("==========step2") + print("drop built-in user") + try: + tdSql.execute("drop user root") + except Exception as e: + if len(e.args) > 0 and 'no rights' != e.args[0]: + tdLog.exit(e) + return + + tdLog.exit("drop built-in user is error.") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 249245c762..6aec67f9ce 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -81,3 +81,7 @@ python3 ./test.py $1 -f import_merge/importToCommit.py python3 ./test.py $1 -f import_merge/importTORestart.py python3 ./test.py $1 -f import_merge/importTPORestart.py python3 ./test.py $1 -f import_merge/importTRestart.py + +# user +python3 ./test.py $1 -f user/user_create.py +python3 ./test.py $1 -f user/pass_len.py \ No newline at end of file diff --git a/tests/pytest/user/__init__.py b/tests/pytest/user/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/pytest/user/pass_len.py b/tests/pytest/user/pass_len.py new file mode 100644 index 0000000000..40bd1ca5fc --- /dev/null +++ b/tests/pytest/user/pass_len.py @@ -0,0 +1,63 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + print("==============step1") + try: + tdSql.execute("create user abc pass '123456'") + except Exception as e: + tdLog.exit(e) + print("create user abc pass '123456'") + + print("==============step2") + try: + tdSql.execute("alter user abc pass 'taosdata'") + except Exception as e: + tdLog.exit(e) + print("alter user abc pass 'taosdata'") + + print("==============step3") + try: + tdSql.execute("alter user abc pass ''") + except Exception as e: + print("alter user abc pass ''") + else: + tdLog.exit("Error: alert user abc pass''") + + print("==============step4") + try: + tdSql.execute("alter user abc pass null") + except Exception as e: + print("alter user abc pass null") + else: + tdLog.exit("Error: alter user abc pass null") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/user/user_create.py b/tests/pytest/user/user_create.py new file mode 100644 index 0000000000..f8ac5c6799 --- /dev/null +++ b/tests/pytest/user/user_create.py @@ -0,0 +1,54 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql + + +class TDTestCase: + def init(self, conn): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + print("==============step1") + try: + tdSql.execute("create user &abc PASS 'pass123'") + except Exception as e: + print(e) + + print("==============step2") + try: + tdSql.execute("create user a&bc PASS 'pass123'") + except Exception as e: + print(e) + + print("==============step3") + try: + tdSql.execute("create user '涛思' PASS 'pass123'") + except Exception as e: + print(e) + return + + tdLog.exit("create user with special character.") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) From 924c46bb87ea9449ec7edb3251dac77871f35721 Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 9 May 2020 18:33:41 +0800 Subject: [PATCH 27/41] scripts --- src/vnode/src/vnodeWrite.c | 16 ++-- tests/script/basicSuite.sim | 58 ++++---------- tests/script/general/http/grafana_bug.sim | 38 ++++----- tests/script/general/http/telegraf.sim | 14 ++-- tests/script/general/insert/insert_drop.sim | 11 ++- tests/script/jenkins/basic.txt | 86 ++++++++++----------- 6 files changed, 102 insertions(+), 121 deletions(-) diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 6f0bc5fcce..f560c648e1 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -184,7 +184,7 @@ static int32_t vnodeProcessAlterTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet int16_t numOfColumns = htons(pTable->numOfColumns); int16_t numOfTags = htons(pTable->numOfTags); int32_t sid = htonl(pTable->sid); - uint64_t uid = htobe64(pTable->uid); + uint64_t uid = htobe64(pTable->uid); SSchema *pSchema = (SSchema *) pTable->data; int32_t totalCols = numOfColumns + numOfTags; @@ -231,13 +231,15 @@ static int32_t vnodeProcessDropStableMsg(SVnodeObj *pVnode, void *pCont, SRspRet int32_t code = 0; vTrace("vgId:%d, stable:%s, start to drop", pVnode->vgId, pTable->tableId); - // TODO: drop stable in vvnode - //int64_t uid = htobe64(pTable->uid); - //void *pTsdb = dnodeGetVnodeTsdb(pMsg->pVnode); - //rpcRsp.code = tsdbDropTable(pTsdb, pTable->uid); + + STableId stableId = { + .uid = htobe64(pTable->uid), + .tid = -1 + }; - code = TSDB_CODE_SUCCESS; - vTrace("vgId:%d, stable:%s, drop stable result:%x", pVnode, pTable->tableId, code); + code = tsdbDropTable(pVnode->tsdb, stableId); + + vTrace("vgId:%d, stable:%s, drop stable result:%s", pVnode, pTable->tableId, tstrerror(code)); return code; } diff --git a/tests/script/basicSuite.sim b/tests/script/basicSuite.sim index 93cd0de4d2..676ac93bf2 100644 --- a/tests/script/basicSuite.sim +++ b/tests/script/basicSuite.sim @@ -1,49 +1,25 @@ ################################# -run general/db/basic1.sim -run general/db/basic2.sim -run general/db/basic3.sim +run general/cache/new_metrics.sim +run general/compress/compress.sim +run general/compute/avg.sim +run general/compute/bottom.sim +run general/compute/count.sim +run general/db/len.sim run general/db/basic4.sim -run general/db/basic5.sim - -run general/table/basic1.sim -run general/table/basic2.sim +run general/http/restful_insert.sim +run general/import/basic.sim +run general/import/commit.sim +run general/insert/basic.sim +run general/insert/query_file_memory.sim +run general/parser/binary_escapeCharacter.sim +run general/parser/columnValue_bigint.sim +run general/parser/select_from_cache_disk.sim +run general/table/autocreate.sim run general/table/basic3.sim -run general/table/column_num.sim run general/table/column_name.sim -run general/table/bigint.sim -run general/table/bool.sim -run general/table/double.sim -run general/table/float.sim run general/table/int.sim -run general/table/smallint.sim -run general/table/tinyint.sim -run general/table/db.table.sim - +run general/table/vgroup.sim run general/user/basic1.sim -run general/user/pass_alter.sim -run general/user/pass_len.sim -run general/user/user_create.sim run general/user/user_len.sim - -# run general/compute/count.sim -# run general/compute/avg.sim -# run general/compute/sum.sim -# run general/compute/min.sim -# run general/compute/max.sim -# run general/compute/first.sim -# run general/compute/last.sim -run general/compute/stddev.sim -# run general/compute/leastsquare.sim -run general/compute/top.sim -run general/compute/bottom.sim -run general/compute/percentile.sim -run general/compute/diff.sim -# run general/compute/interval.sim -run general/compute/null.sim -# run general/compute/diff2.sim - -run general/parse/testSuite.sim -run general/field/testSuite.sim - - +run general/vector/single.sim ################################## diff --git a/tests/script/general/http/grafana_bug.sim b/tests/script/general/http/grafana_bug.sim index 6f12849b2b..708af23cfc 100644 --- a/tests/script/general/http/grafana_bug.sim +++ b/tests/script/general/http/grafana_bug.sim @@ -35,7 +35,7 @@ print =============== step1 - one query, 1 column, with timestamp system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query print step1-> $system_content -if $system_content != @[{"refId":"A","target":"A","datapoints":[["-",1577980800000],["-",1578067200000]]}]@ then +if $system_content != @[{"refId":"A","target":"A","datapoints":[[null,1577980800000],[null,1578067200000]]}]@ then return -1 endi @@ -51,32 +51,32 @@ print =============== step3 - one query, 3 column, with timestamp system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val,val1 from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query print step3.1-> $system_content -if $system_content != @[{"refId":"A","target":"13","datapoints":[[2,1577980800000]]},{"refId":"A","target":"14","datapoints":[[2,1578067200000]]}]@ then +if $system_content != @[{"refId":"A","target":"{val1:13,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"{val1:14,}","datapoints":[[2,1578067200000]]}]@ then return -1 endi system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val,val1 from db.tb "} ]' 127.0.0.1:6020/grafana/query print step3.2-> $system_content -if $system_content != @[{"refId":"A","target":"11","datapoints":[[1,1577808000000]]},{"refId":"A","target":"12","datapoints":[[1,1577894400000]]},{"refId":"A","target":"13","datapoints":[[2,1577980800000]]},{"refId":"A","target":"14","datapoints":[[2,1578067200000]]}]@ then +if $system_content != @[{"refId":"A","target":"{val1:11,}","datapoints":[[1,1577808000000]]},{"refId":"A","target":"{val1:12,}","datapoints":[[1,1577894400000]]},{"refId":"A","target":"{val1:13,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"{val1:14,}","datapoints":[[2,1578067200000]]}]@ then return -1 endi system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val1,val from db.tb "} ]' 127.0.0.1:6020/grafana/query print step3.3-> $system_content -if $system_content != @[{"refId":"A","target":"1","datapoints":[[11,1577808000000],[12,1577894400000]]},{"refId":"A","target":"2","datapoints":[[13,1577980800000],[14,1578067200000]]}]@ then +if $system_content != @[{"refId":"A","target":"{val:1,}","datapoints":[[11,1577808000000],[12,1577894400000]]},{"refId":"A","target":"{val:2,}","datapoints":[[13,1577980800000],[14,1578067200000]]}]@ then return -1 endi print =============== step4 - one query, 4 column, with timestamp system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val2,val1,val from db.tb "} ]' 127.0.0.1:6020/grafana/query print step4.1-> $system_content -if $system_content != @[{"refId":"A","target":"1","datapoints":[[21,1577808000000],[22,1577894400000]]},{"refId":"A","target":"2","datapoints":[[23,1577980800000],[24,1578067200000]]}]@ then +if $system_content != @[{"refId":"A","target":"{val1:11,, val:1,}","datapoints":[[21,1577808000000]]},{"refId":"A","target":"{val1:12,, val:1,}","datapoints":[[22,1577894400000]]},{"refId":"A","target":"{val1:13,, val:2,}","datapoints":[[23,1577980800000]]},{"refId":"A","target":"{val1:14,, val:2,}","datapoints":[[24,1578067200000]]}]@ then return -1 endi system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select ts,val,val1,val2 from db.tb "} ]' 127.0.0.1:6020/grafana/query print step4.2-> $system_content -if $system_content != @[{"refId":"A","target":"21","datapoints":[[1,1577808000000]]},{"refId":"A","target":"22","datapoints":[[1,1577894400000]]},{"refId":"A","target":"23","datapoints":[[2,1577980800000]]},{"refId":"A","target":"24","datapoints":[[2,1578067200000]]}]@ then +if $system_content != @[{"refId":"A","target":"{val1:11,, val2:21,}","datapoints":[[1,1577808000000]]},{"refId":"A","target":"{val1:12,, val2:22,}","datapoints":[[1,1577894400000]]},{"refId":"A","target":"{val1:13,, val2:23,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"{val1:14,, val2:24,}","datapoints":[[2,1578067200000]]}]@ then return -1 endi @@ -90,20 +90,20 @@ endi print =============== step6 - one query, 2 column, no timestamp system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select val1,val2 from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query print step1-> $system_content -if $system_content != @[{"refId":"A","target":"23","datapoints":[[13,"-"]]},{"refId":"A","target":"24","datapoints":[[14,"-"]]}]@ then +if $system_content != @[{"refId":"A","target":"{val2:23,}","datapoints":[[13,"-"]]},{"refId":"A","target":"{val2:24,}","datapoints":[[14,"-"]]}]@ then return -1 endi print =============== step7 - one query, 3 column, no timestamp system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select val1,val2,val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query print step1-> $system_content -if $system_content != @[{"refId":"A","target":"2","datapoints":[[13,"-"],[14,"-"]]}]@ then +if $system_content != @[{"refId":"A","target":"{val2:23,, val:2,}","datapoints":[[13,"-"]]},{"refId":"A","target":"{val2:24,, val:2,}","datapoints":[[14,"-"]]}]@ then return -1 endi system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"A","alias":"","sql":"select val1,val2,val from db.tb"} ]' 127.0.0.1:6020/grafana/query print step1-> $system_content -if $system_content != @[{"refId":"A","target":"1","datapoints":[[11,"-"],[12,"-"]]},{"refId":"A","target":"2","datapoints":[[13,"-"],[14,"-"]]}]@ then +if $system_content != @[{"refId":"A","target":"{val2:21,, val:1,}","datapoints":[[11,"-"]]},{"refId":"A","target":"{val2:22,, val:1,}","datapoints":[[12,"-"]]},{"refId":"A","target":"{val2:23,, val:2,}","datapoints":[[13,"-"]]},{"refId":"A","target":"{val2:24,, val:2,}","datapoints":[[14,"-"]]}]@ then return -1 endi @@ -132,7 +132,7 @@ print =============== step11 - two query, 1 column, with timestamp, 1 column, w system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"","sql":"select ts from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query print step1-> $system_content -if $system_content != @[{"refId":"B","target":"BB","datapoints":[["-",1577980800000],["-",1578067200000]]},{"refId":"A","target":"A","datapoints":[["-",1577980800000],["-",1578067200000]]}]@ then +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[null,1577980800000],[null,1578067200000]]},{"refId":"A","target":"A","datapoints":[[null,1577980800000],[null,1578067200000]]}]@ then return -1 endi @@ -140,14 +140,14 @@ print =============== step12 - two query, 1 column, with timestamp, 2 column, w system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"","sql":"select ts,val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query print step1-> $system_content -if $system_content != @[{"refId":"B","target":"BB","datapoints":[["-",1577980800000],["-",1578067200000]]},{"refId":"A","target":"A","datapoints":[[2,1577980800000],[2,1578067200000]]}]@ then +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[null,1577980800000],[null,1578067200000]]},{"refId":"A","target":"A","datapoints":[[2,1577980800000],[2,1578067200000]]}]@ then return -1 endi print =============== step13 - two query, 1 column, with timestamp, 3 column, with timestamp system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"","sql":"select ts,val,val1 from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query print step1-> $system_content -if $system_content != @[{"refId":"B","target":"BB","datapoints":[["-",1577980800000],["-",1578067200000]]},{"refId":"A","target":"13","datapoints":[[2,1577980800000]]},{"refId":"A","target":"14","datapoints":[[2,1578067200000]]}]@ then +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[null,1577980800000],[null,1578067200000]]},{"refId":"A","target":"{val1:13,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"{val1:14,}","datapoints":[[2,1578067200000]]}]@ then return -1 endi @@ -161,14 +161,14 @@ endi print =============== step15 - two query, 2 column, with timestamp, 3 column, with timestamp system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts, val2, val1 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query print step1-> $system_content -if $system_content != @[{"refId":"B","target":"BB213","datapoints":[[223,1577980800000]]},{"refId":"B","target":"BB214","datapoints":[[224,1578067200000]]},{"refId":"A","target":"AA","datapoints":[[2,1577980800000],[2,1578067200000]]}]@ then +if $system_content != @[{"refId":"B","target":"BB{val1:213,}","datapoints":[[223,1577980800000]]},{"refId":"B","target":"BB{val1:214,}","datapoints":[[224,1578067200000]]},{"refId":"A","target":"AA","datapoints":[[2,1577980800000],[2,1578067200000]]}]@ then return -1 endi print =============== step16 - two query, 3 column, with timestamp, 4 column, with timestamp system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select ts, val, val1, val2, val1 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val,val1 from db.tb where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query print step1-> $system_content -if $system_content != @[{"refId":"B","target":"BB213","datapoints":[[22,1577980800000]]},{"refId":"B","target":"BB214","datapoints":[[22,1578067200000]]},{"refId":"A","target":"AA13","datapoints":[[2,1577980800000]]},{"refId":"A","target":"AA14","datapoints":[[2,1578067200000]]}]@ then +if $system_content != @[{"refId":"B","target":"BB{val1:213,, val2:223,, val1:213,}","datapoints":[[22,1577980800000]]},{"refId":"B","target":"BB{val1:214,, val2:224,, val1:214,}","datapoints":[[22,1578067200000]]},{"refId":"A","target":"AA{val1:13,}","datapoints":[[2,1577980800000]]},{"refId":"A","target":"AA{val1:14,}","datapoints":[[2,1578067200000]]}]@ then return -1 endi @@ -196,7 +196,7 @@ endi print =============== step20 - two query, 1 column, no timestamp, 1 column, with timestamp system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query print step1-> $system_content -if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,"-"],[22,"-"]]},{"refId":"A","target":"AA","datapoints":[["-",1577980800000],["-",1578067200000]]}]@ then +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,"-"],[22,"-"]]},{"refId":"A","target":"AA","datapoints":[[null,1577980800000],[null,1578067200000]]}]@ then return -1 endi @@ -210,28 +210,28 @@ endi print =============== step22 - two query, 1 column, no timestamp, 3 column, with timestamp system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select ts,val1, val2 from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query print step1-> $system_content -if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,"-"],[22,"-"]]},{"refId":"A","target":"AA223","datapoints":[[213,1577980800000]]},{"refId":"A","target":"AA224","datapoints":[[214,1578067200000]]}]@ then +if $system_content != @[{"refId":"B","target":"BB","datapoints":[[22,"-"],[22,"-"]]},{"refId":"A","target":"AA{val2:223,}","datapoints":[[213,1577980800000]]},{"refId":"A","target":"AA{val2:224,}","datapoints":[[214,1578067200000]]}]@ then return -1 endi print =============== step23 - two query, 2 column, no timestamp, 1 column, no timestamp system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val1,val2 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select val1 from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query print step1-> $system_content -if $system_content != @[{"refId":"B","target":"BB223","datapoints":[[213,"-"]]},{"refId":"B","target":"BB224","datapoints":[[214,"-"]]},{"refId":"A","target":"AA","datapoints":[[213,"-"],[214,"-"]]}]@ then +if $system_content != @[{"refId":"B","target":"BB{val2:223,}","datapoints":[[213,"-"]]},{"refId":"B","target":"BB{val2:224,}","datapoints":[[214,"-"]]},{"refId":"A","target":"AA","datapoints":[[213,"-"],[214,"-"]]}]@ then return -1 endi print =============== step24 - two query, 2 column, no timestamp, 2 column, no timestamp system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val1,val2 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select val,val1 from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query print step1-> $system_content -if $system_content != @[{"refId":"B","target":"BB223","datapoints":[[213,"-"]]},{"refId":"B","target":"BB224","datapoints":[[214,"-"]]},{"refId":"A","target":"AA213","datapoints":[[22,"-"]]},{"refId":"A","target":"AA214","datapoints":[[22,"-"]]}]@ then +if $system_content != @[{"refId":"B","target":"BB{val2:223,}","datapoints":[[213,"-"]]},{"refId":"B","target":"BB{val2:224,}","datapoints":[[214,"-"]]},{"refId":"A","target":"AA{val1:213,}","datapoints":[[22,"-"]]},{"refId":"A","target":"AA{val1:214,}","datapoints":[[22,"-"]]}]@ then return -1 endi print =============== step25 - two query, 2 column, no timestamp, 3 column, no timestamp system_content curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d '[ {"refId":"B","alias":"BB","sql":"select val1,val2 from db.tb2 where ts >= 1577980800000 "},{"refId":"A","alias":"AA","sql":"select val,val1,val2 from db.tb2 where ts >= 1577980800000 "} ]' 127.0.0.1:6020/grafana/query print step1-> $system_content -if $system_content != @[{"refId":"B","target":"BB223","datapoints":[[213,"-"]]},{"refId":"B","target":"BB224","datapoints":[[214,"-"]]},{"refId":"A","target":"AA223","datapoints":[[22,"-"]]},{"refId":"A","target":"AA224","datapoints":[[22,"-"]]}]@ then +if $system_content != @[{"refId":"B","target":"BB{val2:223,}","datapoints":[[213,"-"]]},{"refId":"B","target":"BB{val2:224,}","datapoints":[[214,"-"]]},{"refId":"A","target":"AA{val1:213,, val2:223,}","datapoints":[[22,"-"]]},{"refId":"A","target":"AA{val1:214,, val2:224,}","datapoints":[[22,"-"]]}]@ then return -1 endi diff --git a/tests/script/general/http/telegraf.sim b/tests/script/general/http/telegraf.sim index 60eeec652e..d9f3340f06 100644 --- a/tests/script/general/http/telegraf.sim +++ b/tests/script/general/http/telegraf.sim @@ -16,14 +16,14 @@ print =============== step1 - parse system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/ print $system_content -if $system_content != @{"status":"error","code":1022,"desc":"database name can not be NULL"}@ then +if $system_content != @{"status":"error","code":1022,"desc":"database name can not be null"}@ then return -1 endi system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_admin' -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/ print $system_content -if $system_content != @{"status":"error","code":1022,"desc":"database name can not be NULL"}@ then +if $system_content != @{"status":"error","code":1022,"desc":"database name can not be null"}@ then return -1 endi @@ -170,7 +170,7 @@ endi system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"":"windows"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 print $system_content -if $system_content != @{"status":"error","code":1038,"desc":"tag name is NULL"}@ then +if $system_content != @{"status":"error","code":1038,"desc":"tag name is null"}@ then return -1 endi @@ -191,14 +191,14 @@ endi system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":""},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 print $system_content -if $system_content != @{"status":"error","code":1041,"desc":"tag value is NULL"}@ then +if $system_content != @{"status":"error","code":1041,"desc":"tag value is null"}@ then return -1 endi system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"1022":"111"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 print $system_content -if $system_content != @{"status":"error","code":1042,"desc":"table is NULL"}@ then +if $system_content != @{"status":"error","code":1042,"desc":"table is null"}@ then return -1 endi @@ -219,14 +219,14 @@ endi system_content curl -u root:taosdata -d '{"fields":{"":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 print $system_content -if $system_content != @{"status":"error","code":1048,"desc":"field name is NULL"}@ then +if $system_content != @{"status":"error","code":1048,"desc":"field name is null"}@ then return -1 endi system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":"","Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 print $system_content -if $system_content != @{"status":"error","code":1051,"desc":"field value is NULL"}@ then +if $system_content != @{"status":"error","code":1051,"desc":"field value is null"}@ then return -1 endi diff --git a/tests/script/general/insert/insert_drop.sim b/tests/script/general/insert/insert_drop.sim index 087b9f6aa9..5655576e20 100644 --- a/tests/script/general/insert/insert_drop.sim +++ b/tests/script/general/insert/insert_drop.sim @@ -46,8 +46,9 @@ system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed -sql connect -sleep 3000 + +sql reset query cache +sleep 1000 sql use $db sql drop table tb5 @@ -71,13 +72,15 @@ system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed -sql connect -sleep 3000 + +sql reset query cache +sleep 1000 sql use $db sql create table tb5 using $stb tags(5) sql select * from tb5 +print $rows should be 0 if $rows != 0 then return -1 endi diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 1858211c50..6e9572e83c 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -65,20 +65,20 @@ cd ../../../debug; make #./test.sh -f general/field/4.sim #./test.sh -f general/field/5.sim #./test.sh -f general/field/6.sim -./test.sh -f general/field/bigint.sim +##./test.sh -f general/field/bigint.sim #./test.sh -f general/field/binary.sim -./test.sh -f general/field/bool.sim +##./test.sh -f general/field/bool.sim #./test.sh -f general/field/single.sim -./test.sh -f general/field/smallint.sim -./test.sh -f general/field/tinyint.sim +##./test.sh -f general/field/smallint.sim +##./test.sh -f general/field/tinyint.sim -./test.sh -f general/http/restful.sim +##./test.sh -f general/http/restful.sim ./test.sh -f general/http/restful_insert.sim ./test.sh -f general/http/restful_limit.sim -./test.sh -f general/http/restful_full.sim +##./test.sh -f general/http/restful_full.sim ./test.sh -f general/http/prepare.sim ./test.sh -f general/http/telegraf.sim -#./test.sh -f general/http/grafana_bug.sim +./test.sh -f general/http/grafana_bug.sim #./test.sh -f general/http/grafana.sim ./test.sh -f general/import/basic.sim @@ -220,9 +220,9 @@ cd ../../../debug; make ./test.sh -f general/user/basic1.sim #./test.sh -f general/user/monitor.sim -./test.sh -f general/user/pass_alter.sim +##./test.sh -f general/user/pass_alter.sim ./test.sh -f general/user/pass_len.sim -./test.sh -f general/user/user_create.sim +##./test.sh -f general/user/user_create.sim ./test.sh -f general/user/user_len.sim #./test.sh -f general/vector/metrics_field.sim @@ -240,24 +240,24 @@ cd ../../../debug; make ################################# ./test.sh -u -f unique/account/account_create.sim -./test.sh -u -f unique/account/account_delete.sim +##./test.sh -u -f unique/account/account_delete.sim ./test.sh -u -f unique/account/account_len.sim -./test.sh -u -f unique/account/authority.sim +##./test.sh -u -f unique/account/authority.sim ./test.sh -u -f unique/account/basic.sim ./test.sh -u -f unique/account/paras.sim -./test.sh -u -f unique/account/pass_alter.sim +##./test.sh -u -f unique/account/pass_alter.sim ./test.sh -u -f unique/account/pass_len.sim ./test.sh -u -f unique/account/usage.sim -./test.sh -u -f unique/account/user_create.sim +##./test.sh -u -f unique/account/user_create.sim ./test.sh -u -f unique/account/user_len.sim #./test.sh -u -f unique/big/balance.sim #./test.sh -u -f unique/big/maxvnodes.sim #./test.sh -u -f unique/big/tcp.sim -./test.sh -u -f unique/cluster/balance1.sim -./test.sh -u -f unique/cluster/balance2.sim -./test.sh -u -f unique/cluster/balance3.sim +##./test.sh -u -f unique/cluster/balance1.sim +##./test.sh -u -f unique/cluster/balance2.sim +##./test.sh -u -f unique/cluster/balance3.sim #./test.sh -u -f unique/cluster/cache.sim ./test.sh -u -f unique/column/replica3.sim @@ -265,26 +265,26 @@ cd ../../../debug; make #./test.sh -u -f unique/db/commit.sim #./test.sh -u -f unique/db/delete.sim #./test.sh -u -f unique/db/delete_part.sim -./test.sh -u -f unique/db/replica_add12.sim -./test.sh -u -f unique/db/replica_add13.sim -./test.sh -u -f unique/db/replica_add23.sim -./test.sh -u -f unique/db/replica_reduce21.sim -./test.sh -u -f unique/db/replica_reduce32.sim -./test.sh -u -f unique/db/replica_reduce31.sim -./test.sh -u -f unique/db/replica_part.sim +##./test.sh -u -f unique/db/replica_add12.sim +##./test.sh -u -f unique/db/replica_add13.sim +##./test.sh -u -f unique/db/replica_add23.sim +##./test.sh -u -f unique/db/replica_reduce21.sim +##./test.sh -u -f unique/db/replica_reduce32.sim +##./test.sh -u -f unique/db/replica_reduce31.sim +##./test.sh -u -f unique/db/replica_part.sim -./test.sh -u -f unique/dnode/balance1.sim -./test.sh -u -f unique/dnode/balance2.sim -./test.sh -u -f unique/dnode/balance3.sim -./test.sh -u -f unique/dnode/balancex.sim -./test.sh -u -f unique/dnode/offline1.sim -./test.sh -u -f unique/dnode/offline2.sim +##./test.sh -u -f unique/dnode/balance1.sim +##./test.sh -u -f unique/dnode/balance2.sim +##./test.sh -u -f unique/dnode/balance3.sim +##./test.sh -u -f unique/dnode/balancex.sim +##./test.sh -u -f unique/dnode/offline1.sim +##./test.sh -u -f unique/dnode/offline2.sim #./test.sh -u -f unique/dnode/remove1.sim #./test.sh -u -f unique/dnode/remove2.sim #./test.sh -u -f unique/dnode/vnode_clean.sim -./test.sh -u -f unique/http/admin.sim -./test.sh -u -f unique/http/opentsdb.sim +##./test.sh -u -f unique/http/admin.sim +##./test.sh -u -f unique/http/opentsdb.sim #./test.sh -u -f unique/import/replica2.sim #./test.sh -u -f unique/import/replica3.sim @@ -298,28 +298,28 @@ cd ../../../debug; make #./test.sh -u -f unique/metrics/replica3_dnode6.sim #./test.sh -u -f unique/metrics/replica3_vnode3.sim -./test.sh -u -f unique/mnode/mgmt22.sim -./test.sh -u -f unique/mnode/mgmt23.sim -./test.sh -u -f unique/mnode/mgmt24.sim -./test.sh -u -f unique/mnode/mgmt25.sim -./test.sh -u -f unique/mnode/mgmt26.sim -./test.sh -u -f unique/mnode/mgmt33.sim -./test.sh -u -f unique/mnode/mgmt34.sim +##./test.sh -u -f unique/mnode/mgmt22.sim +##./test.sh -u -f unique/mnode/mgmt23.sim +##./test.sh -u -f unique/mnode/mgmt24.sim +##./test.sh -u -f unique/mnode/mgmt25.sim +##./test.sh -u -f unique/mnode/mgmt26.sim +##./test.sh -u -f unique/mnode/mgmt33.sim +##./test.sh -u -f unique/mnode/mgmt34.sim #./test.sh -u -f unique/mnode/mgmtr2.sim #./test.sh -u -f unique/mnode/secondIp.sim #stream -./test.sh -u -f unique/table/delete_part.sim +##./test.sh -u -f unique/table/delete_part.sim -./test.sh -u -f unique/vnode/replica2_basic2.sim -./test.sh -u -f unique/vnode/replica3_basic.sim +##./test.sh -u -f unique/vnode/replica2_basic2.sim +##./test.sh -u -f unique/vnode/replica3_basic.sim #./test.sh -u -f unique/vnode/commit.sim #./test.sh -u -f unique/vnode/many.sim #./test.sh -u -f unique/vnode/replica2_basic.sim -./test.sh -u -f unique/vnode/replica2_basic2.sim +##./test.sh -u -f unique/vnode/replica2_basic2.sim #./test.sh -u -f unique/vnode/replica2_repeat.sim -./test.sh -u -f unique/vnode/replica3_basic.sim +##./test.sh -u -f unique/vnode/replica3_basic.sim #./test.sh -u -f unique/vnode/replica3_repeat.sim #./test.sh -u -f unique/vnode/replica3_vgroup.sim From 78dc2bdfbd0d5b7591255fb2d7b93f76eeb32156 Mon Sep 17 00:00:00 2001 From: chang Date: Sat, 9 May 2020 18:49:58 +0800 Subject: [PATCH 28/41] fix: sys -> monitor stream -> _root --- tests/script/general/user/user_create.sim | 8 ++++---- tests/script/sh/stop_dnodes.sh | 10 +++++----- tests/script/unique/account/user_create.sim | 8 ++++---- tests/script/windows/account/user_create.sim | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/script/general/user/user_create.sim b/tests/script/general/user/user_create.sim index 4da60b7e39..34934d09e6 100644 --- a/tests/script/general/user/user_create.sim +++ b/tests/script/general/user/user_create.sim @@ -34,10 +34,10 @@ print =============== step3 sql drop user read -x step31 return -1 step31: -sql drop user sys -x step32 +sql drop user _root -x step32 return -1 step32: -sql drop user stream -x step33 +sql drop user monitor -x step33 return -1 step33: @@ -71,11 +71,11 @@ sql alter user read privilege 1 -x step43 return -1 step43: -sql drop user sys -x step41 +sql drop user _root -x step41 return -1 step41: -sql drop user stream -x step42 +sql drop user monitor -x step42 return -1 step42: diff --git a/tests/script/sh/stop_dnodes.sh b/tests/script/sh/stop_dnodes.sh index a873eb5654..2364dff9b3 100755 --- a/tests/script/sh/stop_dnodes.sh +++ b/tests/script/sh/stop_dnodes.sh @@ -2,14 +2,14 @@ PID=`ps -ef|grep /usr/bin/taosd | grep -v grep | awk '{print $2}'` if [ -n "$PID" ]; then - echo sudo systemctl stop taosd - sudo systemctl stop taosd + echo systemctl stop taosd + systemctl stop taosd fi PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` while [ -n "$PID" ]; do - echo sudo kill -9 $PID - sudo pkill -9 taosd - sudo fuser -k -n tcp 6030 + echo kill -9 $PID + pkill -9 taosd + fuser -k -n tcp 6030 PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` done diff --git a/tests/script/unique/account/user_create.sim b/tests/script/unique/account/user_create.sim index 075da848d6..789035cfcc 100644 --- a/tests/script/unique/account/user_create.sim +++ b/tests/script/unique/account/user_create.sim @@ -35,10 +35,10 @@ print =============== step3 sql drop user read -x step31 return -1 step31: -sql drop user sys -x step32 +sql drop user _root -x step32 return -1 step32: -sql drop user stream -x step33 +sql drop user monitor -x step33 return -1 step33: @@ -71,11 +71,11 @@ sql alter user read privilege 1 -x step43 return -1 step43: -sql drop user sys -x step41 +sql drop user _root -x step41 return -1 step41: -sql drop user stream -x step42 +sql drop user monitor -x step42 return -1 step42: diff --git a/tests/script/windows/account/user_create.sim b/tests/script/windows/account/user_create.sim index aea95b7c5c..6dc9ab05b3 100644 --- a/tests/script/windows/account/user_create.sim +++ b/tests/script/windows/account/user_create.sim @@ -30,10 +30,10 @@ print =============== step3 sql drop user read -x step31 return -1 step31: -sql drop user sys -x step32 +sql drop user _root -x step32 return -1 step32: -sql drop user stream -x step33 +sql drop user monitor -x step33 return -1 step33: @@ -64,11 +64,11 @@ sql alter user read privilege 1 -x step43 return -1 step43: -sql drop user sys -x step41 +sql drop user _root -x step41 return -1 step41: -sql drop user stream -x step42 +sql drop user monitor -x step42 return -1 step42: From 224496954f2f0dc42954970fc2983eab4206c968 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Sat, 9 May 2020 19:14:33 +0800 Subject: [PATCH 29/41] fix issue pytest stop dnode by pkill. --- .travis.yml | 4 +- tests/pytest/insert/binary.py | 1 - tests/pytest/smoketest.sh | 168 ++++++++++++---------------------- tests/pytest/test.py | 14 +-- tests/pytest/util/dnodes.py | 78 +++++++++++++--- 5 files changed, 129 insertions(+), 136 deletions(-) diff --git a/.travis.yml b/.travis.yml index f9a27fdabd..17ede412d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -72,8 +72,8 @@ matrix: fi done - grep 'definitely lost' mem-error-out.txt | uniq | tee uniq-definitely-lost-out.txt - for defiMemError in `cat uniq-definitely-lost-out.txt | awk '{print $7}'` + grep 'definitely lost:' mem-error-out.txt | uniq | tee uniq-definitely-lost-out.txt + for defiMemError in `cat uniq-definitely-lost-out.txt | awk '{print $4}'` do if [ -n "$defiMemError" ]; then if [ "$defiMemError" -gt 16 ]; then diff --git a/tests/pytest/insert/binary.py b/tests/pytest/insert/binary.py index e254fb1438..677ae4bf29 100644 --- a/tests/pytest/insert/binary.py +++ b/tests/pytest/insert/binary.py @@ -14,7 +14,6 @@ class TDTestCase: def run(self): tdSql.prepare() - tdLog.info('=============== step1') tdLog.info('create table tb (ts timestamp, speed binary(5))') tdSql.execute('create table tb (ts timestamp, speed binary(5))') diff --git a/tests/pytest/smoketest.sh b/tests/pytest/smoketest.sh index 37af5f3f42..e51e8792ec 100755 --- a/tests/pytest/smoketest.sh +++ b/tests/pytest/smoketest.sh @@ -1,172 +1,116 @@ #!/bin/bash python3 ./test.py $1 -f insert/basic.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/int.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/float.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/bigint.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/bool.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/double.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/smallint.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/tinyint.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/binary.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/date.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/nchar.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f table/column_name.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f table/column_num.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f table/db_table.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importDataLastTO.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importDataLastT.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importDataTO.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importDataT.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importHeadOverlap.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importHeadPartOverlap.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importHORestart.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importHPORestart.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importHRestart.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importLastSub.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock1HO.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock1HPO.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock1H.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock1S.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock1Sub.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock1TO.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock1TPO.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock1T.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock2HO.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock2HPO.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock2H.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock2S.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock2Sub.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock2TO.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock2TPO.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlock2T.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importBlockbetween.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importCacheFileSub.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importCacheFileTO.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importCacheFileT.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importDataLastSub.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importHead.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importLastTO.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importLastT.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importSpan.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importSRestart.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importSubRestart.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importTailOverlap.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importTail.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importTORestart.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importTPORestart.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importTRestart.py -python3 ./test.py -s $1 -sleep 1 +python3 ./test.py $1 -s && sleep 1 diff --git a/tests/pytest/test.py b/tests/pytest/test.py index 9bf1660634..a4129be34c 100644 --- a/tests/pytest/test.py +++ b/tests/pytest/test.py @@ -92,23 +92,23 @@ if __name__ == "__main__": tdDnodes.start(1) if masterIp == "": - host='127.0.0.1' + host = '127.0.0.1' else: - host=masterIp + host = masterIp - tdLog.notice("Procedures for tdengine deployed in %s" % (host)) + tdLog.info("Procedures for tdengine deployed in %s" % (host)) if testCluster: - tdLog.notice("Procedures for testing cluster") + tdLog.info("Procedures for testing cluster") if fileName == "all": tdCases.runAllCluster() else: tdCases.runOneCluster(fileName) else: - tdLog.notice("Procedures for testing self-deployment") + tdLog.info("Procedures for testing self-deployment") conn = taos.connect( - host, - config=tdDnodes.getSimCfgPath()) + host, + config=tdDnodes.getSimCfgPath()) if fileName == "all": tdCases.runAllLinux(conn) else: diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 2532cec702..e492a35c20 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -205,24 +205,47 @@ class TDDnode: time.sleep(2) def stop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + if self.running != 0: - cmd = "ps -ef|grep -w taosd | grep '%s' | grep -v grep | awk '{print $2}' && pkill -sigint taosd" % ( - self.cfgDir) - if os.system(cmd) != 0: - tdLog.exit(cmd) - tdLog.debug("dnode:%d is stopped by kill -SIGINT" % (self.index)) + killCmd = "ps -ef|grep -w %s| grep '%s' | grep -v grep | awk '{print $2}' | xargs kill -INT" % ( + toBeKilled, self.cfgDir) + + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output(psCmd, shell=True) + + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) + + tdLog.debug("dnode:%d is stopped by kill -INT" % (self.index)) tdLog.debug( "wait 2 seconds for the dnode:%d to stop." % (self.index)) time.sleep(2) def forcestop(self): + if self.valgrind == 0: + toBeKilled = "taosd" + else: + toBeKilled = "valgrind.bin" + if self.running != 0: - cmd = "ps -ef|grep -w taosd | grep '%s' | grep -v grep | awk '{print $2}' && pkill -sigkill taosd" % ( - self.cfgDir) - if os.system(cmd) != 0: - tdLog.exit(cmd) - tdLog.debug("dnode:%d is stopped by kill -9" % (self.index)) + killCmd = "ps -ef|grep -w %s| grep '%s' | grep -v grep | awk '{print $2}' | xargs kill -KILL" % ( + toBeKilled, self.cfgDir) + psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled + processID = subprocess.check_output(psCmd, shell=True) + + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) + + tdLog.debug("dnode:%d is stopped by kill -KILL" % (self.index)) tdLog.debug( "wait 2 seconds for the dnode:%d to stop." % (self.index)) @@ -268,8 +291,21 @@ class TDDnodes: self.dnodes.append(TDDnode(10)) def init(self, path): - cmd = "ps -ef|grep -w taosd | grep 'taosd' | grep -v grep | awk '{print $2}' && pkill -sigkill taosd" - os.system(cmd) + killCmd = "ps -ef|grep -w taosd | grep -v grep | awk '{print $2}' | xargs kill -KILL" + psCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True) + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) + + killCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}' | xargs kill -KILL" + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True) + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) binPath = os.path.dirname(os.path.realpath(__file__)) binPath = binPath + "/../../../debug/" @@ -361,8 +397,22 @@ class TDDnodes: os.system(cmd) # if os.system(cmd) != 0 : # tdLog.exit(cmd) - cmd = "ps -ef | grep -w taosd | grep 'dnode' | grep -v grep | awk '{print $2}' && pkill -sigkill taosd" - os.system(cmd) + killCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}' | xargs kill -KILL" + psCmd = "ps -ef|grep -w taosd| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True) + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) + + killCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}' | xargs kill -KILL" + psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'" + processID = subprocess.check_output(psCmd, shell=True) + while(processID): + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output(psCmd, shell=True) + # if os.system(cmd) != 0 : # tdLog.exit(cmd) From 0b1cab6cc60e3fc1c152437e0f2ef9c4cd951b4b Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 9 May 2020 22:08:41 +0800 Subject: [PATCH 30/41] fix bug while drop sdb --- src/dnode/src/dnodeVWrite.c | 2 +- src/inc/taosmsg.h | 1 + src/mnode/src/mgmtTable.c | 49 ++++++++++++++++++++----------------- src/vnode/src/vnodeMain.c | 2 +- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/dnode/src/dnodeVWrite.c b/src/dnode/src/dnodeVWrite.c index 147d2bdfbb..5de4c16c50 100644 --- a/src/dnode/src/dnodeVWrite.c +++ b/src/dnode/src/dnodeVWrite.c @@ -85,7 +85,7 @@ void dnodeCleanupWrite() { void dnodeDispatchToVnodeWriteQueue(SRpcMsg *pMsg) { char *pCont = (char *)pMsg->pCont; - if (pMsg->msgType == TSDB_MSG_TYPE_SUBMIT || pMsg->msgType == TSDB_MSG_TYPE_MD_DROP_STABLE) { + if (pMsg->msgType == TSDB_MSG_TYPE_SUBMIT) { SMsgDesc *pDesc = (SMsgDesc *)pCont; pDesc->numOfVnodes = htonl(pDesc->numOfVnodes); pCont += sizeof(SMsgDesc); diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index c359ede22e..8dac73606d 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -326,6 +326,7 @@ typedef struct { } SMDDropTableMsg; typedef struct { + int32_t contLen; int32_t vgId; int64_t uid; char tableId[TSDB_TABLE_ID_LEN + 1]; diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index 2225e08f58..bfe357cf7c 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -701,10 +701,10 @@ static void mgmtProcessDropTableMsg(SQueuedMsg *pMsg) { } if (pMsg->pTable->type == TSDB_SUPER_TABLE) { - mTrace("table:%s, start to drop stable", pDrop->tableId); + mPrint("table:%s, start to drop stable", pDrop->tableId); mgmtProcessDropSuperTableMsg(pMsg); } else { - mTrace("table:%s, start to drop ctable", pDrop->tableId); + mPrint("table:%s, start to drop ctable", pDrop->tableId); mgmtProcessDropChildTableMsg(pMsg); } } @@ -802,29 +802,32 @@ static void mgmtProcessDropSuperTableMsg(SQueuedMsg *pMsg) { int32_t vgId = pStable->vgList[vg]; if (vgId == 0) break; + SVgObj *pVgroup = mgmtGetVgroup(vgId); + if (pVgroup == NULL) break; + SMDDropSTableMsg *pDrop = rpcMallocCont(sizeof(SMDDropSTableMsg)); + pDrop->contLen = htonl(sizeof(SMDDropSTableMsg)); pDrop->vgId = htonl(vgId); pDrop->uid = htobe64(pStable->uid); mgmtExtractTableName(pStable->info.tableId, pDrop->tableId); - - SVgObj *pVgroup = mgmtGetVgroup(vgId); - if (pVgroup != NULL) { - SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pVgroup); - SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE}; - dnodeSendMsgToDnode(&ipSet, &rpcMsg); - mgmtDecVgroupRef(pVgroup); - } + + mPrint("stable:%s, send drop stable msg to vgId:%d", pStable->info.tableId, vgId); + SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pVgroup); + SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE}; + dnodeSendMsgToDnode(&ipSet, &rpcMsg); + mgmtDecVgroupRef(pVgroup); } - } else { - SSdbOper oper = { - .type = SDB_OPER_GLOBAL, - .table = tsSuperTableSdb, - .pObj = pStable - }; - int32_t code = sdbDeleteRow(&oper); - mLPrint("stable:%s, is dropped from sdb, result:%s", pStable->info.tableId, tstrerror(code)); - mgmtSendSimpleResp(pMsg->thandle, code); - } + } + + SSdbOper oper = { + .type = SDB_OPER_GLOBAL, + .table = tsSuperTableSdb, + .pObj = pStable + }; + + int32_t code = sdbDeleteRow(&oper); + mLPrint("stable:%s, is dropped from sdb, result:%s", pStable->info.tableId, tstrerror(code)); + mgmtSendSimpleResp(pMsg->thandle, code); } static int32_t mgmtFindSuperTableTagIndex(SSuperTableObj *pStable, const char *tagName) { @@ -1303,7 +1306,7 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { } static void mgmtProcessDropSuperTableRsp(SRpcMsg *rpcMsg) { - mTrace("drop stable rsp received, handle:%p code:%s", rpcMsg->handle, tstrerror(rpcMsg->code)); + mPrint("drop stable rsp received, result:%s", tstrerror(rpcMsg->code)); } static void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableObj *pTable) { @@ -1540,7 +1543,7 @@ static void mgmtProcessDropChildTableMsg(SQueuedMsg *pMsg) { SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pMsg->pVgroup); - mTrace("table:%s, send drop ctable msg", pDrop->tableId); + mPrint("table:%s, send drop ctable msg", pDrop->tableId); SQueuedMsg *newMsg = mgmtCloneQueuedMsg(pMsg); newMsg->ahandle = pMsg->pTable; SRpcMsg rpcMsg = { @@ -1867,7 +1870,7 @@ static void mgmtProcessDropChildTableRsp(SRpcMsg *rpcMsg) { queueMsg->received++; SChildTableObj *pTable = queueMsg->ahandle; - mTrace("table:%s, drop table rsp received, thandle:%p result:%s", pTable->info.tableId, queueMsg->thandle, tstrerror(rpcMsg->code)); + mPrint("table:%s, drop table rsp received, thandle:%p result:%s", pTable->info.tableId, queueMsg->thandle, tstrerror(rpcMsg->code)); if (rpcMsg->code != TSDB_CODE_SUCCESS) { mError("table:%s, failed to drop in dnode, reason:%s", pTable->info.tableId, tstrerror(rpcMsg->code)); diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 6ffac08b4e..16845812bf 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -301,7 +301,7 @@ void *vnodeGetVnode(int32_t vgId) { SVnodeObj **ppVnode = (SVnodeObj **)taosGetIntHashData(tsDnodeVnodesHash, vgId); if (ppVnode == NULL || *ppVnode == NULL) { terrno = TSDB_CODE_INVALID_VGROUP_ID; - vPrint("vgId:%d not exist", vgId); + vPrint("vgId:%d, not exist", vgId); return NULL; } From 92a19d9c164f39d7982fa19e9ca6b4e4ccc5c92f Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 9 May 2020 22:15:45 +0800 Subject: [PATCH 31/41] scripts --- tests/script/general/metrics/testSuite.sim | 4 ---- tests/script/general/{metrics => stable}/disk.sim | 0 tests/script/general/{metrics => stable}/metrics.sim | 0 tests/script/general/stable/testSuite.sim | 4 ++++ tests/script/general/{metrics => stable}/values.sim | 0 tests/script/general/{metrics => stable}/vnode3.sim | 0 tests/script/general/table/basic3.sim | 7 +++++++ tests/script/jenkins/basic.txt | 10 +++++----- 8 files changed, 16 insertions(+), 9 deletions(-) delete mode 100644 tests/script/general/metrics/testSuite.sim rename tests/script/general/{metrics => stable}/disk.sim (100%) rename tests/script/general/{metrics => stable}/metrics.sim (100%) create mode 100644 tests/script/general/stable/testSuite.sim rename tests/script/general/{metrics => stable}/values.sim (100%) rename tests/script/general/{metrics => stable}/vnode3.sim (100%) diff --git a/tests/script/general/metrics/testSuite.sim b/tests/script/general/metrics/testSuite.sim deleted file mode 100644 index 55300034b6..0000000000 --- a/tests/script/general/metrics/testSuite.sim +++ /dev/null @@ -1,4 +0,0 @@ -run general/metrics/disk.sim -run general/metrics/metrics.sim -run general/metrics/values.sim -run general/metrics/vnode3.sim diff --git a/tests/script/general/metrics/disk.sim b/tests/script/general/stable/disk.sim similarity index 100% rename from tests/script/general/metrics/disk.sim rename to tests/script/general/stable/disk.sim diff --git a/tests/script/general/metrics/metrics.sim b/tests/script/general/stable/metrics.sim similarity index 100% rename from tests/script/general/metrics/metrics.sim rename to tests/script/general/stable/metrics.sim diff --git a/tests/script/general/stable/testSuite.sim b/tests/script/general/stable/testSuite.sim new file mode 100644 index 0000000000..a3696c8706 --- /dev/null +++ b/tests/script/general/stable/testSuite.sim @@ -0,0 +1,4 @@ +run general/stable/disk.sim +run general/stable/metrics.sim +run general/stable/values.sim +run general/stable/vnode3.sim diff --git a/tests/script/general/metrics/values.sim b/tests/script/general/stable/values.sim similarity index 100% rename from tests/script/general/metrics/values.sim rename to tests/script/general/stable/values.sim diff --git a/tests/script/general/metrics/vnode3.sim b/tests/script/general/stable/vnode3.sim similarity index 100% rename from tests/script/general/metrics/vnode3.sim rename to tests/script/general/stable/vnode3.sim diff --git a/tests/script/general/table/basic3.sim b/tests/script/general/table/basic3.sim index 7f90dc0c52..ded00e153a 100644 --- a/tests/script/general/table/basic3.sim +++ b/tests/script/general/table/basic3.sim @@ -70,4 +70,11 @@ if $data21 != 3 then return -1 endi +print =============== drop stable +sql drop table db.st +sql show db.stables +if $rows != 0 then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 6e9572e83c..48617c149a 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -96,11 +96,6 @@ cd ../../../debug; make ./test.sh -f general/insert/query_multi_file.sim ./test.sh -f general/insert/tcp.sim -#./test.sh -f general/metrics/disk.sim -#./test.sh -f general/metrics/metrics.sim -#./test.sh -f general/metrics/values.sim -#./test.sh -f general/metrics/vnode3.sim - #parser # ./test.sh -f general/parser/alter.sim @@ -162,6 +157,11 @@ cd ../../../debug; make # ./test.sh -f general/parser/select_with_tags.sim # ./test.sh -f general/parser/groupby.sim +#./test.sh -f general/stable/disk.sim +#./test.sh -f general/stable/metrics.sim +#./test.sh -f general/stable/values.sim +#./test.sh -f general/stable/vnode3.sim + #stream ./test.sh -f general/table/autocreate.sim From dba2b23ce375cf367744f22412ca6d877fddafed Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 9 May 2020 22:41:46 +0800 Subject: [PATCH 32/41] fix valgrind error --- src/mnode/src/mgmtSdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mnode/src/mgmtSdb.c b/src/mnode/src/mgmtSdb.c index 4a18c5e285..c25f4457a9 100644 --- a/src/mnode/src/mgmtSdb.c +++ b/src/mnode/src/mgmtSdb.c @@ -278,7 +278,7 @@ void sdbUpdateSync() { sdbPrint("mnode:%d, %s:%d", syncCfg.nodeInfo[i].nodeId, syncCfg.nodeInfo[i].nodeFqdn, syncCfg.nodeInfo[i].nodePort); } - SSyncInfo syncInfo; + SSyncInfo syncInfo = {0}; syncInfo.vgId = 1; syncInfo.version = sdbGetVersion(); syncInfo.syncCfg = syncCfg; From 2267048e72c4163fd6c33af9afede75c0184fc26 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Sat, 9 May 2020 23:49:08 +0800 Subject: [PATCH 33/41] fix memory error formula in .travis. reduce threshold to 5. --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 17ede412d2..2cb7b8e966 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,12 +59,12 @@ matrix: GREEN_UNDERLINE='\033[4;32m' NC='\033[0m' - grep 'ERROR SUMMARY' mem-error-out.txt | uniq | tee uniq-mem-error-out.txt + grep 'ERROR SUMMARY' mem-error-out.txt|grep -v 'grep'|uniq|tee uniq-mem-error-out.txt for memError in `cat uniq-mem-error-out.txt | awk '{print $4}'` do if [ -n "$memError" ]; then - if [ "$memError" -gt 16 ]; then + if [ "$memError" -gt 5 ]; then echo -e "${RED} ## Memory errors number valgrind reports is $memError.\ More than our threshold! ## ${NC}" travis_terminate $memError @@ -72,11 +72,11 @@ matrix: fi done - grep 'definitely lost:' mem-error-out.txt | uniq | tee uniq-definitely-lost-out.txt - for defiMemError in `cat uniq-definitely-lost-out.txt | awk '{print $4}'` + grep 'definitely lost:' mem-error-out.txt|grep -v 'grep'|uniq|tee uniq-definitely-lost-out.txt + for defiMemError in `cat uniq-definitely-lost-out.txt | awk '{print $7}'` do if [ -n "$defiMemError" ]; then - if [ "$defiMemError" -gt 16 ]; then + if [ "$defiMemError" -gt 3 ]; then echo -e "${RED} ## Memory errors number valgrind reports \ Definitely lost is $defiMemError. More than our threshold! ## ${NC}" travis_terminate $defiMemError From c43695e344d1e495cdbd08bf2bf555fe56e81414 Mon Sep 17 00:00:00 2001 From: slguan Date: Sun, 10 May 2020 00:06:37 +0800 Subject: [PATCH 34/41] fix bug in pass_alter.sim, add log, revise shellActiveTimer --- src/client/src/tscSql.c | 4 ++-- src/client/src/tscSystem.c | 2 ++ src/client/src/tscUtil.c | 2 +- src/dnode/src/dnodePeer.c | 4 ++-- src/dnode/src/dnodeShell.c | 2 +- src/rpc/src/rpcMain.c | 2 +- tests/script/general/user/pass_alter.sim | 25 +++++++++++++++++++++--- 7 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index a45db94b49..14f0fa07ca 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -172,7 +172,7 @@ static void syncConnCallback(void *param, TAOS_RES *tres, int code) { } TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) { - tscTrace("try to create a connection to %s", ip); + tscTrace("try to create a connection to %s:%u, user:%s db:%s", ip, port, user, db); STscObj *pObj = taosConnectImpl(ip, user, pass, db, port, NULL, NULL, NULL); if (pObj != NULL) { @@ -191,7 +191,7 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha return NULL; } - tscTrace("%p DB connection is opening", pObj); + tscTrace("%p DB connection is opening, dnodeConn:%p", pObj, pObj->pDnodeConn); // version compare only requires the first 3 segments of the version string int code = taosCheckVersion(version, taos_get_server_info(pObj), 3); diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index d713a9ee5f..07926306db 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -69,6 +69,8 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn) { if (*pDnodeConn == NULL) { tscError("failed to init connection to TDengine"); return -1; + } else { + tscTrace("dnodeConn:%p is created, user:%s", *pDnodeConn, user); } } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index ccb363d9e8..dd3cb76cbf 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -766,7 +766,7 @@ void tscCloseTscObj(STscObj* pObj) { rpcClose(pObj->pDnodeConn); } - tscTrace("%p DB connection is closed", pObj); + tscTrace("%p DB connection is closed, dnodeConn:%p", pObj, pObj->pDnodeConn); tfree(pObj); } diff --git a/src/dnode/src/dnodePeer.c b/src/dnode/src/dnodePeer.c index b1e5d9fd38..ea21ed0206 100644 --- a/src/dnode/src/dnodePeer.c +++ b/src/dnode/src/dnodePeer.c @@ -61,7 +61,7 @@ int32_t dnodeInitServer() { rpcInit.cfp = dnodeProcessReqMsgFromDnode; rpcInit.sessions = 100; rpcInit.connType = TAOS_CONN_SERVER; - rpcInit.idleTime = tsShellActivityTimer * 2000; + rpcInit.idleTime = tsShellActivityTimer * 1000; tsDnodeServerRpc = rpcOpen(&rpcInit); if (tsDnodeServerRpc == NULL) { @@ -122,7 +122,7 @@ int32_t dnodeInitClient() { rpcInit.ufp = dnodeUpdateIpSet; rpcInit.sessions = 100; rpcInit.connType = TAOS_CONN_CLIENT; - rpcInit.idleTime = tsShellActivityTimer * 2000; + rpcInit.idleTime = tsShellActivityTimer * 1000; rpcInit.user = "t"; rpcInit.ckey = "key"; rpcInit.secret = "secret"; diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index cf6b5e38ab..28679262fa 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -86,7 +86,7 @@ int32_t dnodeInitShell() { rpcInit.cfp = dnodeProcessMsgFromShell; rpcInit.sessions = TSDB_SESSIONS_PER_DNODE; rpcInit.connType = TAOS_CONN_SERVER; - rpcInit.idleTime = tsShellActivityTimer * 1500; + rpcInit.idleTime = tsShellActivityTimer * 1000; rpcInit.afp = dnodeRetrieveUserAuthInfo; tsDnodeShellRpc = rpcOpen(&rpcInit); diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 685b0f2b86..f5244545fc 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -793,7 +793,7 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) { pConn->chandle = pRecv->chandle; pConn->peerIp = pRecv->ip; - if (pConn->peerPort == 0) pConn->peerPort = pRecv->port; + pConn->peerPort = pRecv->port; if (pHead->port) pConn->peerPort = htons(pHead->port); terrno = rpcCheckAuthentication(pConn, (char *)pHead, pRecv->msgLen); diff --git a/tests/script/general/user/pass_alter.sim b/tests/script/general/user/pass_alter.sim index 034e704a87..857d658db1 100644 --- a/tests/script/general/user/pass_alter.sim +++ b/tests/script/general/user/pass_alter.sim @@ -19,28 +19,47 @@ endi print ============= step2 sql close +sleep 2500 +print user read login sql connect read -sleep 2000 sql alter user read pass 'taosdata' sql alter user write pass 'taosdata1' -x step2 return -1 step2: +sql_error create user read pass 'taosdata1' +sql_error create user write pass 'taosdata1' + +sql show users +if $rows != 5 then + return -1 +endi print ============= step3 sql close +sleep 2500 +print user write login sql connect write -sleep 2000 + +sql_error create user read pass 'taosdata1' +sql_error create user write pass 'taosdata1' sql alter user write pass 'taosdata' sql alter user read pass 'taosdata' -x step3 return -1 step3: +sql show users +if $rows != 5 then + return -1 +endi + print ============= step4 sql close +sleep 2500 +print root write login sql connect -sleep 2000 sql create user oroot pass 'taosdata' + sql show users if $rows != 6 then return -1 From 105f44069083d5120dabc7a223cf8a3081171421 Mon Sep 17 00:00:00 2001 From: slguan Date: Sun, 10 May 2020 00:10:37 +0800 Subject: [PATCH 35/41] scripts --- tests/script/basicSuite.sim | 1 + tests/script/jenkins/basic.txt | 12 ++++++------ tests/tsim/src/simExe.c | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/script/basicSuite.sim b/tests/script/basicSuite.sim index 676ac93bf2..aa0fbf65b7 100644 --- a/tests/script/basicSuite.sim +++ b/tests/script/basicSuite.sim @@ -20,6 +20,7 @@ run general/table/column_name.sim run general/table/int.sim run general/table/vgroup.sim run general/user/basic1.sim +run general/user/pass_alter.sim run general/user/user_len.sim run general/vector/single.sim ################################## diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 48617c149a..d96a1db2b4 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -220,9 +220,9 @@ cd ../../../debug; make ./test.sh -f general/user/basic1.sim #./test.sh -f general/user/monitor.sim -##./test.sh -f general/user/pass_alter.sim +./test.sh -f general/user/pass_alter.sim ./test.sh -f general/user/pass_len.sim -##./test.sh -f general/user/user_create.sim +./test.sh -f general/user/user_create.sim ./test.sh -f general/user/user_len.sim #./test.sh -f general/vector/metrics_field.sim @@ -240,15 +240,15 @@ cd ../../../debug; make ################################# ./test.sh -u -f unique/account/account_create.sim -##./test.sh -u -f unique/account/account_delete.sim +./test.sh -u -f unique/account/account_delete.sim ./test.sh -u -f unique/account/account_len.sim -##./test.sh -u -f unique/account/authority.sim +./test.sh -u -f unique/account/authority.sim ./test.sh -u -f unique/account/basic.sim ./test.sh -u -f unique/account/paras.sim -##./test.sh -u -f unique/account/pass_alter.sim +./test.sh -u -f unique/account/pass_alter.sim ./test.sh -u -f unique/account/pass_len.sim ./test.sh -u -f unique/account/usage.sim -##./test.sh -u -f unique/account/user_create.sim +./test.sh -u -f unique/account/user_create.sim ./test.sh -u -f unique/account/user_len.sim #./test.sh -u -f unique/big/balance.sim diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index d6ab2d5b92..5ea1cb4a1a 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -415,7 +415,7 @@ void simCloseNativeConnect(SScript *script) { simTrace("script:%s, taos:%p closed", script->fileName, script->taos); taos_close(script->taos); - taosMsleep(1000); + taosMsleep(1200); script->taos = NULL; } From 5e2cd9fe1bf6e71636ea1ac237210ce0ef88dd03 Mon Sep 17 00:00:00 2001 From: slguan Date: Sun, 10 May 2020 11:14:51 +0800 Subject: [PATCH 36/41] rename log var names --- src/client/inc/tscLog.h | 16 ++++++++-------- src/client/src/TSDBJNIConnector.c | 12 ++++++------ src/common/inc/tglobal.h | 10 +++++----- src/common/src/tglobal.c | 30 +++++++++++++++--------------- src/mnode/inc/mgmtInt.h | 8 ++++---- src/query/inc/queryLog.h | 14 +++++++------- src/util/src/tconfig.c | 2 +- 7 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/client/inc/tscLog.h b/src/client/inc/tscLog.h index e82b824123..346e1a6795 100644 --- a/src/client/inc/tscLog.h +++ b/src/client/inc/tscLog.h @@ -22,25 +22,25 @@ extern "C" { #include "tlog.h" -extern int32_t cdebugFlag; +extern int32_t cDebugFlag; #define tscError(...) \ - if (cdebugFlag & DEBUG_ERROR) { \ + if (cDebugFlag & DEBUG_ERROR) { \ taosPrintLog("ERROR TSC ", 255, __VA_ARGS__); \ } #define tscWarn(...) \ - if (cdebugFlag & DEBUG_WARN) { \ - taosPrintLog("WARN TSC ", cdebugFlag, __VA_ARGS__); \ + if (cDebugFlag & DEBUG_WARN) { \ + taosPrintLog("WARN TSC ", cDebugFlag, __VA_ARGS__); \ } #define tscTrace(...) \ - if (cdebugFlag & DEBUG_TRACE) { \ - taosPrintLog("TSC ", cdebugFlag, __VA_ARGS__); \ + if (cDebugFlag & DEBUG_TRACE) { \ + taosPrintLog("TSC ", cDebugFlag, __VA_ARGS__); \ } #define tscPrint(...) \ { taosPrintLog("TSC ", 255, __VA_ARGS__); } #define tscDump(...) \ - if (cdebugFlag & DEBUG_TRACE) { \ - taosPrintLongString("TSC ", cdebugFlag, __VA_ARGS__); \ + if (cDebugFlag & DEBUG_TRACE) { \ + taosPrintLongString("TSC ", cDebugFlag, __VA_ARGS__); \ } #ifdef __cplusplus diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index 05b7a2be1e..812c197ef7 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -23,16 +23,16 @@ #include "ttime.h" #define jniError(...) \ - if (jnidebugFlag & DEBUG_ERROR) { \ - taosPrintLog("ERROR JNI ", jnidebugFlag, __VA_ARGS__); \ + if (jniDebugFlag & DEBUG_ERROR) { \ + taosPrintLog("ERROR JNI ", jniDebugFlag, __VA_ARGS__); \ } #define jniWarn(...) \ - if (jnidebugFlag & DEBUG_WARN) { \ - taosPrintLog("WARN JNI ", jnidebugFlag, __VA_ARGS__); \ + if (jniDebugFlag & DEBUG_WARN) { \ + taosPrintLog("WARN JNI ", jniDebugFlag, __VA_ARGS__); \ } #define jniTrace(...) \ - if (jnidebugFlag & DEBUG_TRACE) { \ - taosPrintLog("JNI ", jnidebugFlag, __VA_ARGS__); \ + if (jniDebugFlag & DEBUG_TRACE) { \ + taosPrintLog("JNI ", jniDebugFlag, __VA_ARGS__); \ } #define jniPrint(...) \ { taosPrintLog("JNI ", 255, __VA_ARGS__); } diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 05afbab642..b077f40945 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -141,9 +141,9 @@ extern int32_t tsAsyncLog; extern int32_t tsNumOfLogLines; extern int32_t dDebugFlag; extern int32_t vDebugFlag; -extern int32_t mdebugFlag; -extern int32_t cdebugFlag; -extern int32_t jnidebugFlag; +extern int32_t mDebugFlag; +extern int32_t cDebugFlag; +extern int32_t jniDebugFlag; extern int32_t tmrDebugFlag; extern int32_t sdbDebugFlag; extern int32_t httpDebugFlag; @@ -151,8 +151,8 @@ extern int32_t monitorDebugFlag; extern int32_t uDebugFlag; extern int32_t rpcDebugFlag; extern int32_t debugFlag; -extern int32_t odbcdebugFlag; -extern int32_t qdebugFlag; +extern int32_t odbcDebugFlag; +extern int32_t qDebugFlag; extern uint32_t taosMaxTmrCtrl; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 991c1b403b..90637265b3 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -127,16 +127,16 @@ int32_t tsRestRowLimit = 10240; int32_t tsMaxSQLStringLen = TSDB_MAX_SQL_LEN; int32_t tsNumOfLogLines = 10000000; -int32_t mdebugFlag = 135; +int32_t mDebugFlag = 135; int32_t sdbDebugFlag = 135; int32_t dDebugFlag = 135; int32_t vDebugFlag = 135; -int32_t cdebugFlag = 135; -int32_t jnidebugFlag = 131; -int32_t odbcdebugFlag = 131; +int32_t cDebugFlag = 135; +int32_t jniDebugFlag = 131; +int32_t odbcDebugFlag = 131; int32_t httpDebugFlag = 131; int32_t monitorDebugFlag = 131; -int32_t qdebugFlag = 131; +int32_t qDebugFlag = 131; int32_t rpcDebugFlag = 135; int32_t uDebugFlag = 131; int32_t debugFlag = 131; @@ -204,19 +204,19 @@ static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT; void taosSetAllDebugFlag() { for (int32_t i = 0; i < tsGlobalConfigNum; ++i) { - mdebugFlag = debugFlag; + mDebugFlag = debugFlag; sdbDebugFlag = debugFlag; dDebugFlag = debugFlag; vDebugFlag = debugFlag; - cdebugFlag = debugFlag; - jnidebugFlag = debugFlag; - odbcdebugFlag = debugFlag; + cDebugFlag = debugFlag; + jniDebugFlag = debugFlag; + odbcDebugFlag = debugFlag; httpDebugFlag = debugFlag; monitorDebugFlag = debugFlag; rpcDebugFlag = debugFlag; uDebugFlag = debugFlag; sDebugFlag = debugFlag; - //qdebugFlag = debugFlag; + //qDebugFlag = debugFlag; } uPrint("all debug flag are set to %d", debugFlag); } @@ -1002,7 +1002,7 @@ static void doInitGlobalConfig() { taosInitConfigOption(cfg); cfg.option = "mDebugFlag"; - cfg.ptr = &mdebugFlag; + cfg.ptr = &mDebugFlag; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG; cfg.minValue = 0; @@ -1062,7 +1062,7 @@ static void doInitGlobalConfig() { taosInitConfigOption(cfg); cfg.option = "cDebugFlag"; - cfg.ptr = &cdebugFlag; + cfg.ptr = &cDebugFlag; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT; cfg.minValue = 0; @@ -1072,7 +1072,7 @@ static void doInitGlobalConfig() { taosInitConfigOption(cfg); cfg.option = "jniDebugFlag"; - cfg.ptr = &jnidebugFlag; + cfg.ptr = &jniDebugFlag; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT; cfg.minValue = 0; @@ -1082,7 +1082,7 @@ static void doInitGlobalConfig() { taosInitConfigOption(cfg); cfg.option = "odbcDebugFlag"; - cfg.ptr = &odbcdebugFlag; + cfg.ptr = &odbcDebugFlag; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT; cfg.minValue = 0; @@ -1122,7 +1122,7 @@ static void doInitGlobalConfig() { taosInitConfigOption(cfg); cfg.option = "qDebugFlag"; - cfg.ptr = &qdebugFlag; + cfg.ptr = &qDebugFlag; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT; cfg.minValue = 0; diff --git a/src/mnode/inc/mgmtInt.h b/src/mnode/inc/mgmtInt.h index 17553ade72..a83d5beee0 100644 --- a/src/mnode/inc/mgmtInt.h +++ b/src/mnode/inc/mgmtInt.h @@ -23,13 +23,13 @@ extern "C" { #include "tlog.h" #include "monitor.h" -extern int32_t mdebugFlag; +extern int32_t mDebugFlag; extern int32_t sdbDebugFlag; // mnode log function -#define mError(...) if (mdebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MND ", 255, __VA_ARGS__); } -#define mWarn(...) if (mdebugFlag & DEBUG_WARN) { taosPrintLog("WARN MND ", mdebugFlag, __VA_ARGS__); } -#define mTrace(...) if (mdebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mdebugFlag, __VA_ARGS__); } +#define mError(...) if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MND ", 255, __VA_ARGS__); } +#define mWarn(...) if (mDebugFlag & DEBUG_WARN) { taosPrintLog("WARN MND ", mDebugFlag, __VA_ARGS__); } +#define mTrace(...) if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); } #define mPrint(...) { taosPrintLog("MND ", 255, __VA_ARGS__); } #define mLError(...) monitorSaveLog(2, __VA_ARGS__); mError(__VA_ARGS__) diff --git a/src/query/inc/queryLog.h b/src/query/inc/queryLog.h index 2c77ee6032..4894d67e04 100644 --- a/src/query/inc/queryLog.h +++ b/src/query/inc/queryLog.h @@ -22,20 +22,20 @@ extern "C" { #include "tlog.h" -extern int32_t qdebugFlag; +extern int32_t qDebugFlag; #define qTrace(...) \ - if (qdebugFlag & DEBUG_TRACE) { \ - taosPrintLog("DND QRY ", qdebugFlag, __VA_ARGS__); \ + if (qDebugFlag & DEBUG_TRACE) { \ + taosPrintLog("DND QRY ", qDebugFlag, __VA_ARGS__); \ } #define qError(...) \ - if (qdebugFlag & DEBUG_ERROR) { \ - taosPrintLog("ERROR QRY ", qdebugFlag, __VA_ARGS__); \ + if (qDebugFlag & DEBUG_ERROR) { \ + taosPrintLog("ERROR QRY ", qDebugFlag, __VA_ARGS__); \ } #define qWarn(...) \ - if (qdebugFlag & DEBUG_WARN) { \ - taosPrintLog("WARN QRY ", qdebugFlag, __VA_ARGS__); \ + if (qDebugFlag & DEBUG_WARN) { \ + taosPrintLog("WARN QRY ", qDebugFlag, __VA_ARGS__); \ } #ifdef __cplusplus diff --git a/src/util/src/tconfig.c b/src/util/src/tconfig.c index dfbdc5e35d..61ae647bf4 100644 --- a/src/util/src/tconfig.c +++ b/src/util/src/tconfig.c @@ -236,7 +236,7 @@ void taosReadGlobalLogCfg() { int olen, vlen; char fileName[PATH_MAX] = {0}; - mdebugFlag = 135; + mDebugFlag = 135; sdbDebugFlag = 135; wordexp_t full_path; From 156f0df4c467f156795e39ab1a7a82dbd728acc5 Mon Sep 17 00:00:00 2001 From: slguan Date: Sun, 10 May 2020 19:03:06 +0800 Subject: [PATCH 37/41] scripts --- tests/script/unique/mnode/mgmt22.sim | 10 +++------- tests/script/unique/vnode/replica2_basic2.sim | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/script/unique/mnode/mgmt22.sim b/tests/script/unique/mnode/mgmt22.sim index 50692524cf..041a6734e2 100644 --- a/tests/script/unique/mnode/mgmt22.sim +++ b/tests/script/unique/mnode/mgmt22.sim @@ -8,7 +8,7 @@ system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2 print ============== step1 -system sh/exec_up.sh -n dnode1 -s start -t +system sh/exec_up.sh -n dnode1 -s start sleep 3000 sql connect @@ -20,7 +20,7 @@ if $data2_1 != master then endi print ============== step2 -system sh/exec_up.sh -n dnode2 -s start -t +system sh/exec_up.sh -n dnode2 -s start sql create dnode $hostname2 $x = 0 @@ -45,10 +45,6 @@ print ============== step3 sql_error drop dnode $hostname1 -x error1 print should not drop master -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -return - print ============== step4 system sh/exec_up.sh -n dnode1 -s stop -x SIGINT sql_error show mnodes @@ -83,7 +79,7 @@ if $data2_2 != slave then endi print ============== step7 -system sh/exec_up.sh -n dnode3 -s start -t +system sh/exec_up.sh -n dnode3 -s start sql create dnode $hostname3 sleep 5000 diff --git a/tests/script/unique/vnode/replica2_basic2.sim b/tests/script/unique/vnode/replica2_basic2.sim index a86071faaf..041db8249a 100644 --- a/tests/script/unique/vnode/replica2_basic2.sim +++ b/tests/script/unique/vnode/replica2_basic2.sim @@ -27,6 +27,7 @@ system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 print ========= start dnodes system sh/exec_up.sh -n dnode1 -s start +sleep 3000 sql connect sql create dnode $hostname2 system sh/exec_up.sh -n dnode2 -s start @@ -89,6 +90,19 @@ if $data2_3 != 4 then return -1 endi +if $data4_1 != ready then + print dnode1 status should ready but is $data4_1 + return -1 +endi + +if $data4_2 != ready then + return -1 +endi + +if $data4_3 != ready then + return -1 +endi + print ========= step2 sql insert into d1.t1 values(now, 2) sql insert into d2.t2 values(now, 2) From 41f634dc48d0f943cfa18eb6c2a0467bdad9177c Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Sun, 10 May 2020 14:08:13 +0000 Subject: [PATCH 38/41] port shall be htons --- src/mnode/src/mgmtServer.c | 4 +++- src/mnode/src/mgmtShell.c | 2 +- src/rpc/src/rpcMain.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mnode/src/mgmtServer.c b/src/mnode/src/mgmtServer.c index a6b4362cbf..7810189e34 100644 --- a/src/mnode/src/mgmtServer.c +++ b/src/mnode/src/mgmtServer.c @@ -88,10 +88,12 @@ void mgmtProcessReqMsgFromDnode(SRpcMsg *rpcMsg) { SRpcIpSet ipSet = {0}; dnodeGetMnodeDnodeIpSet(&ipSet); + for (int i = 0; i < ipSet.numOfIps; ++i) + ipSet.port[i] = htons(ipSet.port[i]); mTrace("conn from dnode ip:%s user:%s redirect msg, inUse:%d", taosIpStr(connInfo.clientIp), connInfo.user, ipSet.inUse); for (int32_t i = 0; i < ipSet.numOfIps; ++i) { - mTrace("index:%d %s:%d", i, ipSet.fqdn[i], ipSet.port[i]); + mTrace("mnode index:%d %s:%d", i, ipSet.fqdn[i], htons(ipSet.port[i])); } rpcSendRedirectRsp(rpcMsg->handle, &ipSet); return; diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index c869e752d3..cd74c166d1 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -137,7 +137,7 @@ void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) { mgmtGetMnodeIpSet(&ipSet); mTrace("conn from shell ip:%s user:%s redirect msg, inUse:%d", taosIpStr(connInfo.clientIp), connInfo.user, ipSet.inUse); for (int32_t i = 0; i < ipSet.numOfIps; ++i) { - mTrace("index:%d ip:%s:%d", i, ipSet.fqdn[i], ipSet.port[i]); + mTrace("mnode index:%d ip:%s:%d", i, ipSet.fqdn[i], htons(ipSet.port[i])); } rpcSendRedirectRsp(rpcMsg->handle, &ipSet); diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index f5244545fc..a2333566f1 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -1094,8 +1094,8 @@ static void rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) { } else { if (pHead->code == 0) pConn->secured = 1; // for success response, set link as secured if (pHead->msgType < TSDB_MSG_TYPE_CM_HEARTBEAT || (rpcDebugFlag & 16)) - tTrace( "%s %p, %s is sent to %s:%hu, code:0x%x len:%d sig:0x%08x:0x%08x:%d", - pRpc->label, pConn, taosMsg[pHead->msgType], pConn->peerFqdn, pConn->peerPort, + tTrace( "%s %p, %s is sent to 0x%x:%hu, code:0x%x len:%d sig:0x%08x:0x%08x:%d", + pRpc->label, pConn, taosMsg[pHead->msgType], pConn->peerIp, pConn->peerPort, htonl(pHead->code), msgLen, pHead->sourceId, pHead->destId, pHead->tranId); } From dc2537d4d8f7f6deeec137ffe651f9c5ba2e5f6f Mon Sep 17 00:00:00 2001 From: slguan Date: Sun, 10 May 2020 22:15:50 +0800 Subject: [PATCH 39/41] scripts and revise logs --- src/vnode/src/vnodeMain.c | 7 ++++--- src/vnode/src/vnodeWrite.c | 2 +- tests/script/general/db/delete_reusevnode2.sim | 6 ++---- tests/script/unique/mnode/mgmt22.sim | 10 ++++++++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 16845812bf..d3e9751738 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -267,7 +267,7 @@ void vnodeRelease(void *pVnodeRaw) { assert(refCount >= 0); if (refCount > 0) { - vTrace("vgId:%d, release vnode, refCount:%d", pVnode, vgId, refCount); + vTrace("vgId:%d, release vnode, refCount:%d", vgId, refCount); return; } @@ -693,8 +693,9 @@ static bool vnodeReadVersion(SVnodeObj *pVnode) { sprintf(versionFile, "%s/vnode%d/version.json", tsVnodeDir, pVnode->vgId); FILE *fp = fopen(versionFile, "r"); if (!fp) { - vTrace("vgId:%d, failed to open version file:%s error:%s", pVnode->vgId, - versionFile, strerror(errno)); + if (errno != ENOENT) { + vError("vgId:%d, failed to open version file:%s error:%s", pVnode->vgId, versionFile, strerror(errno)); + } return false; } diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index f560c648e1..3fc079ca13 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -239,7 +239,7 @@ static int32_t vnodeProcessDropStableMsg(SVnodeObj *pVnode, void *pCont, SRspRet code = tsdbDropTable(pVnode->tsdb, stableId); - vTrace("vgId:%d, stable:%s, drop stable result:%s", pVnode, pTable->tableId, tstrerror(code)); + vTrace("vgId:%d, stable:%s, drop stable result:%s", pVnode->vgId, pTable->tableId, tstrerror(code)); return code; } diff --git a/tests/script/general/db/delete_reusevnode2.sim b/tests/script/general/db/delete_reusevnode2.sim index 12357b9e44..ff9361260c 100644 --- a/tests/script/general/db/delete_reusevnode2.sim +++ b/tests/script/general/db/delete_reusevnode2.sim @@ -1,7 +1,5 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 - system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 10 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 10 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 10 @@ -36,7 +34,7 @@ while $i < 10 sql create table $tb1 using st tags(1) sql insert into $tb1 values(now, 1); - $tb1 = $tb . 5 + $tb1 = $tb . 4 sql create table $tb1 using st tags(1) sql insert into $tb1 values(now, 1); @@ -58,7 +56,7 @@ while $i < 10 sql drop table st - sleep 1000 + sleep 2000 print times $i $i = $i + 1 diff --git a/tests/script/unique/mnode/mgmt22.sim b/tests/script/unique/mnode/mgmt22.sim index 041a6734e2..895a93840f 100644 --- a/tests/script/unique/mnode/mgmt22.sim +++ b/tests/script/unique/mnode/mgmt22.sim @@ -8,7 +8,7 @@ system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2 print ============== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec_up.sh -n dnode1 -s start -t sleep 3000 sql connect @@ -20,7 +20,7 @@ if $data2_1 != master then endi print ============== step2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start -t sql create dnode $hostname2 $x = 0 @@ -41,6 +41,12 @@ if $data2_2 != slave then goto show2 endi +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +return + print ============== step3 sql_error drop dnode $hostname1 -x error1 print should not drop master From bdface5172b2a405e1eb33cfda8f646056c04518 Mon Sep 17 00:00:00 2001 From: slguan Date: Sun, 10 May 2020 22:44:34 +0800 Subject: [PATCH 40/41] init sequence is incorrect, resulting in the dnodeId not read successfully --- src/dnode/src/dnodeMain.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index 5b62192fa8..dc5f7d192f 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -167,9 +167,9 @@ static int32_t dnodeInitSystem() { if (dnodeInitRead() != 0) return -1; if (dnodeInitWrite() != 0) return -1; if (dnodeInitClient() != 0) return -1; - if (dnodeInitModules() != 0) return -1; if (dnodeInitServer() != 0) return -1; if (dnodeInitMgmt() != 0) return -1; + if (dnodeInitModules() != 0) return -1; if (dnodeInitShell() != 0) return -1; dnodeStartModules(); @@ -184,14 +184,14 @@ static void dnodeCleanUpSystem() { if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_STOPPED) { dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_STOPPED); dnodeCleanupShell(); - dnodeCleanupServer(); + dnodeCleanUpModules(); dnodeCleanupMgmt(); + dnodeCleanupServer(); dnodeCleanupClient(); dnodeCleanupWrite(); dnodeCleanupRead(); - dnodeCleanUpModules(); - taos_cleanup(); dnodeCleanupStorage(); + taos_cleanup(); taosCloseLog(); } } From efe4e3fe1c0f1992a7ceb17ebe91a5662688f694 Mon Sep 17 00:00:00 2001 From: slguan Date: Sun, 10 May 2020 22:45:00 +0800 Subject: [PATCH 41/41] init sequence is incorrect, resulting in the dnodeId not read successfully --- tests/script/unique/mnode/mgmt22.sim | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/script/unique/mnode/mgmt22.sim b/tests/script/unique/mnode/mgmt22.sim index 895a93840f..37e38fbf66 100644 --- a/tests/script/unique/mnode/mgmt22.sim +++ b/tests/script/unique/mnode/mgmt22.sim @@ -8,7 +8,7 @@ system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2 print ============== step1 -system sh/exec_up.sh -n dnode1 -s start -t +system sh/exec_up.sh -n dnode1 -s start sleep 3000 sql connect @@ -20,7 +20,7 @@ if $data2_1 != master then endi print ============== step2 -system sh/exec_up.sh -n dnode2 -s start -t +system sh/exec_up.sh -n dnode2 -s start sql create dnode $hostname2 $x = 0 @@ -41,12 +41,6 @@ if $data2_2 != slave then goto show2 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -return - print ============== step3 sql_error drop dnode $hostname1 -x error1 print should not drop master @@ -107,7 +101,7 @@ endi if $data2_2 != slave then goto show7 endi -if $data3_3 != NULL then +if $data3_3 != null then goto show7 endi