diff --git a/.gitignore b/.gitignore index 47eae4dc03e979cdfc23c71b98a44ee0c6b03812..67cc2929b45049b7bb7ccf377b02bdaad70c3315 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,27 @@ pysim/ # Doxygen Generated files html/ +/.vs +/CMakeFiles/3.10.2 +/CMakeCache.txt +/Makefile +/*.cmake +/deps +/src/cq/test/CMakeFiles/cqtest.dir/*.cmake +*.cmake +/src/cq/test/CMakeFiles/cqtest.dir/*.make +*.make +link.txt +*.internal +*.includecache +*.marks +Makefile +CMakeError.log +*.log +/CMakeFiles/CMakeRuleHashes.txt +/CMakeFiles/Makefile2 +/CMakeFiles/TargetDirectories.txt +/CMakeFiles/cmake.check_cache +/out/isenseconfig/WSL-Clang-Debug +/out/isenseconfig/WSL-GCC-Debug +/test/cfg diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 0000000000000000000000000000000000000000..4b54f10f2f69fe2fa62e59003d58a4ef9c53a41b --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,25 @@ +{ + "configurations": [ + { + "name": "WSL-GCC-Debug", + "generator": "Unix Makefiles", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\build\\", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeExecutable": "/usr/bin/cmake", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "linux_x64" ], + "wslPath": "${defaultWSLPath}", + "addressSanitizerRuntimeFlags": "detect_leaks=0", + "variables": [ + { + "name": "CMAKE_INSTALL_PREFIX", + "value": "/mnt/d/TDengine/TDengine/build", + "type": "PATH" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index b51fd32a0b8d102871e20b17c11cbda060feb090..7cfa923f9eacd154ba3f2ec20c6433f3b3524cf4 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -226,11 +226,8 @@ typedef struct { int command; uint8_t msgType; - union { - bool existsCheck; // check if the table exists or not - bool autoCreated; // if the table is missing, on-the-fly create it. during getmeterMeta - int8_t dataSourceType; // load data from file or not - }; + bool autoCreated; // if the table is missing, on-the-fly create it. during getmeterMeta + int8_t dataSourceType; // load data from file or not union { int32_t count; diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index ca9f439e4cf3ffc4e923614eac35b5dd13693605..62f27c0960de80f5dc025ed7f4df358491c8ff42 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -956,7 +956,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { } else { sql = sToken.z; } - code = tscGetTableMeta(pSql, pTableMetaInfo); + code = tscGetMeterMetaEx(pSql, pTableMetaInfo, false); if (pCmd->curSql == NULL) { assert(code == TSDB_CODE_ACTION_IN_PROGRESS); diff --git a/src/client/src/tscSecondaryMerge.c b/src/client/src/tscSecondaryMerge.c index 251d4079e3cc186636d032427d2d106c218f47ee..35658d18674f41085d3ee41bbf5e60cfe2748c95 100644 --- a/src/client/src/tscSecondaryMerge.c +++ b/src/client/src/tscSecondaryMerge.c @@ -638,7 +638,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - (*pMemBuffer) = (tExtMemBuffer **)malloc(POINTER_BYTES * 1); + (*pMemBuffer) = (tExtMemBuffer **)malloc(POINTER_BYTES * pSql->numOfSubs); if (*pMemBuffer == NULL) { tscError("%p failed to allocate memory", pSql); pRes->code = TSDB_CODE_CLI_OUT_OF_MEMORY; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index d9065505911927cf4ce46198a736fd7040f3cb09..0aac5daa2eb3e541d35f5dffdf3b21080445853c 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -571,7 +571,6 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char pTableIdInfo->key = htobe64(tscGetSubscriptionProgress(pSql->pSubscription, pTableMeta->uid, dfltKey)); pQueryMsg->numOfTables = htonl(1); // set the number of tables - pMsg += sizeof(STableIdInfo); } else { int32_t index = pTableMetaInfo->vgroupIndex; @@ -601,8 +600,8 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char } } - tscTrace("%p vgId:%d, query on table:%s, uid:%" PRIu64, pSql, htonl(pQueryMsg->head.vgId), pTableMetaInfo->name, - pTableMeta->uid); + tscTrace("%p vgId:%d, query on table:%s, tid:%d, uid:%" PRIu64, pSql, htonl(pQueryMsg->head.vgId), pTableMetaInfo->name, + pTableMeta->sid, pTableMeta->uid); return pMsg; } @@ -1869,6 +1868,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) { } free(pTableMeta); + tscTrace("%p recv table meta: %"PRId64 ", tid:%d, name:%s", pSql, pTableMeta->uid, pTableMeta->sid, pTableMetaInfo->name); return TSDB_CODE_SUCCESS; } diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index da8f3cd1e1971518d744cbe69ac05b187a6aa412..319772b60652d6e567e9aa70d06cbffb8167b218 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -103,6 +103,7 @@ extern int32_t tsOfflineThreshold; extern int32_t tsMgmtEqualVnodeNum; extern int32_t tsEnableHttpModule; +extern int32_t tsEnableMqttModule; extern int32_t tsEnableMonitorModule; extern int32_t tsRestRowLimit; @@ -147,6 +148,7 @@ extern int32_t jniDebugFlag; extern int32_t tmrDebugFlag; extern int32_t sdbDebugFlag; extern int32_t httpDebugFlag; +extern int32_t mqttDebugFlag; extern int32_t monitorDebugFlag; extern int32_t uDebugFlag; extern int32_t rpcDebugFlag; diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index bd082db16c4dab6db04ea4f322b8ceccb21b58e7..cf1b77d12ce671d3d0f31bc9c4a1c8a535bc6113 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -427,27 +427,25 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, SDataCol TSKEY key1 = (*iter1 >= src1->numOfPoints) ? INT64_MAX : ((TSKEY *)(src1->cols[0].pData))[*iter1]; TSKEY key2 = (*iter2 >= src2->numOfPoints) ? INT64_MAX : ((TSKEY *)(src2->cols[0].pData))[*iter2]; - if (key1 < key2) { + if (key1 <= key2) { for (int i = 0; i < src1->numOfCols; i++) { ASSERT(target->cols[i].type == src1->cols[i].type); - dataColAppendVal(target->cols[i].pData, tdGetColDataOfRow(src1->cols + i, *iter1), target->numOfPoints, + dataColAppendVal(&(target->cols[i]), tdGetColDataOfRow(src1->cols + i, *iter1), target->numOfPoints, target->maxPoints); } target->numOfPoints++; (*iter1)++; - } else if (key1 > key2) { + if (key1 == key2) (*iter2)++; + } else { for (int i = 0; i < src2->numOfCols; i++) { ASSERT(target->cols[i].type == src2->cols[i].type); - dataColAppendVal(target->cols[i].pData, tdGetColDataOfRow(src2->cols + i, *iter2), target->numOfPoints, + dataColAppendVal(&(target->cols[i]), tdGetColDataOfRow(src2->cols + i, *iter2), target->numOfPoints, target->maxPoints); } target->numOfPoints++; (*iter2)++; - } else { - // TODO: deal with duplicate keys - ASSERT(false); } } } \ No newline at end of file diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 6b348b7fc7e7cf2aee7fb8210cb715f2bfb27ba9..250b79febe1886cda66209082121fbc5f1cbb213 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -120,6 +120,7 @@ int32_t tsOfflineThreshold = 86400*100; // seconds 10days int32_t tsMgmtEqualVnodeNum = 4; int32_t tsEnableHttpModule = 1; +int32_t tsEnableMqttModule = 0; // not finished yet, not started it by default int32_t tsEnableMonitorModule = 0; int32_t tsRestRowLimit = 10240; @@ -134,6 +135,7 @@ int32_t cDebugFlag = 135; int32_t jniDebugFlag = 131; int32_t odbcDebugFlag = 131; int32_t httpDebugFlag = 131; +int32_t mqttDebugFlag = 131; int32_t monitorDebugFlag = 131; int32_t qDebugFlag = 131; int32_t rpcDebugFlag = 135; @@ -212,6 +214,7 @@ void taosSetAllDebugFlag() { jniDebugFlag = debugFlag; odbcDebugFlag = debugFlag; httpDebugFlag = debugFlag; + mqttDebugFlag = debugFlag; monitorDebugFlag = debugFlag; rpcDebugFlag = debugFlag; uDebugFlag = debugFlag; @@ -890,6 +893,17 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + + cfg.option = "mqtt"; + cfg.ptr = &tsEnableMqttModule; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = 0; + cfg.maxValue = 1; + cfg.ptrLength = 1; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + cfg.option = "monitor"; cfg.ptr = &tsEnableMonitorModule; cfg.valType = TAOS_CFG_VTYPE_INT32; @@ -1112,6 +1126,17 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "mqttDebugFlag"; + cfg.ptr = &mqttDebugFlag; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG; + cfg.minValue = 0; + cfg.maxValue = 255; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + + cfg.option = "monitorDebugFlag"; cfg.ptr = &monitorDebugFlag; cfg.valType = TAOS_CFG_VTYPE_INT32; diff --git a/src/common/src/ttypes.c b/src/common/src/ttypes.c index 0037c6c688b1375b9bb888d455dae61436f3a516..265e63222c784227fdd21f7f37c2717e4f8769c1 100644 --- a/src/common/src/ttypes.c +++ b/src/common/src/ttypes.c @@ -304,7 +304,7 @@ tDataTypeDescriptor tDataTypeDesc[11] = { {TSDB_DATA_TYPE_FLOAT, 5, FLOAT_BYTES, "FLOAT", tsCompressFloat, tsDecompressFloat, getStatics_f}, {TSDB_DATA_TYPE_DOUBLE, 6, DOUBLE_BYTES, "DOUBLE", tsCompressDouble, tsDecompressDouble, getStatics_d}, {TSDB_DATA_TYPE_BINARY, 6, 0, "BINARY", tsCompressString, tsDecompressString, NULL}, - {TSDB_DATA_TYPE_TIMESTAMP, 9, LONG_BYTES, "TIMESTAMP", tsCompressTimestamp, tsDecompressTimestamp, NULL}, + {TSDB_DATA_TYPE_TIMESTAMP, 9, LONG_BYTES, "TIMESTAMP", tsCompressTimestamp, tsDecompressTimestamp, getStatics_i64}, {TSDB_DATA_TYPE_NCHAR, 5, 8, "NCHAR", tsCompressString, tsDecompressString, NULL}, }; diff --git a/src/dnode/CMakeLists.txt b/src/dnode/CMakeLists.txt index af2dc2d777bb6d294beecf3b3fa2210ab7230571..de6e15e6b9fa8546ad232c16c8ac2c9472806cb4 100644 --- a/src/dnode/CMakeLists.txt +++ b/src/dnode/CMakeLists.txt @@ -16,7 +16,7 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) AUX_SOURCE_DIRECTORY(src SRC) ADD_EXECUTABLE(taosd ${SRC}) - TARGET_LINK_LIBRARIES(taosd mnode taos_static monitor http tsdb twal vnode cJson lz4) + TARGET_LINK_LIBRARIES(taosd mnode taos_static monitor http mqtt tsdb twal vnode cJson lz4) IF (TD_ACCOUNT) TARGET_LINK_LIBRARIES(taosd account) diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index 2f693c61fbf5df441b57a130f7beab1cc77cd81e..68fe9869899edc42a1f6c251cce9749a800f43f6 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -37,6 +37,7 @@ static SDnodeRunStatus tsDnodeRunStatus = TSDB_DNODE_RUN_STATUS_STOPPED; int32_t dnodeInitSystem() { dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_INITIALIZE); tscEmbedded = 1; + taosBlockSIGPIPE(); taosResolveCRC(); taosInitGlobalCfg(); taosReadGlobalLogCfg(); diff --git a/src/dnode/src/dnodeModule.c b/src/dnode/src/dnodeModule.c index f5c28c9573ddaee4039114313fad44f5700ea22b..2f3008c33e52b2c2265fd80d786e1312705468d7 100644 --- a/src/dnode/src/dnodeModule.c +++ b/src/dnode/src/dnodeModule.c @@ -20,6 +20,7 @@ #include "trpc.h" #include "mnode.h" #include "http.h" +#include "mqtt.h" #include "monitor.h" #include "dnodeInt.h" #include "dnodeModule.h" @@ -62,6 +63,16 @@ static void dnodeAllocModules() { dnodeSetModuleStatus(TSDB_MOD_HTTP); } + tsModule[TSDB_MOD_MQTT].enable = (tsEnableMqttModule == 1); + tsModule[TSDB_MOD_MQTT].name = "mqtt"; + tsModule[TSDB_MOD_MQTT].initFp = mqttInitSystem; + tsModule[TSDB_MOD_MQTT].cleanUpFp = mqttCleanUpSystem; + tsModule[TSDB_MOD_MQTT].startFp = mqttStartSystem; + tsModule[TSDB_MOD_MQTT].stopFp = mqttStopSystem; + if (tsEnableMqttModule) { + dnodeSetModuleStatus(TSDB_MOD_MQTT); + } + tsModule[TSDB_MOD_MONITOR].enable = (tsEnableMonitorModule == 1); tsModule[TSDB_MOD_MONITOR].name = "monitor"; tsModule[TSDB_MOD_MONITOR].initFp = monitorInitSystem; diff --git a/src/inc/mqtt.h b/src/inc/mqtt.h new file mode 100644 index 0000000000000000000000000000000000000000..710737e79a320989ad1ebf0a669246e8352a4f1d --- /dev/null +++ b/src/inc/mqtt.h @@ -0,0 +1,35 @@ +/* + * 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_MQTT_H +#define TDENGINE_MQTT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +int32_t mqttGetReqCount(); +int32_t mqttInitSystem(); +int32_t mqttStartSystem(); +void mqttStopSystem(); +void mqttCleanUpSystem(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index b6a37d85a2c6a5df1ebad940e3a8c83cca782f13..6914961463aeddb1a4bbf230495f6389a33c28e4 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -376,6 +376,7 @@ typedef enum { TSDB_MOD_MGMT, TSDB_MOD_HTTP, TSDB_MOD_MONITOR, + TSDB_MOD_MQTT, TSDB_MOD_MAX } EModuleType; diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 83a35bfa94bc3a7c7c58404d559bdbb3f3c2b080..f550b1660fb071a9af04244f66fa628edea2ea79 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -725,6 +725,8 @@ typedef struct { typedef struct { uint32_t queryId; uint32_t streamId; + uint32_t totalDnodes; + uint32_t onlineDnodes; int8_t killConnection; SRpcIpSet ipList; } SCMHeartBeatRsp; diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 3cacafa50501cfd0cf677c92327df499bff7a220..04194c6127f2b825735dcc7cf102c0a321f3079b 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -362,6 +362,26 @@ int main(int argc, char *argv[]) { time_t tTime = time(NULL); struct tm tm = *localtime(&tTime); + printf("###################################################################\n"); + printf("# Server IP: %s:%hu\n", ip_addr == NULL ? "localhost" : ip_addr, port); + printf("# User: %s\n", user); + printf("# Password: %s\n", pass); + printf("# Use metric: %s\n", use_metric ? "true" : "false"); + printf("# Datatype of Columns: %s\n", dataString); + printf("# Binary Length(If applicable): %d\n", + (strcasestr(dataString, "BINARY") != NULL) ? len_of_binary : -1); + printf("# Number of Columns per record: %d\n", ncols_per_record); + printf("# Number of Connections: %d\n", nconnections); + printf("# Number of Tables: %d\n", ntables); + printf("# Number of Data per Table: %d\n", nrecords_per_table); + printf("# Records/Request: %d\n", nrecords_per_request); + printf("# Database name: %s\n", db_name); + printf("# Table prefix: %s\n", tb_prefix); + printf("# Test time: %d-%02d-%02d %02d:%02d:%02d\n", tm.tm_year + 1900, tm.tm_mon + 1, + tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); + printf("###################################################################\n\n"); + printf("Press enter key to continue"); + getchar(); fprintf(fp, "###################################################################\n"); fprintf(fp, "# Server IP: %s:%hu\n", ip_addr == NULL ? "localhost" : ip_addr, port); @@ -858,15 +878,16 @@ void generateData(char *res, char **data_type, int num_of_cols, int64_t timestam pstr += sprintf(pstr, ")"); } +static const char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJK1234567890"; void rand_string(char *str, int size) { - memset(str, 0, size); - const char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJK1234567890"; - char *sptr = str; - if (size) { + str[0] = 0; + if (size > 0) { --size; - for (size_t n = 0; n < size; n++) { + int n; + for (n = 0; n < size; n++) { int key = rand() % (int)(sizeof charset - 1); - sptr += sprintf(sptr, "%c", charset[key]); + str[n] = charset[key]; } + str[n] = 0; } } diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index 5ea75a1cde7d1d918b377b26ca4a8fa77872c803..9886a91f48242191a6259a9d15bbc1f3cefc0a81 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -533,7 +533,7 @@ int taosDumpOut(SDumpArguments *arguments) { } } - taos_free_result(result); + // taos_free_result(result); if (count == 0) { fprintf(stderr, "No databases valid to dump\n"); @@ -722,6 +722,57 @@ void taosDumpCreateMTableClause(STableDef *tableDes, char *metric, int numOfCols count_temp = counter; for (; counter < numOfCols; counter++) { + TAOS_ROW row = NULL; + + sprintf(command, "select %s from %s limit 1", tableDes->cols[counter].field, tableDes->name); + if (taos_query(taos, command) != 0) { + fprintf(stderr, "failed to run command %s\n", command); + return; + } + + result = taos_use_result(taos); + if (result == NULL) { + fprintf(stderr, "failed to use result\n"); + return; + } + + TAOS_FIELD *fields = taos_fetch_fields(result); + + row = taos_fetch_row(result); + switch (fields[0].type) { + case TSDB_DATA_TYPE_BOOL: + sprintf(tableDes->cols[counter].note, "%d", ((((int)(*((char *)row[0]))) == 1) ? 1 : 0)); + break; + case TSDB_DATA_TYPE_TINYINT: + sprintf(tableDes->cols[counter].note, "%d", (int)(*((char *)row[0]))); + break; + case TSDB_DATA_TYPE_SMALLINT: + sprintf(tableDes->cols[counter].note, "%d", (int)(*((short *)row[0]))); + break; + case TSDB_DATA_TYPE_INT: + sprintf(tableDes->cols[counter].note, "%d", *((int *)row[0])); + break; + case TSDB_DATA_TYPE_BIGINT: + sprintf(tableDes->cols[counter].note, "%" PRId64 "", *((int64_t *)row[0])); + break; + case TSDB_DATA_TYPE_FLOAT: + sprintf(tableDes->cols[counter].note, "%f", GET_FLOAT_VAL(row[0])); + break; + case TSDB_DATA_TYPE_DOUBLE: + sprintf(tableDes->cols[counter].note, "%f", GET_DOUBLE_VAL(row[0])); + break; + case TSDB_DATA_TYPE_TIMESTAMP: + sprintf(tableDes->cols[counter].note, "%" PRId64 "", *(int64_t *)row[0]); + break; + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: + default: + strncpy(tableDes->cols[counter].note, (char *)row[0], fields[0].bytes); + break; + } + + taos_free_result(result); + if (counter != count_temp) { if (strcasecmp(tableDes->cols[counter].type, "binary") == 0 || strcasecmp(tableDes->cols[counter].type, "nchar") == 0) { diff --git a/src/mnode/inc/mgmtDef.h b/src/mnode/inc/mgmtDef.h index fac342901aaadebaa825a206dba97c3af5be8e62..58d16ce1b38c082d212203d6291ad37260c12bfc 100644 --- a/src/mnode/inc/mgmtDef.h +++ b/src/mnode/inc/mgmtDef.h @@ -66,7 +66,6 @@ typedef struct SMnodeObj { SDnodeObj *pDnode; } SMnodeObj; -// todo use dynamic length string typedef struct { char *tableId; int8_t type; diff --git a/src/mnode/inc/mgmtDnode.h b/src/mnode/inc/mgmtDnode.h index c9e062255b017a06e4a53ff65ef7d8f2dcbd7479..14960c5701b358259f695002808b876ce8b39fe4 100644 --- a/src/mnode/inc/mgmtDnode.h +++ b/src/mnode/inc/mgmtDnode.h @@ -34,6 +34,7 @@ char* mgmtGetDnodeStatusStr(int32_t dnodeStatus); void mgmtMonitorDnodeModule(); int32_t mgmtGetDnodesNum(); +int32_t mgmtGetOnlinDnodesNum(); void * mgmtGetNextDnode(void *pIter, SDnodeObj **pDnode); void mgmtIncDnodeRef(SDnodeObj *pDnode); void mgmtDecDnodeRef(SDnodeObj *pDnode); diff --git a/src/mnode/inc/mgmtTable.h b/src/mnode/inc/mgmtTable.h index 84220c9cf8ce942f86c668320e831beab2927fe0..3ef4c6d45309a681d585f7e2a0cb2e48c35b4842 100644 --- a/src/mnode/inc/mgmtTable.h +++ b/src/mnode/inc/mgmtTable.h @@ -31,6 +31,7 @@ void * mgmtGetNextChildTable(void *pIter, SChildTableObj **pTable); void * mgmtGetNextSuperTable(void *pIter, SSuperTableObj **pTable); void mgmtDropAllChildTables(SDbObj *pDropDb); void mgmtDropAllSuperTables(SDbObj *pDropDb); +void mgmtDropAllChildTablesInVgroups(SVgObj *pVgroup); #ifdef __cplusplus } diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index 1189da92e2fd2ce8fef3a55f02047b578b0d7a6d..93c8276b14f3571f7743667f4536c5b8a375437b 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -74,7 +74,6 @@ static int32_t mgmtDnodeActionDelete(SSdbOper *pOper) { SDnodeObj *pDnode = pOper->pObj; #ifndef _SYNC - //TODO: drop dnode local mgmtDropAllDnodeVgroups(pDnode); #endif mgmtDropMnodeLocal(pDnode->dnodeId); @@ -179,6 +178,23 @@ int32_t mgmtGetDnodesNum() { return sdbGetNumOfRows(tsDnodeSdb); } +int32_t mgmtGetOnlinDnodesNum(char *ep) { + SDnodeObj *pDnode = NULL; + void * pIter = NULL; + int32_t onlineDnodes = 0; + + while (1) { + pIter = mgmtGetNextDnode(pIter, &pDnode); + if (pDnode == NULL) break; + if (pDnode->status != TAOS_DN_STATUS_OFFLINE) onlineDnodes++; + mgmtDecDnodeRef(pDnode); + } + + sdbFreeIter(pIter); + + return onlineDnodes; +} + void *mgmtGetDnode(int32_t dnodeId) { return sdbGetRow(tsDnodeSdb, &dnodeId); } @@ -397,7 +413,6 @@ static int32_t mgmtCreateDnode(char *ep) { return code; } -//TODO drop others tables int32_t mgmtDropDnode(SDnodeObj *pDnode) { SSdbOper oper = { .type = SDB_OPER_GLOBAL, @@ -410,7 +425,7 @@ int32_t mgmtDropDnode(SDnodeObj *pDnode) { code = TSDB_CODE_SDB_ERROR; } - mLPrint("dnode:%d is dropped from cluster, result:%s", pDnode->dnodeId, tstrerror(code)); + mLPrint("dnode:%d, is dropped from cluster, result:%s", pDnode->dnodeId, tstrerror(code)); return code; } diff --git a/src/mnode/src/mgmtMnode.c b/src/mnode/src/mgmtMnode.c index 3ba7042c4091c265c8ff703ef658875525c98b73..e9d14dc6e77ae904e456109586c4c4cc782b26ef 100644 --- a/src/mnode/src/mgmtMnode.c +++ b/src/mnode/src/mgmtMnode.c @@ -210,6 +210,9 @@ void mgmtUpdateMnodeIpSet() { mgmtMnodeWrLock(); + memset(ipSet, 0, sizeof(tsMnodeRpcIpSet)); + memset(mnodes, 0, sizeof(SDMMnodeInfos)); + int32_t index = 0; void * pIter = NULL; while (1) { diff --git a/src/mnode/src/mgmtSdb.c b/src/mnode/src/mgmtSdb.c index ef7668c88e14440193a7dd05cf516586e3e79498..3d4e6fcab10e70d07f8e5bfd8aac6af593fca2fc 100644 --- a/src/mnode/src/mgmtSdb.c +++ b/src/mnode/src/mgmtSdb.c @@ -354,7 +354,7 @@ void sdbIncRef(void *handle, void *pObj) { int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos); atomic_add_fetch_32(pRefCount, 1); if (0 && (pTable->tableId == SDB_TABLE_MNODE || pTable->tableId == SDB_TABLE_DNODE)) { - sdbTrace("table:%s, add ref to record:%s:%d", pTable->tableName, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); + sdbTrace("add ref to table:%s record:%s:%d", pTable->tableName, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); } } @@ -365,7 +365,7 @@ void sdbDecRef(void *handle, void *pObj) { int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos); int32_t refCount = atomic_sub_fetch_32(pRefCount, 1); if (0 && (pTable->tableId == SDB_TABLE_MNODE || pTable->tableId == SDB_TABLE_DNODE)) { - sdbTrace("table:%s, def ref of record:%s:%d", pTable->tableName, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); + sdbTrace("def ref of table:%s record:%s:%d", pTable->tableName, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); } int8_t *updateEnd = pObj + pTable->refCountPos - 1; diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index 1da811de13ae36b0ad0931062c6c239d433c33a0..ccbed350dc3b22ebbfde250ef2edfd0c887a1cde 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -325,6 +325,8 @@ static void mgmtProcessHeartBeatMsg(SQueuedMsg *pMsg) { return; } + pHBRsp->onlineDnodes = htonl(mgmtGetOnlinDnodesNum()); + pHBRsp->totalDnodes = htonl(mgmtGetDnodesNum()); mgmtGetMnodeIpSet(&pHBRsp->ipList); /* diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index 0d821ee9e861c4bcf250842d059193c5e54d8a7f..abd226e568651869fab3ffde32fe9d63ba42af29 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -1305,7 +1305,7 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { if (pDnode == NULL) break; strncpy(pVgroupInfo->vgroups[vgSize].ipAddr[vn].fqdn, pDnode->dnodeFqdn, tListLen(pDnode->dnodeFqdn)); - pVgroupInfo->vgroups[vgSize].ipAddr[vn].port = htons(tsDnodeShellPort); + pVgroupInfo->vgroups[vgSize].ipAddr[vn].port = htons(pDnode->dnodePort); pVgroupInfo->vgroups[vgSize].numOfIps++; } @@ -1787,6 +1787,34 @@ static void mgmtGetChildTableMeta(SQueuedMsg *pMsg) { rpcSendResponse(&rpcRsp); } +void mgmtDropAllChildTablesInVgroups(SVgObj *pVgroup) { + void * pIter = NULL; + int32_t numOfTables = 0; + SChildTableObj *pTable = NULL; + + mPrint("vgId:%d, all child tables will be dropped from sdb", pVgroup->vgId); + + while (1) { + pIter = mgmtGetNextChildTable(pIter, &pTable); + if (pTable == NULL) break; + + if (pTable->vgId == pVgroup->vgId) { + SSdbOper oper = { + .type = SDB_OPER_LOCAL, + .table = tsChildTableSdb, + .pObj = pTable, + }; + sdbDeleteRow(&oper); + numOfTables++; + } + mgmtDecTableRef(pTable); + } + + sdbFreeIter(pIter); + + mPrint("vgId:%d, all child tables is dropped from sdb", pVgroup->vgId); +} + void mgmtDropAllChildTables(SDbObj *pDropDb) { void * pIter = NULL; int32_t numOfTables = 0; @@ -1996,7 +2024,7 @@ static void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) { SCMMultiTableInfoMsg *pInfo = pMsg->pCont; pInfo->numOfTables = htonl(pInfo->numOfTables); - int32_t totalMallocLen = 4*1024*1024; // first malloc 4 MB, subsequent reallocation as twice + int32_t totalMallocLen = 4 * 1024 * 1024; // first malloc 4 MB, subsequent reallocation as twice SMultiTableMeta *pMultiMeta = rpcMallocCont(totalMallocLen); if (pMultiMeta == NULL) { mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY); @@ -2006,26 +2034,30 @@ static void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) { pMultiMeta->contLen = sizeof(SMultiTableMeta); pMultiMeta->numOfTables = 0; - for (int t = 0; t < pInfo->numOfTables; ++t) { - char *tableId = (char*)(pInfo->tableIds + t * TSDB_TABLE_ID_LEN); + for (int32_t t = 0; t < pInfo->numOfTables; ++t) { + char * tableId = (char *)(pInfo->tableIds + t * TSDB_TABLE_ID_LEN + 1); SChildTableObj *pTable = mgmtGetChildTable(tableId); if (pTable == NULL) continue; if (pMsg->pDb == NULL) pMsg->pDb = mgmtGetDbByTableId(tableId); - if (pMsg->pDb == NULL) continue; + if (pMsg->pDb == NULL) { + mgmtDecTableRef(pTable); + continue; + } int availLen = totalMallocLen - pMultiMeta->contLen; if (availLen <= sizeof(STableMetaMsg) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16)) { - //TODO realloc - //totalMallocLen *= 2; - //pMultiMeta = rpcReMalloc(pMultiMeta, totalMallocLen); - //if (pMultiMeta == NULL) { - /// rpcSendResponse(ahandle, TSDB_CODE_SERV_OUT_OF_MEMORY, NULL, 0); - // return TSDB_CODE_SERV_OUT_OF_MEMORY; - //} else { - // t--; - // continue; - //} + totalMallocLen *= 2; + pMultiMeta = rpcReallocCont(pMultiMeta, totalMallocLen); + if (pMultiMeta == NULL) { + mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY); + mgmtDecTableRef(pTable); + return; + } else { + t--; + mgmtDecTableRef(pTable); + continue; + } } STableMetaMsg *pMeta = (STableMetaMsg *)(pMultiMeta->metas + pMultiMeta->contLen); @@ -2034,6 +2066,8 @@ static void mgmtProcessMultiTableMetaMsg(SQueuedMsg *pMsg) { pMultiMeta->numOfTables ++; pMultiMeta->contLen += pMeta->contLen; } + + mgmtDecTableRef(pTable); } SRpcMsg rpcRsp = {0}; diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index 4c85351148cd7d8c148ef47381411343d44b1477..960863d665504e0c6d6e6b9cef54581f84c325b2 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -747,11 +747,14 @@ void mgmtDropAllDnodeVgroups(SDnodeObj *pDropDnode) { SVgObj *pVgroup = NULL; int32_t numOfVgroups = 0; + mPrint("dnode:%d, all vgroups will be dropped from sdb", pDropDnode->dnodeId); + while (1) { pIter = mgmtGetNextVgroup(pIter, &pVgroup); if (pVgroup == NULL) break; if (pVgroup->vnodeGid[0].dnodeId == pDropDnode->dnodeId) { + mgmtDropAllChildTablesInVgroups(pVgroup); SSdbOper oper = { .type = SDB_OPER_LOCAL, .table = tsVgroupSdb, @@ -759,12 +762,13 @@ void mgmtDropAllDnodeVgroups(SDnodeObj *pDropDnode) { }; sdbDeleteRow(&oper); numOfVgroups++; - continue; } mgmtDecVgroupRef(pVgroup); } sdbFreeIter(pIter); + + mPrint("dnode:%d, all vgroups is dropped from sdb", pDropDnode->dnodeId); } void mgmtUpdateAllDbVgroups(SDbObj *pAlterDb) { diff --git a/src/os/linux/src/linuxPlatform.c b/src/os/linux/src/linuxPlatform.c index 73cccd020aec4f6b59b4fc18f7eca4f93aa28539..782a508b174d87576f454c73dda6478b116207f0 100644 --- a/src/os/linux/src/linuxPlatform.c +++ b/src/os/linux/src/linuxPlatform.c @@ -148,6 +148,10 @@ static void taosDeleteTimer(void *tharg) { timer_delete(*pTimer); } +static pthread_t timerThread; +static timer_t timerId; +static volatile bool stopTimer = false; + void *taosProcessAlarmSignal(void *tharg) { // Block the signal sigset_t sigset; @@ -156,7 +160,6 @@ void *taosProcessAlarmSignal(void *tharg) { sigprocmask(SIG_BLOCK, &sigset, NULL); void (*callback)(int) = tharg; - static timer_t timerId; struct sigevent sevent = {{0}}; #ifdef _ALPINE @@ -187,7 +190,7 @@ void *taosProcessAlarmSignal(void *tharg) { } int signo; - while (1) { + while (!stopTimer) { if (sigwait(&sigset, &signo)) { uError("Failed to wait signal: number %d", signo); continue; @@ -202,7 +205,6 @@ void *taosProcessAlarmSignal(void *tharg) { return NULL; } -static pthread_t timerThread; int taosInitTimer(void (*callback)(int), int ms) { pthread_attr_t tattr; @@ -217,7 +219,7 @@ int taosInitTimer(void (*callback)(int), int ms) { } void taosUninitTimer() { - pthread_cancel(timerThread); + stopTimer = true; pthread_join(timerThread, NULL); } diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 562de724105ae934fb804fb7c6f9844ddfbe5e17..2bc6bf54bfe9b330ede401cee521b0931f4be684 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -3,3 +3,4 @@ PROJECT(TDengine) ADD_SUBDIRECTORY(monitor) ADD_SUBDIRECTORY(http) +ADD_SUBDIRECTORY(mqtt) diff --git a/src/plugins/http/src/httpServer.c b/src/plugins/http/src/httpServer.c index 11da145463c6eb43dde0b99120889973e7346355..9a9c659b038a0061c4af3acc5581298800db378d 100644 --- a/src/plugins/http/src/httpServer.c +++ b/src/plugins/http/src/httpServer.c @@ -267,8 +267,10 @@ static void httpStopThread(HttpThread* pThread) { struct epoll_event event = { .events = EPOLLIN }; eventfd_t fd = eventfd(1, 0); if (fd == -1) { + httpError("%s, failed to create eventfd, will call pthread_cancel instead, which may result in data corruption: %s", pThread->label, strerror(errno)); pthread_cancel(pThread->thread); } else if (epoll_ctl(pThread->pollFd, EPOLL_CTL_ADD, fd, &event) < 0) { + httpError("%s, failed to call epoll_ctl, will call pthread_cancel instead, which may result in data corruption: %s", pThread->label, strerror(errno)); pthread_cancel(pThread->thread); } diff --git a/src/plugins/mqtt/CMakeLists.txt b/src/plugins/mqtt/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..6224a0cad4471bbf15157cf9b9b3b0455440853f --- /dev/null +++ b/src/plugins/mqtt/CMakeLists.txt @@ -0,0 +1,22 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +PROJECT(TDengine) + +IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/zlib-1.2.11/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lz4/inc) + INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc) + INCLUDE_DIRECTORIES(inc) + AUX_SOURCE_DIRECTORY(src SRC) + ADD_LIBRARY(mqtt ${SRC}) + TARGET_LINK_LIBRARIES(mqtt taos_static z) + + IF (TD_ADMIN) + TARGET_LINK_LIBRARIES(mqtt admin) + ENDIF () +ENDIF () diff --git a/src/plugins/mqtt/inc/mqttLog.h b/src/plugins/mqtt/inc/mqttLog.h new file mode 100644 index 0000000000000000000000000000000000000000..735678a326c0842c1c3084ad203255991a0e3615 --- /dev/null +++ b/src/plugins/mqtt/inc/mqttLog.h @@ -0,0 +1,42 @@ +/* + * 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_MQTT_LOG_H +#define TDENGINE_MQTT_LOG_H + +#include "tlog.h" + +extern int32_t mqttDebugFlag; + +#define mqttError(...) \ + if (mqttDebugFlag & DEBUG_ERROR) { \ + taosPrintLog("ERROR MQT ", 255, __VA_ARGS__); \ + } +#define mqttWarn(...) \ + if ( mqttDebugFlag & DEBUG_WARN) { \ + taosPrintLog("WARN MQT ", mqttDebugFlag, __VA_ARGS__); \ + } +#define mqttTrace(...) \ + if ( mqttDebugFlag & DEBUG_TRACE) { \ + taosPrintLog("MQT ", mqttDebugFlag, __VA_ARGS__); \ + } +#define mqttDump(...) \ + if ( mqttDebugFlag & DEBUG_TRACE) { \ + taosPrintLongString("MQT ", mqttDebugFlag, __VA_ARGS__); \ + } +#define mqttPrint(...) \ + { taosPrintLog("MQT ", 255, __VA_ARGS__); } + +#endif diff --git a/src/plugins/mqtt/inc/mqttSystem.h b/src/plugins/mqtt/inc/mqttSystem.h new file mode 100644 index 0000000000000000000000000000000000000000..c61318806d0adc65ce19eb42d36e42a53c015918 --- /dev/null +++ b/src/plugins/mqtt/inc/mqttSystem.h @@ -0,0 +1,34 @@ +/* + * 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_MQTT_SYSTEM_H +#define TDENGINE_MQTT_SYSTEM_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +int32_t mqttGetReqCount(); +int32_t mqttInitSystem(); +int32_t mqttStartSystem(); +void mqttStopSystem(); +void mqttCleanUpSystem(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/plugins/mqtt/src/mqttSystem.c b/src/plugins/mqtt/src/mqttSystem.c new file mode 100644 index 0000000000000000000000000000000000000000..ccf6cfb3e34844eea95c48f774f9202794f6a3fa --- /dev/null +++ b/src/plugins/mqtt/src/mqttSystem.c @@ -0,0 +1,43 @@ +/* + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "mqttSystem.h" +#include "mqtt.h" +#include "mqttLog.h" +#include "os.h" +#include "taos.h" +#include "tglobal.h" +#include "tsocket.h" +#include "ttimer.h" + +int32_t mqttGetReqCount() { return 0; } +int mqttInitSystem() { + mqttPrint("mqttInitSystem"); + return 0; +} + +int mqttStartSystem() { + mqttPrint("mqttStartSystem"); + return 0; +} + +void mqttStopSystem() { + mqttPrint("mqttStopSystem"); +} + +void mqttCleanUpSystem() { + mqttPrint("mqttCleanUpSystem"); +} diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index cdb847654624753fb617c0ca393766d89604c000..052273a90cfd539eb36b9bea55dd7943d1a6a495 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -6041,6 +6041,8 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi isSTableQuery = TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_MULTITABLE_QUERY); STableIdInfo *id = taosArrayGet(pTableIdList, 0); + qTrace("qmsg:%p query table, uid:%"PRId64", tid:%d", pQueryMsg, id->uid, id->tid); + if ((code = tsdbGetOneTableGroup(tsdb, id->uid, &groupInfo)) != TSDB_CODE_SUCCESS) { goto _over; } diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 0410281f0dee3c7f685417b08620aa8d2c9aec49..a8bb2fd65b2091e33eb26d3f738cbfe4f736f69e 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -867,9 +867,8 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) { // underlying UDP layer does not know it is server or client pRecv->connType = pRecv->connType | pRpc->connType; - if (pRecv->ip==0 && pConn) { - rpcProcessBrokenLink(pConn); - rpcFreeMsg(pRecv->msg); + if (pRecv->ip == 0 && pConn) { + rpcProcessBrokenLink(pConn); return NULL; } diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index 739b86d7a57ab0027cb3cea4382d93add3db7ab1..a7312fadf1139541a41fa24c3809650b600ece18 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -147,8 +147,10 @@ static void taosStopTcpThread(SThreadObj* pThreadObj) { struct epoll_event event = { .events = EPOLLIN }; eventfd_t fd = eventfd(1, 0); if (fd == -1) { + tError("%s, failed to create eventfd, will call pthread_cancel instead, which may result in data corruption: %s", pThreadObj->label, strerror(errno)); pthread_cancel(pThreadObj->thread); } else if (epoll_ctl(pThreadObj->pollFd, EPOLL_CTL_ADD, fd, &event) < 0) { + tError("%s, failed to call epoll_ctl, will call pthread_cancel instead, which may result in data corruption: %s", pThreadObj->label, strerror(errno)); pthread_cancel(pThreadObj->thread); } @@ -213,7 +215,6 @@ static void* taosAcceptTcpConnection(void *arg) { continue; } - tTrace("%s TCP connection from ip:%s:%hu", pServerObj->label, inet_ntoa(caddr.sin_addr), caddr.sin_port); taosKeepTcpAlive(connFd); // pick up the thread to handle this connection @@ -227,7 +228,8 @@ static void* taosAcceptTcpConnection(void *arg) { inet_ntoa(caddr.sin_addr), pFdObj->port, pFdObj, pThreadObj->numOfFds); } else { close(connFd); - tError("%s failed to malloc FdObj(%s)", pServerObj->label, strerror(errno)); + tError("%s failed to malloc FdObj(%s) for connection from:%s:%hu", pServerObj->label, strerror(errno), + inet_ntoa(caddr.sin_addr), caddr.sin_port); } // pick up next thread for next connection @@ -339,7 +341,9 @@ static void taosReportBrokenLink(SFdObj *pFdObj) { recvInfo.chandle = NULL; recvInfo.connType = RPC_CONN_TCP; (*(pThreadObj->processData))(&recvInfo); - } + } else { + taosFreeFdObj(pFdObj); + } } #define maxEvents 10 @@ -350,7 +354,7 @@ static void *taosProcessTcpData(void *param) { struct epoll_event events[maxEvents]; SRecvInfo recvInfo; SRpcHead rpcHead; - + while (1) { int fdNum = epoll_wait(pThreadObj->pollFd, events, maxEvents, -1); if (pThreadObj->stop) { @@ -464,7 +468,7 @@ static void taosFreeFdObj(SFdObj *pFdObj) { pFdObj->signature = NULL; epoll_ctl(pThreadObj->pollFd, EPOLL_CTL_DEL, pFdObj->fd, NULL); - close(pFdObj->fd); + taosCloseSocket(pFdObj->fd); pThreadObj->numOfFds--; diff --git a/src/rpc/test/rserver.c b/src/rpc/test/rserver.c index 958d099027f2072b82aee45fe302f0042c1fd8aa..508f04fbc349ec5485360e70992c6e35b1f8728c 100644 --- a/src/rpc/test/rserver.c +++ b/src/rpc/test/rserver.c @@ -127,6 +127,8 @@ int main(int argc, char *argv[]) { SRpcInit rpcInit; char dataName[20] = "server.data"; + taosBlockSIGPIPE(); + memset(&rpcInit, 0, sizeof(rpcInit)); rpcInit.localPort = 7000; rpcInit.label = "SER"; diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h index 8a0a9e1208b7fb45994be95200a3f2a2a0ceb4ff..4225602292726bc3f75253d2e2fa93bc6bd774e7 100644 --- a/src/tsdb/inc/tsdbMain.h +++ b/src/tsdb/inc/tsdbMain.h @@ -495,11 +495,12 @@ void tsdbSetHelperTable(SRWHelper *pHelper, STable *pTable, STsdbRepo *pRepo); int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError); // --------- For read operations -int tsdbLoadCompIdx(SRWHelper *pHelper, void *target); -int tsdbLoadCompInfo(SRWHelper *pHelper, void *target); -int tsdbLoadCompData(SRWHelper *pHelper, SCompBlock *pCompBlock, void *target); -int tsdbLoadBlockDataCols(SRWHelper *pHelper, SDataCols *pDataCols, int blkIdx, int16_t *colIds, int numOfColIds); -int tsdbLoadBlockData(SRWHelper *pHelper, SCompBlock *pCompBlock, SDataCols *target); +int tsdbLoadCompIdx(SRWHelper *pHelper, void *target); +int tsdbLoadCompInfo(SRWHelper *pHelper, void *target); +int tsdbLoadCompData(SRWHelper *pHelper, SCompBlock *pCompBlock, void *target); +int tsdbLoadBlockDataCols(SRWHelper *pHelper, SDataCols *pDataCols, int blkIdx, int16_t *colIds, int numOfColIds); +int tsdbLoadBlockData(SRWHelper *pHelper, SCompBlock *pCompBlock, SDataCols *target); +void tsdbGetDataStatis(SRWHelper *pHelper, SDataStatis *pStatis, int numOfCols); // --------- For write operations int tsdbWriteDataBlock(SRWHelper *pHelper, SDataCols *pDataCols); diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index de8304aa6251782a97ac6866f3fb8174ca294251..95680f95c4565a500a00b14e8dfec9de91d902fe 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -289,6 +289,13 @@ int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg) { if (tsdbCheckTableCfg(pCfg) < 0) return -1; + STable *pTable = tsdbGetTableByUid(pMeta, pCfg->tableId.uid); + if (pTable != NULL) { + tsdbError("vgId:%d table %s already exists, tid %d uid %" PRId64, pRepo->config.tsdbId, varDataVal(pTable->name), + pTable->tableId.tid, pTable->tableId.uid); + return TSDB_CODE_TABLE_ALREADY_EXIST; + } + STable *super = NULL; int newSuper = 0; diff --git a/src/tsdb/src/tsdbRWHelper.c b/src/tsdb/src/tsdbRWHelper.c index 7205a70eccc5117c3612ae6bbf9af784f6544f8b..82584fc5df7e846d7a4ad5eed0e3f07c657cb51e 100644 --- a/src/tsdb/src/tsdbRWHelper.c +++ b/src/tsdb/src/tsdbRWHelper.c @@ -543,6 +543,34 @@ int tsdbLoadCompData(SRWHelper *pHelper, SCompBlock *pCompBlock, void *target) { return 0; } +void tsdbGetDataStatis(SRWHelper *pHelper, SDataStatis *pStatis, int numOfCols) { + SCompData *pCompData = pHelper->pCompData; + + for (int i = 0, j = 0; i < numOfCols;) { + if (j >= pCompData->numOfCols) { + pStatis[i].numOfNull = -1; + i++; + continue; + } + + if (pStatis[i].colId == pCompData->cols[j].colId) { + pStatis[i].sum = pCompData->cols[j].sum; + pStatis[i].max = pCompData->cols[j].max; + pStatis[i].min = pCompData->cols[j].min; + pStatis[i].maxIndex = pCompData->cols[j].maxIndex; + pStatis[i].minIndex = pCompData->cols[j].minIndex; + pStatis[i].numOfNull = pCompData->cols[j].numOfNull; + i++; + j++; + } else if (pStatis[i].colId < pCompData->cols[j].colId) { + pStatis[i].numOfNull = -1; + i++; + } else { + j++; + } + } +} + static int comparColIdCompCol(const void *arg1, const void *arg2) { return (*(int16_t *)arg1) - ((SCompCol *)arg2)->colId; } @@ -748,7 +776,7 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa pCompCol->colId = pDataCol->colId; pCompCol->type = pDataCol->type; - if (tDataTypeDesc[pDataCol->type].getStatisFunc) { + if (tDataTypeDesc[pDataCol->type].getStatisFunc && ncol != 0) { (*tDataTypeDesc[pDataCol->type].getStatisFunc)( (TSKEY *)(pDataCols->cols[0].pData), pDataCol->pData, rowsToWrite, &(pCompCol->min), &(pCompCol->max), &(pCompCol->sum), &(pCompCol->minIndex), &(pCompCol->maxIndex), &(pCompCol->numOfNull)); diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index d3d890f36115faf65659bfd1670ee1c65a597732..b5340d4ba9455c128de6979ab21a0ff0952886d8 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -26,7 +26,7 @@ #include "tsdbMain.h" #define EXTRA_BYTES 2 -#define ASCENDING_ORDER_TRAVERSE(o) (o == TSDB_ORDER_ASC) +#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC) #define QH_GET_NUM_OF_COLS(handle) ((size_t)(taosArrayGetSize((handle)->pColumns))) enum { @@ -80,7 +80,7 @@ typedef struct STableCheckInfo { SSkipListIterator* iter; // skip list iterator SSkipListIterator* iiter; // imem iterator - bool hasObtainBuf; // if we should initialize the in-memory skip list iterator + bool initBuf; // if we should initialize the in-memory skip list iterator } STableCheckInfo; typedef struct { @@ -188,7 +188,7 @@ TsdbQueryHandleT* tsdbQueryTables(TsdbRepoT* tsdb, STsdbQueryCond* pCond, STable * For ascending timestamp order query, query starts from data files. In contrast, buffer will be checked in the first place * in case of descending timestamp order query. */ - pQueryHandle->checkFiles = true;//ASCENDING_ORDER_TRAVERSE(pQueryHandle->order); + pQueryHandle->checkFiles = true;//ASCENDING_TRAVERSE(pQueryHandle->order); pQueryHandle->activeIndex = 0; // allocate buffer in order to load data blocks from file @@ -234,11 +234,11 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh STable* pTable = pCheckInfo->pTableObj; assert(pTable != NULL); - if (pCheckInfo->hasObtainBuf) { + if (pCheckInfo->initBuf) { return true; } - pCheckInfo->hasObtainBuf = true; + pCheckInfo->initBuf = true; int32_t order = pHandle->order; // no data in buffer, abort @@ -335,8 +335,8 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) { pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, pCheckInfo->lastKey, pHandle->order, pHandle->qinfo); // all data in mem are checked already. - if ((pCheckInfo->lastKey > pHandle->window.ekey && ASCENDING_ORDER_TRAVERSE(pHandle->order)) || - (pCheckInfo->lastKey < pHandle->window.ekey && !ASCENDING_ORDER_TRAVERSE(pHandle->order))) { + if ((pCheckInfo->lastKey > pHandle->window.ekey && ASCENDING_TRAVERSE(pHandle->order)) || + (pCheckInfo->lastKey < pHandle->window.ekey && !ASCENDING_TRAVERSE(pHandle->order))) { return false; } @@ -394,9 +394,10 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo STableCheckInfo* pCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, i); SCompIdx* compIndex = &pQueryHandle->rhelper.pCompIdx[pCheckInfo->tableId.tid]; - if (compIndex->len == 0 || compIndex->numOfBlocks == 0) { // no data block in this file, try next file + if (compIndex->len == 0 || compIndex->numOfBlocks == 0 || + compIndex->uid != pCheckInfo->tableId.uid) { // no data block in this file, try next file pCheckInfo->numOfBlocks = 0; - continue;//no data blocks in the file belongs to pCheckInfo->pTable + continue; // no data blocks in the file belongs to pCheckInfo->pTable } else { if (pCheckInfo->compSize < compIndex->len) { assert(compIndex->len > 0); @@ -482,9 +483,11 @@ static SArray* getDefaultLoadColumns(STsdbQueryHandle* pQueryHandle, bool loadTS return pLocalIdList; } -static void mergeDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock, +static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock, SArray* sa); static int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order); +static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY maxKey, int maxRowsToRead, TSKEY* skey, TSKEY* ekey, + STsdbQueryHandle* pQueryHandle); static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo) { STsdbRepo *pRepo = pQueryHandle->pTsdb; @@ -518,11 +521,95 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo return blockLoaded; } +static void handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo){ + SArray* sa = getDefaultLoadColumns(pQueryHandle, true); + + SQueryFilePos* cur = &pQueryHandle->cur; + SDataBlockInfo binfo = getTrueDataBlockInfo(pCheckInfo, pBlock); + /*bool hasData = */ initTableMemIterator(pQueryHandle, pCheckInfo); + + TSKEY k1 = TSKEY_INITIAL_VAL, k2 = TSKEY_INITIAL_VAL; + if (pCheckInfo->iter != NULL && tSkipListIterGet(pCheckInfo->iter) != NULL) { + SSkipListNode* node = tSkipListIterGet(pCheckInfo->iter); + + SDataRow row = SL_GET_NODE_DATA(node); + k1 = dataRowKey(row); + + if (k1 == binfo.window.skey) { + if (tSkipListIterNext(pCheckInfo->iter)) { + node = tSkipListIterGet(pCheckInfo->iter); + row = SL_GET_NODE_DATA(node); + k1 = dataRowKey(row); + } else { + k1 = TSKEY_INITIAL_VAL; + } + } + } + + if (pCheckInfo->iiter != NULL && tSkipListIterGet(pCheckInfo->iiter) != NULL) { + SSkipListNode* node = tSkipListIterGet(pCheckInfo->iiter); + + SDataRow row = SL_GET_NODE_DATA(node); + k2 = dataRowKey(row); + + if (k2 == binfo.window.skey) { + if (tSkipListIterNext(pCheckInfo->iiter)) { + node = tSkipListIterGet(pCheckInfo->iiter); + row = SL_GET_NODE_DATA(node); + k2 = dataRowKey(row); + } else { + k2 = TSKEY_INITIAL_VAL; + } + } + } + + cur->pos = ASCENDING_TRAVERSE(pQueryHandle->order)? 0:(binfo.rows-1); + + if ((ASCENDING_TRAVERSE(pQueryHandle->order) && + ((k1 != TSKEY_INITIAL_VAL && k1 <= binfo.window.ekey) || (k2 != TSKEY_INITIAL_VAL && k2 <= binfo.window.ekey))) || + (!ASCENDING_TRAVERSE(pQueryHandle->order) && + ((k1 != TSKEY_INITIAL_VAL && k1 >= binfo.window.skey) || (k2 != TSKEY_INITIAL_VAL && k2 >= binfo.window.skey)))) { + + if ((ASCENDING_TRAVERSE(pQueryHandle->order) && + ((k1 != TSKEY_INITIAL_VAL && k1 < binfo.window.skey) || (k2 != TSKEY_INITIAL_VAL && k2 < binfo.window.skey))) || + (!ASCENDING_TRAVERSE(pQueryHandle->order) && + (((k1 != TSKEY_INITIAL_VAL && k1 > binfo.window.skey) || (k2 != TSKEY_INITIAL_VAL && k2 > binfo.window.skey))))) { + // do not load file block into buffer + int32_t step = ASCENDING_TRAVERSE(pQueryHandle->order) ? 1 : -1; + + cur->rows = tsdbReadRowsFromCache(pCheckInfo->iter, pCheckInfo->pTableObj, binfo.window.skey - step, + pQueryHandle->outputCapacity, &cur->win.skey, &cur->win.ekey, pQueryHandle); + pQueryHandle->realNumOfRows = cur->rows; + + // update the last key value + pCheckInfo->lastKey = cur->win.ekey + step; + if (!ASCENDING_TRAVERSE(pQueryHandle->order)) { + SWAP(cur->win.skey, cur->win.ekey, TSKEY); + } + + cur->mixBlock = true; + cur->blockCompleted = false; + return; + } + + doLoadFileDataBlock(pQueryHandle, pBlock, pCheckInfo); + doMergeTwoLevelData(pQueryHandle, pCheckInfo, pBlock, sa); + } else { + pQueryHandle->realNumOfRows = binfo.rows; + + cur->rows = binfo.rows; + cur->win = binfo.window; + cur->mixBlock = false; + cur->blockCompleted = true; + cur->lastKey = binfo.window.ekey + (ASCENDING_TRAVERSE(pQueryHandle->order)? 1:-1); + } +} + static bool loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo) { SArray* sa = getDefaultLoadColumns(pQueryHandle, true); SQueryFilePos* cur = &pQueryHandle->cur; - if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) { + if (ASCENDING_TRAVERSE(pQueryHandle->order)) { // query ended in current block if (pQueryHandle->window.ekey < pBlock->keyLast || pCheckInfo->lastKey > pBlock->keyFirst) { if (!doLoadFileDataBlock(pQueryHandle, pBlock, pCheckInfo)) { @@ -539,62 +626,11 @@ static bool loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock cur->pos = 0; } - mergeDataInDataBlock(pQueryHandle, pCheckInfo, pBlock, sa); + doMergeTwoLevelData(pQueryHandle, pCheckInfo, pBlock, sa); } else { // the whole block is loaded in to buffer - SDataBlockInfo binfo = getTrueDataBlockInfo(pCheckInfo, pBlock); - /*bool hasData = */ initTableMemIterator(pQueryHandle, pCheckInfo); - - TSKEY k1 = TSKEY_INITIAL_VAL, k2 = TSKEY_INITIAL_VAL; - if (pCheckInfo->iter != NULL && tSkipListIterGet(pCheckInfo->iter) != NULL) { - SSkipListNode* node = tSkipListIterGet(pCheckInfo->iter); - - SDataRow row = SL_GET_NODE_DATA(node); - k1 = dataRowKey(row); - - if (k1 == binfo.window.skey) { - if (tSkipListIterNext(pCheckInfo->iter)) { - node = tSkipListIterGet(pCheckInfo->iter); - row = SL_GET_NODE_DATA(node); - k1 = dataRowKey(row); - } else { - k1 = TSKEY_INITIAL_VAL; - } - } - } - - if (pCheckInfo->iiter != NULL && tSkipListIterGet(pCheckInfo->iiter) != NULL) { - SSkipListNode* node = tSkipListIterGet(pCheckInfo->iiter); - - SDataRow row = SL_GET_NODE_DATA(node); - k2 = dataRowKey(row); - - if (k2 == binfo.window.skey) { - if (tSkipListIterNext(pCheckInfo->iiter)) { - node = tSkipListIterGet(pCheckInfo->iiter); - row = SL_GET_NODE_DATA(node); - k2 = dataRowKey(row); - } else { - k2 = TSKEY_INITIAL_VAL; - } - } - } - - cur->pos = 0; - if ((k1 != TSKEY_INITIAL_VAL && k1 < binfo.window.ekey) || (k2 != TSKEY_INITIAL_VAL && k2 < binfo.window.ekey)) { - doLoadFileDataBlock(pQueryHandle, pBlock, pCheckInfo); - mergeDataInDataBlock(pQueryHandle, pCheckInfo, pBlock, sa); - } else { - pQueryHandle->realNumOfRows = binfo.rows; - - cur->rows = binfo.rows; - cur->win = binfo.window; - cur->mixBlock = false; - cur->blockCompleted = true; - cur->lastKey = binfo.window.ekey + (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)? 1:-1); - } + handleDataMergeIfNeeded(pQueryHandle, pBlock, pCheckInfo); } - } else { //desc order - // query ended in current block + } else { //desc order, query ended in current block if (pQueryHandle->window.ekey > pBlock->keyFirst) { if (!doLoadFileDataBlock(pQueryHandle, pBlock, pCheckInfo)) { return false; @@ -608,55 +644,11 @@ static bool loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock cur->pos = pBlock->numOfPoints - 1; } - mergeDataInDataBlock(pQueryHandle, pCheckInfo, pBlock, sa); + doMergeTwoLevelData(pQueryHandle, pCheckInfo, pBlock, sa); } else { - SDataBlockInfo binfo = getTrueDataBlockInfo(pCheckInfo, pBlock); - /*bool hasData = */ initTableMemIterator(pQueryHandle, pCheckInfo); - - TSKEY k1 = TSKEY_INITIAL_VAL, k2 = TSKEY_INITIAL_VAL; - if (pCheckInfo->iter != NULL) { - SSkipListNode* node = tSkipListIterGet(pCheckInfo->iter); - SDataRow row = SL_GET_NODE_DATA(node); - k1 = dataRowKey(row); - - if (k1 == binfo.window.skey) { - if (tSkipListIterNext(pCheckInfo->iter)) { - node = tSkipListIterGet(pCheckInfo->iter); - row = SL_GET_NODE_DATA(node); - k1 = dataRowKey(row); - } else { - k1 = TSKEY_INITIAL_VAL; - } - } - } - - if (pCheckInfo->iiter != NULL) { - SSkipListNode* node = tSkipListIterGet(pCheckInfo->iiter); - SDataRow row = SL_GET_NODE_DATA(node); - k2 = dataRowKey(row); - - if (k2 == binfo.window.skey) { - if (tSkipListIterNext(pCheckInfo->iiter)) { - node = tSkipListIterGet(pCheckInfo->iiter); - row = SL_GET_NODE_DATA(node); - k2 = dataRowKey(row); - } else { - k2 = TSKEY_INITIAL_VAL; - } - } - } - - cur->pos = binfo.rows - 1; - if ((k1 != TSKEY_INITIAL_VAL && k1 > binfo.window.ekey) || (k2 != TSKEY_INITIAL_VAL && k2 > binfo.window.ekey)) { - doLoadFileDataBlock(pQueryHandle, pBlock, pCheckInfo); - mergeDataInDataBlock(pQueryHandle, pCheckInfo, pBlock, sa); - } else { - pQueryHandle->realNumOfRows = binfo.rows; - } - } -// pQueryHandle->realNumOfRows = pBlock->numOfPoints; -// cur->pos = pBlock->numOfPoints - 1; + handleDataMergeIfNeeded(pQueryHandle, pBlock, pCheckInfo); } + } taosArrayDestroy(sa); return pQueryHandle->realNumOfRows > 0; @@ -726,20 +718,20 @@ static int vnodeBinarySearchKey(char* pValue, int num, TSKEY key, int order) { static int32_t copyDataFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t capacity, int32_t numOfRows, int32_t start, int32_t end) { char* pData = NULL; - int32_t step = ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)? 1 : -1; + int32_t step = ASCENDING_TRAVERSE(pQueryHandle->order)? 1 : -1; SDataCols* pCols = pQueryHandle->rhelper.pDataCols[0]; TSKEY* tsArray = pCols->cols[0].pData; int32_t num = end - start + 1; - int32_t reqiredNumOfCols = taosArrayGetSize(pQueryHandle->pColumns); + int32_t requiredNumOfCols = taosArrayGetSize(pQueryHandle->pColumns); //data in buffer has greater timestamp, copy data in file block - for (int32_t i = 0; i < reqiredNumOfCols; ++i) { + for (int32_t i = 0; i < requiredNumOfCols; ++i) { SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i); int32_t bytes = pColInfo->info.bytes; - if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) { + if (ASCENDING_TRAVERSE(pQueryHandle->order)) { pData = pColInfo->pData + numOfRows * pColInfo->info.bytes; } else { pData = pColInfo->pData + (capacity - numOfRows - num) * pColInfo->info.bytes; @@ -783,7 +775,7 @@ static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, STableCheckInfo* p for (int32_t i = 0; i < numOfCols; ++i) { SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i); - if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) { + if (ASCENDING_TRAVERSE(pQueryHandle->order)) { pData = pColInfo->pData + numOfRows * pColInfo->info.bytes; } else { pData = pColInfo->pData + (capacity - numOfRows - 1) * pColInfo->info.bytes; @@ -810,7 +802,7 @@ static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, STableCheckInfo* p // only return the qualified data to client in terms of query time window, data rows in the same block but do not // be included in the query time window will be discarded -static void mergeDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock, +static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock, SArray* sa) { SQueryFilePos* cur = &pQueryHandle->cur; SDataBlockInfo blockInfo = getTrueDataBlockInfo(pCheckInfo, pBlock); @@ -819,10 +811,10 @@ static void mergeDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInfo SDataCols* pCols = pQueryHandle->rhelper.pDataCols[0]; int32_t endPos = cur->pos; - if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order) && pQueryHandle->window.ekey > blockInfo.window.ekey) { + if (ASCENDING_TRAVERSE(pQueryHandle->order) && pQueryHandle->window.ekey > blockInfo.window.ekey) { endPos = blockInfo.rows - 1; cur->mixBlock = (cur->pos != 0); - } else if (!ASCENDING_ORDER_TRAVERSE(pQueryHandle->order) && pQueryHandle->window.ekey < blockInfo.window.skey) { + } else if (!ASCENDING_TRAVERSE(pQueryHandle->order) && pQueryHandle->window.ekey < blockInfo.window.skey) { endPos = 0; cur->mixBlock = (cur->pos != blockInfo.rows - 1); } else { @@ -839,13 +831,13 @@ static void mergeDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInfo int32_t numOfRows = 0; pQueryHandle->cur.win = TSWINDOW_INITIALIZER; - int32_t step = ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)? 1:-1; + int32_t step = ASCENDING_TRAVERSE(pQueryHandle->order)? 1:-1; // no data in buffer, load data from file directly if (pCheckInfo->iiter == NULL && pCheckInfo->iter == NULL) { int32_t start = cur->pos; int32_t end = endPos; - if (!ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) { + if (!ASCENDING_TRAVERSE(pQueryHandle->order)) { end = cur->pos; start = endPos; } @@ -857,7 +849,7 @@ static void mergeDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInfo numOfRows = copyDataFromFileBlock(pQueryHandle, pQueryHandle->outputCapacity, numOfRows, start, end); // if the buffer is not full in case of descending order query, move the data in the front of the buffer - if (!ASCENDING_ORDER_TRAVERSE(pQueryHandle->order) && numOfRows < pQueryHandle->outputCapacity) { + if (!ASCENDING_TRAVERSE(pQueryHandle->order) && numOfRows < pQueryHandle->outputCapacity) { int32_t emptySize = pQueryHandle->outputCapacity - numOfRows; int32_t reqNumOfCols = taosArrayGetSize(pQueryHandle->pColumns); @@ -868,8 +860,8 @@ static void mergeDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInfo } pos += (end - start + 1) * step; - cur->blockCompleted = (((pos >= endPos || cur->lastKey > pQueryHandle->window.ekey) && ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) || - ((pos <= endPos || cur->lastKey < pQueryHandle->window.ekey) && !ASCENDING_ORDER_TRAVERSE(pQueryHandle->order))); + cur->blockCompleted = (((pos >= endPos || cur->lastKey > pQueryHandle->window.ekey) && ASCENDING_TRAVERSE(pQueryHandle->order)) || + ((pos <= endPos || cur->lastKey < pQueryHandle->window.ekey) && !ASCENDING_TRAVERSE(pQueryHandle->order))); pCheckInfo->lastKey = cur->lastKey; pQueryHandle->realNumOfRows = numOfRows; @@ -889,18 +881,18 @@ static void mergeDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInfo SDataRow row = SL_GET_NODE_DATA(node); TSKEY key = dataRowKey(row); - if ((key > pQueryHandle->window.ekey && ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) || - (key < pQueryHandle->window.ekey && !ASCENDING_ORDER_TRAVERSE(pQueryHandle->order))) { + if ((key > pQueryHandle->window.ekey && ASCENDING_TRAVERSE(pQueryHandle->order)) || + (key < pQueryHandle->window.ekey && !ASCENDING_TRAVERSE(pQueryHandle->order))) { break; } - if (((tsArray[pos] > pQueryHandle->window.ekey || pos > endPos) && ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) || - ((tsArray[pos] < pQueryHandle->window.ekey || pos < endPos) && !ASCENDING_ORDER_TRAVERSE(pQueryHandle->order))) { + if (((tsArray[pos] > pQueryHandle->window.ekey || pos > endPos) && ASCENDING_TRAVERSE(pQueryHandle->order)) || + ((tsArray[pos] < pQueryHandle->window.ekey || pos < endPos) && !ASCENDING_TRAVERSE(pQueryHandle->order))) { break; } - if ((key < tsArray[pos] && ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) || - (key > tsArray[pos] && !ASCENDING_ORDER_TRAVERSE(pQueryHandle->order))) { + if ((key < tsArray[pos] && ASCENDING_TRAVERSE(pQueryHandle->order)) || + (key > tsArray[pos] && !ASCENDING_TRAVERSE(pQueryHandle->order))) { copyOneRowFromMem(pQueryHandle, pCheckInfo, pQueryHandle->outputCapacity, numOfRows, row, pSchema); numOfRows += 1; if (cur->win.skey == TSKEY_INITIAL_VAL) { @@ -914,20 +906,20 @@ static void mergeDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInfo tSkipListIterNext(pCheckInfo->iter); } else if (key == tsArray[pos]) { // data in buffer has the same timestamp of data in file block, ignore it tSkipListIterNext(pCheckInfo->iter); - } else if ((key > tsArray[pos] && ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) || - (key < tsArray[pos] && !ASCENDING_ORDER_TRAVERSE(pQueryHandle->order))) { + } else if ((key > tsArray[pos] && ASCENDING_TRAVERSE(pQueryHandle->order)) || + (key < tsArray[pos] && !ASCENDING_TRAVERSE(pQueryHandle->order))) { if (cur->win.skey == TSKEY_INITIAL_VAL) { cur->win.skey = tsArray[pos]; } - int32_t order = (pQueryHandle->order == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC; + int32_t order = ASCENDING_TRAVERSE(pQueryHandle->order) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC; int32_t end = vnodeBinarySearchKey(pCols->cols[0].pData, pCols->numOfPoints, key, order); if (tsArray[end] == key) { // the value of key in cache equals to the end timestamp value, ignore it tSkipListIterNext(pCheckInfo->iter); } int32_t start = -1; - if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) { + if (ASCENDING_TRAVERSE(pQueryHandle->order)) { int32_t remain = end - pos + 1; if (remain + numOfRows > pQueryHandle->outputCapacity) { end = (pQueryHandle->outputCapacity - numOfRows) + pos - 1; @@ -950,9 +942,13 @@ static void mergeDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInfo } while (numOfRows < pQueryHandle->outputCapacity); if (numOfRows < pQueryHandle->outputCapacity) { + /** + * if cache is empty, load remain file block data. In contrast, if there are remain data in cache, do NOT + * copy them all to result buffer, since it may be overlapped with file data block. + */ if (node == NULL || - ((dataRowKey(SL_GET_NODE_DATA(node)) > pQueryHandle->window.ekey) && ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) || - ((dataRowKey(SL_GET_NODE_DATA(node)) < pQueryHandle->window.ekey) && !ASCENDING_ORDER_TRAVERSE(pQueryHandle->order))) { + ((dataRowKey(SL_GET_NODE_DATA(node)) > pQueryHandle->window.ekey) && ASCENDING_TRAVERSE(pQueryHandle->order)) || + ((dataRowKey(SL_GET_NODE_DATA(node)) < pQueryHandle->window.ekey) && !ASCENDING_TRAVERSE(pQueryHandle->order))) { // no data in cache or data in cache is greater than the ekey of time window, load data from file block if (cur->win.skey == TSKEY_INITIAL_VAL) { cur->win.skey = tsArray[pos]; @@ -962,7 +958,7 @@ static void mergeDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInfo int32_t end = -1; // all remain data are qualified, but check the remain capacity in the first place. - if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) { + if (ASCENDING_TRAVERSE(pQueryHandle->order)) { int32_t remain = endPos - pos + 1; if (remain + numOfRows > pQueryHandle->outputCapacity) { endPos = (pQueryHandle->outputCapacity - numOfRows) + pos - 1; @@ -982,44 +978,22 @@ static void mergeDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInfo numOfRows = copyDataFromFileBlock(pQueryHandle, pQueryHandle->outputCapacity, numOfRows, start, end); pos += (end - start + 1) * step; - } else { - - while(numOfRows < pQueryHandle->outputCapacity && node != NULL && - (((dataRowKey(SL_GET_NODE_DATA(node)) <= pQueryHandle->window.ekey) && ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) || - ((dataRowKey(SL_GET_NODE_DATA(node)) >= pQueryHandle->window.ekey) && !ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)))) { - SDataRow row = SL_GET_NODE_DATA(node); - TSKEY key = dataRowKey(row); - - copyOneRowFromMem(pQueryHandle, pCheckInfo, pQueryHandle->outputCapacity, numOfRows, row, pSchema); - numOfRows += 1; - - if (cur->win.skey == TSKEY_INITIAL_VAL) { - cur->win.skey = key; - } - - cur->win.ekey = key; - cur->lastKey = key + step; - cur->mixBlock = true; - - tSkipListIterNext(pCheckInfo->iter); - node = tSkipListIterGet(pCheckInfo->iter); - } } } } - cur->blockCompleted = (((pos >= endPos || cur->lastKey > pQueryHandle->window.ekey) && ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) || - ((pos <= endPos || cur->lastKey < pQueryHandle->window.ekey) && !ASCENDING_ORDER_TRAVERSE(pQueryHandle->order))); + cur->blockCompleted = (((pos >= endPos || cur->lastKey > pQueryHandle->window.ekey) && ASCENDING_TRAVERSE(pQueryHandle->order)) || + ((pos <= endPos || cur->lastKey < pQueryHandle->window.ekey) && !ASCENDING_TRAVERSE(pQueryHandle->order))); - if (!ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) { + if (!ASCENDING_TRAVERSE(pQueryHandle->order)) { SWAP(cur->win.skey, cur->win.ekey, TSKEY); // if the buffer is not full in case of descending order query, move the data in the front of the buffer if (numOfRows < pQueryHandle->outputCapacity) { int32_t emptySize = pQueryHandle->outputCapacity - numOfRows; - int32_t reqiredNumOfCols = taosArrayGetSize(pQueryHandle->pColumns); - for(int32_t i = 0; i < reqiredNumOfCols; ++i) { + int32_t requiredNumOfCols = taosArrayGetSize(pQueryHandle->pColumns); + for(int32_t i = 0; i < requiredNumOfCols; ++i) { SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i); memmove(pColInfo->pData, pColInfo->pData + emptySize * pColInfo->info.bytes, numOfRows * pColInfo->info.bytes); } @@ -1245,7 +1219,7 @@ static bool getDataBlocksInFilesImpl(STsdbQueryHandle* pQueryHandle) { int32_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo); while ((pQueryHandle->pFileGroup = tsdbGetFileGroupNext(&pQueryHandle->fileIter)) != NULL) { - int32_t type = ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)? QUERY_RANGE_GREATER_EQUAL:QUERY_RANGE_LESS_EQUAL; + int32_t type = ASCENDING_TRAVERSE(pQueryHandle->order)? QUERY_RANGE_GREATER_EQUAL:QUERY_RANGE_LESS_EQUAL; if (getFileCompInfo(pQueryHandle, &numOfBlocks, type) != TSDB_CODE_SUCCESS) { break; } @@ -1277,7 +1251,7 @@ static bool getDataBlocksInFilesImpl(STsdbQueryHandle* pQueryHandle) { return false; } - cur->slot = ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)? 0:pQueryHandle->numOfBlocks-1; + cur->slot = ASCENDING_TRAVERSE(pQueryHandle->order)? 0:pQueryHandle->numOfBlocks-1; cur->fid = pQueryHandle->pFileGroup->fileId; STableBlockInfo* pBlockInfo = &pQueryHandle->pDataBlockInfo[cur->slot]; @@ -1304,12 +1278,13 @@ static bool getDataBlocksInFiles(STsdbQueryHandle* pQueryHandle) { // current block is done, try next if (!cur->mixBlock || cur->blockCompleted) { - if ((cur->slot == pQueryHandle->numOfBlocks - 1 && ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) || - (cur->slot == 0 && !ASCENDING_ORDER_TRAVERSE(pQueryHandle->order))) { + if ((cur->slot == pQueryHandle->numOfBlocks - 1 && ASCENDING_TRAVERSE(pQueryHandle->order)) || + (cur->slot == 0 && !ASCENDING_TRAVERSE(pQueryHandle->order))) { // all data blocks in current file has been checked already, try next file if exists return getDataBlocksInFilesImpl(pQueryHandle); - } else { // next block of the same file - int32_t step = ASCENDING_ORDER_TRAVERSE(pQueryHandle->order) ? 1 : -1; + } else { + // next block of the same file + int32_t step = ASCENDING_TRAVERSE(pQueryHandle->order) ? 1 : -1; cur->slot += step; cur->mixBlock = false; @@ -1319,9 +1294,8 @@ static bool getDataBlocksInFiles(STsdbQueryHandle* pQueryHandle) { return loadFileDataBlock(pQueryHandle, pNext->pBlock.compBlock, pNext->pTableCheckInfo); } } else { - SArray* sa = getDefaultLoadColumns(pQueryHandle, true); - mergeDataInDataBlock(pQueryHandle, pCheckInfo, pBlockInfo->pBlock.compBlock, sa); - return true; + handleDataMergeIfNeeded(pQueryHandle, pBlockInfo->pBlock.compBlock, pCheckInfo); + return pQueryHandle->realNumOfRows > 0; } } } @@ -1364,7 +1338,7 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pqHandle) { void changeQueryHandleForLastrowQuery(TsdbQueryHandleT pqHandle) { STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pqHandle; - assert(!ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)); + assert(!ASCENDING_TRAVERSE(pQueryHandle->order)); // starts from the buffer in case of descending timestamp order check data blocks @@ -1432,8 +1406,8 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY SDataRow row = SL_GET_NODE_DATA(node); TSKEY key = dataRowKey(row); - if ((key > maxKey && ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) || - (key < maxKey && !ASCENDING_ORDER_TRAVERSE(pQueryHandle->order))) { + if ((key > maxKey && ASCENDING_TRAVERSE(pQueryHandle->order)) || + (key < maxKey && !ASCENDING_TRAVERSE(pQueryHandle->order))) { uTrace("%p key:%"PRIu64" beyond qrange:%"PRId64" - %"PRId64", no more data in buffer", pQueryHandle, key, pQueryHandle->window.skey, pQueryHandle->window.ekey); @@ -1456,7 +1430,7 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY for (int32_t i = 0; i < numOfCols; ++i) { SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i); - if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order)) { + if (ASCENDING_TRAVERSE(pQueryHandle->order)) { pData = pColInfo->pData + numOfRows * pColInfo->info.bytes; } else { pData = pColInfo->pData + (maxRowsToRead - numOfRows - 1) * pColInfo->info.bytes; @@ -1489,7 +1463,7 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY assert(numOfRows <= maxRowsToRead); // if the buffer is not full in case of descending order query, move the data in the front of the buffer - if (!ASCENDING_ORDER_TRAVERSE(pQueryHandle->order) && numOfRows < maxRowsToRead) { + if (!ASCENDING_TRAVERSE(pQueryHandle->order) && numOfRows < maxRowsToRead) { int32_t emptySize = maxRowsToRead - numOfRows; for(int32_t i = 0; i < numOfCols; ++i) { @@ -1505,17 +1479,14 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY SDataBlockInfo tsdbRetrieveDataBlockInfo(TsdbQueryHandleT* pQueryHandle) { STsdbQueryHandle* pHandle = (STsdbQueryHandle*)pQueryHandle; - STable* pTable = NULL; - int32_t rows = 0; - - int32_t step = ASCENDING_ORDER_TRAVERSE(pHandle->order)? 1:-1; + int32_t step = ASCENDING_TRAVERSE(pHandle->order)? 1:-1; // there are data in file if (pHandle->cur.fid >= 0) { STableBlockInfo* pBlockInfo = &pHandle->pDataBlockInfo[pHandle->cur.slot]; STableCheckInfo* pCheckInfo = pBlockInfo->pTableCheckInfo; - - pTable = pCheckInfo->pTableObj; + + STable* pTable = pCheckInfo->pTableObj; if (pHandle->cur.mixBlock) { SDataBlockInfo blockInfo = { @@ -1527,33 +1498,31 @@ SDataBlockInfo tsdbRetrieveDataBlockInfo(TsdbQueryHandleT* pQueryHandle) { return blockInfo; } else { - SDataBlockInfo binfo = getTrueDataBlockInfo(pCheckInfo, pBlockInfo->pBlock.compBlock); - return binfo; + return getTrueDataBlockInfo(pCheckInfo, pBlockInfo->pBlock.compBlock); } } else { STableCheckInfo* pCheckInfo = taosArrayGet(pHandle->pTableCheckInfo, pHandle->activeIndex); - pTable = pCheckInfo->pTableObj; - - if (pTable->mem != NULL) { - // create mem table iterator if it is not created yet + + STable* pTable = pCheckInfo->pTableObj; + if (pTable->mem != NULL) { // create mem table iterator if it is not created yet assert(pCheckInfo->iter != NULL); STimeWindow* win = &pHandle->cur.win; - rows = tsdbReadRowsFromCache(pCheckInfo->iter, pCheckInfo->pTableObj, pHandle->window.ekey, + pHandle->cur.rows = tsdbReadRowsFromCache(pCheckInfo->iter, pCheckInfo->pTableObj, pHandle->window.ekey, pHandle->outputCapacity, &win->skey, &win->ekey, pHandle); // todo refactor API // update the last key value pCheckInfo->lastKey = win->ekey + step; } - if (!ASCENDING_ORDER_TRAVERSE(pHandle->order)) { + if (!ASCENDING_TRAVERSE(pHandle->order)) { SWAP(pHandle->cur.win.skey, pHandle->cur.win.ekey, TSKEY); } SDataBlockInfo blockInfo = { .uid = pTable->tableId.uid, .tid = pTable->tableId.tid, - .rows = rows, + .rows = pHandle->cur.rows, .window = pHandle->cur.win, }; @@ -1600,7 +1569,7 @@ SArray* tsdbRetrieveDataBlock(TsdbQueryHandleT* pQueryHandle, SArray* pIdList) { int32_t numOfRows = copyDataFromFileBlock(pHandle, pHandle->outputCapacity, 0, 0, pBlock->numOfPoints - 1); // if the buffer is not full in case of descending order query, move the data in the front of the buffer - if (!ASCENDING_ORDER_TRAVERSE(pHandle->order) && numOfRows < pHandle->outputCapacity) { + if (!ASCENDING_TRAVERSE(pHandle->order) && numOfRows < pHandle->outputCapacity) { int32_t emptySize = pHandle->outputCapacity - numOfRows; int32_t reqNumOfCols = taosArrayGetSize(pHandle->pColumns); diff --git a/src/util/inc/tsocket.h b/src/util/inc/tsocket.h index 309aa80ef6c0ae4e04d20e72ebb0d91835bcb66d..97abc16333ae08cec2387045d8ae458de43b3a06 100644 --- a/src/util/inc/tsocket.h +++ b/src/util/inc/tsocket.h @@ -31,7 +31,6 @@ int taosOpenUdpSocket(uint32_t localIp, uint16_t localPort); int taosOpenTcpClientSocket(uint32_t ip, uint16_t port, uint32_t localIp); int taosOpenTcpServerSocket(uint32_t ip, uint16_t port); int taosKeepTcpAlive(int sockFd); -void taosCloseTcpSocket(int sockFd); int taosGetFqdn(char *); uint32_t taosGetIpFromFqdn(const char *); diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index 4bac669dc07689129a241b7ace45c56ad4485ca4..751bd0fc34f443fde9496a5ee75aa33f35987564 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -216,14 +216,14 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c return (str[j] == 0 || j >= size) ? TSDB_PATTERN_MATCH : TSDB_PATTERN_NOMATCH; } -static UNUSED_FUNC int32_t compareStrPatternComp(const void* pLeft, const void* pRight) { +static int32_t compareStrPatternComp(const void* pLeft, const void* pRight) { SPatternCompareInfo pInfo = {'%', '_'}; - const char* pattern = pRight; - const char* str = pLeft; - - int32_t ret = patternMatch(pattern, str, strlen(str), &pInfo); + char pattern[128] = {0}; + memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); + assert(varDataLen(pRight) < 128); + int32_t ret = patternMatch(pattern, varDataVal(pLeft), varDataLen(pLeft), &pInfo); return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; } @@ -232,14 +232,14 @@ static int32_t compareFindStrInArray(const void* pLeft, const void* pRight) { return taosArraySearchString(arr, pLeft) == NULL ? 0 : 1; } -static UNUSED_FUNC int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) { +static int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) { SPatternCompareInfo pInfo = {'%', '_'}; - const wchar_t* pattern = pRight; - const wchar_t* str = pLeft; - - int32_t ret = WCSPatternMatch(pattern, str, wcslen(str), &pInfo); + wchar_t pattern[128] = {0}; + memcpy(pattern, varDataVal(pRight), varDataLen(pRight)/TSDB_NCHAR_SIZE); + assert(varDataLen(pRight) < 128); + int32_t ret = WCSPatternMatch(pattern, varDataVal(pLeft), varDataLen(pLeft)/TSDB_NCHAR_SIZE, &pInfo); return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; } diff --git a/src/util/src/tsocket.c b/src/util/src/tsocket.c index efdf7529608b272230f804437d71377f1fc6feea..f2b89c8243ec7c38acd663a6465955aa0b6df966 100644 --- a/src/util/src/tsocket.c +++ b/src/util/src/tsocket.c @@ -305,18 +305,9 @@ int taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clientI sockFd = -1; } - return sockFd; -} - -void taosCloseTcpSocket(int sockFd) { - struct linger linger; - linger.l_onoff = 1; - linger.l_linger = 0; - if (taosSetSockOpt(sockFd, SOL_SOCKET, SO_LINGER, (void *)&linger, sizeof(linger)) < 0) { - uError("setsockopt SO_LINGER failed: %d (%s)", errno, strerror(errno)); - } + taosKeepTcpAlive(sockFd); - taosCloseSocket(sockFd); + return sockFd; } int taosKeepTcpAlive(int sockFd) { @@ -355,6 +346,15 @@ int taosKeepTcpAlive(int sockFd) { return -1; } + struct linger linger = {0}; + linger.l_onoff = 1; + //linger.l_linger = 0; + if (taosSetSockOpt(sockFd, SOL_SOCKET, SO_LINGER, (void *)&linger, sizeof(linger)) < 0) { + uError("setsockopt SO_LINGER failed: %d (%s)", errno, strerror(errno)); + close(sockFd); + return -1; + } + return 0; } diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 173062fb1f31309d23859440c43f6c89d7364b6b..999332d33bdc838ad77b9276b022ee27b8f47d50 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -1,130 +1,132 @@ #!/bin/bash -python3 ./test.py $1 -f insert/basic.py -python3 ./test.py $1 -f insert/int.py -python3 ./test.py $1 -f insert/float.py -python3 ./test.py $1 -f insert/bigint.py -python3 ./test.py $1 -f insert/bool.py -python3 ./test.py $1 -f insert/double.py -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 insert/nchar-boundary.py -python3 ./test.py $1 -f insert/nchar-unicode.py -python3 ./test.py $1 -f insert/multi.py +python3 ./test.py -f insert/basic.py +python3 ./test.py -f insert/int.py +python3 ./test.py -f insert/float.py +python3 ./test.py -f insert/bigint.py +python3 ./test.py -f insert/bool.py +python3 ./test.py -f insert/double.py +python3 ./test.py -f insert/smallint.py +python3 ./test.py -f insert/tinyint.py +python3 ./test.py -f insert/date.py +python3 ./test.py -f insert/binary.py +python3 ./test.py -f insert/nchar.py +python3 ./test.py -f insert/nchar-boundary.py +python3 ./test.py -f insert/nchar-unicode.py +python3 ./test.py -f insert/multi.py +python3 ./test.py -f insert/randomNullCommit.py -python3 ./test.py $1 -f table/column_name.py -python3 ./test.py $1 -f table/column_num.py -python3 ./test.py $1 -f table/db_table.py -python3 ./test.py $1 -f table/tablename-boundary.py +python3 ./test.py -f table/column_name.py +python3 ./test.py -f table/column_num.py +python3 ./test.py -f table/db_table.py +python3 ./test.py -f table/tablename-boundary.py # tag -python3 ./test.py $1 -f tag_lite/filter.py -python3 ./test.py $1 -f tag_lite/create-tags-boundary.py -python3 ./test.py $1 -f tag_lite/3.py -python3 ./test.py $1 -f tag_lite/4.py -python3 ./test.py $1 -f tag_lite/5.py -python3 ./test.py $1 -f tag_lite/6.py -python3 ./test.py $1 -f tag_lite/add.py -python3 ./test.py $1 -f tag_lite/bigint.py -python3 ./test.py $1 -f tag_lite/binary_binary.py -python3 ./test.py $1 -f tag_lite/binary.py -python3 ./test.py $1 -f tag_lite/bool_binary.py -python3 ./test.py $1 -f tag_lite/bool_int.py -python3 ./test.py $1 -f tag_lite/bool.py -python3 ./test.py $1 -f tag_lite/change.py -python3 ./test.py $1 -f tag_lite/column.py -python3 ./test.py $1 -f tag_lite/commit.py -python3 ./test.py $1 -f tag_lite/create.py -python3 ./test.py $1 -f tag_lite/datatype.py -python3 ./test.py $1 -f tag_lite/datatype-without-alter.py -python3 ./test.py $1 -f tag_lite/delete.py -python3 ./test.py $1 -f tag_lite/double.py -python3 ./test.py $1 -f tag_lite/float.py -python3 ./test.py $1 -f tag_lite/int_binary.py -python3 ./test.py $1 -f tag_lite/int_float.py -python3 ./test.py $1 -f tag_lite/int.py -python3 ./test.py $1 -f tag_lite/set.py -python3 ./test.py $1 -f tag_lite/smallint.py -python3 ./test.py $1 -f tag_lite/tinyint.py +python3 ./test.py -f tag_lite/filter.py +python3 ./test.py -f tag_lite/create-tags-boundary.py +python3 ./test.py -f tag_lite/3.py +python3 ./test.py -f tag_lite/4.py +python3 ./test.py -f tag_lite/5.py +python3 ./test.py -f tag_lite/6.py +python3 ./test.py -f tag_lite/add.py +python3 ./test.py -f tag_lite/bigint.py +python3 ./test.py -f tag_lite/binary_binary.py +python3 ./test.py -f tag_lite/binary.py +python3 ./test.py -f tag_lite/bool_binary.py +python3 ./test.py -f tag_lite/bool_int.py +python3 ./test.py -f tag_lite/bool.py +python3 ./test.py -f tag_lite/change.py +python3 ./test.py -f tag_lite/column.py +python3 ./test.py -f tag_lite/commit.py +python3 ./test.py -f tag_lite/create.py +python3 ./test.py -f tag_lite/datatype.py +python3 ./test.py -f tag_lite/datatype-without-alter.py +python3 ./test.py -f tag_lite/delete.py +python3 ./test.py -f tag_lite/double.py +python3 ./test.py -f tag_lite/float.py +python3 ./test.py -f tag_lite/int_binary.py +python3 ./test.py -f tag_lite/int_float.py +python3 ./test.py -f tag_lite/int.py +python3 ./test.py -f tag_lite/set.py +python3 ./test.py -f tag_lite/smallint.py +python3 ./test.py -f tag_lite/tinyint.py -python3 ./test.py $1 -f dbmgmt/database-name-boundary.py +python3 ./test.py -f dbmgmt/database-name-boundary.py -python3 ./test.py $1 -f import_merge/importBlock1HO.py -python3 ./test.py $1 -f import_merge/importBlock1HPO.py -python3 ./test.py $1 -f import_merge/importBlock1H.py -python3 ./test.py $1 -f import_merge/importBlock1S.py -python3 ./test.py $1 -f import_merge/importBlock1Sub.py -python3 ./test.py $1 -f import_merge/importBlock1TO.py -python3 ./test.py $1 -f import_merge/importBlock1TPO.py -python3 ./test.py $1 -f import_merge/importBlock1T.py -python3 ./test.py $1 -f import_merge/importBlock2HO.py -python3 ./test.py $1 -f import_merge/importBlock2HPO.py -python3 ./test.py $1 -f import_merge/importBlock2H.py -python3 ./test.py $1 -f import_merge/importBlock2S.py -python3 ./test.py $1 -f import_merge/importBlock2Sub.py -python3 ./test.py $1 -f import_merge/importBlock2TO.py -python3 ./test.py $1 -f import_merge/importBlock2TPO.py -python3 ./test.py $1 -f import_merge/importBlock2T.py -python3 ./test.py $1 -f import_merge/importBlockbetween.py -python3 ./test.py $1 -f import_merge/importCacheFileHO.py -python3 ./test.py $1 -f import_merge/importCacheFileHPO.py -python3 ./test.py $1 -f import_merge/importCacheFileH.py -python3 ./test.py $1 -f import_merge/importCacheFileS.py -python3 ./test.py $1 -f import_merge/importCacheFileSub.py -python3 ./test.py $1 -f import_merge/importCacheFileTO.py -python3 ./test.py $1 -f import_merge/importCacheFileTPO.py -python3 ./test.py $1 -f import_merge/importCacheFileT.py -python3 ./test.py $1 -f import_merge/importDataH2.py -python3 ./test.py $1 -f import_merge/importDataHO2.py -python3 ./test.py $1 -f import_merge/importDataHO.py -python3 ./test.py $1 -f import_merge/importDataHPO.py -python3 ./test.py $1 -f import_merge/importDataLastHO.py -python3 ./test.py $1 -f import_merge/importDataLastHPO.py -python3 ./test.py $1 -f import_merge/importDataLastH.py -python3 ./test.py $1 -f import_merge/importDataLastS.py -python3 ./test.py $1 -f import_merge/importDataLastSub.py -python3 ./test.py $1 -f import_merge/importDataLastTO.py -python3 ./test.py $1 -f import_merge/importDataLastTPO.py -python3 ./test.py $1 -f import_merge/importDataLastT.py -python3 ./test.py $1 -f import_merge/importDataS.py -python3 ./test.py $1 -f import_merge/importDataSub.py -python3 ./test.py $1 -f import_merge/importDataTO.py -python3 ./test.py $1 -f import_merge/importDataTPO.py -python3 ./test.py $1 -f import_merge/importDataT.py -python3 ./test.py $1 -f import_merge/importHeadOverlap.py -python3 ./test.py $1 -f import_merge/importHeadPartOverlap.py -python3 ./test.py $1 -f import_merge/importHead.py -python3 ./test.py $1 -f import_merge/importHORestart.py -python3 ./test.py $1 -f import_merge/importHPORestart.py -python3 ./test.py $1 -f import_merge/importHRestart.py -python3 ./test.py $1 -f import_merge/importLastHO.py -python3 ./test.py $1 -f import_merge/importLastHPO.py -python3 ./test.py $1 -f import_merge/importLastH.py -python3 ./test.py $1 -f import_merge/importLastS.py -python3 ./test.py $1 -f import_merge/importLastSub.py -python3 ./test.py $1 -f import_merge/importLastTO.py -python3 ./test.py $1 -f import_merge/importLastTPO.py -python3 ./test.py $1 -f import_merge/importLastT.py -python3 ./test.py $1 -f import_merge/importSpan.py -python3 ./test.py $1 -f import_merge/importSRestart.py -python3 ./test.py $1 -f import_merge/importSubRestart.py -python3 ./test.py $1 -f import_merge/importTailOverlap.py -python3 ./test.py $1 -f import_merge/importTailPartOverlap.py -python3 ./test.py $1 -f import_merge/importTail.py -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 +python3 ./test.py -f import_merge/importBlock1HO.py +python3 ./test.py -f import_merge/importBlock1HPO.py +python3 ./test.py -f import_merge/importBlock1H.py +python3 ./test.py -f import_merge/importBlock1S.py +python3 ./test.py -f import_merge/importBlock1Sub.py +python3 ./test.py -f import_merge/importBlock1TO.py +python3 ./test.py -f import_merge/importBlock1TPO.py +python3 ./test.py -f import_merge/importBlock1T.py +python3 ./test.py -f import_merge/importBlock2HO.py +python3 ./test.py -f import_merge/importBlock2HPO.py +python3 ./test.py -f import_merge/importBlock2H.py +python3 ./test.py -f import_merge/importBlock2S.py +python3 ./test.py -f import_merge/importBlock2Sub.py +python3 ./test.py -f import_merge/importBlock2TO.py +python3 ./test.py -f import_merge/importBlock2TPO.py +python3 ./test.py -f import_merge/importBlock2T.py +python3 ./test.py -f import_merge/importBlockbetween.py +python3 ./test.py -f import_merge/importCacheFileHO.py +python3 ./test.py -f import_merge/importCacheFileHPO.py +python3 ./test.py -f import_merge/importCacheFileH.py +python3 ./test.py -f import_merge/importCacheFileS.py +python3 ./test.py -f import_merge/importCacheFileSub.py +python3 ./test.py -f import_merge/importCacheFileTO.py +python3 ./test.py -f import_merge/importCacheFileTPO.py +python3 ./test.py -f import_merge/importCacheFileT.py +python3 ./test.py -f import_merge/importDataH2.py +python3 ./test.py -f import_merge/importDataHO2.py +python3 ./test.py -f import_merge/importDataHO.py +python3 ./test.py -f import_merge/importDataHPO.py +python3 ./test.py -f import_merge/importDataLastHO.py +python3 ./test.py -f import_merge/importDataLastHPO.py +python3 ./test.py -f import_merge/importDataLastH.py +python3 ./test.py -f import_merge/importDataLastS.py +python3 ./test.py -f import_merge/importDataLastSub.py +python3 ./test.py -f import_merge/importDataLastTO.py +python3 ./test.py -f import_merge/importDataLastTPO.py +python3 ./test.py -f import_merge/importDataLastT.py +python3 ./test.py -f import_merge/importDataS.py +python3 ./test.py -f import_merge/importDataSub.py +python3 ./test.py -f import_merge/importDataTO.py +python3 ./test.py -f import_merge/importDataTPO.py +python3 ./test.py -f import_merge/importDataT.py +python3 ./test.py -f import_merge/importHeadOverlap.py +python3 ./test.py -f import_merge/importHeadPartOverlap.py +python3 ./test.py -f import_merge/importHead.py +python3 ./test.py -f import_merge/importHORestart.py +python3 ./test.py -f import_merge/importHPORestart.py +python3 ./test.py -f import_merge/importHRestart.py +python3 ./test.py -f import_merge/importLastHO.py +python3 ./test.py -f import_merge/importLastHPO.py +python3 ./test.py -f import_merge/importLastH.py +python3 ./test.py -f import_merge/importLastS.py +python3 ./test.py -f import_merge/importLastSub.py +python3 ./test.py -f import_merge/importLastTO.py +python3 ./test.py -f import_merge/importLastTPO.py +python3 ./test.py -f import_merge/importLastT.py +python3 ./test.py -f import_merge/importSpan.py +python3 ./test.py -f import_merge/importSRestart.py +python3 ./test.py -f import_merge/importSubRestart.py +python3 ./test.py -f import_merge/importTailOverlap.py +python3 ./test.py -f import_merge/importTailPartOverlap.py +python3 ./test.py -f import_merge/importTail.py +python3 ./test.py -f import_merge/importToCommit.py +python3 ./test.py -f import_merge/importTORestart.py +python3 ./test.py -f import_merge/importTPORestart.py +python3 ./test.py -f import_merge/importTRestart.py +python3 ./test.py -f import_merge/importInsertThenImport.py # user -python3 ./test.py $1 -f user/user_create.py -python3 ./test.py $1 -f user/pass_len.py +python3 ./test.py -f user/user_create.py +python3 ./test.py -f user/pass_len.py # table -#python3 ./test.py $1 -f table/del_stable.py +#python3 ./test.py -f table/del_stable.py #query -python3 ./test.py $1 -f query/filter.py +python3 ./test.py -f query/filter.py diff --git a/tests/pytest/import_merge/importInsertThenImport.py b/tests/pytest/import_merge/importInsertThenImport.py new file mode 100644 index 0000000000000000000000000000000000000000..292fae8c47b398dcbacdb8b76592826bcc8b6019 --- /dev/null +++ b/tests/pytest/import_merge/importInsertThenImport.py @@ -0,0 +1,85 @@ +################################################################### +# 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 * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def run(self): + self.ntables = 1 + self.startTime = 1520000010000 + + tdSql.prepare() + + tdLog.info("================= step1") + tdLog.info("create 1 table") + tdSql.execute('create table tb1 (ts timestamp, i int)') + + tdLog.info("================= step2") + tdLog.info("insert 100 sequential data") + startTime = self.startTime + for rid in range(1, 101): + tdSql.execute( + 'insert into tb1 values(%ld, %d)' % + (startTime + rid, rid)) + + tdLog.info("================= step3") + tdSql.query('select * from tb1') + tdSql.checkRows(100) + + tdLog.info("================= step4") + tdLog.info("import 100 sequential data") + startTime = self.startTime + for rid in range(1, 101): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, 100 + rid)) + + tdSql.query('select * from tb1') + tdSql.checkRows(100) + tdSql.checkData(0, 1, 1) + + tdLog.info("================= step5") + tdDnodes.stop(1) + tdDnodes.start(1) + tdLog.sleep(10) + + tdLog.info("================= step6") + tdLog.info("import 100 sequential data again") + startTime = self.startTime + for rid in range(1, 101): + tdSql.execute( + 'import into tb1 values(%ld, %d)' % + (startTime + rid, 100 + rid)) + + tdLog.info("================= step7") + tdSql.query('select * from tb1') + tdSql.checkRows(100) + tdSql.checkData(0, 1, 1) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/randomNullCommit.py b/tests/pytest/insert/randomNullCommit.py new file mode 100644 index 0000000000000000000000000000000000000000..f90bb9b3e5e985aa1777899c6e53b261072193aa --- /dev/null +++ b/tests/pytest/insert/randomNullCommit.py @@ -0,0 +1,64 @@ +################################################################### +# 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 random + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + tdLog.info("=============== step1") + tdSql.execute('create table tb (ts timestamp, speed int, temp float, note binary(5), flag bool)') + + numOfRecords = 0 + randomList = [10, 50, 100, 500, 1000, 5000] + for i in range(0, 10): + num = random.choice(randomList) + tdLog.info("will insert %d records" % num) + for x in range(0, num): + tdLog.info( + 'insert into tb values (now + %da, NULL, NULL, NULL, TRUE)' % x) + tdSql.execute( + 'insert into tb values (now + %da, NULL, NULL, NULL, TRUE)' % x) + + numOfRecords = numOfRecords + num + + tdSql.query("select * from tb") + tdSql.checkRows(numOfRecords) + tdSql.checkData(numOfRecords-num, 1, None) + tdSql.checkData(numOfRecords-1, 2, None) + + tdLog.info("stop dnode to commit data to disk") + tdDnodes.stop(1) + tdDnodes.start(1) + tdLog.sleep(5) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/query/filter.py b/tests/pytest/query/filter.py index e58907aa47745798496287b8cea7af9959a7974e..43c8e5bf0aa612079b26fdf9edc9d303023a1405 100644 --- a/tests/pytest/query/filter.py +++ b/tests/pytest/query/filter.py @@ -19,7 +19,7 @@ from util.sql import * class TDTestCase: - def init(self, conn): + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor()) diff --git a/tests/pytest/smoketest.sh b/tests/pytest/smoketest.sh index 8e0ccbd4b04b5bfc987611eefa0cbc6b7b3a6fab..cda46a360444515b6efa101f1ac17c555d389e95 100755 --- a/tests/pytest/smoketest.sh +++ b/tests/pytest/smoketest.sh @@ -50,6 +50,8 @@ python3 ./test.py $1 -f import_merge/importTail.py python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f import_merge/importTRestart.py python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f import_merge/importInsertThenImport.py +python3 ./test.py $1 -s && sleep 1 #tag python3 ./test.py $1 -f tag_lite/filter.py diff --git a/tests/script/general/db/alter_tables_d2.sim b/tests/script/general/db/alter_tables_d2.sim index 7e8d4e117abfd53dba5800f13abcd71a1e452c47..1fd24f9cec5b54c1be7531f24a3f590d94b28e38 100644 --- a/tests/script/general/db/alter_tables_d2.sim +++ b/tests/script/general/db/alter_tables_d2.sim @@ -375,7 +375,7 @@ endi print ============================ step11 sql_error create table db.t400 using db.st tags(10) sql show db.tables -if $rows != 50 then +if $rows != 80 then return -1 endi @@ -427,7 +427,7 @@ sql insert into db.t418 values(now, 1) sql insert into db.t419 values(now, 1) sql show db.tables -if $rows != 50 then +if $rows != 100 then return -1 endi diff --git a/tests/script/general/db/dropdnodes.sim b/tests/script/general/db/dropdnodes.sim new file mode 100644 index 0000000000000000000000000000000000000000..7ba5e7b66e26a506f6204259a60e8acd69454b6c --- /dev/null +++ b/tests/script/general/db/dropdnodes.sim @@ -0,0 +1,104 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/deploy.sh -n dnode2 -i 2 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 + +print ========== prepare data +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start + +sleep 3000 +sql connect + +sql create dnode $hostname2 +sleep 2000 + +sql create database db maxTables 4 +sql use db + +print ========== step1 +sql create table mt (ts timestamp, tbcol int) TAGS(tgcol int) +sql create table db.t1 using db.mt tags(1) +sql create table db.t2 using db.mt tags(2) +sql create table db.t3 using db.mt tags(3) +sql create table db.t4 using db.mt tags(4) +sql create table db.t5 using db.mt tags(5) +sql create table db.t6 using db.mt tags(6) +sql create table db.t7 using db.mt tags(7) +sql create table db.t8 using db.mt tags(8) +sql create table db.t9 using db.mt tags(9) +sql create table db.t10 using db.mt tags(10) +sql create table db.t11 using db.mt tags(11) +sql create table db.t12 using db.mt tags(12) +sql create table db.t13 using db.mt tags(13) +sql create table db.t14 using db.mt tags(14) +sql create table db.t15 using db.mt tags(15) +sql create table db.t16 using db.mt tags(16) + +sql insert into db.t1 values(now, 1) +sql insert into db.t2 values(now, 1) +sql insert into db.t3 values(now, 1) +sql insert into db.t4 values(now, 1) +sql insert into db.t5 values(now, 1) +sql insert into db.t6 values(now, 1) +sql insert into db.t7 values(now, 1) +sql insert into db.t8 values(now, 1) +sql insert into db.t9 values(now, 1) +sql insert into db.t10 values(now, 1) +sql insert into db.t11 values(now, 1) +sql insert into db.t12 values(now, 1) +sql insert into db.t13 values(now, 1) +sql insert into db.t14 values(now, 1) +sql insert into db.t15 values(now, 1) +sql insert into db.t16 values(now, 1) + +print ========== step2 +sql show tables +print $rows +if $rows != 16 then + return -1 +endi + +sql select * from mt +print $rows +if $rows != 16 then + return -1 +endi + +print ========== step3 + +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 500 +sql drop dnode $hostname2 +sleep 2000 + +print ========== step3 + +sql show tables +print $rows +if $rows != 8 then + return -1 +endi + +sql select * from mt +print $rows +if $rows != 8 then + return -1 +endi + +sql select * from db.t5 +if $rows != 1 then + return -1 +endi + +sql select * from db.t13 +if $rows != 1 then + return -1 +endi + +sql_error select * from db.t1 +sql_error select * from db.t9 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/http/restful_insert.sim b/tests/script/general/http/restful_insert.sim index 7b1e88a25f53c188072963f6bbd39c419a81dc12..b36a92c0034b844bacf9c05dff41c8537dd19382 100644 --- a/tests/script/general/http/restful_insert.sim +++ b/tests/script/general/http/restful_insert.sim @@ -37,7 +37,7 @@ endi print =============== step3 - query data -system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql +system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'insert into d1.table_rest1 values('now+1s', 1) d1.table_rest2 values('now+1s', 1) d1.table_rest3 values('now+1s', 1) d1.table_rest4 values('now+1s', 1) ' 127.0.0.1:6020/rest/sql diff --git a/tests/script/general/import/replica1.sim b/tests/script/general/import/replica1.sim index ad5a3faed5d00941d56ed3fa18af5340a40240d3..61f563ba8e9489e2ad0ffe217b37603ffb975319 100644 --- a/tests/script/general/import/replica1.sim +++ b/tests/script/general/import/replica1.sim @@ -32,10 +32,10 @@ sql connect sql create database ir1db days 7 sql use ir1db -sql create table tb(ts timestamp, i int) +sql create table tb(ts timestamp, i bigint) print ================= step1 -sql import into tb values(1520000010000, 10000) +sql import into tb values(1520000010000, 1520000010000) sql select * from tb; print $rows if $rows != 1 then @@ -43,7 +43,7 @@ if $rows != 1 then endi print ================= step2 -sql insert into tb values(1520000008000, 8000) +sql insert into tb values(1520000008000, 1520000008000) print $rows sql select * from tb; if $rows != 2 then @@ -51,7 +51,7 @@ if $rows != 2 then endi print ================= step3 -sql insert into tb values(1520000020000, 20000) +sql insert into tb values(1520000020000, 1520000020000) sql select * from tb; print $rows if $rows != 3 then @@ -59,9 +59,9 @@ if $rows != 3 then endi print ================= step4 -sql import into tb values(1520000009000, 9000) -sql import into tb values(1520000015000, 15000) -sql import into tb values(1520000030000, 30000) +sql import into tb values(1520000009000, 1520000009000) +sql import into tb values(1520000015000, 1520000015000) +sql import into tb values(1520000030000, 1520000030000) sql select * from tb; print $rows if $rows != 6 then @@ -69,10 +69,10 @@ if $rows != 6 then endi print ================= step5 -sql insert into tb values(1520000008000, 8000) -sql insert into tb values(1520000014000, 14000) -sql insert into tb values(1520000025000, 25000) -sql insert into tb values(1520000040000, 40000) +sql insert into tb values(1520000008000, 1520000008000) +sql insert into tb values(1520000014000, 1520000014000) +sql insert into tb values(1520000025000, 1520000025000) +sql insert into tb values(1520000040000, 1520000040000) sql select * from tb; print $rows if $rows != 9 then @@ -80,11 +80,11 @@ if $rows != 9 then endi print ================= step6 -sql import into tb values(1520000007000, 7000) -sql import into tb values(1520000012000, 12000) -sql import into tb values(1520000023000, 23000) -sql import into tb values(1520000034000, 34000) -sql import into tb values(1520000050000, 50000) +sql import into tb values(1520000007000, 1520000007000) +sql import into tb values(1520000012000, 1520000012000) +sql import into tb values(1520000023000, 1520000023000) +sql import into tb values(1520000034000, 1520000034000) +sql import into tb values(1520000050000, 1520000050000) sql select * from tb; print $rows if $rows != 14 then @@ -104,11 +104,11 @@ if $rows != 14 then endi print ================= step7 -sql import into tb values(1520000007001, 7001) -sql import into tb values(1520000012001, 12001) -sql import into tb values(1520000023001, 23001) -sql import into tb values(1520000034001, 34001) -sql import into tb values(1520000050001, 50001) +sql import into tb values(1520000007001, 1520000007001) +sql import into tb values(1520000012001, 1520000012001) +sql import into tb values(1520000023001, 1520000023001) +sql import into tb values(1520000034001, 1520000034001) +sql import into tb values(1520000050001, 1520000050001) sql select * from tb; print $rows if $rows != 19 then @@ -117,10 +117,10 @@ if $rows != 19 then endi print ================= step8 -sql insert into tb values(1520000008002, 8002) -sql insert into tb values(1520000014002, 14002) -sql insert into tb values(1520000025002, 25002) -sql insert into tb values(1520000060000, 60000) +sql insert into tb values(1520000008002, 1520000008002) +sql insert into tb values(1520000014002, 1520000014002) +sql insert into tb values(1520000025002, 1520000025002) +sql insert into tb values(1520000060000, 1520000060000) sql select * from tb; print $rows if $rows != 23 then @@ -142,18 +142,18 @@ print ================= step9 #sql import into tb values(now+14d, 50001) #sql import into tb values(now+16d, 500051) -sql import into tb values(1517408000000, 7003) -sql import into tb values(1518272000000, 34003) -sql import into tb values(1519136000000, 34003) -sql import into tb values(1519568000000, 34003) -sql import into tb values(1519654400000, 50001) -sql import into tb values(1519827200000, 50001) -sql import into tb values(1520345600000, 50001) -sql import into tb values(1520691200000, 50002) -sql import into tb values(1520864000000, 50003) -sql import into tb values(1521900800000, 50004) -sql import into tb values(1523110400000, 50001) -sql import into tb values(1521382400000, 500051) +sql import into tb values(1517408000000, 1517408000000) +sql import into tb values(1518272000000, 1518272000000) +sql import into tb values(1519136000000, 1519136000000) +sql import into tb values(1519568000000, 1519568000000) +sql import into tb values(1519654400000, 1519654400000) +sql import into tb values(1519827200000, 1519827200000) +sql import into tb values(1520345600000, 1520345600000) +sql import into tb values(1520691200000, 1520691200000) +sql import into tb values(1520864000000, 1520864000000) +sql import into tb values(1521900800000, 1521900800000) +sql import into tb values(1523110400000, 1523110400000) +sql import into tb values(1521382400000, 1521382400000) sql select * from tb; print $rows if $rows != 35 then @@ -176,7 +176,7 @@ endi print ================= step11 #sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) -sql import into tb values(1515680000000, 7003) (1515852800000, 7003) (1516025600000, 7003) (1516198400000, 7003) (1516371200000, 7003) +sql import into tb values(1515680000000, 1) (1515852800000, 2) (1516025600000, 3) (1516198400000, 4) (1516371200000, 5) sql select * from tb; if $rows != 40 then return -1 @@ -184,8 +184,8 @@ endi print ================= step12 #1520000000000 -#sql import into tb values(now-19d, 7003) (now-18d, 7003) (now-17d, 7003) (now-16d, 7003) (now-15d, 7003) (now-14d, 7003) (now-13d, 7003) (now-12d, 7003) (now-11d, 7003) -sql import into tb values(1518358400000, 7003) (1518444800000, 7003) (1518531200000, 7003) (1518617600000, 7003) (1518704000000, 7003) (1518790400000, 7003) (1518876800000, 7003) (1518963200000, 7003) (1519049600000, 7003) +#sql import into tb values(now-19d, -19) (now-18d, -18) (now-17d, -17) (now-16d, -16) (now-15d, -15) (now-14d, -14) (now-13d, -13) (now-12d, -12) (now-11d, -11) +sql import into tb values(1518358400000, 6) (1518444800000, 7) (1518531200000, 8) (1518617600000, 9) (1518704000000, 10) (1518790400000, 11) (1518876800000, 12) (1518963200000, 13) (1519049600000, 14) sql select * from tb; print $rows if $rows != 49 then @@ -195,13 +195,13 @@ endi print ================= step14 #1520000000000 -#sql import into tb values(now-48d, 34003) -#sql import into tb values(now-38d, 50001) -#sql import into tb values(now-28d, 50001) +#sql import into tb values(now-48d, -48) +#sql import into tb values(now-38d, -38) +#sql import into tb values(now-28d, -28) -sql import into tb values(1515852800001, 34003) -sql import into tb values(1516716800000, 50001) -sql import into tb values(1517580800000, 50001) +sql import into tb values(1515852800001, -48) +sql import into tb values(1516716800000, -38) +sql import into tb values(1517580800000, -28) sql select * from tb; if $rows != 52 then diff --git a/tests/script/general/parser/limit1.sim b/tests/script/general/parser/limit1.sim index 7971cb81c6eec09530b4bcaf264e5c5b154b388a..48fb6aaedeef38ed26fc0cde92d5b7869afcb3ba 100644 --- a/tests/script/general/parser/limit1.sim +++ b/tests/script/general/parser/limit1.sim @@ -65,7 +65,7 @@ sleep 2000 system sh/exec.sh -n dnode1 -s start print ================== server restart completed -#run general/parser/limit1_tb.sim +run general/parser/limit1_tb.sim run general/parser/limit1_stb.sim system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/parser/limit1_tblocks100.sim b/tests/script/general/parser/limit1_tblocks100.sim index af4d3eda852ae7fe5219fbb66642950003fdb78a..126c3227a7eb21852f8fcf23333a99a20e6a1763 100644 --- a/tests/script/general/parser/limit1_tblocks100.sim +++ b/tests/script/general/parser/limit1_tblocks100.sim @@ -21,7 +21,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db tblocks 100 +sql create database $db cache 16 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 int) diff --git a/tests/script/general/parser/limit_stb.sim b/tests/script/general/parser/limit_stb.sim index c6a3766b7d41b690cda319859ad3186af23ef6dd..9983424dbfe3ee4fd31beef7a5d9022c286a7569 100644 --- a/tests/script/general/parser/limit_stb.sim +++ b/tests/script/general/parser/limit_stb.sim @@ -47,19 +47,21 @@ sql select * from $stb order by ts desc limit 5 if $rows != 5 then return -1 endi + sql select * from $stb order by ts desc limit 5 offset 1 if $rows != 5 then return -1 endi -if $data01 != 8 then +if $data01 != 9 then return -1 endi -if $data11 != 7 then +if $data11 != 9 then return -1 endi -if $data41 != 4 then +if $data41 != 9 then return -1 endi + sql select * from $stb order by ts asc limit 5 if $rows != 5 then return -1 @@ -67,19 +69,28 @@ endi if $data00 != @18-09-17 09:00:00.000@ then return -1 endi + +if $data40 != @18-09-17 09:00:00.000@ then + return -1 +endi + if $data01 != 0 then return -1 endi -if $data12 != 1 then + +print data12 = $data12 +if $data12 != NULL then return -1 endi -if $data24 != 2.000000000 then + +if $data24 != NULL then return -1 endi -if $data35 != 3 then + +if $data35 != 0 then return -1 endi -if $data49 != nchar4 then +if $data49 != nchar0 then return -1 endi @@ -87,10 +98,18 @@ sql select * from $stb order by ts asc limit 5 offset 1 if $rows != 5 then return -1 endi -if $data01 != 1 then +if $data01 != 0 then return -1 endi -if $data41 != 5 then +if $data41 != 0 then + return -1 +endi + +if $data40 != @18-09-17 09:00:00.000@ then + return -1 +endi + +if $data00 != @18-09-17 09:00:00.000@ then return -1 endi @@ -98,6 +117,7 @@ sql select * from $stb limit 500 offset 1 if $rows != 99 then return -1 endi + if $data01 != 1 then return -1 endi @@ -629,6 +649,7 @@ endi if $data09 != 7 then return -1 endi +print $data13 if $data13 != 0.000000000 then return -1 endi @@ -656,6 +677,8 @@ endi if $data35 != 0 then return -1 endi + +print $data36 if $data36 != 0.000000000 then return -1 endi @@ -675,49 +698,49 @@ if $data59 != 2 then return -1 endi -sql select max(c2), min(c2), avg(c2), count(c2), sum(c2), spread(c2), first(c2), last(c2) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 interval(5m) group by t1 order by t1 desc limit 3 offset 1 -if $rows != 3 then - return -1 -endi -if $data00 != @18-09-17 09:20:00.000@ then - return -1 -endi -if $data01 != 2 then - return -1 -endi -if $data02 != 2 then - return -1 -endi -if $data09 != 4 then - return -1 -endi -if $data13 != 3.000000000 then - return -1 -endi -if $data19 != 4 then - return -1 -endi -if $data20 != @18-09-17 09:40:00.000@ then - return -1 -endi -if $data24 != 1 then - return -1 -endi -if $data25 != 4 then - return -1 -endi -if $data26 != 0.000000000 then - return -1 -endi -if $data27 != 4 then - return -1 -endi -if $data28 != 4 then - return -1 -endi -if $data29 != 4 then - return -1 -endi +#sql select max(c2), min(c2), avg(c2), count(c2), sum(c2), spread(c2), first(c2), last(c2) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 interval(5m) group by t1 order by t1 desc limit 3 offset 1 +#if $rows != 3 then +# return -1 +#endi +#if $data00 != @18-09-17 09:20:00.000@ then +# return -1 +#endi +#if $data01 != 2 then +# return -1 +#endi +#if $data02 != 2 then +# return -1 +#endi +#if $data09 != 4 then +# return -1 +#endi +#if $data13 != 3.000000000 then +# return -1 +#endi +#if $data19 != 4 then +# return -1 +#endi +#if $data20 != @18-09-17 09:40:00.000@ then +# return -1 +#endi +#if $data24 != 1 then +# return -1 +#endi +#if $data25 != 4 then +# return -1 +#endi +#if $data26 != 0.000000000 then +# return -1 +#endi +#if $data27 != 4 then +# return -1 +#endi +#if $data28 != 4 then +# return -1 +#endi +#if $data29 != 4 then +# return -1 +#endi sql select max(c2), min(c2), avg(c2), count(c2), spread(c2), first(c2), last(c2), count(ts) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 interval(5m) group by t1 order by t1 desc limit 3 offset 1 if $rows != 6 then diff --git a/tests/script/general/parser/testSuite.sim b/tests/script/general/parser/testSuite.sim index 0b7d705688aebc86367de89e6eae1fbf26cda802..3d5f33842e771b6ea93bdd11fa7856f34d628805 100644 --- a/tests/script/general/parser/testSuite.sim +++ b/tests/script/general/parser/testSuite.sim @@ -38,7 +38,6 @@ sleep 2000 run general/parser/lastrow.sim sleep 2000 run general/parser/nchar.sim - sleep 2000 run general/parser/null_char.sim sleep 2000 @@ -46,42 +45,45 @@ run general/parser/single_row_in_tb.sim sleep 2000 run general/parser/select_from_cache_disk.sim sleep 2000 -run general/parser/limit.sim - -sleep 2000 -run general/parser/fill.sim -sleep 2000 -run general/parser/fill_stb.sim -sleep 2000 -run general/parser/tags_dynamically_specifiy.sim +run general/parser/selectResNum.sim sleep 2000 -run general/parser/interp.sim +run general/parser/mixed_blocks.sim sleep 2000 run general/parser/limit1.sim sleep 2000 +run general/parser/limit.sim +sleep 2000 run general/parser/limit1_tblocks100.sim +sleep 2000 +run general/parser/select_across_vnodes.sim + sleep 2000 run general/parser/limit2.sim sleep 2000 -run general/parser/mixed_blocks.sim +run general/parser/tbnameIn.sim sleep 2000 -run general/parser/selectResNum.sim +run general/parser/slimit.sim sleep 2000 -run general/parser/select_across_vnodes.sim +run general/parser/slimit1.sim + sleep 2000 -run general/parser/set_tag_vals.sim +run general/parser/fill.sim sleep 2000 -run general/parser/slimit.sim +run general/parser/fill_stb.sim sleep 2000 -run general/parser/slimit1.sim +run general/parser/tags_dynamically_specifiy.sim +sleep 2000 +run general/parser/interp.sim +sleep 2000 +run general/parser/set_tag_vals.sim + sleep 2000 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 diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 027204af5bcd4fb5d9874086359a2ae52c11abc5..9d116aebc5cc3f93aaae28833631631d5f50368c 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -44,7 +44,7 @@ cd ../../../debug; make ./test.sh -f general/compute/top.sim ./test.sh -f general/db/alter_option.sim -#./test.sh -f general/db/alter_tables_d2.sim +./test.sh -f general/db/alter_tables_d2.sim ./test.sh -f general/db/alter_tables_v1.sim ./test.sh -f general/db/alter_tables_v4.sim ./test.sh -f general/db/alter_vgroups.sim @@ -61,10 +61,11 @@ cd ../../../debug; make ./test.sh -f general/db/delete_writing1.sim ./test.sh -f general/db/delete_writing2.sim ./test.sh -f general/db/delete.sim +./test.sh -f general/db/dropdnodes.sim ./test.sh -f general/db/len.sim ./test.sh -f general/db/repeat.sim ./test.sh -f general/db/tables.sim -#liao ./test.sh -f general/db/vnodes.sim +./test.sh -f general/db/vnodes.sim ./test.sh -f general/field/2.sim ./test.sh -f general/field/3.sim @@ -90,10 +91,10 @@ cd ../../../debug; make ./test.sh -f general/import/basic.sim ./test.sh -f general/import/commit.sim ./test.sh -f general/import/large.sim -#liao ./test.sh -f general/import/replica1.sim +./test.sh -f general/import/replica1.sim ./test.sh -f general/insert/basic.sim -#liao ./test.sh -f general/insert/insert_drop.sim +./test.sh -f general/insert/insert_drop.sim ./test.sh -f general/insert/query_block1_memory.sim ./test.sh -f general/insert/query_block2_memory.sim ./test.sh -f general/insert/query_block1_file.sim @@ -120,22 +121,22 @@ cd ../../../debug; make ./test.sh -f general/parser/insert_tb.sim ./test.sh -f general/parser/first_last.sim # ./test.sh -f general/parser/import_file.sim -# ./test.sh -f general/parser/lastrow.sim +./test.sh -f general/parser/lastrow.sim # ./test.sh -f general/parser/nchar.sim # ./test.sh -f general/parser/null_char.sim -# ./test.sh -f general/parser/single_row_in_tb.sim +./test.sh -f general/parser/single_row_in_tb.sim ./test.sh -f general/parser/select_from_cache_disk.sim -# ./test.sh -f general/parser/limit.sim +./test.sh -f general/parser/limit.sim # ./test.sh -f general/parser/fill.sim # ./test.sh -f general/parser/fill_stb.sim # ./test.sh -f general/parser/tags_dynamically_specifiy.sim # ./test.sh -f general/parser/interp.sim -# ./test.sh -f general/parser/limit1.sim -# ./test.sh -f general/parser/limit1_tblocks100.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/mixed_blocks.sim ./test.sh -f general/parser/selectResNum.sim -# ./test.sh -f general/parser/select_across_vnodes.sim +./test.sh -f general/parser/select_across_vnodes.sim # ./test.sh -f general/parser/set_tag_vals.sim # ./test.sh -f general/parser/slimit.sim ./test.sh -f general/parser/slimit1.sim @@ -155,7 +156,7 @@ cd ../../../debug; make #./test.sh -f general/parser/bug.sim ./test.sh -f general/stable/disk.sim -#liao ./test.sh -f general/stable/dnode3.sim +./test.sh -f general/stable/dnode3.sim ./test.sh -f general/stable/metrics.sim ./test.sh -f general/stable/values.sim ./test.sh -f general/stable/vnode3.sim @@ -246,8 +247,8 @@ cd ../../../debug; make ./test.sh -u -f unique/account/user_create.sim ./test.sh -u -f unique/account/user_len.sim -#liao wait ./test.sh -u -f unique/big/balance.sim -#liao wait ./test.sh -u -f unique/big/maxvnodes.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 @@ -273,25 +274,25 @@ cd ../../../debug; make ./test.sh -u -f unique/dnode/balance3.sim ./test.sh -u -f unique/dnode/balancex.sim ./test.sh -u -f unique/dnode/offline1.sim -#jeff ./test.sh -u -f unique/dnode/offline2.sim +./test.sh -u -f unique/dnode/offline2.sim ./test.sh -u -f unique/dnode/remove1.sim -#jeff ./test.sh -u -f unique/dnode/remove2.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 -#liao wait ./test.sh -u -f unique/import/replica2.sim -#liao wait ./test.sh -u -f unique/import/replica3.sim +./test.sh -u -f unique/import/replica2.sim +./test.sh -u -f unique/import/replica3.sim -#liao wait ./test.sh -u -f unique/stable/balance_replica1.sim -#liao wait ./test.sh -u -f unique/stable/dnode2_stop.sim -#liao wait ./test.sh -u -f unique/stable/dnode2.sim -#liao wait ./test.sh -u -f unique/stable/dnode3.sim -#liao wait ./test.sh -u -f unique/stable/replica2_dnode4.sim -#liao wait ./test.sh -u -f unique/stable/replica2_vnode3.sim -#liao wait ./test.sh -u -f unique/stable/replica3_dnode6.sim -#liao wait ./test.sh -u -f unique/stable/replica3_vnode3.sim +./test.sh -u -f unique/stable/balance_replica1.sim +./test.sh -u -f unique/stable/dnode2_stop.sim +./test.sh -u -f unique/stable/dnode2.sim +./test.sh -u -f unique/stable/dnode3.sim +./test.sh -u -f unique/stable/replica2_dnode4.sim +./test.sh -u -f unique/stable/replica2_vnode3.sim +./test.sh -u -f unique/stable/replica3_dnode6.sim +./test.sh -u -f unique/stable/replica3_vnode3.sim ./test.sh -u -f unique/mnode/mgmt22.sim ./test.sh -u -f unique/mnode/mgmt23.sim diff --git a/tests/script/jenkins/sync.txt b/tests/script/jenkins/sync.txt new file mode 100644 index 0000000000000000000000000000000000000000..934680b7c0c42974a40025afd6f0226e1a6ccf9c --- /dev/null +++ b/tests/script/jenkins/sync.txt @@ -0,0 +1,79 @@ +cd ../../debug; cmake .. +cd ../../debug; make +cd ../../../debug; cmake .. +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_len.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_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_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/cache.sim + +./test.sh -u -f unique/column/replica3.sim + +./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/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/import/replica2.sim +./test.sh -u -f unique/import/replica3.sim + +./test.sh -u -f unique/stable/balance_replica1.sim +./test.sh -u -f unique/stable/dnode2_stop.sim +./test.sh -u -f unique/stable/dnode2.sim +./test.sh -u -f unique/stable/dnode3.sim +./test.sh -u -f unique/stable/replica2_dnode4.sim +./test.sh -u -f unique/stable/replica2_vnode3.sim +./test.sh -u -f unique/stable/replica3_dnode6.sim +./test.sh -u -f unique/stable/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/mgmtr2.sim + +./test.sh -u -f unique/vnode/many.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_repeat.sim +./test.sh -u -f unique/vnode/replica3_vgroup.sim diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index bd85ce9704945c26ea75ba663a66a735038bb971..83ecea555a8c85eebadfd19fade5fd17340b237e 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -107,6 +107,7 @@ echo "monitorDebugFlag 131" >> $TAOS_CFG echo "udebugFlag 131" >> $TAOS_CFG echo "jnidebugFlag 131" >> $TAOS_CFG echo "sdebugFlag 135" >> $TAOS_CFG +echo "qdebugFlag 135" >> $TAOS_CFG echo "monitor 0" >> $TAOS_CFG echo "monitorInterval 1" >> $TAOS_CFG echo "http 0" >> $TAOS_CFG diff --git a/tests/script/tmp/prepare.sim b/tests/script/tmp/prepare.sim index 68a05a33e75e0716d83c21da3aade66a16ca472a..31d78395668502b844b22608922622c52387988a 100644 --- a/tests/script/tmp/prepare.sim +++ b/tests/script/tmp/prepare.sim @@ -1,4 +1,14 @@ system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 + +system sh/cfg.sh -n dnode1 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2 + +return +system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 diff --git a/tests/script/unique/big/balance.sim b/tests/script/unique/big/balance.sim index 4b0a6cd0bf25f1ad4a279ab9150adf1f114b3b60..5259f415c88da90c99372ee2f81786d2743fddbc 100644 --- a/tests/script/unique/big/balance.sim +++ b/tests/script/unique/big/balance.sim @@ -93,7 +93,7 @@ $x = 0 show1: $x = $x + 1 sleep 3000 - if $x == 100 then + if $x == 10 then return -1 endi @@ -107,6 +107,9 @@ if $data2_2 != 2 then goto show1 endi +sql reset query cache +sleep 1000 + sql select count(*) from t10 print select count(*) from t10 $data00 expect $rowNum if $data00 != $rowNum then @@ -149,7 +152,7 @@ $x = 0 show3: $x = $x + 1 sleep 3000 - if $x == 100 then + if $x == 10 then return -1 endi @@ -160,7 +163,7 @@ print dnode3 freeVnodes $data2_3 if $data2_1 != 2 then goto show3 endi -if $data2_2 != NULL then +if $data2_2 != null then goto show3 endi if $data2_3 != 2 then @@ -169,6 +172,9 @@ endi system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +sql reset query cache +sleep 1000 + sql select count(*) from t10 print select count(*) from t10 $data00 expect $rowNum if $data00 != $rowNum then @@ -206,22 +212,25 @@ $x = 0 show4: $x = $x + 1 sleep 3000 - if $x == 100 then + if $x == 10 then return -1 endi sql show dnodes print dnode1 freeVnodes $data2_1 print dnode3 freeVnodes $data2_3 -if $data2_1 != 0 then +if $data2_1 != 4 then goto show4 endi -if $data2_3 != NULL then +if $data2_3 != null then goto show4 endi system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +sql reset query cache +sleep 1000 + sql select count(*) from t10 print select count(*) from t10 $data00 expect $rowNum if $data00 != $rowNum then @@ -253,28 +262,33 @@ if $data00 != $totalNum then endi print ========== step5 -sql alter database db replica 2 -sql create dnode $hostname4 system sh/exec_up.sh -n dnode4 -s start +sql create dnode $hostname4 + +sleep 3000 +sql alter database db replica 2 $x = 0 show5: $x = $x + 1 sleep 3000 - if $x == 100 then + if $x == 10 then return -1 endi sql show dnodes print dnode1 freeVnodes $data2_1 print dnode4 freeVnodes $data2_4 -if $data2_1 != 0 then +if $data2_1 != 4 then goto show5 endi -if $data2_4 != 0 then +if $data2_4 != 4 then goto show5 endi +sql reset query cache +sleep 1000 + sql select count(*) from t10 print select count(*) from t10 $data00 expect $rowNum if $data00 != $rowNum then diff --git a/tests/script/unique/big/maxvnodes.sim b/tests/script/unique/big/maxvnodes.sim index 2b56f51e599f72e9c2bf62251e82aff675722af1..f019ea607c6b1097e12e2aa788c8b69656ce23cf 100644 --- a/tests/script/unique/big/maxvnodes.sim +++ b/tests/script/unique/big/maxvnodes.sim @@ -1,8 +1,8 @@ system sh/stop_dnodes.sh -$totalVnodes = 100 -$minVnodes = 50 -$maxVnodes = 50 +$totalVnodes = 20 +$minVnodes = 10 +$maxVnodes = 10 $maxTables = 4 $totalRows = $totalVnodes * $maxTables diff --git a/tests/script/unique/dnode/remove2.sim b/tests/script/unique/dnode/remove2.sim index 73e7a31250f2b7ab09d38013cb0e09839c27cc19..42cb9e5485b2a65b67b29bccff99f73055056ed0 100644 --- a/tests/script/unique/dnode/remove2.sim +++ b/tests/script/unique/dnode/remove2.sim @@ -111,10 +111,10 @@ sql show dnodes print dnode1 openVnodes $data2_1 print dnode2 openVnodes $data2_2 print dnode3 openVnodes $data2_3 -if $data2_2 != null then +if $data2_1 != 1 then goto show4 endi -if $data2_1 != 1 then +if $data2_2 != null then goto show4 endi if $data2_3 != 3 then diff --git a/tests/script/unique/import/replica2.sim b/tests/script/unique/import/replica2.sim index bcb4179c12b1b3f9045a4690e7ecaa5685aa1f1e..70097a50221195b4f7bee6d7e5f54572faa509a3 100644 --- a/tests/script/unique/import/replica2.sim +++ b/tests/script/unique/import/replica2.sim @@ -20,10 +20,10 @@ system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000 -system sh/cfg.sh -n dnode1 -c commitlog -v 0 -system sh/cfg.sh -n dnode2 -c commitlog -v 0 -system sh/cfg.sh -n dnode3 -c commitlog -v 0 -system sh/cfg.sh -n dnode4 -c commitlog -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 print ========= start dnode1 system sh/exec_up.sh -n dnode1 -s start @@ -35,10 +35,10 @@ system sh/exec_up.sh -n dnode2 -s start sql create database ir2db replica 2 days 7 sql use ir2db -sql create table tb(ts timestamp, i int) +sql create table tb(ts timestamp, i bigint) print ================= step1 -sql import into tb values(1520000010000, 10000) +sql import into tb values(1520000010000, 1520000010000) sql select * from tb; print $rows if $rows != 1 then @@ -46,7 +46,7 @@ if $rows != 1 then endi print ================= step2 -sql insert into tb values(1520000008000, 8000) +sql insert into tb values(1520000008000, 1520000008000) print $rows sql select * from tb; if $rows != 2 then @@ -54,7 +54,7 @@ if $rows != 2 then endi print ================= step3 -sql insert into tb values(1520000020000, 20000) +sql insert into tb values(1520000020000, 1520000020000) sql select * from tb; print $rows if $rows != 3 then @@ -62,9 +62,9 @@ if $rows != 3 then endi print ================= step4 -sql import into tb values(1520000009000, 9000) -sql import into tb values(1520000015000, 15000) -sql import into tb values(1520000030000, 30000) +sql import into tb values(1520000009000, 1520000009000) +sql import into tb values(1520000015000, 1520000015000) +sql import into tb values(1520000030000, 1520000030000) sql select * from tb; print $rows if $rows != 6 then @@ -72,10 +72,10 @@ if $rows != 6 then endi print ================= step5 -sql insert into tb values(1520000008000, 8000) -sql insert into tb values(1520000014000, 14000) -sql insert into tb values(1520000025000, 25000) -sql insert into tb values(1520000040000, 40000) +sql insert into tb values(1520000008000, 1520000008000) +sql insert into tb values(1520000014000, 1520000014000) +sql insert into tb values(1520000025000, 1520000025000) +sql insert into tb values(1520000040000, 1520000040000) sql select * from tb; print $rows if $rows != 9 then @@ -83,11 +83,11 @@ if $rows != 9 then endi print ================= step6 -sql import into tb values(1520000007000, 7000) -sql import into tb values(1520000012000, 12000) -sql import into tb values(1520000023000, 23000) -sql import into tb values(1520000034000, 34000) -sql import into tb values(1520000050000, 50000) +sql import into tb values(1520000007000, 1520000007000) +sql import into tb values(1520000012000, 1520000012000) +sql import into tb values(1520000023000, 1520000023000) +sql import into tb values(1520000034000, 1520000034000) +sql import into tb values(1520000050000, 1520000050000) sql select * from tb; print $rows if $rows != 14 then @@ -105,25 +105,26 @@ if $rows != 14 then endi print ================= step7 -sql import into tb values(1520000007001, 7001) -sql import into tb values(1520000012001, 12001) -sql import into tb values(1520000023001, 23001) -sql import into tb values(1520000034001, 34001) -sql import into tb values(1520000050001, 50001) +sql import into tb values(1520000007001, 1520000007001) +sql import into tb values(1520000012001, 1520000012001) +sql import into tb values(1520000023001, 1520000023001) +sql import into tb values(1520000034001, 1520000034001) +sql import into tb values(1520000050001, 1520000050001) sql select * from tb; print $rows -if $rows != 19 then +if $rows != 19 then + print expect 19, actual: $rows return -1 endi print ================= step8 -sql insert into tb values(1520000008002, 8002) -sql insert into tb values(1520000014002, 14002) -sql insert into tb values(1520000025002, 25002) -sql insert into tb values(1520000060000, 60000) +sql insert into tb values(1520000008002, 1520000008002) +sql insert into tb values(1520000014002, 1520000014002) +sql insert into tb values(1520000025002, 1520000025002) +sql insert into tb values(1520000060000, 1520000060000) sql select * from tb; print $rows -if $rows != 24 then +if $rows != 23 then return -1 endi @@ -142,21 +143,21 @@ print ================= step9 #sql import into tb values(now+14d, 50001) #sql import into tb values(now+16d, 500051) -sql import into tb values(1517408000000, 7003) -sql import into tb values(1518272000000, 34003) -sql import into tb values(1519136000000, 34003) -sql import into tb values(1519568000000, 34003) -sql import into tb values(1519654400000, 50001) -sql import into tb values(1519827200000, 50001) -sql import into tb values(1520345600000, 50001) -sql import into tb values(1520691200000, 50002) -sql import into tb values(1520864000000, 50003) -sql import into tb values(1521900800000, 50004) -sql import into tb values(1523110400000, 50001) -sql import into tb values(1521382400000, 500051) +sql import into tb values(1517408000000, 1517408000000) +sql import into tb values(1518272000000, 1518272000000) +sql import into tb values(1519136000000, 1519136000000) +sql import into tb values(1519568000000, 1519568000000) +sql import into tb values(1519654400000, 1519654400000) +sql import into tb values(1519827200000, 1519827200000) +sql import into tb values(1520345600000, 1520345600000) +sql import into tb values(1520691200000, 1520691200000) +sql import into tb values(1520864000000, 1520864000000) +sql import into tb values(1521900800000, 1521900800000) +sql import into tb values(1523110400000, 1523110400000) +sql import into tb values(1521382400000, 1521382400000) sql select * from tb; print $rows -if $rows != 36 then +if $rows != 35 then return -1 endi @@ -167,55 +168,57 @@ system sh/exec_up.sh -n dnode1 -s start sleep 5000 sql select * from tb; print $rows -if $rows != 36 then +if $rows != 35 then return -1 endi print ================= step11 #sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) -sql import into tb values(1515680000000, 7003) (1515852800000, 7003) (1516025600000, 7003) (1516198400000, 7003) (1516371200000, 7003) +sql import into tb values(1515680000000, 1) (1515852800000, 2) (1516025600000, 3) (1516198400000, 4) (1516371200000, 5) sql select * from tb; -if $rows != 41 then +if $rows != 40 then return -1 endi print ================= step12 #1520000000000 -#sql import into tb values(now-19d, 7003) (now-18d, 7003) (now-17d, 7003) (now-16d, 7003) (now-15d, 7003) (now-14d, 7003) (now-13d, 7003) (now-12d, 7003) (now-11d, 7003) -sql import into tb values(1518358400000, 7003) (1518444800000, 7003) (1518531200000, 7003) (1518617600000, 7003) (1518704000000, 7003) (1518790400000, 7003) (1518876800000, 7003) (1518963200000, 7003) (1519049600000, 7003) +#sql import into tb values(now-19d, -19) (now-18d, -18) (now-17d, -17) (now-16d, -16) (now-15d, -15) (now-14d, -14) (now-13d, -13) (now-12d, -12) (now-11d, -11) +sql import into tb values(1518358400000, 6) (1518444800000, 7) (1518531200000, 8) (1518617600000, 9) (1518704000000, 10) (1518790400000, 11) (1518876800000, 12) (1518963200000, 13) (1519049600000, 14) sql select * from tb; print $rows -if $rows != 50 then +if $rows != 49 then return -1 endi print ================= step13 -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +sleep 5000 +system sh/exec_up.sh -n dnode2 -s start sleep 5000 print ================= step14 #1520000000000 -#sql import into tb values(now-48d, 34003) -#sql import into tb values(now-38d, 50001) -#sql import into tb values(now-28d, 50001) +#sql import into tb values(now-48d, -48) +#sql import into tb values(now-38d, -38) +#sql import into tb values(now-28d, -28) -sql import into tb values(1515852800001, 34003) -sql import into tb values(1516716800000, 50001) -sql import into tb values(1517580800000, 50001) +sql import into tb values(1515852800001, -48) +sql import into tb values(1516716800000, -38) +sql import into tb values(1517580800000, -28) sql select * from tb; -if $rows != 50 then +if $rows != 52 then return -1 endi print ================= step15 -system sh/exec_up.sh -n dnode2 -s start -sleep 8000 -system sh/exec_up.sh -n dnode1 -s stop -sleep 10000 +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +sleep 5000 +system sh/exec_up.sh -n dnode1 -s start +sleep 5000 -if $rows != 50 then +if $rows != 52 then return -1 endi diff --git a/tests/script/unique/import/replica3.sim b/tests/script/unique/import/replica3.sim index 8d70d227a5033b837bb0faf3940b18f81ed0be38..ad236bfb0cae4a821b757d93d0f04285439f0f7b 100644 --- a/tests/script/unique/import/replica3.sim +++ b/tests/script/unique/import/replica3.sim @@ -20,14 +20,14 @@ system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000 -system sh/cfg.sh -n dnode1 -c commitlog -v 0 -system sh/cfg.sh -n dnode2 -c commitlog -v 0 -system sh/cfg.sh -n dnode3 -c commitlog -v 0 -system sh/cfg.sh -n dnode4 -c commitlog -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 print ========= start dnode1 system sh/exec_up.sh -n dnode1 -s start -sleep 5000 +sleep 3000 sql connect sql create dnode $hostname2 @@ -38,10 +38,10 @@ system sh/exec_up.sh -n dnode3 -s start sql create database ir3db replica 3 days 7 sql use ir3db -sql create table tb(ts timestamp, i int) +sql create table tb(ts timestamp, i bigint) print ================= step1 -sql import into tb values(1520000010000, 10000) +sql import into tb values(1520000010000, 1520000010000) sql select * from tb; print $rows if $rows != 1 then @@ -49,7 +49,7 @@ if $rows != 1 then endi print ================= step2 -sql insert into tb values(1520000008000, 8000) +sql insert into tb values(1520000008000, 1520000008000) print $rows sql select * from tb; if $rows != 2 then @@ -57,7 +57,7 @@ if $rows != 2 then endi print ================= step3 -sql insert into tb values(1520000020000, 20000) +sql insert into tb values(1520000020000, 1520000020000) sql select * from tb; print $rows if $rows != 3 then @@ -65,9 +65,9 @@ if $rows != 3 then endi print ================= step4 -sql import into tb values(1520000009000, 9000) -sql import into tb values(1520000015000, 15000) -sql import into tb values(1520000030000, 30000) +sql import into tb values(1520000009000, 1520000009000) +sql import into tb values(1520000015000, 1520000015000) +sql import into tb values(1520000030000, 1520000030000) sql select * from tb; print $rows if $rows != 6 then @@ -75,10 +75,10 @@ if $rows != 6 then endi print ================= step5 -sql insert into tb values(1520000008000, 8000) -sql insert into tb values(1520000014000, 14000) -sql insert into tb values(1520000025000, 25000) -sql insert into tb values(1520000040000, 40000) +sql insert into tb values(1520000008000, 1520000008000) +sql insert into tb values(1520000014000, 1520000014000) +sql insert into tb values(1520000025000, 1520000025000) +sql insert into tb values(1520000040000, 1520000040000) sql select * from tb; print $rows if $rows != 9 then @@ -86,47 +86,48 @@ if $rows != 9 then endi print ================= step6 -sql import into tb values(1520000007000, 7000) -sql import into tb values(1520000012000, 12000) -sql import into tb values(1520000023000, 23000) -sql import into tb values(1520000034000, 34000) -sql import into tb values(1520000050000, 50000) +sql import into tb values(1520000007000, 1520000007000) +sql import into tb values(1520000012000, 1520000012000) +sql import into tb values(1520000023000, 1520000023000) +sql import into tb values(1520000034000, 1520000034000) +sql import into tb values(1520000050000, 1520000050000) sql select * from tb; print $rows if $rows != 14 then return -1 endi -#print ================== dnode restart -#system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -#sleep 5000 -#system sh/exec_up.sh -n dnode1 -s start -#sleep 5000 -#sql select * from tb; -#if $rows != 14 then -# return -1 -#endi +print ================== dnode restart +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +sleep 5000 +system sh/exec_up.sh -n dnode1 -s start +sleep 5000 +sql select * from tb; +if $rows != 14 then + return -1 +endi print ================= step7 -sql import into tb values(1520000007001, 7001) -sql import into tb values(1520000012001, 12001) -sql import into tb values(1520000023001, 23001) -sql import into tb values(1520000034001, 34001) -sql import into tb values(1520000050001, 50001) +sql import into tb values(1520000007001, 1520000007001) +sql import into tb values(1520000012001, 1520000012001) +sql import into tb values(1520000023001, 1520000023001) +sql import into tb values(1520000034001, 1520000034001) +sql import into tb values(1520000050001, 1520000050001) sql select * from tb; print $rows -if $rows != 19 then +if $rows != 19 then + print expect 19, actual: $rows return -1 endi print ================= step8 -sql insert into tb values(1520000008002, 8002) -sql insert into tb values(1520000014002, 14002) -sql insert into tb values(1520000025002, 25002) -sql insert into tb values(1520000060000, 60000) +sql insert into tb values(1520000008002, 1520000008002) +sql insert into tb values(1520000014002, 1520000014002) +sql insert into tb values(1520000025002, 1520000025002) +sql insert into tb values(1520000060000, 1520000060000) sql select * from tb; print $rows -if $rows != 24 then +if $rows != 23 then return -1 endi @@ -145,21 +146,21 @@ print ================= step9 #sql import into tb values(now+14d, 50001) #sql import into tb values(now+16d, 500051) -sql import into tb values(1517408000000, 7003) -sql import into tb values(1518272000000, 34003) -sql import into tb values(1519136000000, 34003) -sql import into tb values(1519568000000, 34003) -sql import into tb values(1519654400000, 50001) -sql import into tb values(1519827200000, 50001) -sql import into tb values(1520345600000, 50001) -sql import into tb values(1520691200000, 50002) -sql import into tb values(1520864000000, 50003) -sql import into tb values(1521900800000, 50004) -sql import into tb values(1523110400000, 50001) -sql import into tb values(1521382400000, 500051) +sql import into tb values(1517408000000, 1517408000000) +sql import into tb values(1518272000000, 1518272000000) +sql import into tb values(1519136000000, 1519136000000) +sql import into tb values(1519568000000, 1519568000000) +sql import into tb values(1519654400000, 1519654400000) +sql import into tb values(1519827200000, 1519827200000) +sql import into tb values(1520345600000, 1520345600000) +sql import into tb values(1520691200000, 1520691200000) +sql import into tb values(1520864000000, 1520864000000) +sql import into tb values(1521900800000, 1521900800000) +sql import into tb values(1523110400000, 1523110400000) +sql import into tb values(1521382400000, 1521382400000) sql select * from tb; print $rows -if $rows != 36 then +if $rows != 35 then return -1 endi @@ -170,55 +171,57 @@ system sh/exec_up.sh -n dnode1 -s start sleep 5000 sql select * from tb; print $rows -if $rows != 36 then +if $rows != 35 then return -1 endi print ================= step11 #sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) -sql import into tb values(1515680000000, 7003) (1515852800000, 7003) (1516025600000, 7003) (1516198400000, 7003) (1516371200000, 7003) +sql import into tb values(1515680000000, 1) (1515852800000, 2) (1516025600000, 3) (1516198400000, 4) (1516371200000, 5) sql select * from tb; -if $rows != 41 then +if $rows != 40 then return -1 endi print ================= step12 #1520000000000 -#sql import into tb values(now-19d, 7003) (now-18d, 7003) (now-17d, 7003) (now-16d, 7003) (now-15d, 7003) (now-14d, 7003) (now-13d, 7003) (now-12d, 7003) (now-11d, 7003) -sql import into tb values(1518358400000, 7003) (1518444800000, 7003) (1518531200000, 7003) (1518617600000, 7003) (1518704000000, 7003) (1518790400000, 7003) (1518876800000, 7003) (1518963200000, 7003) (1519049600000, 7003) +#sql import into tb values(now-19d, -19) (now-18d, -18) (now-17d, -17) (now-16d, -16) (now-15d, -15) (now-14d, -14) (now-13d, -13) (now-12d, -12) (now-11d, -11) +sql import into tb values(1518358400000, 6) (1518444800000, 7) (1518531200000, 8) (1518617600000, 9) (1518704000000, 10) (1518790400000, 11) (1518876800000, 12) (1518963200000, 13) (1519049600000, 14) sql select * from tb; print $rows -if $rows != 50 then +if $rows != 49 then return -1 endi print ================= step13 -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +sleep 5000 +system sh/exec_up.sh -n dnode2 -s start sleep 5000 print ================= step14 #1520000000000 -#sql import into tb values(now-48d, 34003) -#sql import into tb values(now-38d, 50001) -#sql import into tb values(now-28d, 50001) +#sql import into tb values(now-48d, -48) +#sql import into tb values(now-38d, -38) +#sql import into tb values(now-28d, -28) -sql import into tb values(1515852800001, 34003) -sql import into tb values(1516716800000, 50001) -sql import into tb values(1517580800000, 50001) +sql import into tb values(1515852800001, -48) +sql import into tb values(1516716800000, -38) +sql import into tb values(1517580800000, -28) sql select * from tb; -if $rows != 50 then +if $rows != 52 then return -1 endi print ================= step15 -system sh/exec_up.sh -n dnode2 -s start -sleep 8000 -system sh/exec_up.sh -n dnode3 -s stop -sleep 3000 +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +sleep 5000 +system sh/exec_up.sh -n dnode3 -s start +sleep 5000 -if $rows != 50 then +if $rows != 52 then return -1 endi diff --git a/tests/script/unique/stable/balance_replica1.sim b/tests/script/unique/stable/balance_replica1.sim index 8cf41319a020d201af62d4a775737aac679f9bba..9257ba79beeea5060ed8b4b7dc38e0ad7721c59b 100644 --- a/tests/script/unique/stable/balance_replica1.sim +++ b/tests/script/unique/stable/balance_replica1.sim @@ -7,8 +7,8 @@ system sh/cfg.sh -n dnode1 -c statusInterval -v 1 system sh/cfg.sh -n dnode2 -c statusInterval -v 1 system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode2 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 0 system sh/cfg.sh -n dnode2 -c mgmtEqualVnodeNum -v 0 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 @@ -60,20 +60,20 @@ print =============== step2 $x = 0 show1: $x = $x + 1 - sleep 1000 - if $x == 20 then + sleep 2000 + if $x == 10 then return -1 endi sql show dnodes -x show1 -$dnode1Vnodes = $data3_192.168.0.1 +$dnode1Vnodes = $data2_1 print dnode1 $dnode1Vnodes -$dnode2Vnodes = $data3_192.168.0.2 +$dnode2Vnodes = $data2_2 print dnode2 $dnode2Vnodes -if $dnode1Vnodes != 0 then +if $dnode1Vnodes != 4 then goto show1 endi -if $dnode2Vnodes != NULL then +if $dnode2Vnodes != null then goto show1 endi print =============== step3 start dnode2 @@ -89,9 +89,9 @@ show2: return -1 endi sql show dnodes -x show2 -$dnode1Vnodes = $data3_192.168.0.1 +$dnode1Vnodes = $data2_1 print dnode1 $dnode1Vnodes -$dnode2Vnodes = $data3_192.168.0.2 +$dnode2Vnodes = $data2_2 print dnode2 $dnode2Vnodes if $dnode1Vnodes != 2 then diff --git a/tests/script/unique/stable/dnode2_stop.sim b/tests/script/unique/stable/dnode2_stop.sim index 55ad5fcf094bb35cd399762bbce23e3b0b390d4b..0cf13fa286b7ff332f609ed88fe3504347046642 100644 --- a/tests/script/unique/stable/dnode2_stop.sim +++ b/tests/script/unique/stable/dnode2_stop.sim @@ -1,8 +1,8 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 -system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode2 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 diff --git a/tests/script/unique/stable/dnode3.sim b/tests/script/unique/stable/dnode3.sim index c9dd31f6f80421791f4b2fecf34d58e2205383d8..8025b180d898014d16b2450a0acc4ff63eaf8162 100644 --- a/tests/script/unique/stable/dnode3.sim +++ b/tests/script/unique/stable/dnode3.sim @@ -84,13 +84,13 @@ print dnode2 $dnode2Vnodes $dnode3Vnodes = $data2_3 print dnode3 $dnode3Vnodes -if $dnode1Vnodes != 3 then +if $dnode1Vnodes != 1 then return -1 endi -if $dnode2Vnodes != 3 then +if $dnode2Vnodes != 1 then return -1 endi -if $dnode3Vnodes != 3 then +if $dnode3Vnodes != 1 then return -1 endi diff --git a/tests/script/unique/stable/replica2_dnode4.sim b/tests/script/unique/stable/replica2_dnode4.sim index f204e059491b63e79008a9d54b2e1934b9f28072..b96535fccd4f89a1472964d5d22823c953102f46 100644 --- a/tests/script/unique/stable/replica2_dnode4.sim +++ b/tests/script/unique/stable/replica2_dnode4.sim @@ -3,10 +3,10 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode4 -i 4 -system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode2 -c walLevel -v 0 -system sh/cfg.sh -n dnode3 -c walLevel -v 0 -system sh/cfg.sh -n dnode4 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 diff --git a/tests/script/unique/stable/replica2_vnode3.sim b/tests/script/unique/stable/replica2_vnode3.sim index 238e2e4aee36c3311cb57a6c16e270db1a9e8195..c7882d7a960077c20b935b8a3e5c2dafb2610a7e 100644 --- a/tests/script/unique/stable/replica2_vnode3.sim +++ b/tests/script/unique/stable/replica2_vnode3.sim @@ -1,8 +1,8 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 -system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode2 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 diff --git a/tests/script/unique/stable/replica3_dnode6.sim b/tests/script/unique/stable/replica3_dnode6.sim index 1c8a8ae10ecb817fef4a1f72518caa30c4da197d..0dc81999ca63b3c9551980fa84f451ee8d86c8ca 100644 --- a/tests/script/unique/stable/replica3_dnode6.sim +++ b/tests/script/unique/stable/replica3_dnode6.sim @@ -6,12 +6,12 @@ system sh/deploy.sh -n dnode4 -i 4 system sh/deploy.sh -n dnode5 -i 5 system sh/deploy.sh -n dnode6 -i 6 -system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode2 -c walLevel -v 0 -system sh/cfg.sh -n dnode3 -c walLevel -v 0 -system sh/cfg.sh -n dnode4 -c walLevel -v 0 -system sh/cfg.sh -n dnode5 -c walLevel -v 0 -system sh/cfg.sh -n dnode6 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 +system sh/cfg.sh -n dnode5 -c walLevel -v 2 +system sh/cfg.sh -n dnode6 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 diff --git a/tests/script/unique/stable/replica3_vnode3.sim b/tests/script/unique/stable/replica3_vnode3.sim index 75870af4c43de82dc99ba375a0035040bf249d9e..fe310aa0f7e5136db9517866b23c5a666674ce08 100644 --- a/tests/script/unique/stable/replica3_vnode3.sim +++ b/tests/script/unique/stable/replica3_vnode3.sim @@ -4,10 +4,10 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode4 -i 4 -system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode2 -c walLevel -v 0 -system sh/cfg.sh -n dnode3 -c walLevel -v 0 -system sh/cfg.sh -n dnode4 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 diff --git a/tests/test-all.sh b/tests/test-all.sh index f54d094649bb417d2a3d37edac81a64209543182..a56b5eeef7fcb7c306318a81655c8656a78e4843 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -40,7 +40,6 @@ fi totalPySuccess=`grep 'successfully executed' pytest-out.txt | wc -l` if [ "$totalPySuccess" -gt "0" ]; then - grep 'successfully executed' pytest-out.txt echo -e "${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}" fi