diff --git a/.travis.yml b/.travis.yml index 877e717eaf..af41d45ac0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,7 +51,7 @@ matrix: ./test-all.sh $TRAVIS_EVENT_TYPE || travis_terminate $? cd ${TRAVIS_BUILD_DIR}/tests/pytest - ./valgrind-test.sh 2>&1 > mem-error-out.txt + ./valgrind-test.sh 2>&1 > mem-error-out.log sleep 1 # Color setting @@ -61,9 +61,9 @@ matrix: GREEN_UNDERLINE='\033[4;32m' NC='\033[0m' - grep 'start to execute\|ERROR SUMMARY' mem-error-out.txt|grep -v 'grep'|uniq|tee uniq-mem-error-out.txt + grep 'start to execute\|ERROR SUMMARY' mem-error-out.log|grep -v 'grep'|uniq|tee uniq-mem-error-out.log - for memError in `grep 'ERROR SUMMARY' uniq-mem-error-out.txt | awk '{print $4}'` + for memError in `grep 'ERROR SUMMARY' uniq-mem-error-out.log | awk '{print $4}'` do if [ -n "$memError" ]; then if [ "$memError" -gt 12 ]; then @@ -74,8 +74,8 @@ matrix: fi done - grep 'start to execute\|definitely lost:' mem-error-out.txt|grep -v 'grep'|uniq|tee uniq-definitely-lost-out.txt - for defiMemError in `grep 'definitely lost:' uniq-definitely-lost-out.txt | awk '{print $7}'` + grep 'start to execute\|definitely lost:' mem-error-out.log|grep -v 'grep'|uniq|tee uniq-definitely-lost-out.log + for defiMemError in `grep 'definitely lost:' uniq-definitely-lost-out.log | awk '{print $7}'` do if [ -n "$defiMemError" ]; then if [ "$defiMemError" -gt 13 ]; then diff --git a/importSampleData/app/main.go b/importSampleData/app/main.go index aef4133207..d714fc339c 100644 --- a/importSampleData/app/main.go +++ b/importSampleData/app/main.go @@ -18,7 +18,7 @@ import ( "sync" "time" - _ "github.com/taosdata/TDengine/src/connector/go/src/taosSql" + _ "github.com/taosdata/TDengine/src/connector/go/taosSql" ) const ( @@ -634,6 +634,7 @@ func insertData(threadIndex, start, end int, wg *sync.WaitGroup, successRows [] if appendRows == batch { // executebatch insertSql := buffers.String() + connection.Exec("use " + db) affectedRows := executeBatchInsert(insertSql, connection) successRows[threadIndex] += affectedRows @@ -658,6 +659,7 @@ func insertData(threadIndex, start, end int, wg *sync.WaitGroup, successRows [] if appendRows > 0 { // executebatch insertSql := buffers.String() + connection.Exec("use " + db) affectedRows := executeBatchInsert(insertSql, connection) successRows[threadIndex] += affectedRows diff --git a/importSampleData/bin/taosimport b/importSampleData/bin/taosimport index b042549341..235fde9f06 100755 Binary files a/importSampleData/bin/taosimport and b/importSampleData/bin/taosimport differ diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index 715d76e072..e4857dd18d 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -175,7 +175,7 @@ SSqlExpr* tscSqlExprAppend(SQueryInfo* pQueryInfo, int16_t functionId, SColumnIn SSqlExpr* tscSqlExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t functionId, int16_t srcColumnIndex, int16_t type, int16_t size); -int32_t tscSqlExprNumOfExprs(SQueryInfo* pQueryInfo); +size_t tscSqlExprNumOfExprs(SQueryInfo* pQueryInfo); SSqlExpr* tscSqlExprGet(SQueryInfo* pQueryInfo, int32_t index); void tscSqlExprCopy(SArray* dst, const SArray* src, uint64_t uid, bool deepcopy); diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index c04c31dfb7..f1b620176d 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -84,7 +84,7 @@ typedef struct SSqlExpr { int16_t functionId; // function id in aAgg array int16_t resType; // return value type int16_t resBytes; // length of return value - int16_t interBytes; // inter result buffer size + int32_t interBytes; // inter result buffer size int16_t numOfParams; // argument value of each function tVariant param[3]; // parameters are not more than 3 int32_t offset; // sub result column value of arithmetic expression. @@ -320,7 +320,7 @@ typedef struct SSqlObj { tsem_t rspSem; SSqlCmd cmd; SSqlRes res; - uint8_t numOfSubs; + uint16_t numOfSubs; struct SSqlObj **pSubs; struct SSqlObj * prev, *next; } SSqlObj; diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 6fba0efd97..96837e4dd4 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -57,6 +57,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const } pSql->sqlstr = realloc(pSql->sqlstr, sqlLen + 1); + if (pSql->sqlstr == NULL) { tscError("%p failed to malloc sql string buffer", pSql); tscQueueAsyncError(fp, param, TSDB_CODE_CLI_OUT_OF_MEMORY); @@ -165,7 +166,7 @@ static void tscProcessAsyncRetrieveImpl(void *param, TAOS_RES *tres, int numOfRo SSqlRes *pRes = &pSql->res; if ((pRes->qhandle == 0 || numOfRows != 0) && pCmd->command < TSDB_SQL_LOCAL) { - if (pRes->qhandle == 0) { + if (pRes->qhandle == 0 && numOfRows != 0) { tscError("qhandle is NULL"); } else { pRes->code = numOfRows; diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index 81602d17f4..baefdbe102 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -153,7 +153,7 @@ typedef struct SRateInfo { int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionId, int32_t param, int16_t *type, - int16_t *bytes, int16_t *interBytes, int16_t extLength, bool isSuperTable) { + int16_t *bytes, int32_t *interBytes, int16_t extLength, bool isSuperTable) { if (!isValidDataType(dataType, dataBytes)) { tscError("Illegal data type %d or data type length %d", dataType, dataBytes); return TSDB_CODE_INVALID_SQL; @@ -478,7 +478,7 @@ int32_t count_load_data_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32 if (colId == PRIMARYKEY_TIMESTAMP_COL_INDEX) { return BLK_DATA_NO_NEEDED; } else { - return BLK_DATA_FILEDS_NEEDED; + return BLK_DATA_STATIS_NEEDED; } } @@ -690,7 +690,7 @@ static void sum_func_second_merge(SQLFunctionCtx *pCtx) { } static int32_t precal_req_load_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { - return BLK_DATA_FILEDS_NEEDED; + return BLK_DATA_STATIS_NEEDED; } static int32_t data_req_load_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { @@ -1848,13 +1848,14 @@ static void last_row_function(SQLFunctionCtx *pCtx) { pResInfo->hasResult = DATA_SET_FLAG; SLastrowInfo *pInfo = (SLastrowInfo *)pResInfo->interResultBuf; - pInfo->ts = pCtx->param[0].i64Key; + pInfo->ts = pCtx->ptsList[0]; + pInfo->hasResult = DATA_SET_FLAG; // set the result to final result buffer if (pResInfo->superTableQ) { SLastrowInfo *pInfo1 = (SLastrowInfo *)(pCtx->aOutputBuf + pCtx->inputBytes); - pInfo1->ts = pCtx->param[0].i64Key; + pInfo1->ts = pCtx->ptsList[0]; pInfo1->hasResult = DATA_SET_FLAG; DO_UPDATE_TAG_COLUMNS(pCtx, pInfo1->ts); @@ -1904,12 +1905,12 @@ static void valuePairAssign(tValuePair *dst, int16_t type, const char *val, int6 memcpy(dst->pTags, pTags, (size_t)pTagInfo->tagsLen); } else { // the tags are dumped from the ctx tag fields for (int32_t i = 0; i < pTagInfo->numOfTagCols; ++i) { - SQLFunctionCtx* __ctx = pTagInfo->pTagCtxList[i]; - if (__ctx->functionId == TSDB_FUNC_TS_DUMMY) { - __ctx->tag = (tVariant) {.nType = TSDB_DATA_TYPE_BIGINT, .i64Key = tsKey}; + SQLFunctionCtx* ctx = pTagInfo->pTagCtxList[i]; + if (ctx->functionId == TSDB_FUNC_TS_DUMMY) { + ctx->tag = (tVariant) {.nType = TSDB_DATA_TYPE_BIGINT, .i64Key = tsKey}; } - tVariantDump(&pTagInfo->pTagCtxList[i]->tag, dst->pTags + size, pTagInfo->pTagCtxList[i]->tag.nType); + tVariantDump(&ctx->tag, dst->pTags + size, ctx->tag.nType, true); size += pTagInfo->pTagCtxList[i]->outputBytes; } } @@ -2226,7 +2227,6 @@ static STopBotInfo *getTopBotOutputInfo(SQLFunctionCtx *pCtx) { static void buildTopBotStruct(STopBotInfo *pTopBotInfo, SQLFunctionCtx *pCtx) { char *tmp = (char *)pTopBotInfo + sizeof(STopBotInfo); pTopBotInfo->res = (tValuePair**) tmp; - tmp += POINTER_BYTES * pCtx->param[0].i64Key; size_t size = sizeof(tValuePair) + pCtx->tagInfo.tagsLen; @@ -2981,14 +2981,7 @@ static void tag_project_function(SQLFunctionCtx *pCtx) { assert(pCtx->inputBytes == pCtx->outputBytes); for (int32_t i = 0; i < pCtx->size; ++i) { - char* output = pCtx->aOutputBuf; - - if (pCtx->tag.nType == TSDB_DATA_TYPE_BINARY || pCtx->tag.nType == TSDB_DATA_TYPE_NCHAR) { - varDataSetLen(output, pCtx->tag.nLen); - tVariantDump(&pCtx->tag, varDataVal(output), pCtx->outputType); - } else { - tVariantDump(&pCtx->tag, output, pCtx->outputType); - } + tVariantDump(&pCtx->tag, pCtx->aOutputBuf, pCtx->outputType, true); pCtx->aOutputBuf += pCtx->outputBytes; } @@ -2997,13 +2990,7 @@ static void tag_project_function(SQLFunctionCtx *pCtx) { static void tag_project_function_f(SQLFunctionCtx *pCtx, int32_t index) { INC_INIT_VAL(pCtx, 1); - char* output = pCtx->aOutputBuf; - if (pCtx->tag.nType == TSDB_DATA_TYPE_BINARY || pCtx->tag.nType == TSDB_DATA_TYPE_NCHAR) { - *(int16_t*) output = pCtx->tag.nLen; - output += VARSTR_HEADER_SIZE; - } - - tVariantDump(&pCtx->tag, output, pCtx->tag.nType); + tVariantDump(&pCtx->tag, pCtx->aOutputBuf, pCtx->tag.nType, true); pCtx->aOutputBuf += pCtx->outputBytes; } @@ -3016,30 +3003,12 @@ static void tag_project_function_f(SQLFunctionCtx *pCtx, int32_t index) { */ static void tag_function(SQLFunctionCtx *pCtx) { SET_VAL(pCtx, 1, 1); - - char* output = pCtx->aOutputBuf; - - // todo refactor to dump length presented string(var string) - if (pCtx->tag.nType == TSDB_DATA_TYPE_BINARY || pCtx->tag.nType == TSDB_DATA_TYPE_NCHAR) { - *(int16_t*) output = pCtx->tag.nLen; - output += VARSTR_HEADER_SIZE; - } - - tVariantDump(&pCtx->tag, output, pCtx->tag.nType); + tVariantDump(&pCtx->tag, pCtx->aOutputBuf, pCtx->tag.nType, true); } static void tag_function_f(SQLFunctionCtx *pCtx, int32_t index) { SET_VAL(pCtx, 1, 1); - - char* output = pCtx->aOutputBuf; - - // todo refactor to dump length presented string(var string) - if (pCtx->tag.nType == TSDB_DATA_TYPE_BINARY || pCtx->tag.nType == TSDB_DATA_TYPE_NCHAR) { - *(int16_t*) output = pCtx->tag.nLen; - output += VARSTR_HEADER_SIZE; - } - - tVariantDump(&pCtx->tag, output, pCtx->tag.nType); + tVariantDump(&pCtx->tag, pCtx->aOutputBuf, pCtx->tag.nType, true); } static void copy_function(SQLFunctionCtx *pCtx) { @@ -3853,15 +3822,15 @@ void twa_function_finalizer(SQLFunctionCtx *pCtx) { } /** - * param[1]: default value/previous value of specified timestamp - * param[2]: next value of specified timestamp - * param[3]: denotes if the result is a precious result or interpolation results * * @param pCtx */ static void interp_function(SQLFunctionCtx *pCtx) { // at this point, the value is existed, return directly - if (pCtx->param[3].i64Key == 1) { + SResultInfo *pResInfo = GET_RES_INFO(pCtx); + SInterpInfoDetail* pInfo = pResInfo->interResultBuf; + + if (pCtx->size == 1) { char *pData = GET_INPUT_CHAR(pCtx); assignVal(pCtx->aOutputBuf, pData, pCtx->inputBytes, pCtx->inputType); } else { @@ -3869,76 +3838,65 @@ static void interp_function(SQLFunctionCtx *pCtx) { * use interpolation to generate the result. * Note: the result of primary timestamp column uses the timestamp specified by user in the query sql */ - assert(pCtx->param[3].i64Key == 2); + assert(pCtx->size == 2); + if (pInfo->type == TSDB_FILL_NONE) { // set no output result + return; + } - SInterpInfo interpInfo = *(SInterpInfo *)pCtx->aOutputBuf; - SInterpInfoDetail *pInfoDetail = interpInfo.pInterpDetail; - - /* set no output result */ - if (pInfoDetail->type == TSDB_FILL_NONE) { - pCtx->param[3].i64Key = 0; - } else if (pInfoDetail->primaryCol == 1) { - *(TSKEY *)pCtx->aOutputBuf = pInfoDetail->ts; + if (pInfo->primaryCol == 1) { + *(TSKEY *) pCtx->aOutputBuf = pInfo->ts; } else { - if (pInfoDetail->type == TSDB_FILL_NULL) { + if (pInfo->type == TSDB_FILL_NULL) { if (pCtx->outputType == TSDB_DATA_TYPE_BINARY || pCtx->outputType == TSDB_DATA_TYPE_NCHAR) { setVardataNull(pCtx->aOutputBuf, pCtx->outputType); } else { setNull(pCtx->aOutputBuf, pCtx->outputType, pCtx->outputBytes); } - } else if (pInfoDetail->type == TSDB_FILL_SET_VALUE) { - tVariantDump(&pCtx->param[1], pCtx->aOutputBuf, pCtx->inputType); - } else if (pInfoDetail->type == TSDB_FILL_PREV) { - char *data = pCtx->param[1].pz; - char *pVal = data + TSDB_KEYSIZE; - - if (pCtx->outputType == TSDB_DATA_TYPE_FLOAT) { - float v = GET_DOUBLE_VAL(pVal); - assignVal(pCtx->aOutputBuf, (const char*) &v, pCtx->outputBytes, pCtx->outputType); - } else { - assignVal(pCtx->aOutputBuf, pVal, pCtx->outputBytes, pCtx->outputType); - } - - } else if (pInfoDetail->type == TSDB_FILL_LINEAR) { - char *data1 = pCtx->param[1].pz; - char *data2 = pCtx->param[2].pz; - - char *pVal1 = data1 + TSDB_KEYSIZE; - char *pVal2 = data2 + TSDB_KEYSIZE; - - SPoint point1 = {.key = *(TSKEY *)data1, .val = &pCtx->param[1].i64Key}; - SPoint point2 = {.key = *(TSKEY *)data2, .val = &pCtx->param[2].i64Key}; - - SPoint point = {.key = pInfoDetail->ts, .val = pCtx->aOutputBuf}; - + + SET_VAL(pCtx, pCtx->size, 1); + } else if (pInfo->type == TSDB_FILL_SET_VALUE) { + tVariantDump(&pCtx->param[1], pCtx->aOutputBuf, pCtx->inputType, true); + } else if (pInfo->type == TSDB_FILL_PREV) { + char *data = GET_INPUT_CHAR_INDEX(pCtx, 0); + assignVal(pCtx->aOutputBuf, data, pCtx->outputBytes, pCtx->outputType); + + SET_VAL(pCtx, pCtx->size, 1); + } else if (pInfo->type == TSDB_FILL_LINEAR) { + char *data1 = GET_INPUT_CHAR_INDEX(pCtx, 0); + char *data2 = GET_INPUT_CHAR_INDEX(pCtx, 1); + + TSKEY key1 = pCtx->ptsList[0]; + TSKEY key2 = pCtx->ptsList[1]; + + SPoint point1 = {.key = key1, .val = data1}; + SPoint point2 = {.key = key2, .val = data2}; + + SPoint point = {.key = pInfo->ts, .val = pCtx->aOutputBuf}; + int32_t srcType = pCtx->inputType; if ((srcType >= TSDB_DATA_TYPE_TINYINT && srcType <= TSDB_DATA_TYPE_BIGINT) || srcType == TSDB_DATA_TYPE_TIMESTAMP || srcType == TSDB_DATA_TYPE_DOUBLE) { - point1.val = pVal1; - - point2.val = pVal2; - - if (isNull(pVal1, srcType) || isNull(pVal2, srcType)) { + point1.val = data1; + point2.val = data2; + + if (isNull(data1, srcType) || isNull(data2, srcType)) { setNull(pCtx->aOutputBuf, srcType, pCtx->inputBytes); } else { taosDoLinearInterpolation(pCtx->outputType, &point1, &point2, &point); } } else if (srcType == TSDB_DATA_TYPE_FLOAT) { - float v1 = GET_DOUBLE_VAL(pVal1); - float v2 = GET_DOUBLE_VAL(pVal2); - - point1.val = &v1; - point2.val = &v2; - - if (isNull(pVal1, srcType) || isNull(pVal2, srcType)) { + point1.val = data1; + point2.val = data2; + + if (isNull(data1, srcType) || isNull(data2, srcType)) { setNull(pCtx->aOutputBuf, srcType, pCtx->inputBytes); } else { taosDoLinearInterpolation(pCtx->outputType, &point1, &point2, &point); } - + } else { if (srcType == TSDB_DATA_TYPE_BINARY || srcType == TSDB_DATA_TYPE_NCHAR) { - setVardataNull(pCtx->aOutputBuf, pCtx->inputBytes); + setVardataNull(pCtx->aOutputBuf, pCtx->inputType); } else { setNull(pCtx->aOutputBuf, srcType, pCtx->inputBytes); } @@ -3946,15 +3904,8 @@ static void interp_function(SQLFunctionCtx *pCtx) { } } - free(interpInfo.pInterpDetail); } - pCtx->size = pCtx->param[3].i64Key; - - tVariantDestroy(&pCtx->param[1]); - tVariantDestroy(&pCtx->param[2]); - - // data in the check operation are all null, not output SET_VAL(pCtx, pCtx->size, 1); } @@ -4910,7 +4861,7 @@ SQLAggFuncElem aAggs[] = {{ "interp", TSDB_FUNC_INTERP, TSDB_FUNC_INTERP, - TSDB_FUNCSTATE_SO | TSDB_FUNCSTATE_OF | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS, + TSDB_FUNCSTATE_SO | TSDB_FUNCSTATE_OF | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS , function_setup, interp_function, do_sum_f, // todo filter handle @@ -4918,7 +4869,7 @@ SQLAggFuncElem aAggs[] = {{ doFinalizer, noop1, copy_function, - no_data_info, + data_req_load_info, }, { // 28 diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 82460b6a76..965e85efbd 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -142,7 +142,7 @@ static int setColumnFilterInfoForTimestamp(SQueryInfo* pQueryInfo, tVariant* pVa return invalidSqlErrMsg(pQueryInfo->msg, msg); } } else { - if (tVariantDump(pVar, (char*)&time, TSDB_DATA_TYPE_BIGINT)) { + if (tVariantDump(pVar, (char*)&time, TSDB_DATA_TYPE_BIGINT, true)) { return invalidSqlErrMsg(pQueryInfo->msg, msg); } } @@ -1403,7 +1403,6 @@ int32_t addProjectionExprAndResultField(SQueryInfo* pQueryInfo, tSQLExprItem* pI SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE}; strcpy(colSchema.name, TSQL_TBNAME_L); - pQueryInfo->type = TSDB_QUERY_TYPE_STABLE_QUERY; tscAddSpecialColumnForSelect(pQueryInfo, startPos, TSDB_FUNC_TAGPRJ, &index, &colSchema, true); } else { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex); @@ -1595,7 +1594,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr int16_t resultType = 0; int16_t resultSize = 0; - int16_t intermediateResSize = 0; + int32_t intermediateResSize = 0; int16_t functionID = 0; if (changeFunctionID(optr, &functionID) != TSDB_CODE_SUCCESS) { @@ -1628,14 +1627,14 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr if (optr == TK_LEASTSQUARES) { /* set the leastsquares parameters */ char val[8] = {0}; - if (tVariantDump(&pParamElem[1].pNode->val, val, TSDB_DATA_TYPE_DOUBLE) < 0) { + if (tVariantDump(&pParamElem[1].pNode->val, val, TSDB_DATA_TYPE_DOUBLE, true) < 0) { return TSDB_CODE_INVALID_SQL; } addExprParams(pExpr, val, TSDB_DATA_TYPE_DOUBLE, DOUBLE_BYTES, 0); memset(val, 0, tListLen(val)); - if (tVariantDump(&pParamElem[2].pNode->val, val, TSDB_DATA_TYPE_DOUBLE) < 0) { + if (tVariantDump(&pParamElem[2].pNode->val, val, TSDB_DATA_TYPE_DOUBLE, true) < 0) { return TSDB_CODE_INVALID_SQL; } @@ -1795,7 +1794,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr SSqlExpr* pExpr = NULL; if (optr == TK_PERCENTILE || optr == TK_APERCENTILE) { - tVariantDump(pVariant, val, TSDB_DATA_TYPE_DOUBLE); + tVariantDump(pVariant, val, TSDB_DATA_TYPE_DOUBLE, true); double dp = GET_DOUBLE_VAL(val); if (dp < 0 || dp > TOP_BOTTOM_QUERY_LIMIT) { @@ -1818,7 +1817,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr pExpr = tscSqlExprAppend(pQueryInfo, functionId, &index, resultType, resultSize, resultSize, false); addExprParams(pExpr, val, TSDB_DATA_TYPE_DOUBLE, sizeof(double), 0); } else { - tVariantDump(pVariant, val, TSDB_DATA_TYPE_BIGINT); + tVariantDump(pVariant, val, TSDB_DATA_TYPE_BIGINT, true); int64_t nTop = *((int32_t*)val); if (nTop <= 0 || nTop > 100) { // todo use macro @@ -1902,7 +1901,7 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr int16_t bytes = 0; int16_t type = 0; - int16_t inter = 0; + int32_t inter = 0; int32_t ret = getResultDataInfo(s.type, s.bytes, TSDB_FUNC_TID_TAG, 0, &type, &bytes, &inter, 0, 0); assert(ret == TSDB_CODE_SUCCESS); @@ -2288,7 +2287,7 @@ int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) { int16_t bytes = 0; int16_t type = 0; - int16_t intermediateBytes = 0; + int32_t interBytes = 0; size_t size = tscSqlExprNumOfExprs(pQueryInfo); for (int32_t k = 0; k < size; ++k) { @@ -2302,13 +2301,13 @@ int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) { (functionId >= TSDB_FUNC_FIRST_DST && functionId <= TSDB_FUNC_LAST_DST) || (functionId >= TSDB_FUNC_RATE && functionId <= TSDB_FUNC_AVG_IRATE)) { if (getResultDataInfo(pSrcSchema->type, pSrcSchema->bytes, functionId, pExpr->param[0].i64Key, &type, &bytes, - &intermediateBytes, 0, true) != TSDB_CODE_SUCCESS) { + &interBytes, 0, true) != TSDB_CODE_SUCCESS) { return TSDB_CODE_INVALID_SQL; } tscSqlExprUpdate(pQueryInfo, k, functionId, pExpr->colInfo.colIndex, TSDB_DATA_TYPE_BINARY, bytes); // todo refactor - pExpr->interBytes = intermediateBytes; + pExpr->interBytes = interBytes; } } @@ -2328,27 +2327,23 @@ void tscRestoreSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); SSchema* pSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, pExpr->colInfo.colIndex); -// if (/*(pExpr->functionId >= TSDB_FUNC_FIRST_DST && pExpr->functionId <= TSDB_FUNC_LAST_DST) || -// (pExpr->functionId >= TSDB_FUNC_SUM && pExpr->functionId <= TSDB_FUNC_MAX) || -// pExpr->functionId == TSDB_FUNC_LAST_ROW*/) { - // the final result size and type in the same as query on single table. - // so here, set the flag to be false; - int16_t inter = 0; - - int32_t functionId = pExpr->functionId; - if (functionId >= TSDB_FUNC_TS && functionId <= TSDB_FUNC_DIFF) { - continue; - } - - if (functionId == TSDB_FUNC_FIRST_DST) { - functionId = TSDB_FUNC_FIRST; - } else if (functionId == TSDB_FUNC_LAST_DST) { - functionId = TSDB_FUNC_LAST; - } - - getResultDataInfo(pSchema->type, pSchema->bytes, functionId, 0, &pExpr->resType, &pExpr->resBytes, - &inter, 0, false); -// } + // the final result size and type in the same as query on single table. + // so here, set the flag to be false; + int32_t inter = 0; + + int32_t functionId = pExpr->functionId; + if (functionId >= TSDB_FUNC_TS && functionId <= TSDB_FUNC_DIFF) { + continue; + } + + if (functionId == TSDB_FUNC_FIRST_DST) { + functionId = TSDB_FUNC_FIRST; + } else if (functionId == TSDB_FUNC_LAST_DST) { + functionId = TSDB_FUNC_LAST; + } + + getResultDataInfo(pSchema->type, pSchema->bytes, functionId, 0, &pExpr->resType, &pExpr->resBytes, + &inter, 0, false); } } @@ -2631,23 +2626,23 @@ static int32_t doExtractColumnFilterInfo(SQueryInfo* pQueryInfo, SColumnFilterIn } if (pExpr->nSQLOptr == TK_LE || pExpr->nSQLOptr == TK_LT) { - tVariantDump(&pRight->val, (char*)&pColumnFilter->upperBndd, colType); + tVariantDump(&pRight->val, (char*)&pColumnFilter->upperBndd, colType, false); } else { // TK_GT,TK_GE,TK_EQ,TK_NE are based on the pColumn->lowerBndd if (colType == TSDB_DATA_TYPE_BINARY) { pColumnFilter->pz = (int64_t)calloc(1, pRight->val.nLen + 1); pColumnFilter->len = pRight->val.nLen; - tVariantDump(&pRight->val, (char*)pColumnFilter->pz, colType); + tVariantDump(&pRight->val, (char*)pColumnFilter->pz, colType, false); } else if (colType == TSDB_DATA_TYPE_NCHAR) { // pRight->val.nLen + 1 is larger than the actual nchar string length pColumnFilter->pz = (int64_t)calloc(1, (pRight->val.nLen + 1) * TSDB_NCHAR_SIZE); - tVariantDump(&pRight->val, (char*)pColumnFilter->pz, colType); + tVariantDump(&pRight->val, (char*)pColumnFilter->pz, colType, false); size_t len = wcslen((wchar_t*)pColumnFilter->pz); pColumnFilter->len = len * TSDB_NCHAR_SIZE; } else { - tVariantDump(&pRight->val, (char*)&pColumnFilter->lowerBndd, colType); + tVariantDump(&pRight->val, (char*)&pColumnFilter->lowerBndd, colType, false); } } @@ -3336,9 +3331,8 @@ static int32_t handleExprInQueryCond(SQueryInfo* pQueryInfo, tSQLExpr** pExpr, S *pExpr = NULL; // remove this expression *type = TSQL_EXPR_TS; - } else if (index.columnIndex >= tscGetNumOfColumns(pTableMeta) || - index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) { // query on tags - // check for tag query condition + } else if (index.columnIndex >= tscGetNumOfColumns(pTableMeta) || index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) { + // query on tags, check for tag query condition if (UTIL_TABLE_IS_NORMAL_TABLE(pTableMetaInfo)) { return invalidSqlErrMsg(pQueryInfo->msg, msg1); } @@ -3933,7 +3927,7 @@ int32_t getTimeRange(STimeWindow* win, tSQLExpr* pRight, int32_t optr, int16_t t * failed to parse timestamp in regular formation, try next * it may be a epoch time in string format */ - tVariantDump(&pRight->val, (char*)&val, TSDB_DATA_TYPE_BIGINT); + tVariantDump(&pRight->val, (char*)&val, TSDB_DATA_TYPE_BIGINT, true); /* * transfer it into MICROSECOND format if it is a string, since for @@ -4070,14 +4064,13 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) { continue; } - int32_t ret = tVariantDump(&pFillToken->a[j].pVar, (char*)&pQueryInfo->fillVal[i], pFields->type); + int32_t ret = tVariantDump(&pFillToken->a[j].pVar, (char*)&pQueryInfo->fillVal[i], pFields->type, true); if (ret != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(pQueryInfo->msg, msg); } } - if ((pFillToken->nExpr < size) || - ((pFillToken->nExpr - 1 < size) && (tscIsPointInterpQuery(pQueryInfo)))) { + if ((pFillToken->nExpr < size) || ((pFillToken->nExpr - 1 < size) && (tscIsPointInterpQuery(pQueryInfo)))) { tVariantListItem* lastItem = &pFillToken->a[pFillToken->nExpr - 1]; for (int32_t i = numOfFillVal; i < size; ++i) { @@ -4086,7 +4079,7 @@ int32_t parseFillClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySQL) { if (pFields->type == TSDB_DATA_TYPE_BINARY || pFields->type == TSDB_DATA_TYPE_NCHAR) { setVardataNull((char*) &pQueryInfo->fillVal[i], pFields->type); } else { - tVariantDump(&lastItem->pVar, (char*)&pQueryInfo->fillVal[i], pFields->type); + tVariantDump(&lastItem->pVar, (char*)&pQueryInfo->fillVal[i], pFields->type, true); } } } @@ -4168,6 +4161,10 @@ int32_t parseOrderbyClause(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql, SSchema if (index.columnIndex >= tscGetNumOfColumns(pTableMetaInfo->pTableMeta)) { int32_t relTagIndex = index.columnIndex - tscGetNumOfColumns(pTableMetaInfo->pTableMeta); + // it is a tag column + if (pQueryInfo->groupbyExpr.columnInfo == NULL) { + return invalidSqlErrMsg(pQueryInfo->msg, msg2); + } SColIndex* pColIndex = taosArrayGet(pQueryInfo->groupbyExpr.columnInfo, 0); if (relTagIndex == pColIndex->colIndex) { orderByTags = true; @@ -4420,10 +4417,10 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { } SSchema* pTagsSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, columnIndex.columnIndex); - if (tVariantDump(&pVarList->a[1].pVar, pAlterSQL->tagData.data /*pCmd->payload*/, pTagsSchema->type) != - TSDB_CODE_SUCCESS) { + if (tVariantDump(&pVarList->a[1].pVar, pAlterSQL->tagData.data, pTagsSchema->type, true) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(pQueryInfo->msg, msg13); } + pAlterSQL->tagData.dataLen = pTagsSchema->bytes; // validate the length of binary @@ -4680,7 +4677,7 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL* const char* msg0 = "soffset/offset can not be less than 0"; const char* msg1 = "slimit/soffset only available for STable query"; - const char* msg2 = "function not supported on table"; + const char* msg2 = "functions mixed up in table query"; const char* msg3 = "slimit/soffset can not apply to projection query"; // handle the limit offset value, validate the limit @@ -4763,14 +4760,22 @@ int32_t parseLimitClause(SQueryInfo* pQueryInfo, int32_t clauseIndex, SQuerySQL* } size_t size = taosArrayGetSize(pQueryInfo->exprList); - + + bool hasTags = false; + bool hasOtherFunc = false; // filter the query functions operating on "tbname" column that are not supported by normal columns. for (int32_t i = 0; i < size; ++i) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i); - if (pExpr->colInfo.colIndex == TSDB_TBNAME_COLUMN_INDEX) { - return invalidSqlErrMsg(pQueryInfo->msg, msg2); + if (TSDB_COL_IS_TAG(pExpr->colInfo.flag)) { + hasTags = true; + } else { + hasOtherFunc = true; } } + + if (hasTags && hasOtherFunc) { + return invalidSqlErrMsg(pQueryInfo->msg, msg2); + } } return TSDB_CODE_SUCCESS; @@ -5571,21 +5576,9 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { if (pList->a[i].pVar.nLen + VARSTR_HEADER_SIZE > pTagSchema[i].bytes) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); } - - ret = tVariantDump(&(pList->a[i].pVar), varDataVal(tagVal), pTagSchema[i].type); - if (pList->a[i].pVar.nType == TSDB_DATA_TYPE_NULL) { - if (pTagSchema[i].type == TSDB_DATA_TYPE_BINARY) { - varDataSetLen(tagVal, sizeof(uint8_t)); - } else { - varDataSetLen(tagVal, sizeof(uint32_t)); - } - } else { // todo refactor - varDataSetLen(tagVal, pList->a[i].pVar.nLen); - } - } else { - ret = tVariantDump(&(pList->a[i].pVar), tagVal, pTagSchema[i].type); } + ret = tVariantDump(&(pList->a[i].pVar), tagVal, pTagSchema[i].type, true); if (ret != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg4); } @@ -5845,7 +5838,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) { pQueryInfo->window.ekey = pQueryInfo->window.ekey / 1000; } } else { // set the time rang - pQueryInfo->window.skey = 0; + pQueryInfo->window.skey = TSKEY_INITIAL_VAL; pQueryInfo->window.ekey = INT64_MAX; } diff --git a/src/client/src/tscSecondaryMerge.c b/src/client/src/tscSecondaryMerge.c index 7617621e5f..5737564877 100644 --- a/src/client/src/tscSecondaryMerge.c +++ b/src/client/src/tscSecondaryMerge.c @@ -689,7 +689,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr SSchema *p1 = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, pExpr->colInfo.colIndex); - int16_t inter = 0; + int32_t inter = 0; int16_t type = -1; int16_t bytes = 0; @@ -1049,7 +1049,14 @@ static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalReducer *pLocalReducer, int32_t functionId = pExpr->functionId; if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TAG || functionId == TSDB_FUNC_TS_DUMMY) { tVariantDestroy(&pCtx->tag); - tVariantCreateFromBinary(&pCtx->tag, pCtx->aInputElemBuf, pCtx->inputBytes, pCtx->inputType); + char* input = pCtx->aInputElemBuf; + + if (pCtx->inputType == TSDB_DATA_TYPE_BINARY || pCtx->inputType == TSDB_DATA_TYPE_NCHAR) { + assert(varDataLen(input) <= pCtx->inputBytes); + tVariantCreateFromBinary(&pCtx->tag, varDataVal(input), varDataLen(input), pCtx->inputType); + } else { + tVariantCreateFromBinary(&pCtx->tag, input, pCtx->inputBytes, pCtx->inputType); + } } pCtx->currentStage = SECONDARY_STAGE_MERGE; @@ -1309,7 +1316,7 @@ static bool isAllSourcesCompleted(SLocalReducer *pLocalReducer) { return (pLocalReducer->numOfBuffer == pLocalReducer->numOfCompleted); } -static bool doInterpolationForCurrentGroup(SSqlObj *pSql) { +static bool doBuildFilledResultForGroup(SSqlObj *pSql) { SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; @@ -1347,8 +1354,8 @@ static bool doHandleLastRemainData(SSqlObj *pSql) { SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; - SLocalReducer * pLocalReducer = pRes->pLocalReducer; - SFillInfo *pFillInfo = pLocalReducer->pFillInfo; + SLocalReducer *pLocalReducer = pRes->pLocalReducer; + SFillInfo *pFillInfo = pLocalReducer->pFillInfo; bool prevGroupCompleted = (!pLocalReducer->discard) && pLocalReducer->hasUnprocessedRow; @@ -1445,7 +1452,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { return TSDB_CODE_SUCCESS; } - if (doInterpolationForCurrentGroup(pSql)) { + if (doBuildFilledResultForGroup(pSql)) { pLocalReducer->status = TSC_LOCALREDUCE_READY; // set the flag, taos_free_result can release this result. return TSDB_CODE_SUCCESS; } @@ -1464,8 +1471,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) { #ifdef _DEBUG_VIEW printf("chosen data in pTree[0] = %d\n", pTree->pNode[0].index); #endif - assert((pTree->pNode[0].index < pLocalReducer->numOfBuffer) && (pTree->pNode[0].index >= 0) && - tmpBuffer->num == 0); + assert((pTree->pNode[0].index < pLocalReducer->numOfBuffer) && (pTree->pNode[0].index >= 0) && tmpBuffer->num == 0); // chosen from loser tree SLocalDataSource *pOneDataSrc = pLocalReducer->pLocalDataSrc[pTree->pNode[0].index]; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 417108dfce..8ca590a1f6 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -237,10 +237,8 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) { rpcMsg->code = TSDB_CODE_NETWORK_UNAVAIL; } else { STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); - if (rpcMsg->code == TSDB_CODE_NOT_ACTIVE_TABLE || rpcMsg->code == TSDB_CODE_INVALID_TABLE_ID || - rpcMsg->code == TSDB_CODE_INVALID_VNODE_ID || rpcMsg->code == TSDB_CODE_NOT_ACTIVE_VNODE || - rpcMsg->code == TSDB_CODE_NETWORK_UNAVAIL || rpcMsg->code == TSDB_CODE_NOT_ACTIVE_TABLE || - rpcMsg->code == TSDB_CODE_TABLE_ID_MISMATCH) { + if (rpcMsg->code == TSDB_CODE_INVALID_TABLE_ID || rpcMsg->code == TSDB_CODE_INVALID_VGROUP_ID || + rpcMsg->code == TSDB_CODE_NETWORK_UNAVAIL) { /* * not_active_table: 1. the virtual node may fail to create table, since the procedure of create table is asynchronized, * the virtual node may have not create table till now, so try again by using the new metermeta. @@ -653,7 +651,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pQueryMsg->order = htons(pQueryInfo->order.order); pQueryMsg->orderColId = htons(pQueryInfo->order.orderColId); - pQueryMsg->fillType = htons(pQueryInfo->fillType); + pQueryMsg->fillType = htons(pQueryInfo->fillType); pQueryMsg->limit = htobe64(pQueryInfo->limit.limit); pQueryMsg->offset = htobe64(pQueryInfo->limit.offset); pQueryMsg->numOfCols = htons(taosArrayGetSize(pQueryInfo->colList)); @@ -1289,7 +1287,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pAlterTableMsg->numOfCols = htons(tscNumOfFields(pQueryInfo)); SSchema *pSchema = pAlterTableMsg->schema; - for (int i = 0; i < pAlterTableMsg->numOfCols; ++i) { + for (int i = 0; i < tscNumOfFields(pQueryInfo); ++i) { TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i); pSchema->type = pField->type; @@ -1845,17 +1843,6 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) { size_t size = 0; STableMeta* pTableMeta = tscCreateTableMetaFromMsg(pMetaMsg, &size); - -#if 0 - // if current table is created according to super table, get the table meta of super table - if (pTableMeta->tableType == TSDB_CHILD_TABLE) { - char id[TSDB_TABLE_ID_LEN + 1] = {0}; - strncpy(id, pMetaMsg->stableId, TSDB_TABLE_ID_LEN); - - // NOTE: if the table meta of super table is not cached at client side yet, the pSTable is NULL - pTableMeta->pSTable = taosCacheAcquireByName(tscCacheHandle, id); - } -#endif // todo add one more function: taosAddDataIfNotExists(); STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0); @@ -1978,7 +1965,7 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) { pSql->res.code = TSDB_CODE_SUCCESS; pSql->res.numOfTotal = i; - tscTrace("%p load multi-metermeta resp complete num:%d", pSql, pSql->res.numOfTotal); + tscTrace("%p load multi-metermeta resp from complete num:%d", pSql, pSql->res.numOfTotal); #endif return TSDB_CODE_SUCCESS; diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index a9ec33c078..a4cbd7f7ec 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -284,12 +284,11 @@ int taos_query(TAOS *taos, const char *sqlstr) { } SSqlObj* pSql = pObj->pSql; - - size_t sqlLen = strlen(sqlstr); + size_t sqlLen = strlen(sqlstr); doAsyncQuery(pObj, pSql, waitForQueryRsp, taos, sqlstr, sqlLen); // wait for the callback function to post the semaphore - sem_wait(&pSql->rspSem); + tsem_wait(&pSql->rspSem); return pSql->res.code; } @@ -525,7 +524,7 @@ int taos_select_db(TAOS *taos, const char *db) { return taos_query(taos, sql); } -void taos_free_result_imp(TAOS_RES *res, int keepCmd) { +void taos_free_result(TAOS_RES *res) { if (res == NULL) return; SSqlObj *pSql = (SSqlObj *)res; @@ -536,26 +535,23 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) { if (pSql->signature != pSql) return; + STscObj* pObj = pSql->pTscObj; if (pRes == NULL || pRes->qhandle == 0) { /* Query rsp is not received from vnode, so the qhandle is NULL */ tscTrace("%p qhandle is null, abort free, fp:%p", pSql, pSql->fp); - STscObj* pTscObj = pSql->pTscObj; - if (pTscObj->pSql != pSql) { + // The semaphore can not be changed while freeing async sub query objects. + if (pObj->pSql != pSql) { tscTrace("%p SqlObj is freed by app", pSql); tscFreeSqlObj(pSql); } else { - if (keepCmd) { - tscFreeSqlResult(pSql); - } else { - tscPartiallyFreeSqlObj(pSql); - } + tscPartiallyFreeSqlObj(pSql); } - + return; } - // set freeFlag to 1 in retrieve message if there are un-retrieved results + // set freeFlag to 1 in retrieve message if there are un-retrieved results data in node SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); if (pQueryInfo == NULL) { tscPartiallyFreeSqlObj(pSql); @@ -563,6 +559,7 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) { } pQueryInfo->type = TSDB_QUERY_TYPE_FREE_RESOURCE; + STscObj* pTscObj = pSql->pTscObj; STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); @@ -579,9 +576,8 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) { if ((pCmd->command == TSDB_SQL_SELECT || pCmd->command == TSDB_SQL_SHOW || pCmd->command == TSDB_SQL_RETRIEVE || - pCmd->command == TSDB_SQL_FETCH) && - (pRes->code != TSDB_CODE_QUERY_CANCELLED && ((pCmd->command < TSDB_SQL_LOCAL && pRes->completed == false) || - (pRes->code == TSDB_CODE_SUCCESS && pCmd->command == TSDB_SQL_SELECT && pSql->pStream == NULL && pTableMetaInfo->pTableMeta != NULL)))) { + pCmd->command == TSDB_SQL_FETCH) && pRes->code == TSDB_CODE_SUCCESS && pRes->completed == false && + (pCmd->command == TSDB_SQL_SELECT && pSql->pStream == NULL && pTableMetaInfo->pTableMeta != NULL)) { pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH; tscTrace("%p send msg to free qhandle in vnode, code:%d, numOfRows:%d, command:%s", pSql, pRes->code, pRes->numOfRows, @@ -591,27 +587,20 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) { tscProcessSql(pSql); // waits for response and then goes on - sem_wait(&pSql->rspSem); + if (pTscObj->pSql == pSql) { + sem_wait(&pSql->rspSem); + } } else { // if no free resource msg is sent to vnode, we free this object immediately. - STscObj* pTscObj = pSql->pTscObj; - if (pTscObj->pSql != pSql) { tscFreeSqlObj(pSql); tscTrace("%p sql result is freed by app", pSql); } else { - if (keepCmd) { - tscFreeSqlResult(pSql); - tscTrace("%p sql result is freed while sql command is kept", pSql); - } else { - tscPartiallyFreeSqlObj(pSql); - tscTrace("%p sql result is freed by app", pSql); - } + tscPartiallyFreeSqlObj(pSql); + tscTrace("%p sql result is freed by app", pSql); } } } -void taos_free_result(TAOS_RES *res) { taos_free_result_imp(res, 0); } - // todo should not be used in async query int taos_errno(TAOS *taos) { STscObj *pObj = (STscObj *)taos; diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index c4fe0b202b..99163ba327 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -1084,7 +1084,7 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter int16_t bytes = 0; int16_t type = 0; - int16_t inter = 0; + int32_t inter = 0; getResultDataInfo(s.type, s.bytes, TSDB_FUNC_TID_TAG, 0, &type, &bytes, &inter, 0, 0); @@ -1770,6 +1770,8 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { */ pNew->fetchFp = pNew->fp; pSql->pSubs[i] = pNew; + pNew->fetchFp = pNew->fp; + tscTrace("%p sub:%p create subObj success. orderOfSub:%d", pSql, pNew, i); } diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index 2ca53bade1..75249e44ee 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -57,9 +57,9 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn) { memset(&rpcInit, 0, sizeof(rpcInit)); rpcInit.localPort = 0; rpcInit.label = "TSC"; - rpcInit.numOfThreads = tscNumOfThreads; + rpcInit.numOfThreads = 1; // every DB connection has only one thread rpcInit.cfp = tscProcessMsgFromServer; - rpcInit.sessions = tsMaxVnodeConnections; + rpcInit.sessions = tsMaxConnections; rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.user = (char*)user; rpcInit.idleTime = 2000; @@ -121,7 +121,7 @@ void taos_init_imp() { } tscInitMsgsFp(); - int queueSize = tsMaxVnodeConnections + tsMaxMeterConnections + tsMaxMgmtConnections + tsMaxMgmtConnections; + int queueSize = tsMaxConnections*2; if (tscEmbedded == 0) { tscNumOfThreads = tsNumOfCores * tsNumOfThreadsPerCore / 2.0; @@ -137,7 +137,7 @@ void taos_init_imp() { return; } - tscTmr = taosTmrInit(tsMaxMgmtConnections * 2, 200, 60000, "TSC"); + tscTmr = taosTmrInit(tsMaxConnections * 2, 200, 60000, "TSC"); if(0 == tscEmbedded){ taosTmrReset(tscCheckDiskUsage, 10, NULL, tscTmr, &tscCheckDiskUsageTmr); } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 4c8722ecea..4b9d2b920f 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -421,7 +421,6 @@ void tscFreeSqlObj(SSqlObj* pSql) { memset(pCmd->payload, 0, (size_t)pCmd->allocSize); tfree(pCmd->payload); - pCmd->allocSize = 0; tfree(pSql->sqlstr); @@ -1033,7 +1032,7 @@ SSqlExpr* tscSqlExprUpdate(SQueryInfo* pQueryInfo, int32_t index, int16_t functi return pExpr; } -int32_t tscSqlExprNumOfExprs(SQueryInfo* pQueryInfo) { +size_t tscSqlExprNumOfExprs(SQueryInfo* pQueryInfo) { return taosArrayGetSize(pQueryInfo->exprList); } @@ -1352,7 +1351,7 @@ bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId) { return false; } - if (colId == -1 && UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { + if (colId == TSDB_TBNAME_COLUMN_INDEX) { return true; } @@ -1768,11 +1767,12 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void pNewQueryInfo->limit = pQueryInfo->limit; pNewQueryInfo->slimit = pQueryInfo->slimit; pNewQueryInfo->order = pQueryInfo->order; - pNewQueryInfo->clauseLimit = pQueryInfo->clauseLimit; - pNewQueryInfo->pTableMetaInfo = NULL; + pNewQueryInfo->tsBuf = NULL; + pNewQueryInfo->fillType = pQueryInfo->fillType; pNewQueryInfo->fillVal = NULL; + pNewQueryInfo->clauseLimit = pQueryInfo->clauseLimit; pNewQueryInfo->numOfTables = 0; - pNewQueryInfo->tsBuf = NULL; + pNewQueryInfo->pTableMetaInfo = NULL; pNewQueryInfo->groupbyExpr = pQueryInfo->groupbyExpr; if (pQueryInfo->groupbyExpr.columnInfo != NULL) { @@ -1850,8 +1850,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void STableMetaInfo* pFinalInfo = NULL; if (pPrevSql == NULL) { - STableMeta* pTableMeta = taosCacheAcquireByName(tscCacheHandle, name); - // todo handle error + STableMeta* pTableMeta = taosCacheAcquireByData(tscCacheHandle, pTableMetaInfo->pTableMeta); // get by name may failed due to the cache cleanup assert(pTableMeta != NULL); pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, name, pTableMeta, pTableMetaInfo->vgroupList, pTableMetaInfo->tagColList); } else { // transfer the ownership of pTableMeta to the newly create sql object. @@ -1865,7 +1864,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void } if (pFinalInfo->pTableMeta == NULL) { - tscError("%p new subquery failed for get pMeterMeta is NULL from cache", pSql); + tscError("%p new subquery failed for get tableMeta is NULL from cache", pSql); tscFreeSqlObj(pNew); return NULL; } @@ -2012,7 +2011,7 @@ bool hasMoreVnodesToTry(SSqlObj* pSql) { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); assert(pRes->completed); - // for normal table, do not try any more if result are exhausted + // for normal table, no need to try any more if results are all retrieved from one vnode if (!UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo) || (pTableMetaInfo->vgroupList == NULL)) { return false; } @@ -2038,7 +2037,7 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) { int32_t totalVgroups = pTableMetaInfo->vgroupList->numOfVgroups; while (++pTableMetaInfo->vgroupIndex < totalVgroups) { - tscTrace("%p current vnode:%d exhausted, try next:%d. total vnode:%d. current numOfRes:%d", pSql, + tscTrace("%p results from vgroup index:%d completed, try next:%d. total vgroups:%d. current numOfRes:%d", pSql, pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pRes->numOfClauseTotal); /* @@ -2122,7 +2121,7 @@ void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pFieldInfo, int32_t column int32_t type = pInfo->pSqlExpr->resType; int32_t bytes = pInfo->pSqlExpr->resBytes; - char* pData = ((char*) pRes->data) + pInfo->pSqlExpr->offset * pRes->numOfRows + bytes * pRes->row; + char* pData = pRes->data + pInfo->pSqlExpr->offset * pRes->numOfRows + bytes * pRes->row; if (type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_BINARY) { int32_t realLen = varDataLen(pData); @@ -2135,7 +2134,7 @@ void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pFieldInfo, int32_t column } if (realLen < pInfo->pSqlExpr->resBytes - VARSTR_HEADER_SIZE) { // todo refactor - *(char*) (pData + realLen + VARSTR_HEADER_SIZE) = 0; + *(pData + realLen + VARSTR_HEADER_SIZE) = 0; } pRes->length[columnIndex] = realLen; diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index b94d5b2489..d0b42e5877 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -87,7 +87,7 @@ extern int16_t tsWAL; extern int32_t tsReplications; extern int16_t tsAffectedRowsMod; -extern int32_t tsNumOfMPeers; +extern int32_t tsNumOfMnodes; extern int32_t tsMaxShellConns; extern int32_t tsMaxTables; @@ -98,9 +98,7 @@ extern char tsDefaultPass[]; extern char tsMqttBrokerAddress[]; extern char tsMqttBrokerClientId[]; -extern int32_t tsMaxMeterConnections; -extern int32_t tsMaxVnodeConnections; -extern int32_t tsMaxMgmtConnections; +extern int32_t tsMaxConnections; extern int32_t tsBalanceInterval; extern int32_t tsOfflineThreshold; diff --git a/src/common/src/tdataformat.c b/src/common/src/tdataformat.c index 922c8bdea0..e7935900d6 100644 --- a/src/common/src/tdataformat.c +++ b/src/common/src/tdataformat.c @@ -196,6 +196,7 @@ void * tdQueryTagByID(SDataRow row, int16_t colId, int16_t *type) { STagCol key = {colId,0,0}; STagCol * stCol = taosbsearch(&key, pBase, nCols, sizeof(STagCol), compTagId, TD_EQ); if (NULL == stCol) { + type = TSDB_DATA_TYPE_NULL; return NULL; } diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index e0d3912fe3..0f008111c0 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -105,15 +105,13 @@ int32_t tsReplications = TSDB_DEFAULT_REPLICA_NUM; * 1: affected rows include those duplicate records */ int16_t tsAffectedRowsMod = 0; -int32_t tsNumOfMPeers = 3; -int32_t tsMaxShellConns = 2000; +int32_t tsNumOfMnodes = 3; +int32_t tsMaxShellConns = 5000; char tsDefaultDB[TSDB_DB_NAME_LEN] = {0}; char tsDefaultUser[64] = "root"; char tsDefaultPass[64] = "taosdata"; -int32_t tsMaxMeterConnections = 10000; -int32_t tsMaxMgmtConnections = 2000; -int32_t tsMaxVnodeConnections = 10000; +int32_t tsMaxConnections = 50; int32_t tsBalanceInterval = 300; // seconds int32_t tsOfflineThreshold = 86400*100; // seconds 10days @@ -409,8 +407,8 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); - cfg.option = "numOfMPeers"; - cfg.ptr = &tsNumOfMPeers; + cfg.option = "numOfMnodes"; + cfg.ptr = &tsNumOfMnodes; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; cfg.minValue = 1; @@ -429,7 +427,7 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); - // 0-any; 1-mnode; 2-dnode + // 0-any; 1-mnode; 2-vnode cfg.option = "alternativeRole"; cfg.ptr = &tsAlternativeRole; cfg.valType = TAOS_CFG_VTYPE_INT32; @@ -682,7 +680,7 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); - cfg.option = "wallevel"; + cfg.option = "walLevel"; cfg.ptr = &tsWAL; cfg.valType = TAOS_CFG_VTYPE_INT16; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; @@ -836,32 +834,12 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); - cfg.option = "maxMeterConnections"; - cfg.ptr = &tsMaxMeterConnections; + cfg.option = "maxConnections"; + cfg.ptr = &tsMaxConnections; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; - cfg.minValue = 10; - cfg.maxValue = 50000000; - cfg.ptrLength = 0; - cfg.unitType = TAOS_CFG_UTYPE_NONE; - taosInitConfigOption(cfg); - - cfg.option = "maxMgmtConnections"; - cfg.ptr = &tsMaxMgmtConnections; - cfg.valType = TAOS_CFG_VTYPE_INT32; - cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; - cfg.minValue = 10; - cfg.maxValue = 50000000; - cfg.ptrLength = 0; - cfg.unitType = TAOS_CFG_UTYPE_NONE; - taosInitConfigOption(cfg); - - cfg.option = "maxVnodeConnections"; - cfg.ptr = &tsMaxVnodeConnections; - cfg.valType = TAOS_CFG_VTYPE_INT32; - cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; - cfg.minValue = 10; - cfg.maxValue = 50000000; + cfg.minValue = 1; + cfg.maxValue = 100; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); diff --git a/src/common/src/ttypes.c b/src/common/src/ttypes.c index f97a146a1e..a2c16a705f 100644 --- a/src/common/src/ttypes.c +++ b/src/common/src/ttypes.c @@ -32,6 +32,35 @@ const int32_t TYPE_BYTES[11] = { sizeof(VarDataOffsetT) // TSDB_DATA_TYPE_NCHAR }; +static void getStatics_bool(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, + int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { + int8_t *data = (int8_t *)pData; + *min = INT64_MAX; + *max = INT64_MIN; + *minIndex = 0; + *maxIndex = 0; + + ASSERT(numOfRow <= INT16_MAX); + + for (int32_t i = 0; i < numOfRow; ++i) { + if (isNull((char *)&data[i], TSDB_DATA_TYPE_BOOL)) { + (*numOfNull) += 1; + continue; + } + + *sum += data[i]; + if (*min > data[i]) { + *min = data[i]; + *minIndex = i; + } + + if (*max < data[i]) { + *max = data[i]; + *maxIndex = i; + } + } +} + static void getStatics_i8(const TSKEY *primaryKey, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) { int8_t *data = (int8_t *)pData; @@ -131,15 +160,6 @@ static void getStatics_i32(const TSKEY *primaryKey, const void *pData, int32_t n *max = data[i]; *maxIndex = i; } - - // if (isNull(&lastVal, TSDB_DATA_TYPE_INT)) { - // lastKey = primaryKey[i]; - // lastVal = data[i]; - // } else { - // *wsum = lastVal * (primaryKey[i] - lastKey); - // lastKey = primaryKey[i]; - // lastVal = data[i]; - // } } } @@ -279,11 +299,11 @@ static void getStatics_bin(const TSKEY *primaryKey, const void *pData, int32_t n ASSERT(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (isNull((const char*) varDataVal(data), TSDB_DATA_TYPE_BINARY)) { + if (isNull(data, TSDB_DATA_TYPE_BINARY)) { (*numOfNull) += 1; } - data += varDataLen(data); + data += varDataTLen(data); } *sum = 0; @@ -299,11 +319,11 @@ static void getStatics_nchr(const TSKEY *primaryKey, const void *pData, int32_t ASSERT(numOfRow <= INT16_MAX); for (int32_t i = 0; i < numOfRow; ++i) { - if (isNull((const char*) varDataVal(data), TSDB_DATA_TYPE_NCHAR)) { + if (isNull(data, TSDB_DATA_TYPE_NCHAR)) { (*numOfNull) += 1; } - data += varDataLen(data); + data += varDataTLen(data); } *sum = 0; @@ -315,7 +335,7 @@ static void getStatics_nchr(const TSKEY *primaryKey, const void *pData, int32_t tDataTypeDescriptor tDataTypeDesc[11] = { {TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE", NULL, NULL, NULL}, - {TSDB_DATA_TYPE_BOOL, 4, CHAR_BYTES, "BOOL", tsCompressBool, tsDecompressBool, getStatics_i8}, + {TSDB_DATA_TYPE_BOOL, 4, CHAR_BYTES, "BOOL", tsCompressBool, tsDecompressBool, getStatics_bool}, {TSDB_DATA_TYPE_TINYINT, 7, CHAR_BYTES, "TINYINT", tsCompressTinyint, tsDecompressTinyint, getStatics_i8}, {TSDB_DATA_TYPE_SMALLINT, 8, SHORT_BYTES, "SMALLINT", tsCompressSmallint, tsDecompressSmallint, getStatics_i16}, {TSDB_DATA_TYPE_INT, 3, INT_BYTES, "INT", tsCompressInt, tsDecompressInt, getStatics_i32}, diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index 6e81db7db7..9406a2fdce 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -15,17 +15,19 @@ #define _DEFAULT_SOURCE +#include +#include #include #include -#include -#include + +#include "taos.h" #include "taosdef.h" #include "taosmsg.h" +#include "tcq.h" +#include "tdataformat.h" #include "tglobal.h" #include "tlog.h" #include "twal.h" -#include "tcq.h" -#include "taos.h" #define cError(...) { if (cqDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR CQ ", cqDebugFlag, __VA_ARGS__); }} #define cWarn(...) { if (cqDebugFlag & DEBUG_WARN) { taosPrintLog("WARN CQ ", cqDebugFlag, __VA_ARGS__); }} @@ -46,15 +48,14 @@ typedef struct { } SCqContext; typedef struct SCqObj { - int tid; // table ID - int rowSize; // bytes of a row - char *sqlStr; // SQL string - int columns; // number of columns - SSchema *pSchema; // pointer to schema array - void *pStream; - struct SCqObj *prev; - struct SCqObj *next; - SCqContext *pContext; + int tid; // table ID + int rowSize; // bytes of a row + char * sqlStr; // SQL string + STSchema * pSchema; // pointer to schema array + void * pStream; + struct SCqObj *prev; + struct SCqObj *next; + SCqContext * pContext; } SCqObj; int cqDebugFlag = 135; @@ -152,7 +153,7 @@ void cqStop(void *handle) { pthread_mutex_unlock(&pContext->mutex); } -void *cqCreate(void *handle, int tid, char *sqlStr, SSchema *pSchema, int columns) { +void *cqCreate(void *handle, int tid, char *sqlStr, STSchema *pSchema) { SCqContext *pContext = handle; SCqObj *pObj = calloc(sizeof(SCqObj), 1); @@ -162,11 +163,7 @@ void *cqCreate(void *handle, int tid, char *sqlStr, SSchema *pSchema, int column pObj->sqlStr = malloc(strlen(sqlStr)+1); strcpy(pObj->sqlStr, sqlStr); - pObj->columns = columns; - - int size = sizeof(SSchema) * columns; - pObj->pSchema = malloc(size); - memcpy(pObj->pSchema, pSchema, size); + pObj->pSchema = tdDupSchema(pSchema); cTrace("vgId:%d, id:%d CQ:%s is created", pContext->vgId, pObj->tid, pObj->sqlStr); diff --git a/src/cq/test/cqtest.c b/src/cq/test/cqtest.c index 7977bd85bc..3aa649ee34 100644 --- a/src/cq/test/cqtest.c +++ b/src/cq/test/cqtest.c @@ -59,21 +59,16 @@ int main(int argc, char *argv[]) { exit(-1); } - SSchema schema[2]; - schema[0].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(schema[0].name, "ts"); - schema[0].colId = 0; - schema[0].bytes = 8; - - schema[1].type = TSDB_DATA_TYPE_INT; - strcpy(schema[1].name, "avgspeed"); - schema[1].colId = 1; - schema[1].bytes = 4; + STSchema *pSchema = tdNewSchema(2); + tdSchemaAddCol(pSchema, TSDB_DATA_TYPE_TIMESTAMP, 0, 8); + tdSchemaAddCol(pSchema, TSDB_DATA_TYPE_INT, 1, 4); for (int sid =1; sid<10; ++sid) { - cqCreate(pCq, sid, "select avg(speed) from demo.t1 sliding(1s) interval(5s)", schema, 2); + cqCreate(pCq, sid, "select avg(speed) from demo.t1 sliding(1s) interval(5s)", pSchema); } + tdFreeSchema(pSchema); + while (1) { char c = getchar(); diff --git a/src/dnode/inc/dnodeMgmt.h b/src/dnode/inc/dnodeMgmt.h index 4d15dc5a86..826f4ff1c1 100644 --- a/src/dnode/inc/dnodeMgmt.h +++ b/src/dnode/inc/dnodeMgmt.h @@ -22,7 +22,7 @@ extern "C" { int32_t dnodeInitMgmt(); void dnodeCleanupMgmt(); -void dnodeDispatchToDnodeMgmt(SRpcMsg *rpcMsg); +void dnodeDispatchToMgmtQueue(SRpcMsg *rpcMsg); void* dnodeGetVnode(int32_t vgId); int32_t dnodeGetVnodeStatus(void *pVnode); diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index c4a07518ea..7c457defca 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -22,6 +22,7 @@ #include "ttimer.h" #include "tsdb.h" #include "twal.h" +#include "tqueue.h" #include "tsync.h" #include "ttime.h" #include "ttimer.h" @@ -42,10 +43,12 @@ void * tsDnodeTmr = NULL; static void * tsStatusTimer = NULL; static uint32_t tsRebootTime; -static SRpcIpSet tsDMnodeIpSetForPeer = {0}; -static SRpcIpSet tsDMnodeIpSetForShell = {0}; +static SRpcIpSet tsDMnodeIpSet = {0}; static SDMMnodeInfos tsDMnodeInfos = {0}; static SDMDnodeCfg tsDnodeCfg = {0}; +static taos_qset tsMgmtQset = NULL; +static taos_queue tsMgmtQueue = NULL; +static pthread_t tsQthread; static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes); static bool dnodeReadMnodeInfos(); @@ -55,6 +58,7 @@ static bool dnodeReadDnodeCfg(); static void dnodeSaveDnodeCfg(); static void dnodeProcessStatusRsp(SRpcMsg *pMsg); static void dnodeSendStatusMsg(void *handle, void *tmrId); +static void *dnodeProcessMgmtQueue(void *param); static int32_t dnodeOpenVnodes(); static void dnodeCloseVnodes(); @@ -74,52 +78,64 @@ int32_t dnodeInitMgmt() { dnodeReadDnodeCfg(); tsRebootTime = taosGetTimestampSec(); + if (!dnodeReadMnodeInfos()) { + memset(&tsDMnodeIpSet, 0, sizeof(SRpcIpSet)); + memset(&tsDMnodeInfos, 0, sizeof(SDMMnodeInfos)); + + tsDMnodeIpSet.numOfIps = 1; + taosGetFqdnPortFromEp(tsFirst, tsDMnodeIpSet.fqdn[0], &tsDMnodeIpSet.port[0]); + + if (strcmp(tsSecond, tsFirst) != 0) { + tsDMnodeIpSet.numOfIps = 2; + taosGetFqdnPortFromEp(tsSecond, tsDMnodeIpSet.fqdn[1], &tsDMnodeIpSet.port[1]); + } + } else { + tsDMnodeIpSet.inUse = tsDMnodeInfos.inUse; + tsDMnodeIpSet.numOfIps = tsDMnodeInfos.nodeNum; + for (int32_t i = 0; i < tsDMnodeInfos.nodeNum; i++) { + taosGetFqdnPortFromEp(tsDMnodeInfos.nodeInfos[i].nodeEp, tsDMnodeIpSet.fqdn[i], &tsDMnodeIpSet.port[i]); + } + } + + // create the queue and thread to handle the message + tsMgmtQset = taosOpenQset(); + if (tsMgmtQset == NULL) { + dError("failed to create the mgmt queue set"); + dnodeCleanupMgmt(); + return -1; + } + + tsMgmtQueue = taosOpenQueue(); + if (tsMgmtQueue == NULL) { + dError("failed to create the mgmt queue"); + dnodeCleanupMgmt(); + return -1; + } + + taosAddIntoQset(tsMgmtQset, tsMgmtQueue, NULL); + + pthread_attr_t thAttr; + pthread_attr_init(&thAttr); + pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE); + + int32_t code = pthread_create(&tsQthread, &thAttr, dnodeProcessMgmtQueue, NULL); + pthread_attr_destroy(&thAttr); + if (code != 0) { + dError("failed to create thread to process mgmt queue, reason:%s", strerror(errno)); + dnodeCleanupMgmt(); + return -1; + } + + code = dnodeOpenVnodes(); + if (code != TSDB_CODE_SUCCESS) { + dnodeCleanupMgmt(); + return -1; + } + tsDnodeTmr = taosTmrInit(100, 200, 60000, "DND-DM"); if (tsDnodeTmr == NULL) { dError("failed to init dnode timer"); - return -1; - } - - if (!dnodeReadMnodeInfos()) { - memset(&tsDMnodeIpSetForPeer, 0, sizeof(SRpcIpSet)); - memset(&tsDMnodeIpSetForShell, 0, sizeof(SRpcIpSet)); - memset(&tsDMnodeInfos, 0, sizeof(SDMMnodeInfos)); - - tsDMnodeIpSetForPeer.numOfIps = 1; - taosGetFqdnPortFromEp(tsFirst, tsDMnodeIpSetForPeer.fqdn[0], &tsDMnodeIpSetForPeer.port[0]); - tsDMnodeIpSetForPeer.port[0] += TSDB_PORT_DNODEDNODE; - - tsDMnodeIpSetForShell.numOfIps = 1; - taosGetFqdnPortFromEp(tsFirst, tsDMnodeIpSetForShell.fqdn[0], &tsDMnodeIpSetForShell.port[0]); - tsDMnodeIpSetForShell.port[0] += TSDB_PORT_DNODESHELL; - - if (strcmp(tsSecond, tsFirst) != 0) { - tsDMnodeIpSetForPeer.numOfIps = 2; - taosGetFqdnPortFromEp(tsSecond, tsDMnodeIpSetForPeer.fqdn[1], &tsDMnodeIpSetForPeer.port[1]); - tsDMnodeIpSetForPeer.port[1] += TSDB_PORT_DNODEDNODE; - - tsDMnodeIpSetForShell.numOfIps = 2; - taosGetFqdnPortFromEp(tsSecond, tsDMnodeIpSetForShell.fqdn[1], &tsDMnodeIpSetForShell.port[1]); - tsDMnodeIpSetForShell.port[1] += TSDB_PORT_DNODESHELL; - } - } else { - tsDMnodeIpSetForPeer.inUse = tsDMnodeInfos.inUse; - tsDMnodeIpSetForPeer.numOfIps = tsDMnodeInfos.nodeNum; - for (int32_t i = 0; i < tsDMnodeInfos.nodeNum; i++) { - taosGetFqdnPortFromEp(tsDMnodeInfos.nodeInfos[i].nodeEp, tsDMnodeIpSetForPeer.fqdn[i], &tsDMnodeIpSetForPeer.port[i]); - tsDMnodeIpSetForPeer.port[i] += TSDB_PORT_DNODEDNODE; - } - - tsDMnodeIpSetForShell.inUse = tsDMnodeInfos.inUse; - tsDMnodeIpSetForShell.numOfIps = tsDMnodeInfos.nodeNum; - for (int32_t i = 0; i < tsDMnodeInfos.nodeNum; i++) { - taosGetFqdnPortFromEp(tsDMnodeInfos.nodeInfos[i].nodeEp, tsDMnodeIpSetForShell.fqdn[i], &tsDMnodeIpSetForShell.port[i]); - tsDMnodeIpSetForShell.port[i] += TSDB_PORT_DNODESHELL; - } - } - - int32_t code = dnodeOpenVnodes(); - if (code != TSDB_CODE_SUCCESS) { + dnodeCleanupMgmt(); return -1; } @@ -142,22 +158,62 @@ void dnodeCleanupMgmt() { } dnodeCloseVnodes(); + + if (tsMgmtQset) taosQsetThreadResume(tsMgmtQset); + if (tsQthread) pthread_join(tsQthread, NULL); + + if (tsMgmtQueue) taosCloseQueue(tsMgmtQueue); + if (tsMgmtQset) taosCloseQset(tsMgmtQset); + tsMgmtQset = NULL; + tsMgmtQueue = NULL; + } -void dnodeDispatchToDnodeMgmt(SRpcMsg *pMsg) { - SRpcMsg rsp; +void dnodeDispatchToMgmtQueue(SRpcMsg *pMsg) { + void *item; - if (dnodeProcessMgmtMsgFp[pMsg->msgType]) { - rsp.code = (*dnodeProcessMgmtMsgFp[pMsg->msgType])(pMsg); + item = taosAllocateQitem(sizeof(SRpcMsg)); + if (item) { + memcpy(item, pMsg, sizeof(SRpcMsg)); + taosWriteQitem(tsMgmtQueue, 1, item); } else { - rsp.code = TSDB_CODE_MSG_NOT_PROCESSED; + SRpcMsg rsp; + rsp.handle = pMsg->handle; + rsp.pCont = NULL; + rsp.code = TSDB_CODE_SERV_OUT_OF_MEMORY; + rpcSendResponse(&rsp); + rpcFreeCont(pMsg->pCont); + } +} + +static void *dnodeProcessMgmtQueue(void *param) { + SRpcMsg *pMsg; + SRpcMsg rsp; + int type; + void *handle; + + while (1) { + if (taosReadQitemFromQset(tsMgmtQset, &type, (void **) &pMsg, &handle) == 0) { + dTrace("dnode mgmt got no message from qset, exit ..."); + break; + } + + dTrace("%p, msg:%s will be processed", pMsg->ahandle, taosMsg[pMsg->msgType]); + if (dnodeProcessMgmtMsgFp[pMsg->msgType]) { + rsp.code = (*dnodeProcessMgmtMsgFp[pMsg->msgType])(pMsg); + } else { + rsp.code = TSDB_CODE_MSG_NOT_PROCESSED; + } + + rsp.handle = pMsg->handle; + rsp.pCont = NULL; + rpcSendResponse(&rsp); + + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); } - rsp.handle = pMsg->handle; - rsp.pCont = NULL; - rpcSendResponse(&rsp); - - rpcFreeCont(pMsg->pCont); + return NULL; } static int32_t dnodeGetVnodeList(int32_t vnodeList[], int32_t *numOfVnodes) { @@ -284,22 +340,26 @@ static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) { } void dnodeUpdateMnodeIpSetForPeer(SRpcIpSet *pIpSet) { - dPrint("mnode IP list for peer is changed, numOfIps:%d inUse:%d", pIpSet->numOfIps, pIpSet->inUse); + dPrint("mnode IP list for is changed, numOfIps:%d inUse:%d", pIpSet->numOfIps, pIpSet->inUse); for (int i = 0; i < pIpSet->numOfIps; ++i) { + pIpSet->port[i] -= TSDB_PORT_DNODEDNODE; dPrint("mnode index:%d %s:%u", i, pIpSet->fqdn[i], pIpSet->port[i]) } - tsDMnodeIpSetForPeer = *pIpSet; + tsDMnodeIpSet = *pIpSet; } void dnodeGetMnodeIpSetForPeer(void *ipSetRaw) { SRpcIpSet *ipSet = ipSetRaw; - *ipSet = tsDMnodeIpSetForPeer; + *ipSet = tsDMnodeIpSet; + + for (int i=0; inumOfIps; ++i) + ipSet->port[i] += TSDB_PORT_DNODEDNODE; } void dnodeGetMnodeIpSetForShell(void *ipSetRaw) { SRpcIpSet *ipSet = ipSetRaw; - *ipSet = tsDMnodeIpSetForShell; + *ipSet = tsDMnodeIpSet; } static void dnodeProcessStatusRsp(SRpcMsg *pMsg) { @@ -349,19 +409,10 @@ static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes) { dPrint("mnode index:%d, %s", tsDMnodeInfos.nodeInfos[i].nodeId, tsDMnodeInfos.nodeInfos[i].nodeEp); } - tsDMnodeIpSetForPeer.inUse = tsDMnodeInfos.inUse; - tsDMnodeIpSetForPeer.numOfIps = tsDMnodeInfos.nodeNum; + tsDMnodeIpSet.inUse = tsDMnodeInfos.inUse; + tsDMnodeIpSet.numOfIps = tsDMnodeInfos.nodeNum; for (int32_t i = 0; i < tsDMnodeInfos.nodeNum; i++) { - taosGetFqdnPortFromEp(tsDMnodeInfos.nodeInfos[i].nodeEp, tsDMnodeIpSetForPeer.fqdn[i], &tsDMnodeIpSetForPeer.port[i]); - tsDMnodeIpSetForPeer.port[i] += TSDB_PORT_DNODEDNODE; - dPrint("mnode index:%d, for peer %s %d", i, tsDMnodeIpSetForPeer.fqdn[i], tsDMnodeIpSetForPeer.port[i]); - } - - tsDMnodeIpSetForShell.inUse = tsDMnodeInfos.inUse; - tsDMnodeIpSetForShell.numOfIps = tsDMnodeInfos.nodeNum; - for (int32_t i = 0; i < tsDMnodeInfos.nodeNum; i++) { - taosGetFqdnPortFromEp(tsDMnodeInfos.nodeInfos[i].nodeEp, tsDMnodeIpSetForShell.fqdn[i], &tsDMnodeIpSetForShell.port[i]); - dPrint("mnode index:%d, for shell %s %d", i, tsDMnodeIpSetForShell.fqdn[i], tsDMnodeIpSetForShell.port[i]); + taosGetFqdnPortFromEp(tsDMnodeInfos.nodeInfos[i].nodeEp, tsDMnodeIpSet.fqdn[i], &tsDMnodeIpSet.port[i]); } dnodeSaveMnodeInfos(); @@ -369,7 +420,8 @@ static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes) { } static bool dnodeReadMnodeInfos() { - char ipFile[TSDB_FILENAME_LEN] = {0}; + char ipFile[TSDB_FILENAME_LEN*2] = {0}; + sprintf(ipFile, "%s/mnodeIpList.json", tsDnodeDir); FILE *fp = fopen(ipFile, "r"); if (!fp) { @@ -486,7 +538,7 @@ static void dnodeSaveMnodeInfos() { } char *dnodeGetMnodeMasterEp() { - return tsDMnodeInfos.nodeInfos[tsDMnodeIpSetForPeer.inUse].nodeEp; + return tsDMnodeInfos.nodeInfos[tsDMnodeIpSet.inUse].nodeEp; } void* dnodeGetMnodeInfos() { @@ -533,11 +585,14 @@ static void dnodeSendStatusMsg(void *handle, void *tmrId) { .msgType = TSDB_MSG_TYPE_DM_STATUS }; - dnodeSendMsgToDnode(&tsDMnodeIpSetForPeer, &rpcMsg); + SRpcIpSet ipSet; + dnodeGetMnodeIpSetForPeer(&ipSet); + dnodeSendMsgToDnode(&ipSet, &rpcMsg); } static bool dnodeReadDnodeCfg() { - char dnodeCfgFile[TSDB_FILENAME_LEN] = {0}; + char dnodeCfgFile[TSDB_FILENAME_LEN*2] = {0}; + sprintf(dnodeCfgFile, "%s/dnodeCfg.json", tsDnodeDir); FILE *fp = fopen(dnodeCfgFile, "r"); diff --git a/src/dnode/src/dnodePeer.c b/src/dnode/src/dnodePeer.c index 9a7b0837e8..ea3af08d71 100644 --- a/src/dnode/src/dnodePeer.c +++ b/src/dnode/src/dnodePeer.c @@ -43,10 +43,10 @@ int32_t dnodeInitServer() { dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_ALTER_TABLE] = dnodeDispatchToVnodeWriteQueue; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_STABLE] = dnodeDispatchToVnodeWriteQueue; - dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_VNODE] = dnodeDispatchToDnodeMgmt; - dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_VNODE] = dnodeDispatchToDnodeMgmt; - dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_ALTER_STREAM] = dnodeDispatchToDnodeMgmt; - dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeDispatchToDnodeMgmt; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_VNODE] = dnodeDispatchToMgmtQueue; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_VNODE] = dnodeDispatchToMgmtQueue; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_ALTER_STREAM] = dnodeDispatchToMgmtQueue; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeDispatchToMgmtQueue; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_TABLE] = dnodeDispatchToMnodePeerQueue; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = dnodeDispatchToMnodePeerQueue; diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index b875f465c2..b09e14e283 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -84,7 +84,7 @@ int32_t dnodeInitShell() { rpcInit.label = "SHELL"; rpcInit.numOfThreads = numOfThreads; rpcInit.cfp = dnodeProcessMsgFromShell; - rpcInit.sessions = TSDB_SESSIONS_PER_DNODE; + rpcInit.sessions = tsMaxShellConns; rpcInit.connType = TAOS_CONN_SERVER; rpcInit.idleTime = tsShellActivityTimer * 1000; rpcInit.afp = dnodeRetrieveUserAuthInfo; @@ -168,6 +168,44 @@ static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char return rpcRsp.code; } +void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t sid) { + dTrace("vgId:%d, sid:%d send config table msg to mnode", vgId, sid); + + int32_t contLen = sizeof(SDMConfigTableMsg); + SDMConfigTableMsg *pMsg = rpcMallocCont(contLen); + + pMsg->dnodeId = htonl(dnodeGetDnodeId()); + pMsg->vgId = htonl(vgId); + pMsg->sid = htonl(sid); + + SRpcMsg rpcMsg = {0}; + rpcMsg.pCont = pMsg; + rpcMsg.contLen = contLen; + rpcMsg.msgType = TSDB_MSG_TYPE_DM_CONFIG_TABLE; + + SRpcMsg rpcRsp = {0}; + dnodeSendMsgToDnodeRecv(&rpcMsg, &rpcRsp); + terrno = rpcRsp.code; + + if (rpcRsp.code != 0) { + rpcFreeCont(rpcRsp.pCont); + dError("vgId:%d, sid:%d failed to config table from mnode", vgId, sid); + return NULL; + } else { + dPrint("vgId:%d, sid:%d config table msg is received", vgId, sid); + + // delete this after debug finished + SMDCreateTableMsg *pTable = rpcRsp.pCont; + int16_t numOfColumns = htons(pTable->numOfColumns); + int16_t numOfTags = htons(pTable->numOfTags); + int32_t sid = htonl(pTable->sid); + uint64_t uid = htobe64(pTable->uid); + dPrint("table:%s, numOfColumns:%d numOfTags:%d sid:%d uid:%d", pTable->tableId, numOfColumns, numOfTags, sid, uid); + + return rpcRsp.pCont; + } +} + SDnodeStatisInfo dnodeGetStatisInfo() { SDnodeStatisInfo info = {0}; if (dnodeGetRunStatus() == TSDB_DNODE_RUN_STATUS_RUNING) { diff --git a/src/dnode/src/dnodeSystem.c b/src/dnode/src/dnodeSystem.c index a7bfc2d7d2..0f8dabd75a 100644 --- a/src/dnode/src/dnodeSystem.c +++ b/src/dnode/src/dnodeSystem.c @@ -28,8 +28,12 @@ int32_t main(int32_t argc, char *argv[]) { // Set global configuration file for (int32_t i = 1; i < argc; ++i) { if (strcmp(argv[i], "-c") == 0) { - if (i < argc - 1) { - strcpy(configDir, argv[++i]); + if (i < argc - 1) { + if (strlen(argv[++i]) > TSDB_FILENAME_LEN - 1) { + printf("config file path overflow"); + exit(EXIT_FAILURE); + } + strcpy(configDir, argv[i]); } else { printf("'-c' requires a parameter, default:%s\n", configDir); exit(EXIT_FAILURE); diff --git a/src/dnode/src/dnodeVWrite.c b/src/dnode/src/dnodeVWrite.c index bbddfa0927..20c50c5f8c 100644 --- a/src/dnode/src/dnodeVWrite.c +++ b/src/dnode/src/dnodeVWrite.c @@ -129,7 +129,10 @@ void *dnodeAllocateVnodeWqueue(void *pVnode) { if (pWorker->qset == NULL) { pWorker->qset = taosOpenQset(); - if (pWorker->qset == NULL) return NULL; + if (pWorker->qset == NULL) { + taosCloseQueue(queue); + return NULL; + } taosAddIntoQset(pWorker->qset, queue, pVnode); pWorker->qall = taosAllocateQall(); diff --git a/src/inc/dnode.h b/src/inc/dnode.h index 3d3616085d..b561c407a3 100644 --- a/src/inc/dnode.h +++ b/src/inc/dnode.h @@ -44,9 +44,10 @@ void dnodeGetMnodeIpSetForShell(void *ipSet); void * dnodeGetMnodeInfos(); int32_t dnodeGetDnodeId(); -void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); -void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg); -void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp); +void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); +void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg); +void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp); +void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t sid); void *dnodeAllocateVnodeWqueue(void *pVnode); void dnodeFreeVnodeWqueue(void *queue); diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index b2bfe7c590..def30ed8cb 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -293,9 +293,9 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_MAX_COMP_LEVEL 2 #define TSDB_DEFAULT_COMP_LEVEL 2 -#define TSDB_MIN_WAL_LEVEL 0 -#define TSDB_MAX_WAL_LEVEL 2 -#define TSDB_DEFAULT_WAL_LEVEL 2 +#define TSDB_MIN_WAL_LEVEL 1 +#define TSDB_MAX_WAL_LEVEL 2 +#define TSDB_DEFAULT_WAL_LEVEL 1 #define TSDB_MIN_REPLICA_NUM 1 #define TSDB_MAX_REPLICA_NUM 3 @@ -338,9 +338,6 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_ORDER_ASC 1 #define TSDB_ORDER_DESC 2 -#define TSDB_SESSIONS_PER_VNODE (300) -#define TSDB_SESSIONS_PER_DNODE (TSDB_SESSIONS_PER_VNODE * TSDB_MAX_VNODES) - #define TSDB_DEFAULT_MNODES_HASH_SIZE 5 #define TSDB_DEFAULT_DNODES_HASH_SIZE 10 #define TSDB_DEFAULT_ACCOUNTS_HASH_SIZE 10 diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index ca520ff803..db910c9cae 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -72,9 +72,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_NO_RESOURCE, 0, 0x0018, "no resource" TAOS_DEFINE_ERROR(TSDB_CODE_OPS_NOT_SUPPORT, 0, 0x0019, "operations not support") TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_OPTION, 0, 0x001A, "invalid option") TAOS_DEFINE_ERROR(TSDB_CODE_NOT_CONFIGURED, 0, 0x001B, "not configured") -TAOS_DEFINE_ERROR(TSDB_CODE_NODE_OFFLINE, 0, 0x001C, "node offline") -TAOS_DEFINE_ERROR(TSDB_CODE_NETWORK_UNAVAIL, 0, 0x001D, "network unavailable") -TAOS_DEFINE_ERROR(TSDB_CODE_AUTH_REQUIRED, 0, 0x001E, "auth required") +TAOS_DEFINE_ERROR(TSDB_CODE_NETWORK_UNAVAIL, 0, 0x001C, "network unavailable") +TAOS_DEFINE_ERROR(TSDB_CODE_AUTH_REQUIRED, 0, 0x001D, "auth required") // db TAOS_DEFINE_ERROR(TSDB_CODE_DB_NOT_SELECTED, 0, 0x0100, "db not selected") @@ -94,16 +93,13 @@ TAOS_DEFINE_ERROR(TSDB_CODE_NO_USER_FROM_CONN, 0, 0x0185, "can not get TAOS_DEFINE_ERROR(TSDB_CODE_TABLE_ALREADY_EXIST, 0, 0x0200, "table already exist") TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE_ID, 0, 0x0201, "invalid table id") TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE_TYPE, 0, 0x0202, "invalid table typee") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_TABLE, 0, 0x0203, "invalid table name") -TAOS_DEFINE_ERROR(TSDB_CODE_NOT_SUPER_TABLE, 0, 0x0204, "no super table") // operation only available for super table -TAOS_DEFINE_ERROR(TSDB_CODE_NOT_ACTIVE_TABLE, 0, 0x0205, "not active table") -TAOS_DEFINE_ERROR(TSDB_CODE_TABLE_ID_MISMATCH, 0, 0x0206, "table id mismatch") -TAOS_DEFINE_ERROR(TSDB_CODE_TAG_ALREAY_EXIST, 0, 0x0207, "tag already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_TAG_NOT_EXIST, 0, 0x0208, "tag not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_FIELD_ALREAY_EXIST, 0, 0x0209, "field already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_FIELD_NOT_EXIST, 0, 0x020A, "field not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_COL_NAME_TOO_LONG, 0, 0x020B, "column name too long") -TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_TAGS, 0, 0x020C, "too many tags") +TAOS_DEFINE_ERROR(TSDB_CODE_NOT_SUPER_TABLE, 0, 0x0203, "no super table") // operation only available for super table +TAOS_DEFINE_ERROR(TSDB_CODE_TAG_ALREAY_EXIST, 0, 0x0204, "tag already exist") +TAOS_DEFINE_ERROR(TSDB_CODE_TAG_NOT_EXIST, 0, 0x0205, "tag not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_FIELD_ALREAY_EXIST, 0, 0x0206, "field already exist") +TAOS_DEFINE_ERROR(TSDB_CODE_FIELD_NOT_EXIST, 0, 0x0207, "field not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_COL_NAME_TOO_LONG, 0, 0x0209, "column name too long") +TAOS_DEFINE_ERROR(TSDB_CODE_TOO_MANY_TAGS, 0, 0x0209, "too many tags") // dnode & mnode @@ -148,15 +144,13 @@ TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CPU_LIMITED, 0, 0x038F, "grant cpu li // server TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VGROUP_ID, 0, 0x0400, "invalid vgroup id") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VNODE_ID, 0, 0x0401, "invalid vnode id") -TAOS_DEFINE_ERROR(TSDB_CODE_NOT_ACTIVE_VNODE, 0, 0x0402, "not active vnode") -TAOS_DEFINE_ERROR(TSDB_CODE_VG_INIT_FAILED, 0, 0x0403, "vg init failed") -TAOS_DEFINE_ERROR(TSDB_CODE_SERV_NO_DISKSPACE, 0, 0x0404, "server no diskspace") -TAOS_DEFINE_ERROR(TSDB_CODE_SERV_OUT_OF_MEMORY, 0, 0x0405, "server out of memory") -TAOS_DEFINE_ERROR(TSDB_CODE_NO_DISK_PERMISSIONS, 0, 0x0406, "no disk permissions") -TAOS_DEFINE_ERROR(TSDB_CODE_FILE_CORRUPTED, 0, 0x0407, "file corrupted") -TAOS_DEFINE_ERROR(TSDB_CODE_MEMORY_CORRUPTED, 0, 0x0408, "memory corrupted") -TAOS_DEFINE_ERROR(TSDB_CODE_NOT_SUCH_FILE_OR_DIR, 0, 0x0409, "no such file or directory") +TAOS_DEFINE_ERROR(TSDB_CODE_VG_INIT_FAILED, 0, 0x0402, "vgroup init failed") +TAOS_DEFINE_ERROR(TSDB_CODE_SERV_NO_DISKSPACE, 0, 0x0403, "server no diskspace") +TAOS_DEFINE_ERROR(TSDB_CODE_SERV_OUT_OF_MEMORY, 0, 0x0404, "server out of memory") +TAOS_DEFINE_ERROR(TSDB_CODE_NO_DISK_PERMISSIONS, 0, 0x0405, "no disk permissions") +TAOS_DEFINE_ERROR(TSDB_CODE_FILE_CORRUPTED, 0, 0x0406, "file corrupted") +TAOS_DEFINE_ERROR(TSDB_CODE_MEMORY_CORRUPTED, 0, 0x0407, "memory corrupted") +TAOS_DEFINE_ERROR(TSDB_CODE_NOT_SUCH_FILE_OR_DIR, 0, 0x0408, "no such file or directory") // client TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CLIENT_VERSION, 0, 0x0481, "invalid client version") diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 17b975c193..da6d0847ec 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -370,7 +370,7 @@ typedef struct SExprInfo { struct tExprNode* pExpr; int16_t bytes; int16_t type; - int16_t interBytes; + int32_t interBytes; } SExprInfo; typedef struct SColumnFilterInfo { @@ -620,13 +620,6 @@ typedef struct { SCMVgroupInfo vgroups[]; } SVgroupsInfo; -//typedef struct { -// int32_t numOfTables; -// int32_t join; -// int32_t joinCondLen; // for join condition -// int32_t metaElem[TSDB_MAX_JOIN_TABLE_NUM]; -//} SSuperTableMetaMsg; - typedef struct STableMetaMsg { int32_t contLen; char tableId[TSDB_TABLE_ID_LEN + 1]; // table id @@ -676,9 +669,9 @@ typedef struct { } SCMCreateDnodeMsg, SCMDropDnodeMsg; typedef struct { - uint32_t dnode; - int32_t vnode; - int32_t sid; + int32_t dnodeId; + int32_t vgId; + int32_t sid; } SDMConfigTableMsg; typedef struct { diff --git a/src/inc/tcq.h b/src/inc/tcq.h index d0a2097c05..e025afaa0a 100644 --- a/src/inc/tcq.h +++ b/src/inc/tcq.h @@ -19,6 +19,7 @@ extern "C" { #endif +#include "tdataformat.h" typedef int (*FCqWrite)(void *ahandle, void *pHead, int type); @@ -40,7 +41,7 @@ void cqStart(void *handle); void cqStop(void *handle); // cqCreate is called by TSDB to start an instance of CQ -void *cqCreate(void *handle, int sid, char *sqlStr, SSchema *pSchema, int columns); +void *cqCreate(void *handle, int sid, char *sqlStr, STSchema *pSchema); // cqDrop is called by TSDB to stop an instance of CQ, handle is the return value of cqCreate void cqDrop(void *handle); diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index 341dee1476..927b3d08f6 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -43,6 +43,8 @@ typedef struct { void *cqH; int (*notifyStatus)(void *, int status); int (*eventCallBack)(void *); + void *(*cqCreateFunc)(void *handle, int sid, char *sqlStr, STSchema *pSchema); + void (*cqDropFunc)(void *handle); } STsdbAppH; // --------- TSDB REPOSITORY CONFIGURATION DEFINITION @@ -71,7 +73,7 @@ typedef void TsdbRepoT; // use void to hide implementation details from outside int tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg, void *limiter); int32_t tsdbDropRepo(TsdbRepoT *repo); -TsdbRepoT *tsdbOpenRepo(char *tsdbDir, STsdbAppH *pAppH); +TsdbRepoT *tsdbOpenRepo(char *rootDir, STsdbAppH *pAppH); int32_t tsdbCloseRepo(TsdbRepoT *repo, int toCommit); int32_t tsdbConfigRepo(TsdbRepoT *repo, STsdbCfg *pCfg); @@ -198,6 +200,10 @@ TsdbQueryHandleT *tsdbQueryTables(TsdbRepoT *tsdb, STsdbQueryCond *pCond, STable */ TsdbQueryHandleT tsdbQueryLastRow(TsdbRepoT *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupInfo); +SArray* tsdbGetQueriedTableIdList(TsdbQueryHandleT *pHandle); + +TsdbQueryHandleT tsdbQueryRowsInExternalWindow(TsdbRepoT *tsdb, STsdbQueryCond* pCond, STableGroupInfo *groupList); + /** * move to next block if exists * diff --git a/src/kit/shell/src/shellDarwin.c b/src/kit/shell/src/shellDarwin.c index 98ea6510d7..439ca6edad 100644 --- a/src/kit/shell/src/shellDarwin.c +++ b/src/kit/shell/src/shellDarwin.c @@ -96,8 +96,12 @@ void shellParseArgument(int argc, char *argv[], struct arguments *arguments) { exit(EXIT_FAILURE); } } else if (strcmp(argv[i], "-c") == 0) { - if (i < argc - 1) { - strcpy(configDir, argv[++i]); + if (i < argc - 1) { + if (strlen(argv[++i]) > TSDB_FILENAME_LEN - 1) { + fprintf(stderr, "config file path: %s overflow max len %d\n", argv[i], TSDB_FILENAME_LEN - 1); + exit(EXIT_FAILURE); + } + strcpy(configDir, argv[i]); } else { fprintf(stderr, "Option -c requires an argument\n"); exit(EXIT_FAILURE); diff --git a/src/kit/shell/src/shellLinux.c b/src/kit/shell/src/shellLinux.c index b4b74eae3a..7d035126c0 100644 --- a/src/kit/shell/src/shellLinux.c +++ b/src/kit/shell/src/shellLinux.c @@ -80,6 +80,11 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { if (wordexp(arg, &full_path, 0) != 0) { fprintf(stderr, "Invalid path %s\n", arg); return -1; + } + if (strlen(full_path.we_wordv[0]) > TSDB_FILENAME_LEN - 1) { + fprintf(stderr, "config file path: %s overflow max len %d\n", full_path.we_wordv[0], TSDB_FILENAME_LEN - 1); + wordfree(&full_path); + return -1; } strcpy(configDir, full_path.we_wordv[0]); wordfree(&full_path); diff --git a/src/kit/shell/src/shellWindows.c b/src/kit/shell/src/shellWindows.c index 48545f537e..cf96bce5a8 100644 --- a/src/kit/shell/src/shellWindows.c +++ b/src/kit/shell/src/shellWindows.c @@ -76,8 +76,12 @@ void shellParseArgument(int argc, char *argv[], struct arguments *arguments) { exit(EXIT_FAILURE); } } else if (strcmp(argv[i], "-c") == 0) { - if (i < argc - 1) { - strcpy(configDir, argv[++i]); + if (i < argc - 1) { + if (strlen(argv[++i]) > TSDB_FILENAME_LEN - 1) { + fprintf(stderr, "config file path: %s overflow max len %d\n", argv[i], TSDB_FILENAME_LEN - 1); + exit(EXIT_FAILURE); + } + strcpy(configDir, argv[i]); } else { fprintf(stderr, "Option -c requires an argument\n"); exit(EXIT_FAILURE); diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 04194c6127..cf84ecad43 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -49,7 +49,7 @@ static struct argp_option options[] = { {0, 'h', "host", 0, "The host to connect to TDEngine. Default is localhost.", 0}, {0, 'p', "port", 0, "The TCP/IP port number to use for the connection. Default is 0.", 1}, {0, 'u', "user", 0, "The TDEngine user name to use when connecting to the server. Default is 'root'.", 2}, - {0, 'a', "password", 0, "The password to use when connecting to the server. Default is 'taosdata'.", 3}, + {0, 'P', "password", 0, "The password to use when connecting to the server. Default is 'taosdata'.", 3}, {0, 'd', "database", 0, "Destination database. Default is 'test'.", 3}, {0, 'm', "table_prefix", 0, "Table prefix name. Default is 't'.", 3}, {0, 'M', 0, 0, "Use metric flag.", 13}, @@ -58,12 +58,15 @@ static struct argp_option options[] = { {0, 'b', "type_of_cols", 0, "The data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'.", 7}, {0, 'w', "length_of_binary", 0, "The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8", 8}, {0, 'l', "num_of_cols_per_record", 0, "The number of columns per record. Default is 3.", 8}, - {0, 'c', "num_of_conns", 0, "The number of connections. Default is 10.", 9}, + {0, 'T', "num_of_threads", 0, "The number of threads. Default is 10.", 9}, {0, 'r', "num_of_records_per_req", 0, "The number of records per request. Default is 1000.", 10}, {0, 't', "num_of_tables", 0, "The number of tables. Default is 10000.", 11}, {0, 'n', "num_of_records_per_table", 0, "The number of records per table. Default is 100000.", 12}, - {0, 'f', "config_directory", 0, "Configuration directory. Default is '/etc/taos/'.", 14}, + {0, 'c', "config_directory", 0, "Configuration directory. Default is '/etc/taos/'.", 14}, {0, 'x', 0, 0, "Insert only flag.", 13}, + {0, 'O', "order", 0, "Insert mode--0: In order, 1: Out of order. Default is in order.", 14}, + {0, 'R', "rate", 0, "Out of order data's rate--if order=1 Default 10, min: 0, max: 50.", 14}, + {0, 'D', "delete table", 0, "Delete data methods——0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database", 14}, {0}}; /* Used by main to communicate with parse_opt. */ @@ -81,11 +84,14 @@ typedef struct DemoArguments { char *datatype[MAX_NUM_DATATYPE]; int len_of_binary; int num_of_CPR; - int num_of_connections; + int num_of_threads; int num_of_RPR; int num_of_tables; int num_of_DPT; int abort; + int order; + int rate; + int method_of_delete; char **arg_list; } SDemoArguments; @@ -106,7 +112,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { case 'u': arguments->user = arg; break; - case 'a': + case 'P': arguments->password = arg; break; case 'o': @@ -115,8 +121,8 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { case 'q': arguments->mode = atoi(arg); break; - case 'c': - arguments->num_of_connections = atoi(arg); + case 'T': + arguments->num_of_threads = atoi(arg); break; case 'r': arguments->num_of_RPR = atoi(arg); @@ -176,7 +182,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { case 'x': arguments->insert_only = true; break; - case 'f': + case 'c': if (wordexp(arg, &full_path, 0) != 0) { fprintf(stderr, "Invalid path %s\n", arg); return -1; @@ -184,6 +190,30 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { taos_options(TSDB_OPTION_CONFIGDIR, full_path.we_wordv[0]); wordfree(&full_path); break; + case 'O': + arguments->order = atoi(arg); + if (arguments->order > 1 || arguments->order < 0) + { + arguments->order = 0; + } else if (arguments->order == 1) + { + arguments->rate = 10; + } + break; + case 'R': + arguments->rate = atoi(arg); + if (arguments->order == 1 && (arguments->rate > 50 || arguments->rate <= 0)) + { + arguments->rate = 10; + } + break; + case 'D': + arguments->method_of_delete = atoi(arg); + if (arguments->method_of_delete < 0 || arguments->method_of_delete > 3) + { + arguments->method_of_delete = 0; + } + break; case OPT_ABORT: arguments->abort = 1; break; @@ -217,6 +247,8 @@ typedef struct { int ncols_per_record; int nrecords_per_table; int nrecords_per_request; + int data_of_order; + int data_of_rate; int64_t start_time; bool do_aggreFunc; @@ -236,6 +268,8 @@ typedef struct { int ncols_per_record; char **data_type; int len_of_binary; + int data_of_order; + int data_of_rate; sem_t *mutex_sem; int *notFinished; @@ -258,6 +292,8 @@ void *readMetric(void *sarg); void *syncWrite(void *sarg); +void *deleteTable(); + void *asyncWrite(void *sarg); void generateData(char *res, char **data_type, int num_of_cols, int64_t timestamp, int len_of_binary); @@ -291,11 +327,14 @@ int main(int argc, char *argv[]) { }, 8, // len_of_binary 1, // num_of_CPR - 1, // num_of_connections + 1, // num_of_connections/thread 1, // num_of_RPR 1, // num_of_tables 50000, // num_of_DPT 0, // abort + 0, // order + 0, // rate + 0, // method_of_delete NULL // arg_list }; @@ -304,7 +343,7 @@ int main(int argc, char *argv[]) { // For demo use, change default values for some parameters; arguments.num_of_tables = 10000; arguments.num_of_CPR = 3; - arguments.num_of_connections = 10; + arguments.num_of_threads = 10; arguments.num_of_DPT = 100000; arguments.num_of_RPR = 1000; arguments.use_metric = true; @@ -330,8 +369,11 @@ int main(int argc, char *argv[]) { char *tb_prefix = arguments.tb_prefix; int len_of_binary = arguments.len_of_binary; int ncols_per_record = arguments.num_of_CPR; + int order = arguments.order; + int rate = arguments.rate; + int method_of_delete = arguments.method_of_delete; int ntables = arguments.num_of_tables; - int nconnections = arguments.num_of_connections; + int threads = arguments.num_of_threads; int nrecords_per_table = arguments.num_of_DPT; int nrecords_per_request = arguments.num_of_RPR; bool use_metric = arguments.use_metric; @@ -371,12 +413,19 @@ int main(int argc, char *argv[]) { 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 Threads: %d\n", threads); 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); + if (order == 1) + { + printf("# Data order: %d\n", order); + printf("# Data out of order rate: %d\n", rate); + + } + printf("# Delete method: %d\n", method_of_delete); 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"); @@ -392,12 +441,18 @@ int main(int argc, char *argv[]) { fprintf(fp, "# Binary Length(If applicable): %d\n", (strcasestr(dataString, "BINARY") != NULL) ? len_of_binary : -1); fprintf(fp, "# Number of Columns per record: %d\n", ncols_per_record); - fprintf(fp, "# Number of Connections: %d\n", nconnections); + fprintf(fp, "# Number of Threads: %d\n", threads); fprintf(fp, "# Number of Tables: %d\n", ntables); fprintf(fp, "# Number of Data per Table: %d\n", nrecords_per_table); fprintf(fp, "# Records/Request: %d\n", nrecords_per_request); fprintf(fp, "# Database name: %s\n", db_name); fprintf(fp, "# Table prefix: %s\n", tb_prefix); + if (order == 1) + { + printf("# Data order: %d\n", order); + printf("# Data out of order rate: %d\n", rate); + + } fprintf(fp, "# 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); fprintf(fp, "###################################################################\n\n"); @@ -414,7 +469,7 @@ int main(int argc, char *argv[]) { sprintf(command, "drop database %s;", db_name); taos_query(taos, command); - sleep(3); + sprintf(command, "create database %s;", db_name); taos_query(taos, command); @@ -479,22 +534,22 @@ int main(int argc, char *argv[]) { taos_close(taos); } /* Wait for table to create */ - sleep(5); + /* Insert data */ double ts = getCurrentTime(); printf("Inserting data......\n"); - pthread_t *pids = malloc(nconnections * sizeof(pthread_t)); - info *infos = malloc(nconnections * sizeof(info)); + pthread_t *pids = malloc(threads * sizeof(pthread_t)); + info *infos = malloc(threads * sizeof(info)); - int a = ntables / nconnections; + int a = ntables / threads; if (a < 1) { - nconnections = ntables; + threads = ntables; a = 1; } - int b = ntables % nconnections; + int b = ntables % threads; int last = 0; - for (int i = 0; i < nconnections; i++) { + for (int i = 0; i < threads; i++) { info *t_info = infos + i; t_info->threadID = i; strcpy(t_info->db_name, db_name); @@ -507,6 +562,8 @@ int main(int argc, char *argv[]) { t_info->len_of_binary = len_of_binary; t_info->nrecords_per_request = nrecords_per_request; t_info->start_table_id = last; + t_info->data_of_order = order; + t_info->data_of_rate = rate; t_info->end_table_id = i < b ? last + a : last + a - 1; last = t_info->end_table_id + 1; @@ -520,15 +577,15 @@ int main(int argc, char *argv[]) { pthread_create(pids + i, NULL, asyncWrite, t_info); } } - for (int i = 0; i < nconnections; i++) { + for (int i = 0; i < threads; i++) { pthread_join(pids[i], NULL); } double t = getCurrentTime() - ts; if (query_mode == SYNC) { - printf("SYNC Insert with %d connections:\n", nconnections); + printf("SYNC Insert with %d connections:\n", threads); } else { - printf("ASYNC Insert with %d connections:\n", nconnections); + printf("ASYNC Insert with %d connections:\n", threads); } fprintf(fp, "|%10.d | %10.2f | %10.2f | %10.4f |\n\n", @@ -540,7 +597,7 @@ int main(int argc, char *argv[]) { t, ntables * nrecords_per_table, nrecords_per_request, ntables * nrecords_per_table / t); - for (int i = 0; i < nconnections; i++) { + for (int i = 0; i < threads; i++) { info *t_info = infos + i; taos_close(t_info->taos); sem_destroy(&(t_info->mutex_sem)); @@ -551,6 +608,55 @@ int main(int argc, char *argv[]) { free(infos); fclose(fp); + if (method_of_delete != 0) + { + TAOS *dtaos = taos_connect(ip_addr, user, pass, db_name, port); + double dts = getCurrentTime(); + printf("Deleteing %d table(s)......\n", ntables); + + switch (method_of_delete) + { + case 1: + // delete by table + /* Create all the tables; */ + for (int i = 0; i < ntables; i++) { + sprintf(command, "drop table %s.%s%d;", db_name, tb_prefix, i); + queryDB(dtaos, command); + } + break; + case 2: + // delete by stable + if (!use_metric) { + break; + } + else + { + sprintf(command, "drop table %s.meters;", db_name); + queryDB(dtaos, command); + } + break; + case 3: + // delete by database + sprintf(command, "drop database %s;", db_name); + queryDB(dtaos, command); + break; + default: + break; + } + + printf("Table(s) droped!\n"); + taos_close(dtaos); + + double dt = getCurrentTime() - dts; + printf("Spent %.4f seconds to drop %d tables\n", dt, ntables); + + FILE *fp = fopen(arguments.output_file, "a"); + fprintf(fp, "Spent %.4f seconds to drop %d tables\n", dt, ntables); + fclose(fp); + + } + + if (!insert_only) { // query data pthread_t read_id; @@ -735,7 +841,15 @@ void *syncWrite(void *sarg) { pstr += sprintf(pstr, "insert into %s.%s%d values", winfo->db_name, winfo->tb_prefix, tID); int k; for (k = 0; k < winfo->nrecords_per_request;) { - generateData(data, data_type, ncols_per_record, tmp_time++, len_of_binary); + int rand_num = rand() % 100; + if (winfo->data_of_order ==1 && rand_num < winfo->data_of_rate) + { + long d = tmp_time - rand() % 1000000 + rand_num; + generateData(data, data_type, ncols_per_record, d, len_of_binary); + } else + { + generateData(data, data_type, ncols_per_record, tmp_time += 1000, len_of_binary); + } pstr += sprintf(pstr, " %s", data); inserted++; k++; @@ -774,6 +888,8 @@ void *asyncWrite(void *sarg) { tb_info->mutex_sem = &(winfo->mutex_sem); tb_info->notFinished = &(winfo->notFinished); tb_info->lock_sem = &(winfo->lock_sem); + tb_info->data_of_order = winfo->data_of_order; + tb_info->data_of_rate = winfo->data_of_rate; /* char buff[BUFFER_SIZE] = "\0"; */ /* sprintf(buff, "insert into %s values (0, 0)", tb_info->tb_name); */ @@ -815,7 +931,15 @@ void callBack(void *param, TAOS_RES *res, int code) { pstr += sprintf(pstr, "insert into %s values", tb_info->tb_name); for (int i = 0; i < tb_info->nrecords_per_request; i++) { - generateData(data, datatype, ncols_per_record, tmp_time++, len_of_binary); + int rand_num = rand() % 100; + if (tb_info->data_of_order ==1 && rand_num < tb_info->data_of_rate) + { + long d = tmp_time - rand() % 1000000 + rand_num; + generateData(data, datatype, ncols_per_record, d, len_of_binary); + } else + { + generateData(data, datatype, ncols_per_record, tmp_time += 1000, len_of_binary); + } pstr += sprintf(pstr, "%s", data); tb_info->counter++; diff --git a/src/mnode/inc/mnodeDef.h b/src/mnode/inc/mnodeDef.h index aacf8f419f..594fd3fd50 100644 --- a/src/mnode/inc/mnodeDef.h +++ b/src/mnode/inc/mnodeDef.h @@ -220,6 +220,7 @@ typedef struct SAcctObj { typedef struct { int8_t type; + int32_t index; char db[TSDB_DB_NAME_LEN + 1]; void * pIter; int16_t numOfColumns; @@ -228,7 +229,6 @@ typedef struct { int32_t numOfReads; int16_t offset[TSDB_MAX_COLUMNS]; int16_t bytes[TSDB_MAX_COLUMNS]; - void * signature; uint16_t payloadLen; char payload[]; } SShowObj; diff --git a/src/mnode/inc/mnodeDnode.h b/src/mnode/inc/mnodeDnode.h index 2b12a29390..f95a163d83 100644 --- a/src/mnode/inc/mnodeDnode.h +++ b/src/mnode/inc/mnodeDnode.h @@ -27,6 +27,12 @@ typedef enum { TAOS_DN_STATUS_READY } EDnodeStatus; +typedef enum { + TAOS_DN_ALTERNATIVE_ROLE_ANY, + TAOS_DN_ALTERNATIVE_ROLE_MNODE, + TAOS_DN_ALTERNATIVE_ROLE_VNODE +} EDnodeAlternativeRole; + int32_t mnodeInitDnodes(); void mnodeCleanupDnodes(); diff --git a/src/mnode/inc/mnodeVgroup.h b/src/mnode/inc/mnodeVgroup.h index ac8eb73296..d61145d9b8 100644 --- a/src/mnode/inc/mnodeVgroup.h +++ b/src/mnode/inc/mnodeVgroup.h @@ -27,7 +27,8 @@ void mnodeCleanupVgroups(); SVgObj *mnodeGetVgroup(int32_t vgId); void mnodeIncVgroupRef(SVgObj *pVgroup); void mnodeDecVgroupRef(SVgObj *pVgroup); -void mnodeDropAllDbVgroups(SDbObj *pDropDb, bool sendMsg); +void mnodeDropAllDbVgroups(SDbObj *pDropDb); +void mnodeSendDropAllDbVgroupsMsg(SDbObj *pDropDb); void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode); void mnodeUpdateAllDbVgroups(SDbObj *pAlterDb); diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index b904e06e97..23e903dd25 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -81,10 +81,10 @@ static int32_t mnodeDbActionDelete(SSdbOper *pOper) { SDbObj *pDb = pOper->pObj; SAcctObj *pAcct = mnodeGetAcct(pDb->acct); - mnodeDropDbFromAcct(pAcct, pDb); mnodeDropAllChildTables(pDb); mnodeDropAllSuperTables(pDb); - mnodeDropAllDbVgroups(pDb, false); + mnodeDropAllDbVgroups(pDb); + mnodeDropDbFromAcct(pAcct, pDb); mnodeDecAcctRef(pAcct); return TSDB_CODE_SUCCESS; @@ -276,8 +276,8 @@ static int32_t mnodeCheckDbCfg(SDbCfg *pCfg) { return TSDB_CODE_INVALID_OPTION; } - if (pCfg->replications > 1 && pCfg->walLevel <= TSDB_MIN_WAL_LEVEL) { - mError("invalid db option walLevel:%d must > 0, while replica:%d > 1", pCfg->walLevel, pCfg->replications); + if (pCfg->walLevel < TSDB_MIN_WAL_LEVEL) { + mError("invalid db option walLevel:%d must be greater than 0", pCfg->walLevel); return TSDB_CODE_INVALID_OPTION; } @@ -871,8 +871,8 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) { mTrace("db:%s, replications:%d change to %d", pDb->name, pDb->cfg.replications, replications); newCfg.replications = replications; - if (replications > 1 && pDb->cfg.walLevel <= TSDB_MIN_WAL_LEVEL) { - mError("db:%s, walLevel:%d must > 0, while replica:%d > 1", pDb->name, pDb->cfg.walLevel, replications); + if (pDb->cfg.walLevel < TSDB_MIN_WAL_LEVEL) { + mError("db:%s, walLevel:%d must be greater than 0", pDb->name, pDb->cfg.walLevel); terrno = TSDB_CODE_INVALID_OPTION; } @@ -998,19 +998,7 @@ static int32_t mnodeProcessDropDbMsg(SMnodeMsg *pMsg) { return code; } -#if 1 - mnodeDropAllDbVgroups(pMsg->pDb, true); -#else - SVgObj *pVgroup = pMsg->pDb->pHead; - if (pVgroup != NULL) { - mPrint("vgId:%d, will be dropped", pVgroup->vgId); - SMnodeMsg *newMsg = mnodeCloneMsg(pMsg); - newMsg->ahandle = pVgroup; - newMsg->expected = pVgroup->numOfVnodes; - mnodeDropVgroup(pVgroup, newMsg); - return; - } -#endif + mnodeSendDropAllDbVgroupsMsg(pMsg->pDb); mTrace("db:%s, all vgroups is dropped", pMsg->pDb->name); return mnodeDropDb(pMsg); diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index 5aaa2049f1..506511ece9 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -58,6 +58,7 @@ static int32_t mnodeGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC static int32_t mnodeRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn); static int32_t mnodeGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn); static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, void *pConn); +static char* mnodeGetDnodeAlternativeRoleStr(int32_t alternativeRole); static int32_t mnodeDnodeActionDestroy(SSdbOper *pOper) { tfree(pOper->pObj); @@ -521,6 +522,12 @@ static int32_t mnodeGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; + pShow->bytes[cols] = 6 + VARSTR_HEADER_SIZE; + pSchema[cols].type = TSDB_DATA_TYPE_BINARY; + strcpy(pSchema[cols].name, "alternativeRole"); + pSchema[cols].bytes = htons(pShow->bytes[cols]); + cols++; + pShow->bytes[cols] = 8; pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; strcpy(pSchema[cols].name, "create_time"); @@ -572,12 +579,16 @@ static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, vo *(int16_t *)pWrite = pDnode->totalVnodes; cols++; - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; char* status = mnodeGetDnodeStatusStr(pDnode->status); STR_TO_VARSTR(pWrite, status); cols++; + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + char* role = mnodeGetDnodeAlternativeRoleStr(pDnode->alternativeRole); + STR_TO_VARSTR(pWrite, role); + cols++; + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; *(int64_t *)pWrite = pDnode->createdTime; cols++; @@ -895,3 +906,13 @@ char* mnodeGetDnodeStatusStr(int32_t dnodeStatus) { default: return "undefined"; } } + +static char* mnodeGetDnodeAlternativeRoleStr(int32_t alternativeRole) { + switch (alternativeRole) { + case TAOS_DN_ALTERNATIVE_ROLE_ANY: return "any"; + case TAOS_DN_ALTERNATIVE_ROLE_MNODE: return "mnode"; + case TAOS_DN_ALTERNATIVE_ROLE_VNODE: return "vnode"; + default:return "any"; + } +} + diff --git a/src/mnode/src/mnodeMain.c b/src/mnode/src/mnodeMain.c index ac11947757..baecfac077 100644 --- a/src/mnode/src/mnodeMain.c +++ b/src/mnode/src/mnodeMain.c @@ -160,7 +160,7 @@ void mnodeStopSystem() { static void mnodeInitTimer() { if (tsMnodeTmr == NULL) { - tsMnodeTmr = taosTmrInit((tsMaxShellConns)*3, 200, 3600000, "MND"); + tsMnodeTmr = taosTmrInit(tsMaxShellConns, 200, 3600000, "MND"); } } @@ -185,4 +185,4 @@ static bool mnodeNeedStart() { bool mnodeIsRunning() { return tsMgmtIsRunning; -} \ No newline at end of file +} diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index 3fdb1b0dfe..6638fba53b 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -358,8 +358,8 @@ void sdbIncRef(void *handle, void *pObj) { SSdbTable *pTable = handle; 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("add ref to table:%s record:%s:%d", pTable->tableName, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); + if (0 && (pTable->tableId == SDB_TABLE_CTABLE || pTable->tableId == SDB_TABLE_DB)) { + sdbTrace("add ref to table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); } } @@ -369,13 +369,13 @@ void sdbDecRef(void *handle, void *pObj) { SSdbTable *pTable = handle; 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("def ref of table:%s record:%s:%d", pTable->tableName, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); + if (0 && (pTable->tableId == SDB_TABLE_CTABLE || pTable->tableId == SDB_TABLE_DB)) { + sdbTrace("def ref of table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); } int8_t *updateEnd = pObj + pTable->refCountPos - 1; if (refCount <= 0 && *updateEnd) { - sdbTrace("table:%s, record:%s:%d is destroyed", pTable->tableName, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); + sdbTrace("table:%s, record:%p:%s:%d is destroyed", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); SSdbOper oper = {.pObj = pObj}; (*pTable->destroyFp)(&oper); } diff --git a/src/mnode/src/mnodeShow.c b/src/mnode/src/mnodeShow.c index 0973163cf9..20616bfbcd 100644 --- a/src/mnode/src/mnodeShow.c +++ b/src/mnode/src/mnodeShow.c @@ -47,13 +47,14 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *mnodeMsg); static int32_t mnodeProcessUseMsg(SMnodeMsg *mnodeMsg); static void mnodeFreeShowObj(void *data); -static bool mnodeCheckShowObj(SShowObj *pShow); +static bool mnodeAccquireShowObj(SShowObj *pShow); static bool mnodeCheckShowFinished(SShowObj *pShow); -static void *mnodeSaveShowObj(SShowObj *pShow, int32_t size); -static void mnodeCleanupShowObj(void *pShow, bool forceRemove); +static void *mnodePutShowObj(SShowObj *pShow, int32_t size); +static void mnodeReleaseShowObj(void *pShow, bool forceRemove); extern void *tsMnodeTmr; -static void *tsQhandleCache = NULL; +static void *tsMnodeShowCache = NULL; +static int32_t tsShowObjIndex = 0; static SShowMetaFp tsMnodeShowMetaFp[TSDB_MGMT_TABLE_MAX] = {0}; static SShowRetrieveFp tsMnodeShowRetrieveFp[TSDB_MGMT_TABLE_MAX] = {0}; @@ -64,14 +65,15 @@ int32_t mnodeInitShow() { mnodeAddReadMsgHandle(TSDB_MSG_TYPE_CM_CONNECT, mnodeProcessConnectMsg); mnodeAddReadMsgHandle(TSDB_MSG_TYPE_CM_USE_DB, mnodeProcessUseMsg); - tsQhandleCache = taosCacheInitWithCb(tsMnodeTmr, 10, mnodeFreeShowObj); + tsMnodeShowCache = taosCacheInitWithCb(tsMnodeTmr, 10, mnodeFreeShowObj); return 0; } void mnodeCleanUpShow() { - if (tsQhandleCache != NULL) { - taosCacheCleanup(tsQhandleCache); - tsQhandleCache = NULL; + if (tsMnodeShowCache != NULL) { + mPrint("show cache is cleanup"); + taosCacheCleanup(tsMnodeShowCache); + tsMnodeShowCache = NULL; } } @@ -116,35 +118,37 @@ static int32_t mnodeProcessShowMsg(SMnodeMsg *pMsg) { return TSDB_CODE_OPS_NOT_SUPPORT; } - int32_t size = sizeof(SCMShowRsp) + sizeof(SSchema) * TSDB_MAX_COLUMNS + TSDB_EXTRA_PAYLOAD_SIZE; - SCMShowRsp *pShowRsp = rpcMallocCont(size); - if (pShowRsp == NULL) { - return TSDB_CODE_SERV_OUT_OF_MEMORY; - } - int32_t showObjSize = sizeof(SShowObj) + htons(pShowMsg->payloadLen); SShowObj *pShow = (SShowObj *) calloc(1, showObjSize); - pShow->signature = pShow; pShow->type = pShowMsg->type; pShow->payloadLen = htons(pShowMsg->payloadLen); strcpy(pShow->db, pShowMsg->db); memcpy(pShow->payload, pShowMsg->payload, pShow->payloadLen); - pShow = mnodeSaveShowObj(pShow, showObjSize); - if (pShow == NULL) { + pShow = mnodePutShowObj(pShow, showObjSize); + if (pShow == NULL) { + return TSDB_CODE_SERV_OUT_OF_MEMORY; + } + + int32_t size = sizeof(SCMShowRsp) + sizeof(SSchema) * TSDB_MAX_COLUMNS + TSDB_EXTRA_PAYLOAD_SIZE; + SCMShowRsp *pShowRsp = rpcMallocCont(size); + if (pShowRsp == NULL) { + mnodeReleaseShowObj(pShow, true); return TSDB_CODE_SERV_OUT_OF_MEMORY; } pShowRsp->qhandle = htobe64((uint64_t) pShow); - mTrace("show:%p, type:%s, start to get meta", pShow, mnodeGetShowType(pShowMsg->type)); + mTrace("%p, show type:%s, start to get meta", pShow, mnodeGetShowType(pShowMsg->type)); int32_t code = (*tsMnodeShowMetaFp[pShowMsg->type])(&pShowRsp->tableMeta, pShow, pMsg->rpcMsg.handle); if (code == 0) { pMsg->rpcRsp.rsp = pShowRsp; pMsg->rpcRsp.len = sizeof(SCMShowRsp) + sizeof(SSchema) * pShow->numOfColumns; + mnodeReleaseShowObj(pShow, false); return TSDB_CODE_SUCCESS; } else { - mError("show:%p, type:%s, failed to get meta, reason:%s", pShow, mnodeGetShowType(pShowMsg->type), tstrerror(code)); - mnodeCleanupShowObj(pShow, true); + mError("%p, show type:%s, failed to get meta, reason:%s", pShow, mnodeGetShowType(pShowMsg->type), tstrerror(code)); + rpcFreeCont(pShowRsp); + mnodeReleaseShowObj(pShow, true); return code; } } @@ -157,22 +161,20 @@ static int32_t mnodeProcessRetrieveMsg(SMnodeMsg *pMsg) { pRetrieve->qhandle = htobe64(pRetrieve->qhandle); SShowObj *pShow = (SShowObj *)pRetrieve->qhandle; - mTrace("show:%p, type:%s, retrieve data", pShow, mnodeGetShowType(pShow->type)); + mTrace("%p, show type:%s, retrieve data", pShow, mnodeGetShowType(pShow->type)); /* * in case of server restart, apps may hold qhandle created by server before * restart, which is actually invalid, therefore, signature check is required. */ - if (!mnodeCheckShowObj(pShow)) { - mError("retrieve:%p, qhandle:%p is invalid", pRetrieve, pShow); + if (!mnodeAccquireShowObj(pShow)) { + mError("%p, show is invalid", pShow); return TSDB_CODE_INVALID_QHANDLE; } if (mnodeCheckShowFinished(pShow)) { - mTrace("retrieve:%p, qhandle:%p already read finished, numOfReads:%d numOfRows:%d", pRetrieve, pShow, pShow->numOfReads, pShow->numOfRows); + mTrace("%p, show is already read finished, numOfReads:%d numOfRows:%d", pShow, pShow->numOfReads, pShow->numOfRows); pShow->numOfReads = pShow->numOfRows; - //mnodeCleanupShowObj(pShow, true); - //return TSDB_CODE_SUCCESS; } if ((pRetrieve->free & TSDB_QUERY_TYPE_FREE_RESOURCE) != TSDB_QUERY_TYPE_FREE_RESOURCE) { @@ -198,7 +200,7 @@ static int32_t mnodeProcessRetrieveMsg(SMnodeMsg *pMsg) { if (rowsRead < 0) { rpcFreeCont(pRsp); - mnodeCleanupShowObj(pShow, false); + mnodeReleaseShowObj(pShow, false); assert(false); return TSDB_CODE_ACTION_IN_PROGRESS; } @@ -209,12 +211,13 @@ static int32_t mnodeProcessRetrieveMsg(SMnodeMsg *pMsg) { pMsg->rpcRsp.rsp = pRsp; pMsg->rpcRsp.len = size; - if (rowsToRead == 0) { - mnodeCleanupShowObj(pShow, true); + if (rowsToRead == 0 || rowsRead == rowsToRead) { + pRsp->completed = 1; + mnodeReleaseShowObj(pShow, true); } else { - mnodeCleanupShowObj(pShow, false); + mnodeReleaseShowObj(pShow, false); } - + return TSDB_CODE_SUCCESS; } @@ -316,24 +319,29 @@ static bool mnodeCheckShowFinished(SShowObj *pShow) { return false; } -static bool mnodeCheckShowObj(SShowObj *pShow) { - SShowObj *pSaved = taosCacheAcquireByData(tsQhandleCache, pShow); +static bool mnodeAccquireShowObj(SShowObj *pShow) { + char key[10]; + sprintf(key, "%d", pShow->index); + + SShowObj *pSaved = taosCacheAcquireByName(tsMnodeShowCache, key); if (pSaved == pShow) { + mTrace("%p, show is accquired from cache", pShow); return true; } else { - mTrace("show:%p, is already released", pShow); return false; } } -static void *mnodeSaveShowObj(SShowObj *pShow, int32_t size) { - if (tsQhandleCache != NULL) { - char key[24]; - sprintf(key, "show:%p", pShow); - SShowObj *newQhandle = taosCachePut(tsQhandleCache, key, pShow, size, 60); +static void *mnodePutShowObj(SShowObj *pShow, int32_t size) { + if (tsMnodeShowCache != NULL) { + char key[10]; + pShow->index = atomic_add_fetch_32(&tsShowObjIndex, 1); + sprintf(key, "%d", pShow->index); + + SShowObj *newQhandle = taosCachePut(tsMnodeShowCache, key, pShow, size, 60); free(pShow); - mTrace("show:%p, is saved", newQhandle); + mTrace("%p, show is put into cache", newQhandle); return newQhandle; } @@ -343,10 +351,10 @@ static void *mnodeSaveShowObj(SShowObj *pShow, int32_t size) { static void mnodeFreeShowObj(void *data) { SShowObj *pShow = data; sdbFreeIter(pShow->pIter); - mTrace("show:%p, is destroyed", pShow); + mTrace("%p, show is destroyed", pShow); } -static void mnodeCleanupShowObj(void *pShow, bool forceRemove) { - mTrace("show:%p, is released, force:%s", pShow, forceRemove ? "true" : "false"); - taosCacheRelease(tsQhandleCache, &pShow, forceRemove); +static void mnodeReleaseShowObj(void *pShow, bool forceRemove) { + mTrace("%p, show is released, force:%s", pShow, forceRemove ? "true" : "false"); + taosCacheRelease(tsMnodeShowCache, &pShow, forceRemove); } diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 92ab990da4..84a1f659d5 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -148,37 +148,30 @@ static int32_t mnodeChildTableActionDelete(SSdbOper *pOper) { return TSDB_CODE_INVALID_VGROUP_ID; } - SVgObj *pVgroup = mnodeGetVgroup(pTable->vgId); - if (pVgroup == NULL) { - return TSDB_CODE_INVALID_VGROUP_ID; - } - mnodeDecVgroupRef(pVgroup); - - SDbObj *pDb = mnodeGetDb(pVgroup->dbName); - if (pDb == NULL) { - mError("ctable:%s, vgId:%d not in DB:%s", pTable->info.tableId, pVgroup->vgId, pVgroup->dbName); - return TSDB_CODE_INVALID_DB; - } - mnodeDecDbRef(pDb); - - SAcctObj *pAcct = mnodeGetAcct(pDb->acct); - if (pAcct == NULL) { - mError("ctable:%s, acct:%s not exists", pTable->info.tableId, pDb->acct); - return TSDB_CODE_INVALID_ACCT; - } - mnodeDecAcctRef(pAcct); + SVgObj *pVgroup = NULL; + SDbObj *pDb = NULL; + SAcctObj *pAcct = NULL; + + pVgroup = mnodeGetVgroup(pTable->vgId); + if (pVgroup != NULL) pDb = mnodeGetDb(pVgroup->dbName); + if (pDb != NULL) pAcct = mnodeGetAcct(pDb->acct); if (pTable->info.type == TSDB_CHILD_TABLE) { grantRestore(TSDB_GRANT_TIMESERIES, pTable->superTable->numOfColumns - 1); - pAcct->acctInfo.numOfTimeSeries -= (pTable->superTable->numOfColumns - 1); + if (pAcct != NULL) pAcct->acctInfo.numOfTimeSeries -= (pTable->superTable->numOfColumns - 1); mnodeRemoveTableFromStable(pTable->superTable, pTable); mnodeDecTableRef(pTable->superTable); } else { grantRestore(TSDB_GRANT_TIMESERIES, pTable->numOfColumns - 1); - pAcct->acctInfo.numOfTimeSeries -= (pTable->numOfColumns - 1); + if (pAcct != NULL) pAcct->acctInfo.numOfTimeSeries -= (pTable->numOfColumns - 1); } - mnodeRemoveTableFromDb(pDb); - mnodeRemoveTableFromVgroup(pVgroup, pTable); + + if (pDb != NULL) mnodeRemoveTableFromDb(pDb); + if (pVgroup != NULL) mnodeRemoveTableFromVgroup(pVgroup, pTable); + + mnodeDecVgroupRef(pVgroup); + mnodeDecDbRef(pDb); + mnodeDecAcctRef(pAcct); return TSDB_CODE_SUCCESS; } @@ -484,7 +477,10 @@ static int32_t mnodeSuperTableActionDecode(SSdbOper *pOper) { if (pStable == NULL) return TSDB_CODE_SERV_OUT_OF_MEMORY; int32_t len = strlen(pOper->rowData); - if (len > TSDB_TABLE_ID_LEN) return TSDB_CODE_INVALID_TABLE_ID; + if (len > TSDB_TABLE_ID_LEN){ + free(pStable); + return TSDB_CODE_INVALID_TABLE_ID; + } pStable->info.tableId = strdup(pOper->rowData); len++; @@ -690,10 +686,10 @@ static int32_t mnodeProcessCreateTableMsg(SMnodeMsg *pMsg) { } if (pCreate->numOfTags != 0) { - mTrace("table:%s, create msg is received from thandle:%p", pCreate->tableId, pMsg->rpcMsg.handle); + mTrace("table:%s, create stable msg is received from thandle:%p", pCreate->tableId, pMsg->rpcMsg.handle); return mnodeProcessCreateSuperTableMsg(pMsg); } else { - mTrace("table:%s, create msg is received from thandle:%p", pCreate->tableId, pMsg->rpcMsg.handle); + mTrace("table:%s, create ctable msg is received from thandle:%p", pCreate->tableId, pMsg->rpcMsg.handle); return mnodeProcessCreateChildTableMsg(pMsg); } } @@ -718,7 +714,7 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) { return TSDB_CODE_SUCCESS; } else { mError("table:%s, failed to drop table, table not exist", pDrop->tableId); - return TSDB_CODE_INVALID_TABLE; + return TSDB_CODE_INVALID_TABLE_ID; } } @@ -746,7 +742,7 @@ static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *pMsg) { if (pMsg->pTable == NULL) { if (!pInfo->createFlag) { mError("table:%s, failed to get table meta, table not exist", pInfo->tableId); - return TSDB_CODE_INVALID_TABLE; + return TSDB_CODE_INVALID_TABLE_ID; } else { mTrace("table:%s, failed to get table meta, start auto create table ", pInfo->tableId); return mnodeAutoCreateChildTable(pMsg); @@ -783,7 +779,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) { if (pStable->schema == NULL) { free(pStable); mError("table:%s, failed to create, no schema input", pCreate->tableId); - return TSDB_CODE_INVALID_TABLE; + return TSDB_CODE_INVALID_TABLE_ID; } memcpy(pStable->schema, pCreate->schema, numOfCols * sizeof(SSchema)); @@ -1273,9 +1269,9 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) { for (int32_t i = 0; i < numOfTable; ++i) { char *stableName = (char*)pInfo + sizeof(SCMSTableVgroupMsg) + (TSDB_TABLE_ID_LEN) * i; SSuperTableObj *pTable = mnodeGetSuperTable(stableName); - if (pTable->vgHash != NULL) { + if (pTable != NULL && pTable->vgHash != NULL) { contLen += (taosHashGetSize(pTable->vgHash) * sizeof(SCMVgroupInfo) + sizeof(SVgroupsInfo)); - } + } mnodeDecTableRef(pTable); } @@ -1284,12 +1280,23 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) { return TSDB_CODE_SERV_OUT_OF_MEMORY; } - pRsp->numOfTables = htonl(numOfTable); - char* msg = (char*) pRsp + sizeof(SCMSTableVgroupRspMsg); + pRsp->numOfTables = 0; + char *msg = (char *)pRsp + sizeof(SCMSTableVgroupRspMsg); for (int32_t i = 0; i < numOfTable; ++i) { char *stableName = (char*)pInfo + sizeof(SCMSTableVgroupMsg) + (TSDB_TABLE_ID_LEN) * i; SSuperTableObj *pTable = mnodeGetSuperTable(stableName); + if (pTable == NULL) { + mError("stable:%s, not exist while get stable vgroup info", stableName); + mnodeDecTableRef(pTable); + continue; + } + if (pTable->vgHash == NULL) { + mError("stable:%s, not vgroup exist while get stable vgroup info", stableName); + mnodeDecTableRef(pTable); + continue; + } + SVgroupsInfo *pVgroupInfo = (SVgroupsInfo *)msg; SHashMutableIterator *pIter = taosHashCreateIter(pTable->vgHash); @@ -1315,17 +1322,25 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) { } taosHashDestroyIter(pIter); + mnodeDecTableRef(pTable); pVgroupInfo->numOfVgroups = htonl(vgSize); // one table is done, try the next table msg += sizeof(SVgroupsInfo) + vgSize * sizeof(SCMVgroupInfo); + pRsp->numOfTables++; } - pMsg->rpcRsp.rsp = pRsp; - pMsg->rpcRsp.len = msg - (char *)pRsp; + if (pRsp->numOfTables != numOfTable) { + rpcFreeCont(pRsp); + return TSDB_CODE_INVALID_TABLE_ID; + } else { + pRsp->numOfTables = htonl(pRsp->numOfTables); + pMsg->rpcRsp.rsp = pRsp; + pMsg->rpcRsp.len = msg - (char *)pRsp; - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; + } } static void mnodeProcessDropSuperTableRsp(SRpcMsg *rpcMsg) { @@ -1426,8 +1441,8 @@ static SChildTableObj* mnodeDoCreateChildTable(SCMCreateTableMsg *pCreate, SVgOb SSuperTableObj *pSuperTable = mnodeGetSuperTable(pTagData->name); if (pSuperTable == NULL) { mError("table:%s, corresponding super table:%s does not exist", pCreate->tableId, pTagData->name); - free(pTable); - terrno = TSDB_CODE_INVALID_TABLE; + mnodeDestroyChildTable(pTable); + terrno = TSDB_CODE_INVALID_TABLE_ID; return NULL; } mnodeDecTableRef(pSuperTable); @@ -1735,7 +1750,7 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) { static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) { SCMTableInfoMsg *pInfo = pMsg->rpcMsg.pCont; - STagData* pTag = (STagData*)pInfo->tags; + STagData *pTag = (STagData *)pInfo->tags; int32_t contLen = sizeof(SCMCreateTableMsg) + offsetof(STagData, data) + ntohl(pTag->dataLen); SCMCreateTableMsg *pCreateMsg = rpcMallocCont(contLen); @@ -1751,14 +1766,13 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) { pCreateMsg->contLen = htonl(contLen); memcpy(pCreateMsg->schema, pInfo->tags, contLen - sizeof(SCMCreateTableMsg)); + mTrace("table:%s, start to create on demand, stable:%s", pInfo->tableId, ((STagData *)(pCreateMsg->schema))->name); rpcFreeCont(pMsg->rpcMsg.pCont); pMsg->rpcMsg.msgType = TSDB_MSG_TYPE_CM_CREATE_TABLE; pMsg->rpcMsg.pCont = pCreateMsg; pMsg->rpcMsg.contLen = contLen; - - mTrace("table:%s, start to create on demand, stable:%s", pInfo->tableId, pInfo->tags); - + return TSDB_CODE_ACTION_NEED_REPROCESSED; } @@ -1877,38 +1891,25 @@ static SChildTableObj* mnodeGetTableByPos(int32_t vnode, int32_t sid) { static int32_t mnodeProcessTableCfgMsg(SMnodeMsg *pMsg) { SDMConfigTableMsg *pCfg = pMsg->rpcMsg.pCont; - pCfg->dnode = htonl(pCfg->dnode); - pCfg->vnode = htonl(pCfg->vnode); - pCfg->sid = htonl(pCfg->sid); - mTrace("dnode:%s, vnode:%d, sid:%d, receive table config msg", taosIpStr(pCfg->dnode), pCfg->vnode, pCfg->sid); + pCfg->dnodeId = htonl(pCfg->dnodeId); + pCfg->vgId = htonl(pCfg->vgId); + pCfg->sid = htonl(pCfg->sid); + mTrace("dnode:%d, vgId:%d sid:%d, receive table config msg", pCfg->dnodeId, pCfg->vgId, pCfg->sid); - SChildTableObj *pTable = mnodeGetTableByPos(pCfg->vnode, pCfg->sid); + SChildTableObj *pTable = mnodeGetTableByPos(pCfg->vgId, pCfg->sid); if (pTable == NULL) { - mError("dnode:%s, vnode:%d, sid:%d, table not found", taosIpStr(pCfg->dnode), pCfg->vnode, pCfg->sid); - return TSDB_CODE_NOT_ACTIVE_TABLE; + mError("dnode:%d, vgId:%d sid:%d, table not found", pCfg->dnodeId, pCfg->vgId, pCfg->sid); + return TSDB_CODE_INVALID_TABLE_ID; } - SMDCreateTableMsg *pMDCreate = NULL; - pMDCreate = mnodeBuildCreateChildTableMsg(NULL, (SChildTableObj *)pTable); - if (pMDCreate == NULL) { - mnodeDecTableRef(pTable); - return terrno; - } - - SDnodeObj *pDnode = mnodeGetDnode(pCfg->dnode); - SRpcIpSet ipSet = mnodeGetIpSetFromIp(pDnode->dnodeEp); - SRpcMsg rpcRsp = { - .handle = NULL, - .pCont = pMDCreate, - .contLen = htonl(pMDCreate->contLen), - .code = 0, - .msgType = TSDB_MSG_TYPE_MD_CREATE_TABLE - }; - dnodeSendMsgToDnode(&ipSet, &rpcRsp); - + SMDCreateTableMsg *pCreate = NULL; + pCreate = mnodeBuildCreateChildTableMsg(NULL, (SChildTableObj *)pTable); mnodeDecTableRef(pTable); - mnodeDecDnodeRef(pDnode); - + + if (pCreate == NULL) return terrno; + + pMsg->rpcRsp.rsp = pCreate; + pMsg->rpcRsp.len = htonl(pCreate->contLen); return TSDB_CODE_SUCCESS; } @@ -1926,7 +1927,6 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) { if (rpcMsg->code != TSDB_CODE_SUCCESS) { mError("table:%s, failed to drop in dnode, reason:%s", pTable->info.tableId, tstrerror(rpcMsg->code)); dnodeSendRpcMnodeWriteRsp(mnodeMsg, rpcMsg->code); - mnodeDecTableRef(pTable); return; } @@ -2210,7 +2210,7 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) { if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pAlter->tableId); if (pMsg->pTable == NULL) { mError("table:%s, failed to alter table, table not exist", pMsg->pTable->tableId); - return TSDB_CODE_INVALID_TABLE; + return TSDB_CODE_INVALID_TABLE_ID; } pAlter->type = htons(pAlter->type); @@ -2369,4 +2369,4 @@ static int32_t mnodeRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, v mnodeDecDbRef(pDb); return numOfRows; -} \ No newline at end of file +} diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index c8ff6566b6..9c24f7eaf3 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -716,14 +716,14 @@ static int32_t mnodeProcessVnodeCfgMsg(SMnodeMsg *pMsg) { SDnodeObj *pDnode = mnodeGetDnode(pCfg->dnodeId); if (pDnode == NULL) { mTrace("dnode:%s, invalid dnode", taosIpStr(pCfg->dnodeId), pCfg->vgId); - return TSDB_CODE_NOT_ACTIVE_VNODE; + return TSDB_CODE_INVALID_VGROUP_ID; } mnodeDecDnodeRef(pDnode); SVgObj *pVgroup = mnodeGetVgroup(pCfg->vgId); if (pVgroup == NULL) { mTrace("dnode:%s, vgId:%d, no vgroup info", taosIpStr(pCfg->dnodeId), pCfg->vgId); - return TSDB_CODE_NOT_ACTIVE_VNODE; + return TSDB_CODE_INVALID_VGROUP_ID; } mnodeDecVgroupRef(pVgroup); @@ -784,7 +784,7 @@ void mnodeUpdateAllDbVgroups(SDbObj *pAlterDb) { mPrint("db:%s, all vgroups is updated in sdb", pAlterDb->name); } -void mnodeDropAllDbVgroups(SDbObj *pDropDb, bool sendMsg) { +void mnodeDropAllDbVgroups(SDbObj *pDropDb) { void * pIter = NULL; int32_t numOfVgroups = 0; SVgObj *pVgroup = NULL; @@ -802,10 +802,6 @@ void mnodeDropAllDbVgroups(SDbObj *pDropDb, bool sendMsg) { }; sdbDeleteRow(&oper); numOfVgroups++; - - if (sendMsg) { - mnodeSendDropVgroupMsg(pVgroup, NULL); - } } mnodeDecVgroupRef(pVgroup); @@ -815,3 +811,25 @@ void mnodeDropAllDbVgroups(SDbObj *pDropDb, bool sendMsg) { mPrint("db:%s, all vgroups:%d is dropped from sdb", pDropDb->name, numOfVgroups); } + +void mnodeSendDropAllDbVgroupsMsg(SDbObj *pDropDb) { + void * pIter = NULL; + int32_t numOfVgroups = 0; + SVgObj *pVgroup = NULL; + + mPrint("db:%s, all vgroups will be dropped in dnode", pDropDb->name); + while (1) { + pIter = mnodeGetNextVgroup(pIter, &pVgroup); + if (pVgroup == NULL) break; + + if (pVgroup->pDb == pDropDb) { + mnodeSendDropVgroupMsg(pVgroup, NULL); + } + + mnodeDecVgroupRef(pVgroup); + } + + sdbFreeIter(pIter); + + mPrint("db:%s, all vgroups:%d drop msg is sent to dnode", pDropDb->name, numOfVgroups); +} \ No newline at end of file diff --git a/src/plugins/http/src/httpJson.c b/src/plugins/http/src/httpJson.c index cbca19b57f..74e3c409a1 100644 --- a/src/plugins/http/src/httpJson.c +++ b/src/plugins/http/src/httpJson.c @@ -445,10 +445,10 @@ void httpJsonPairStatus(JsonBuf* buf, int code) { httpJsonItemToken(buf); if (code == TSDB_CODE_DB_NOT_SELECTED) { httpJsonPair(buf, "desc", 4, "failed to create database", 23); - } else if (code == TSDB_CODE_INVALID_TABLE) { + } else if (code == TSDB_CODE_INVALID_TABLE_ID) { httpJsonPair(buf, "desc", 4, "failed to create table", 22); } else httpJsonPair(buf, "desc", 4, (char*)tstrerror(code), (int)strlen(tstrerror(code))); } } -} \ No newline at end of file +} diff --git a/src/plugins/http/src/tgHandle.c b/src/plugins/http/src/tgHandle.c index 1a55c325d5..61f9da6368 100644 --- a/src/plugins/http/src/tgHandle.c +++ b/src/plugins/http/src/tgHandle.c @@ -281,7 +281,7 @@ int tgReadSchema(char *fileName) { } void tgInitHandle(HttpServer *pServer) { - char fileName[256] = {0}; + char fileName[TSDB_FILENAME_LEN*2] = {0}; sprintf(fileName, "%s/taos.telegraf.cfg", configDir); if (tgReadSchema(fileName) <= 0) { tgFreeSchemas(); diff --git a/src/plugins/http/src/tgJson.c b/src/plugins/http/src/tgJson.c index cb9c42e792..27059010b8 100644 --- a/src/plugins/http/src/tgJson.c +++ b/src/plugins/http/src/tgJson.c @@ -111,7 +111,7 @@ bool tgCheckFinished(struct HttpContext *pContext, HttpSqlCmd *cmd, int code) { pContext->ipstr); return false; } - } else if (code == TSDB_CODE_INVALID_TABLE) { + } else if (code == TSDB_CODE_INVALID_TABLE_ID) { cmd->cmdState = HTTP_CMD_STATE_RUN_FINISHED; if (multiCmds->cmds[multiCmds->pos - 1].cmdState == HTTP_CMD_STATE_NOT_RUN_YET) { multiCmds->pos = (int16_t)(multiCmds->pos - 2); @@ -151,4 +151,4 @@ void tgSetNextCmd(struct HttpContext *pContext, HttpSqlCmd *cmd, int code) { } else { multiCmds->pos++; } -} \ No newline at end of file +} diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index 0996b643d1..09ac1b6cd7 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -28,21 +28,16 @@ #include "tsdb.h" #include "tsqlfunction.h" -//typedef struct tFilePage { -// int64_t num; -// char data[]; -//} tFilePage; - struct SColumnFilterElem; typedef bool (*__filter_func_t)(struct SColumnFilterElem* pFilter, char* val1, char* val2); typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order); typedef struct SSqlGroupbyExpr { - int16_t tableIndex; - SArray* columnInfo; // SArray, group by columns information - int16_t numOfGroupCols; - int16_t orderIndex; // order by column index - int16_t orderType; // order by type: asc/desc + int16_t tableIndex; + SArray* columnInfo; // SArray, group by columns information + int16_t numOfGroupCols; + int16_t orderIndex; // order by column index + int16_t orderType; // order by type: asc/desc } SSqlGroupbyExpr; typedef struct SPosInfo { @@ -62,25 +57,27 @@ typedef struct SWindowResult { SWindowStatus status; // this result status: closed or opened } SWindowResult; +/** + * If the number of generated results is greater than this value, + * query query will be halt and return results to client immediate. + */ typedef struct SResultRec { - int64_t total; // total generated result size in rows - int64_t rows; // current result set size in rows - int64_t capacity; // capacity of current result output buffer - - // result size threshold in rows. If the result buffer is larger than this, pause query and return to client - int32_t threshold; + int64_t total; // total generated result size in rows + int64_t rows; // current result set size in rows + int64_t capacity; // capacity of current result output buffer + int32_t threshold; // result size threshold in rows. } SResultRec; typedef struct SWindowResInfo { SWindowResult* pResult; // result list - void* hashList; // hash list for quick access + SHashObj* hashList; // hash list for quick access int16_t type; // data type for hash key int32_t capacity; // max capacity int32_t curIndex; // current start active index int32_t size; // number of result set int64_t startTime; // start time of the first time window for sliding query int64_t prevSKey; // previous (not completed) sliding window start key - int64_t threshold; // threshold to pausing query and return closed results. + int64_t threshold; // threshold to halt query and return the generated results. } SWindowResInfo; typedef struct SColumnFilterElem { @@ -90,98 +87,111 @@ typedef struct SColumnFilterElem { } SColumnFilterElem; typedef struct SSingleColumnFilterInfo { - SColumnInfo info; - int32_t numOfFilters; - SColumnFilterElem* pFilters; void* pData; + int32_t numOfFilters; + SColumnInfo info; + SColumnFilterElem* pFilters; } SSingleColumnFilterInfo; typedef struct STableQueryInfo { // todo merge with the STableQueryInfo struct int32_t tableIndex; - int32_t groupIdx; // group id in table list + int32_t groupIndex; // group id in table list TSKEY lastKey; int32_t numOfRes; int16_t queryRangeSet; // denote if the query range is set, only available for interval query int64_t tag; STimeWindow win; STSCursor cur; - STableId id; // for retrieve the page id list - + STableId id; // for retrieve the page id list + SWindowResInfo windowResInfo; } STableQueryInfo; -typedef struct SQueryCostSummary { -} SQueryCostSummary; +typedef struct SQueryCostInfo { + uint64_t loadStatisTime; + uint64_t loadFileBlockTime; + uint64_t loadDataInCacheTime; + uint64_t loadStatisSize; + uint64_t loadFileBlockSize; + uint64_t loadDataInCacheSize; + + uint64_t loadDataTime; + uint64_t dataInRows; + uint64_t checkRows; + uint32_t dataBlocks; + uint32_t loadBlockStatis; + uint32_t discardBlocks; +} SQueryCostInfo; typedef struct SGroupItem { - STableId id; + STableId id; STableQueryInfo* info; } SGroupItem; typedef struct SQuery { - int16_t numOfCols; - int16_t numOfTags; - - SOrderVal order; - STimeWindow window; - int64_t intervalTime; - int64_t slidingTime; // sliding time for sliding window query - char slidingTimeUnit; // interval data type, used for daytime revise - int8_t precision; - int16_t numOfOutput; - int16_t fillType; - int16_t checkBuffer; // check if the buffer is full during scan each block - SLimitVal limit; - int32_t rowSize; - SSqlGroupbyExpr* pGroupbyExpr; - SExprInfo* pSelectExpr; - SColumnInfo* colList; - SColumnInfo* tagColList; - int32_t numOfFilterCols; - int64_t* fillVal; - uint32_t status; // query status - SResultRec rec; - int32_t pos; - tFilePage** sdata; - STableQueryInfo* current; + int16_t numOfCols; + int16_t numOfTags; + SOrderVal order; + STimeWindow window; + int64_t intervalTime; + int64_t slidingTime; // sliding time for sliding window query + char slidingTimeUnit; // interval data type, used for daytime revise + int8_t precision; + int16_t numOfOutput; + int16_t fillType; + int16_t checkBuffer; // check if the buffer is full during scan each block + SLimitVal limit; + int32_t rowSize; + SSqlGroupbyExpr* pGroupbyExpr; + SExprInfo* pSelectExpr; + SColumnInfo* colList; + SColumnInfo* tagColList; + int32_t numOfFilterCols; + int64_t* fillVal; + uint32_t status; // query status + SResultRec rec; + int32_t pos; + tFilePage** sdata; + STableQueryInfo* current; + SSingleColumnFilterInfo* pFilterInfo; } SQuery; typedef struct SQueryRuntimeEnv { - SResultInfo* resultInfo; // todo refactor to merge with SWindowResInfo - SQuery* pQuery; - SQLFunctionCtx* pCtx; - int16_t numOfRowsPerPage; - int16_t offset[TSDB_MAX_COLUMNS]; - uint16_t scanFlag; // denotes reversed scan of data or not - SFillInfo* pFillInfo; - SWindowResInfo windowResInfo; - STSBuf* pTSBuf; - STSCursor cur; - SQueryCostSummary summary; - bool stableQuery; // super table query or not - void* pQueryHandle; - void* pSecQueryHandle; // another thread for - SDiskbasedResultBuf* pResultBuf; // query result buffer based on blocked-wised disk file + SResultInfo* resultInfo; // todo refactor to merge with SWindowResInfo + SQuery* pQuery; + SQLFunctionCtx* pCtx; + int16_t numOfRowsPerPage; + int16_t offset[TSDB_MAX_COLUMNS]; + uint16_t scanFlag; // denotes reversed scan of data or not + SFillInfo* pFillInfo; + SWindowResInfo windowResInfo; + STSBuf* pTSBuf; + STSCursor cur; + SQueryCostInfo summary; + bool stableQuery; // super table query or not + void* pQueryHandle; + void* pSecQueryHandle; // another thread for + SDiskbasedResultBuf* pResultBuf; // query result buffer based on blocked-wised disk file } SQueryRuntimeEnv; typedef struct SQInfo { - void* signature; - TSKEY startTime; - TSKEY elapsedTime; - int32_t pointsInterpo; - int32_t code; // error code to returned to client - sem_t dataReady; - void* tsdb; - int32_t vgId; - + void* signature; + TSKEY startTime; + TSKEY elapsedTime; + int32_t pointsInterpo; + int32_t code; // error code to returned to client + sem_t dataReady; + void* tsdb; + int32_t vgId; + STableGroupInfo tableIdGroupInfo; // table id list < only includes the STableId list> STableGroupInfo groupInfo; // SQueryRuntimeEnv runtimeEnv; int32_t groupIndex; - int32_t offset; // offset in group result set of subgroup, todo refactor + int32_t offset; // offset in group result set of subgroup, todo refactor SArray* arrTableIdInfo; - + T_REF_DECLARE() /* * the query is executed position on which meter of the whole list. @@ -189,8 +199,8 @@ typedef struct SQInfo { * We later may refactor to remove this attribution by using another flag to denote * whether a multimeter query is completed or not. */ - int32_t tableIndex; - int32_t numOfGroupResultPages; + int32_t tableIndex; + int32_t numOfGroupResultPages; } SQInfo; #endif // TDENGINE_QUERYEXECUTOR_H diff --git a/src/query/inc/qextbuffer.h b/src/query/inc/qextbuffer.h index 0d608f1f1b..9721687110 100644 --- a/src/query/inc/qextbuffer.h +++ b/src/query/inc/qextbuffer.h @@ -28,8 +28,7 @@ extern "C" { #include "tdataformat.h" #include "talgo.h" -#define DEFAULT_PAGE_SIZE 16384 // 16k larger than the SHistoInfo -#define MIN_BUFFER_SIZE (1 << 19) +#define DEFAULT_PAGE_SIZE (1024L*56) // 16k larger than the SHistoInfo #define MAX_TMPFILE_PATH_LENGTH PATH_MAX #define INITIAL_ALLOCATION_BUFFER_SIZE 64 diff --git a/src/query/inc/qfill.h b/src/query/inc/qfill.h index 323ff7a812..9ea9c8f7cf 100644 --- a/src/query/inc/qfill.h +++ b/src/query/inc/qfill.h @@ -45,12 +45,13 @@ typedef struct SFillInfo { int32_t numOfCols; // number of columns, including the tags columns int32_t rowSize; // size of each row char ** pTags; // tags value for current interpolation - - int64_t slidingTime; // sliding value to determine the number of result for a given time window + int64_t slidingTime; // sliding value to determine the number of result for a given time window char * prevValues; // previous row of data, to generate the interpolation results char * nextValues; // next row of data + char** pData; // original result data block involved in filling data + int32_t capacityInRows; // data buffer size in rows + SFillColInfo* pFillCol; // column info for fill operations - char** pData; // original result data block involved in filling data } SFillInfo; typedef struct SPoint { diff --git a/src/query/inc/qresultBuf.h b/src/query/inc/qresultBuf.h index 2e813dbd98..1375594210 100644 --- a/src/query/inc/qresultBuf.h +++ b/src/query/inc/qresultBuf.h @@ -44,6 +44,8 @@ typedef struct SDiskbasedResultBuf { SIDList* list; // for each id, there is a page id list } SDiskbasedResultBuf; +#define DEFAULT_INTERN_BUF_PAGE_SIZE (8192L*5) + /** * create disk-based result buffer * @param pResultBuf diff --git a/src/query/inc/tsqlfunction.h b/src/query/inc/tsqlfunction.h index 6e591b28d2..22d126f7a2 100644 --- a/src/query/inc/tsqlfunction.h +++ b/src/query/inc/tsqlfunction.h @@ -161,26 +161,24 @@ typedef struct SExtTagsInfo { // sql function runtime context typedef struct SQLFunctionCtx { - int32_t startOffset; - int32_t size; // number of rows - uint32_t order; // asc|desc - uint32_t scanFlag; // TODO merge with currentStage - - int16_t inputType; - int16_t inputBytes; - - int16_t outputType; - int16_t outputBytes; // size of results, determined by function and input column data type - bool hasNull; // null value exist in current block - int16_t functionId; // function id - void * aInputElemBuf; - char * aOutputBuf; // final result output buffer, point to sdata->data - uint8_t currentStage; // record current running step, default: 0 - int64_t nStartQueryTimestamp; // timestamp range of current query when function is executed on a specific data block - int32_t numOfParams; - tVariant param[4]; // input parameter, e.g., top(k, 20), the number of results for top query is kept in param */ - int64_t *ptsList; // corresponding timestamp array list - void * ptsOutputBuf; // corresponding output buffer for timestamp of each result, e.g., top/bottom*/ + int32_t startOffset; + int32_t size; // number of rows + uint32_t order; // asc|desc + int16_t inputType; + int16_t inputBytes; + + int16_t outputType; + int16_t outputBytes; // size of results, determined by function and input column data type + bool hasNull; // null value exist in current block + int16_t functionId; // function id + void * aInputElemBuf; + char * aOutputBuf; // final result output buffer, point to sdata->data + uint8_t currentStage; // record current running step, default: 0 + int64_t nStartQueryTimestamp; // timestamp range of current query when function is executed on a specific data block + int32_t numOfParams; + tVariant param[4]; // input parameter, e.g., top(k, 20), the number of results for top query is kept in param */ + int64_t * ptsList; // corresponding timestamp array list + void * ptsOutputBuf; // corresponding output buffer for timestamp of each result, e.g., top/bottom*/ SQLPreAggVal preAggVals; tVariant tag; SResultInfo *resultInfo; @@ -219,7 +217,7 @@ typedef struct SQLAggFuncElem { #define GET_RES_INFO(ctx) ((ctx)->resultInfo) int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionId, int32_t param, int16_t *type, - int16_t *len, int16_t *interBytes, int16_t extLength, bool isSuperTable); + int16_t *len, int32_t *interBytes, int16_t extLength, bool isSuperTable); #define IS_STREAM_QUERY_VALID(x) (((x)&TSDB_FUNCSTATE_STREAM) != 0) #define IS_MULTIOUTPUT(x) (((x)&TSDB_FUNCSTATE_MO) != 0) @@ -239,7 +237,7 @@ enum { /* determine the real data need to calculated the result */ enum { BLK_DATA_NO_NEEDED = 0x0, - BLK_DATA_FILEDS_NEEDED = 0x1, + BLK_DATA_STATIS_NEEDED = 0x1, BLK_DATA_ALL_NEEDED = 0x3, }; @@ -269,9 +267,6 @@ extern struct SQLAggFuncElem aAggs[]; /* compatible check array list */ extern int32_t funcCompatDefList[]; -void getStatistics(char *priData, char *data, int32_t size, int32_t numOfRow, int32_t type, int64_t *min, int64_t *max, - int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int32_t *numOfNull); - bool top_bot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, char *minval, char *maxval); bool stableQueryFunctChanged(int32_t funcId); diff --git a/src/query/inc/tvariant.h b/src/query/inc/tvariant.h index c235f5317d..4fd6ea5541 100644 --- a/src/query/inc/tvariant.h +++ b/src/query/inc/tvariant.h @@ -48,7 +48,7 @@ void tVariantAssign(tVariant *pDst, const tVariant *pSrc); int32_t tVariantToString(tVariant *pVar, char *dst); -int32_t tVariantDump(tVariant *pVariant, char *payload, char type); +int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix); int32_t tVariantTypeSetType(tVariant *pVariant, char type); diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 72d018d315..b487c790a9 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include +#include "qfill.h" #include "os.h" #include "hash.h" @@ -30,8 +30,6 @@ #include "tscompression.h" #include "ttime.h" -#define DEFAULT_INTERN_BUF_SIZE 16384L - /** * check if the primary column is load by default, otherwise, the program will * forced to load primary column explicitly. @@ -55,13 +53,7 @@ ((query)->colList[(query)->pSelectExpr[colidx].base.colInfo.colIndex].bytes) #define GET_COLUMN_TYPE(query, colidx) ((query)->colList[(query)->pSelectExpr[colidx].base.colInfo.colIndex].type) -typedef struct SPointInterpoSupporter { - int32_t numOfCols; - SArray* prev; - SArray* next; -} SPointInterpoSupporter; - -typedef enum { +enum { // when query starts to execute, this status will set QUERY_NOT_COMPLETED = 0x1u, @@ -80,11 +72,11 @@ typedef enum { * usually used in case of interval query with interpolation option */ QUERY_OVER = 0x8u, -} vnodeQueryStatus; +}; enum { - TS_JOIN_TS_EQUAL = 0, - TS_JOIN_TS_NOT_EQUALS = 1, + TS_JOIN_TS_EQUAL = 0, + TS_JOIN_TS_NOT_EQUALS = 1, TS_JOIN_TAG_NOT_EQUALS = 2, }; @@ -110,8 +102,9 @@ static void resetMergeResultBuf(SQuery *pQuery, SQLFunctionCtx *pCtx, SResultInf static bool functionNeedToExecute(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx *pCtx, int32_t functionId); static void getNextTimeWindow(SQuery *pQuery, STimeWindow *pTimeWindow); -static void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* pData, TSKEY *tsCol, SDataBlockInfo* pBlockInfo, - int32_t functionId, SDataStatis *pStatis, bool hasNull, void *param, int32_t scanFlag); +static void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, TSKEY *tsCol, SDataBlockInfo* pBlockInfo, + SDataStatis *pStatis, void *param, int32_t colIndex); + static void initCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv); static void destroyTableQueryInfo(STableQueryInfo *pTableQueryInfo, int32_t numOfCols); static void resetCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv); @@ -121,111 +114,6 @@ static void buildTagQueryResult(SQInfo *pQInfo); static int32_t setAdditionalInfo(SQInfo *pQInfo, STableId *pTableId, STableQueryInfo *pTableQueryInfo); static int32_t flushFromResultBuf(SQInfo *pQInfo); -bool getNeighborPoints(SQInfo *pQInfo, void *pMeterObj, SPointInterpoSupporter *pPointInterpSupporter) { -#if 0 - SQueryRuntimeEnv *pRuntimeEnv = &pSupporter->runtimeEnv; - SQuery * pQuery = pRuntimeEnv->pQuery; - - if (!isPointInterpoQuery(pQuery)) { - return false; - } - - /* - * for interpolate point query, points that are directly before/after the specified point are required - */ - if (isFirstLastRowQuery(pQuery)) { - assert(!QUERY_IS_ASC_QUERY(pQuery)); - } else { - assert(QUERY_IS_ASC_QUERY(pQuery)); - } - assert(pPointInterpSupporter != NULL && pQuery->skey == pQuery->ekey); - - SCacheBlock *pBlock = NULL; - - qTrace("QInfo:%p get next data point, fileId:%d, slot:%d, pos:%d", GET_QINFO_ADDR(pQuery), pQuery->fileId, - pQuery->slot, pQuery->pos); - - // save the point that is directly after or equals to the specified point - getOneRowFromDataBlock(pRuntimeEnv, pPointInterpSupporter->pNextPoint, pQuery->pos); - - /* - * 1. for last_row query, return immediately. - * 2. the specified timestamp equals to the required key, interpolation according to neighbor points is not necessary - * for interp query. - */ - TSKEY actualKey = *(TSKEY *)pPointInterpSupporter->pNextPoint[0]; - if (isFirstLastRowQuery(pQuery) || actualKey == pQuery->skey) { - setQueryStatus(pQuery, QUERY_NOT_COMPLETED); - - /* - * the retrieved ts may not equals to pMeterObj->lastKey due to cache re-allocation - * set the pQuery->ekey/pQuery->skey/pQuery->lastKey to be the new value. - */ - if (pQuery->ekey != actualKey) { - pQuery->skey = actualKey; - pQuery->ekey = actualKey; - pQuery->lastKey = actualKey; - pSupporter->rawSKey = actualKey; - pSupporter->rawEKey = actualKey; - } - return true; - } - - /* the qualified point is not the first point in data block */ - if (pQuery->pos > 0) { - int32_t prevPos = pQuery->pos - 1; - - /* save the point that is directly after the specified point */ - getOneRowFromDataBlock(pRuntimeEnv, pPointInterpSupporter->pPrevPoint, prevPos); - } else { - __block_search_fn_t searchFn = vnodeSearchKeyFunc[pMeterObj->searchAlgorithm]; - -// savePointPosition(&pRuntimeEnv->startPos, pQuery->fileId, pQuery->slot, pQuery->pos); - - // backwards movement would not set the pQuery->pos correct. We need to set it manually later. - moveToNextBlock(pRuntimeEnv, QUERY_DESC_FORWARD_STEP, searchFn, true); - - /* - * no previous data exists. - * reset the status and load the data block that contains the qualified point - */ - if (Q_STATUS_EQUAL(pQuery->over, QUERY_NO_DATA_TO_CHECK)) { - qTrace("QInfo:%p no previous data block, start fileId:%d, slot:%d, pos:%d, qrange:%" PRId64 "-%" PRId64 - ", out of range", - GET_QINFO_ADDR(pQuery), pRuntimeEnv->startPos.fileId, pRuntimeEnv->startPos.slot, - pRuntimeEnv->startPos.pos, pQuery->skey, pQuery->ekey); - - // no result, return immediately - setQueryStatus(pQuery, QUERY_COMPLETED); - return false; - } else { // prev has been located - if (pQuery->fileId >= 0) { - pQuery->pos = pQuery->pBlock[pQuery->slot].numOfRows - 1; - getOneRowFromDataBlock(pRuntimeEnv, pPointInterpSupporter->pPrevPoint, pQuery->pos); - - qTrace("QInfo:%p get prev data point, fileId:%d, slot:%d, pos:%d, pQuery->pos:%d", GET_QINFO_ADDR(pQuery), - pQuery->fileId, pQuery->slot, pQuery->pos, pQuery->pos); - } else { - // moveToNextBlock make sure there is a available cache block, if exists - assert(vnodeIsDatablockLoaded(pRuntimeEnv, pMeterObj, -1, true) == DISK_BLOCK_NO_NEED_TO_LOAD); - pBlock = &pRuntimeEnv->cacheBlock; - - pQuery->pos = pBlock->numOfRows - 1; - getOneRowFromDataBlock(pRuntimeEnv, pPointInterpSupporter->pPrevPoint, pQuery->pos); - - qTrace("QInfo:%p get prev data point, fileId:%d, slot:%d, pos:%d, pQuery->pos:%d", GET_QINFO_ADDR(pQuery), - pQuery->fileId, pQuery->slot, pBlock->numOfRows - 1, pQuery->pos); - } - } - } - - pQuery->skey = *(TSKEY *)pPointInterpSupporter->pPrevPoint[0]; - pQuery->ekey = *(TSKEY *)pPointInterpSupporter->pNextPoint[0]; - pQuery->lastKey = pQuery->skey; -#endif - return true; -} - bool doFilterData(SQuery *pQuery, int32_t elemPos) { for (int32_t k = 0; k < pQuery->numOfFilterCols; ++k) { SSingleColumnFilterInfo *pFilterInfo = &pQuery->pFilterInfo[k]; @@ -931,7 +819,7 @@ static char *getDataBlock(SQueryRuntimeEnv *pRuntimeEnv, SArithmeticSupport *sas * * @param pRuntimeEnv * @param forwardStep - * @param primaryKeyCol + * @param tsCols * @param pFields * @param isDiskFileBlock * @return the incremental number of output value, so it maybe 0 for fixed number of query, @@ -941,35 +829,25 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis * SDataBlockInfo *pDataBlockInfo, SWindowResInfo *pWindowResInfo, __block_search_fn_t searchFn, SArray *pDataBlock) { SQLFunctionCtx *pCtx = pRuntimeEnv->pCtx; - SQuery * pQuery = pRuntimeEnv->pQuery; - - SColumnInfoData *pColInfo = NULL; - TSKEY *primaryKeyCol = NULL; + SQuery *pQuery = pRuntimeEnv->pQuery; + TSKEY *tsCols = NULL; if (pDataBlock != NULL) { - pColInfo = taosArrayGet(pDataBlock, 0); - primaryKeyCol = (TSKEY *)(pColInfo->pData); + SColumnInfoData* pColInfo = taosArrayGet(pDataBlock, 0); + tsCols = (TSKEY *)(pColInfo->pData); } SArithmeticSupport *sasArray = calloc((size_t)pQuery->numOfOutput, sizeof(SArithmeticSupport)); for (int32_t k = 0; k < pQuery->numOfOutput; ++k) { - int32_t functionId = pQuery->pSelectExpr[k].base.functionId; - int32_t colId = pQuery->pSelectExpr[k].base.colInfo.colId; - - SDataStatis *tpField = NULL; - - bool hasNull = hasNullValue(pQuery, k, pDataBlockInfo->numOfCols, pStatis, &tpField); char *dataBlock = getDataBlock(pRuntimeEnv, &sasArray[k], k, pDataBlockInfo->rows, pDataBlock); - - setExecParams(pQuery, &pCtx[k], dataBlock, primaryKeyCol, pDataBlockInfo, functionId, tpField, hasNull, - &sasArray[k], colId); + setExecParams(pQuery, &pCtx[k], dataBlock, tsCols, pDataBlockInfo, pStatis, &sasArray[k], k); } int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); if (isIntervalQuery(pQuery)) { int32_t offset = GET_COL_DATA_POS(pQuery, 0, step); - TSKEY ts = primaryKeyCol[offset]; + TSKEY ts = tsCols[offset]; STimeWindow win = getActiveTimeWindow(pWindowResInfo, ts, pQuery); if (setWindowOutputBufByKey(pRuntimeEnv, pWindowResInfo, pDataBlockInfo->tid, &win) != TSDB_CODE_SUCCESS) { @@ -978,16 +856,16 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis * TSKEY ekey = reviseWindowEkey(pQuery, &win); int32_t forwardStep = - getNumOfRowsInTimeWindow(pQuery, pDataBlockInfo, primaryKeyCol, pQuery->pos, ekey, searchFn, true); + getNumOfRowsInTimeWindow(pQuery, pDataBlockInfo, tsCols, pQuery->pos, ekey, searchFn, true); SWindowStatus *pStatus = getTimeWindowResStatus(pWindowResInfo, curTimeWindow(pWindowResInfo)); - doBlockwiseApplyFunctions(pRuntimeEnv, pStatus, &win, pQuery->pos, forwardStep, primaryKeyCol, pDataBlockInfo->rows); + doBlockwiseApplyFunctions(pRuntimeEnv, pStatus, &win, pQuery->pos, forwardStep, tsCols, pDataBlockInfo->rows); int32_t index = pWindowResInfo->curIndex; STimeWindow nextWin = win; while (1) { - int32_t startPos = getNextQualifiedWindow(pRuntimeEnv, &nextWin, pDataBlockInfo, primaryKeyCol, searchFn); + int32_t startPos = getNextQualifiedWindow(pRuntimeEnv, &nextWin, pDataBlockInfo, tsCols, searchFn); if (startPos < 0) { break; } @@ -998,10 +876,10 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis * } ekey = reviseWindowEkey(pQuery, &nextWin); - forwardStep = getNumOfRowsInTimeWindow(pQuery, pDataBlockInfo, primaryKeyCol, startPos, ekey, searchFn, true); + forwardStep = getNumOfRowsInTimeWindow(pQuery, pDataBlockInfo, tsCols, startPos, ekey, searchFn, true); pStatus = getTimeWindowResStatus(pWindowResInfo, curTimeWindow(pWindowResInfo)); - doBlockwiseApplyFunctions(pRuntimeEnv, pStatus, &nextWin, startPos, forwardStep, primaryKeyCol, pDataBlockInfo->rows); + doBlockwiseApplyFunctions(pRuntimeEnv, pStatus, &nextWin, startPos, forwardStep, tsCols, pDataBlockInfo->rows); } pWindowResInfo->curIndex = index; @@ -1163,7 +1041,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS SQuery *pQuery = pRuntimeEnv->pQuery; STableQueryInfo* item = pQuery->current; - TSKEY *primaryKeyCol = (TSKEY*) ((SColumnInfoData *)taosArrayGet(pDataBlock, 0))->pData; + TSKEY *tsCols = (TSKEY*) ((SColumnInfoData *)taosArrayGet(pDataBlock, 0))->pData; bool groupbyStateValue = isGroupbyNormalCol(pQuery->pGroupbyExpr); SArithmeticSupport *sasArray = calloc((size_t)pQuery->numOfOutput, sizeof(SArithmeticSupport)); @@ -1176,16 +1054,8 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS } for (int32_t k = 0; k < pQuery->numOfOutput; ++k) { - int32_t functionId = pQuery->pSelectExpr[k].base.functionId; - int32_t colId = pQuery->pSelectExpr[k].base.colInfo.colId; - - SDataStatis *pColStatis = NULL; - - bool hasNull = hasNullValue(pQuery, k, pDataBlockInfo->numOfCols, pStatis, &pColStatis); char *dataBlock = getDataBlock(pRuntimeEnv, &sasArray[k], k, pDataBlockInfo->rows, pDataBlock); - - setExecParams(pQuery, &pCtx[k], dataBlock, primaryKeyCol, pDataBlockInfo, functionId, pColStatis, hasNull, - &sasArray[k], colId); + setExecParams(pQuery, &pCtx[k], dataBlock, tsCols, pDataBlockInfo, pStatis, &sasArray[k], k); } // set the input column data @@ -1229,7 +1099,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS // interval window query if (isIntervalQuery(pQuery)) { // decide the time window according to the primary timestamp - int64_t ts = primaryKeyCol[offset]; + int64_t ts = tsCols[offset]; STimeWindow win = getActiveTimeWindow(pWindowResInfo, ts, pQuery); int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, pWindowResInfo, pDataBlockInfo->tid, &win); @@ -1237,9 +1107,6 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS continue; } - // all startOffset are identical -// offset -= pCtx[0].startOffset; - SWindowStatus *pStatus = getTimeWindowResStatus(pWindowResInfo, curTimeWindow(pWindowResInfo)); doRowwiseApplyFunctions(pRuntimeEnv, pStatus, &win, offset); @@ -1296,7 +1163,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS } } - item->lastKey = primaryKeyCol[offset] + step; + item->lastKey = tsCols[offset] + step; // todo refactor: extract method for(int32_t i = 0; i < pQuery->numOfOutput; ++i) { @@ -1354,16 +1221,19 @@ static int32_t tableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBl } void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, TSKEY *tsCol, SDataBlockInfo* pBlockInfo, - int32_t functionId, SDataStatis *pStatis, bool hasNull, void *param, int32_t colId) { - pCtx->hasNull = hasNull; + SDataStatis *pStatis, void *param, int32_t colIndex) { + + int32_t functionId = pQuery->pSelectExpr[colIndex].base.functionId; + int32_t colId = pQuery->pSelectExpr[colIndex].base.colInfo.colId; + + SDataStatis *tpField = NULL; + pCtx->hasNull = hasNullValue(pQuery, colIndex, pBlockInfo->numOfCols, pStatis, &tpField); pCtx->aInputElemBuf = inputData; - if (pStatis != NULL) { + if (tpField != NULL) { pCtx->preAggVals.isSet = true; - pCtx->preAggVals.statis = *pStatis; - if (pCtx->preAggVals.statis.numOfNull == -1) { - pCtx->preAggVals.statis.numOfNull = pBlockInfo->rows; // todo :can not be -1 - } + pCtx->preAggVals.statis = *tpField; + assert(pCtx->preAggVals.statis.numOfNull <= pBlockInfo->rows); } else { pCtx->preAggVals.isSet = false; } @@ -1404,6 +1274,19 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, TSKEY pCtx->preAggVals.statis.min = pBlockInfo->window.skey; pCtx->preAggVals.statis.max = pBlockInfo->window.ekey; } + } else if (functionId == TSDB_FUNC_INTERP) { + SInterpInfoDetail *pInterpInfo = GET_RES_INFO(pCtx)->interResultBuf; + pInterpInfo->type = pQuery->fillType; + pInterpInfo->ts = pQuery->window.skey; + pInterpInfo->primaryCol = (colId == PRIMARYKEY_TIMESTAMP_COL_INDEX); + + if (pQuery->fillVal != NULL) { + if (isNull((const char*) &pQuery->fillVal[colIndex], pCtx->inputType)) { + pCtx->param[1].nType = TSDB_DATA_TYPE_NULL; + } else { // todo refactor, tVariantCreateFromBinary should handle the NULL value + tVariantCreateFromBinary(&pCtx->param[1], (char*) &pQuery->fillVal[colIndex], pCtx->inputBytes, pCtx->inputType); + } + } } #if defined(_DEBUG_VIEW) @@ -1425,14 +1308,15 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, TSKEY // set the output buffer for the selectivity + tag query static void setCtxTagColumnInfo(SQuery *pQuery, SQLFunctionCtx *pCtx) { if (isSelectivityWithTagsQuery(pQuery)) { - int32_t num = 0; - SQLFunctionCtx *p = NULL; - + int32_t num = 0; int16_t tagLen = 0; - + + SQLFunctionCtx *p = NULL; SQLFunctionCtx **pTagCtx = calloc(pQuery->numOfOutput, POINTER_BYTES); + for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { SSqlFuncMsg *pSqlFuncMsg = &pQuery->pSelectExpr[i].base; + if (pSqlFuncMsg->functionId == TSDB_FUNC_TAG_DUMMY || pSqlFuncMsg->functionId == TSDB_FUNC_TS_DUMMY) { tagLen += pCtx[i].outputBytes; pTagCtx[num++] = &pCtx[i]; @@ -1455,6 +1339,8 @@ static void setCtxTagColumnInfo(SQuery *pQuery, SQLFunctionCtx *pCtx) { static void setWindowResultInfo(SResultInfo *pResultInfo, SQuery *pQuery, bool isStableQuery) { for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { + assert(pQuery->pSelectExpr[i].interBytes <= DEFAULT_INTERN_BUF_PAGE_SIZE); + setResultInfoBuf(&pResultInfo[i], pQuery->pSelectExpr[i].interBytes, isStableQuery); } } @@ -1486,11 +1372,13 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order pCtx->inputBytes = pQuery->tagColList[index].bytes; pCtx->inputType = pQuery->tagColList[index].type; } + } else { pCtx->inputBytes = pQuery->colList[index].bytes; pCtx->inputType = pQuery->colList[index].type; } - + + assert(isValidDataType(pCtx->inputType, pCtx->inputBytes)); pCtx->ptsOutputBuf = NULL; pCtx->outputBytes = pQuery->pSelectExpr[i].bytes; @@ -1635,10 +1523,11 @@ static bool isFixedOutputQuery(SQuery *pQuery) { return false; } +// todo refactor with isLastRowQuery static bool isPointInterpoQuery(SQuery *pQuery) { for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { int32_t functionID = pQuery->pSelectExpr[i].base.functionId; - if (functionID == TSDB_FUNC_INTERP || functionID == TSDB_FUNC_LAST_ROW) { + if (functionID == TSDB_FUNC_INTERP) { return true; } } @@ -1743,54 +1632,6 @@ void getAlignQueryTimeWindow(SQuery *pQuery, int64_t key, int64_t keyFirst, int6 } } -static UNUSED_FUNC bool doGetQueryPos(TSKEY key, SQInfo *pQInfo, SPointInterpoSupporter *pPointInterpSupporter) { -#if 0 - SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; - SQuery * pQuery = pRuntimeEnv->pQuery; - SMeterObj * pMeterObj = pRuntimeEnv->pTabObj; - - /* key in query range. If not, no qualified in disk file */ - if (key != -1 && key <= pQuery->window.ekey) { - if (isPointInterpoQuery(pQuery)) { /* no qualified data in this query range */ - return getNeighborPoints(pQInfo, pMeterObj, pPointInterpSupporter); - } else { - return true; - } - } else { // key > pQuery->window.ekey, abort for normal query, continue for interp query - if (isPointInterpoQuery(pQuery)) { - return getNeighborPoints(pQInfo, pMeterObj, pPointInterpSupporter); - } else { - return false; - } - } -#endif - return true; -} - -static UNUSED_FUNC bool doSetDataInfo(SQInfo *pQInfo, SPointInterpoSupporter *pPointInterpSupporter, void *pMeterObj, - TSKEY nextKey) { - SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; - SQuery * pQuery = pRuntimeEnv->pQuery; - - if (isFirstLastRowQuery(pQuery)) { - /* - * if the pQuery->window.skey != pQuery->window.ekey for last_row query, - * the query range is existed, so set them both the value of nextKey - */ - if (pQuery->window.skey != pQuery->window.ekey) { - assert(pQuery->window.skey >= pQuery->window.ekey && !QUERY_IS_ASC_QUERY(pQuery) && - nextKey >= pQuery->window.ekey && nextKey <= pQuery->window.skey); - - pQuery->window.skey = nextKey; - pQuery->window.ekey = nextKey; - } - - return getNeighborPoints(pQInfo, pMeterObj, pPointInterpSupporter); - } else { - return true; - } -} - static void setScanLimitationByResultBuffer(SQuery *pQuery) { if (isTopBottomQuery(pQuery)) { pQuery->checkBuffer = 0; @@ -1817,7 +1658,7 @@ static void setScanLimitationByResultBuffer(SQuery *pQuery) { /* * todo add more parameters to check soon.. */ -bool vnodeParametersSafetyCheck(SQuery *pQuery) { +bool colIdCheck(SQuery *pQuery) { // load data column information is incorrect for (int32_t i = 0; i < pQuery->numOfCols - 1; ++i) { if (pQuery->colList[i].colId == pQuery->colList[i + 1].colId) { @@ -1825,6 +1666,7 @@ bool vnodeParametersSafetyCheck(SQuery *pQuery) { return false; } } + return true; } @@ -1851,7 +1693,7 @@ static bool onlyFirstQuery(SQuery *pQuery) { return onlyOneQueryType(pQuery, TSD static bool onlyLastQuery(SQuery *pQuery) { return onlyOneQueryType(pQuery, TSDB_FUNC_LAST, TSDB_FUNC_LAST_DST); } -static void changeExecuteScanOrder(SQuery *pQuery, bool metricQuery) { +static void changeExecuteScanOrder(SQuery *pQuery, bool stableQuery) { // in case of point-interpolation query, use asc order scan char msg[] = "QInfo:%p scan order changed for %s query, old:%d, new:%d, qrange exchanged, old qrange:%" PRId64 "-%" PRId64 ", new qrange:%" PRId64 "-%" PRId64; @@ -1906,7 +1748,7 @@ static void changeExecuteScanOrder(SQuery *pQuery, bool metricQuery) { } } else { // interval query - if (metricQuery) { + if (stableQuery) { if (onlyFirstQuery(pQuery)) { if (!QUERY_IS_ASC_QUERY(pQuery)) { qTrace(msg, GET_QINFO_ADDR(pQuery), "only-first stable", pQuery->order.order, TSDB_ORDER_ASC, @@ -1985,159 +1827,6 @@ static UNUSED_FUNC void doSetInterpVal(SQLFunctionCtx *pCtx, TSKEY ts, int16_t t pCtx->param[index].nLen = len; } -/** - * param[1]: default value/previous value of specified timestamp - * param[2]: next value of specified timestamp - * param[3]: denotes if the result is a precious result or interpolation results - * - * @param pQInfo - * @param pQInfo - * @param pInterpoRaw - */ -void pointInterpSupporterSetData(SQInfo *pQInfo, SPointInterpoSupporter *pPointInterpSupport) { -#if 0 - SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; - SQuery * pQuery = pRuntimeEnv->pQuery; - - // not point interpolation query, abort - if (!isPointInterpoQuery(pQuery)) { - return; - } - - int32_t count = 1; - TSKEY key = *(TSKEY *)pPointInterpSupport->next[0]; - - if (key == pQuery->window.skey) { - // the queried timestamp has value, return it directly without interpolation - for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { - tVariantCreateFromBinary(&pRuntimeEnv->pCtx[i].param[3], (char *)&count, sizeof(count), TSDB_DATA_TYPE_INT); - - pRuntimeEnv->pCtx[i].param[0].i64Key = key; - pRuntimeEnv->pCtx[i].param[0].nType = TSDB_DATA_TYPE_BIGINT; - } - } else { - // set the direct previous(next) point for process - count = 2; - - if (pQuery->fillType == TSDB_FILL_SET_VALUE) { - for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { - SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i]; - - // only the function of interp needs the corresponding information - if (pCtx->functionId != TSDB_FUNC_INTERP) { - continue; - } - - pCtx->numOfParams = 4; - - SInterpInfo *pInterpInfo = (SInterpInfo *)pRuntimeEnv->pCtx[i].aOutputBuf; - pInterpInfo->pInterpDetail = calloc(1, sizeof(SInterpInfoDetail)); - - SInterpInfoDetail *pInterpDetail = pInterpInfo->pInterpDetail; - - // for primary timestamp column, set the flag - if (pQuery->pSelectExpr[i].base.colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX) { - pInterpDetail->primaryCol = 1; - } - - tVariantCreateFromBinary(&pCtx->param[3], (char *)&count, sizeof(count), TSDB_DATA_TYPE_INT); - - if (isNull((char *)&pQuery->fillVal[i], pCtx->inputType)) { - pCtx->param[1].nType = TSDB_DATA_TYPE_NULL; - } else { - tVariantCreateFromBinary(&pCtx->param[1], (char *)&pQuery->fillVal[i], pCtx->inputBytes, pCtx->inputType); - } - - pInterpDetail->ts = pQuery->window.skey; - pInterpDetail->type = pQuery->fillType; - } - } else { - TSKEY prevKey = *(TSKEY *)pPointInterpSupport->pPrevPoint[0]; - TSKEY nextKey = *(TSKEY *)pPointInterpSupport->pNextPoint[0]; - - for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { - SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i]; - - // tag column does not need the interp environment - if (pQuery->pSelectExpr[i].base.functionId == TSDB_FUNC_TAG) { - continue; - } - - int32_t colInBuf = 0; // pQuery->pSelectExpr[i].base.colInfo.colIdxInBuf; - SInterpInfo *pInterpInfo = (SInterpInfo *)pRuntimeEnv->pCtx[i].aOutputBuf; - - pInterpInfo->pInterpDetail = calloc(1, sizeof(SInterpInfoDetail)); - SInterpInfoDetail *pInterpDetail = pInterpInfo->pInterpDetail; - - // int32_t type = GET_COLUMN_TYPE(pQuery, i); - int32_t type = 0; - assert(0); - - // for primary timestamp column, set the flag - if (pQuery->pSelectExpr[i].base.colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX) { - pInterpDetail->primaryCol = 1; - } else { - doSetInterpVal(pCtx, prevKey, type, 1, pPointInterpSupport->pPrevPoint[colInBuf]); - doSetInterpVal(pCtx, nextKey, type, 2, pPointInterpSupport->pNextPoint[colInBuf]); - } - - tVariantCreateFromBinary(&pRuntimeEnv->pCtx[i].param[3], (char *)&count, sizeof(count), TSDB_DATA_TYPE_INT); - - pInterpDetail->ts = pQInfo->runtimeEnv.pQuery->window.skey; - pInterpDetail->type = pQuery->fillType; - } - } - } -#endif -} - -void pointInterpSupporterInit(SQuery *pQuery, SPointInterpoSupporter *pInterpoSupport) { -#if 0 - if (isPointInterpoQuery(pQuery)) { - pInterpoSupport->pPrevPoint = malloc(pQuery->numOfCols * POINTER_BYTES); - pInterpoSupport->pNextPoint = malloc(pQuery->numOfCols * POINTER_BYTES); - - pInterpoSupport->numOfCols = pQuery->numOfCols; - - /* get appropriated size for one row data source*/ - int32_t len = 0; - for (int32_t i = 0; i < pQuery->numOfCols; ++i) { - len += pQuery->colList[i].bytes; - } - - // assert(PRIMARY_TSCOL_LOADED(pQuery)); - - void *prev = calloc(1, len); - void *next = calloc(1, len); - - int32_t offset = 0; - - for (int32_t i = 0; i < pQuery->numOfCols; ++i) { - pInterpoSupport->pPrevPoint[i] = prev + offset; - pInterpoSupport->pNextPoint[i] = next + offset; - - offset += pQuery->colList[i].bytes; - } - } -#endif -} - -void pointInterpSupporterDestroy(SPointInterpoSupporter *pPointInterpSupport) { -#if 0 - if (pPointInterpSupport->numOfCols <= 0 || pPointInterpSupport->pPrevPoint == NULL) { - return; - } - - tfree(pPointInterpSupport->pPrevPoint[0]); - tfree(pPointInterpSupport->pNextPoint[0]); - - tfree(pPointInterpSupport->pPrevPoint); - tfree(pPointInterpSupport->pNextPoint); - - pPointInterpSupport->numOfCols = 0; -#endif -} - static int32_t getInitialPageNum(SQInfo *pQInfo) { SQuery *pQuery = pQInfo->runtimeEnv.pQuery; int32_t INITIAL_RESULT_ROWS_VALUE = 16; @@ -2169,7 +1858,7 @@ static int32_t getRowParamForMultiRowsOutput(SQuery *pQuery, bool isSTableQuery) static int32_t getNumOfRowsInResultPage(SQuery *pQuery, bool isSTableQuery) { int32_t rowSize = pQuery->rowSize * getRowParamForMultiRowsOutput(pQuery, isSTableQuery); - return (DEFAULT_INTERN_BUF_SIZE - sizeof(tFilePage)) / rowSize; + return (DEFAULT_INTERN_BUF_PAGE_SIZE - sizeof(tFilePage)) / rowSize; } char *getPosInResultPage(SQueryRuntimeEnv *pRuntimeEnv, int32_t columnIndex, SWindowResult *pResult) { @@ -2297,9 +1986,12 @@ SArray *loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, void* pQueryHandle, if (pQuery->numOfFilterCols > 0) { r = BLK_DATA_ALL_NEEDED; } else { + // check if this data block is required to load for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { - int32_t functionId = pQuery->pSelectExpr[i].base.functionId; - int32_t colId = pQuery->pSelectExpr[i].base.colInfo.colId; + SSqlFuncMsg* pSqlFunc = &pQuery->pSelectExpr[i].base; + + int32_t functionId = pSqlFunc->functionId; + int32_t colId = pSqlFunc->colInfo.colId; r |= aAggs[functionId].dataReqFunc(&pRuntimeEnv->pCtx[i], pQuery->window.skey, pQuery->window.ekey, colId); } @@ -2309,34 +2001,38 @@ SArray *loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, void* pQueryHandle, } if (r == BLK_DATA_NO_NEEDED) { - qTrace("QInfo:%p data block ignored, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_QINFO_ADDR(pRuntimeEnv), + qTrace("QInfo:%p data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_QINFO_ADDR(pRuntimeEnv), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); - } else if (r == BLK_DATA_FILEDS_NEEDED) { + pRuntimeEnv->summary.discardBlocks += 1; + } else if (r == BLK_DATA_STATIS_NEEDED) { if (tsdbRetrieveDataBlockStatisInfo(pQueryHandle, pStatis) != TSDB_CODE_SUCCESS) { // return DISK_DATA_LOAD_FAILED; } - - if (*pStatis == NULL) { + + pRuntimeEnv->summary.loadBlockStatis += 1; + + if (*pStatis == NULL) { // data block statistics does not exist, load data block pDataBlock = tsdbRetrieveDataBlock(pQueryHandle, NULL); + pRuntimeEnv->summary.checkRows += pBlockInfo->rows; } } else { assert(r == BLK_DATA_ALL_NEEDED); + + // load the data block statistics to perform further filter + pRuntimeEnv->summary.loadBlockStatis +=1; if (tsdbRetrieveDataBlockStatisInfo(pQueryHandle, pStatis) != TSDB_CODE_SUCCESS) { - // return DISK_DATA_LOAD_FAILED; } - - /* - * if this block is completed included in the query range, do more filter operation - * filter the data block according to the value filter condition. - * no need to load the data block, continue for next block - */ - if (!needToLoadDataBlock(pQuery, *pStatis, pRuntimeEnv->pCtx, pBlockInfo->rows)) { + + if (!needToLoadDataBlock(pQuery,*pStatis, pRuntimeEnv->pCtx, pBlockInfo->rows)) { #if defined(_DEBUG_VIEW) qTrace("QInfo:%p block discarded by per-filter", GET_QINFO_ADDR(pRuntimeEnv)); #endif + // current block has been discard due to filter applied + pRuntimeEnv->summary.discardBlocks += 1; // return DISK_DATA_DISCARDED; } - + + pRuntimeEnv->summary.checkRows += pBlockInfo->rows; pDataBlock = tsdbRetrieveDataBlock(pQueryHandle, NULL); } @@ -2406,6 +2102,43 @@ int32_t binarySearchForKey(char *pValue, int num, TSKEY key, int order) { return midPos; } +static void ensureOutputBuffer(SQueryRuntimeEnv* pRuntimeEnv, SDataBlockInfo* pBlockInfo) { + // in case of prj/diff query, ensure the output buffer is sufficient to accommodate the results of current block + SQuery* pQuery = pRuntimeEnv->pQuery; + if (!isIntervalQuery(pQuery) && !isGroupbyNormalCol(pQuery->pGroupbyExpr) && !isFixedOutputQuery(pQuery)) { + SResultRec *pRec = &pQuery->rec; + + if (pQuery->rec.capacity - pQuery->rec.rows < pBlockInfo->rows) { + int32_t remain = pRec->capacity - pRec->rows; + int32_t newSize = pRec->capacity + (pBlockInfo->rows - remain); + + for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { + int32_t bytes = pQuery->pSelectExpr[i].bytes; + + char *tmp = realloc(pQuery->sdata[i], bytes * newSize + sizeof(tFilePage)); + if (tmp == NULL) { // todo handle the oom + assert(0); + } else { + pQuery->sdata[i] = (tFilePage *)tmp; + } + + // set the pCtx output buffer position + pRuntimeEnv->pCtx[i].aOutputBuf = pQuery->sdata[i]->data + pRec->rows * bytes; + + int32_t functionId = pQuery->pSelectExpr[i].base.functionId; + if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) { + pRuntimeEnv->pCtx[i].ptsOutputBuf = pRuntimeEnv->pCtx[0].aOutputBuf; + } + } + + qTrace("QInfo:%p realloc output buffer, new size: %d rows, old:%d, remain:%d", GET_QINFO_ADDR(pRuntimeEnv), + newSize, pRec->capacity, newSize - pRec->rows); + + pRec->capacity = newSize; + } + } +} + static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { SQuery *pQuery = pRuntimeEnv->pQuery; STableQueryInfo* pTableQueryInfo = pQuery->current; @@ -2416,6 +2149,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { TsdbQueryHandleT pQueryHandle = IS_MASTER_SCAN(pRuntimeEnv)? pRuntimeEnv->pQueryHandle : pRuntimeEnv->pSecQueryHandle; while (tsdbNextDataBlock(pQueryHandle)) { + pRuntimeEnv->summary.dataBlocks += 1; if (isQueryKilled(GET_QINFO_ADDR(pRuntimeEnv))) { return 0; } @@ -2448,45 +2182,15 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { } // in case of prj/diff query, ensure the output buffer is sufficient to accommodate the results of current block - if (!isIntervalQuery(pQuery) && !isGroupbyNormalCol(pQuery->pGroupbyExpr) && !isFixedOutputQuery(pQuery)) { - SResultRec *pRec = &pQuery->rec; - - if (pQuery->rec.capacity - pQuery->rec.rows < blockInfo.rows) { - int32_t remain = pRec->capacity - pRec->rows; - int32_t newSize = pRec->capacity + (blockInfo.rows - remain); - - for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { - int32_t bytes = pQuery->pSelectExpr[i].bytes; - - char *tmp = realloc(pQuery->sdata[i], bytes * newSize + sizeof(tFilePage)); - if (tmp == NULL) { // todo handle the oom - assert(0); - } else { - pQuery->sdata[i] = (tFilePage *)tmp; - } - - // set the pCtx output buffer position - pRuntimeEnv->pCtx[i].aOutputBuf = pQuery->sdata[i]->data + pRec->rows * bytes; - - int32_t functionId = pQuery->pSelectExpr[i].base.functionId; - if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) { - pRuntimeEnv->pCtx[i].ptsOutputBuf = pRuntimeEnv->pCtx[0].aOutputBuf; - } - } - - qTrace("QInfo:%p realloc output buffer, new size: %d rows, old:%d, remain:%d", GET_QINFO_ADDR(pRuntimeEnv), - newSize, pRec->capacity, newSize - pRec->rows); - - pRec->capacity = newSize; - } - } + ensureOutputBuffer(pRuntimeEnv, &blockInfo); SDataStatis *pStatis = NULL; - pQuery->pos = QUERY_IS_ASC_QUERY(pQuery) ? 0 : blockInfo.rows - 1; + pQuery->pos = QUERY_IS_ASC_QUERY(pQuery)? 0 : blockInfo.rows - 1; SArray *pDataBlock = loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis); int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, pStatis, binarySearchForKey, pDataBlock); + pRuntimeEnv->summary.dataInRows += blockInfo.rows; qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, lastKey:%"PRId64, GET_QINFO_ADDR(pRuntimeEnv), blockInfo.window.skey, blockInfo.window.ekey, blockInfo.rows, numOfRes, pQuery->current->lastKey); @@ -2590,14 +2294,18 @@ static void doMerge(SQueryRuntimeEnv *pRuntimeEnv, int64_t timestamp, SWindowRes pCtx[i].hasNull = true; pCtx[i].nStartQueryTimestamp = timestamp; pCtx[i].aInputElemBuf = getPosInResultPage(pRuntimeEnv, i, pWindowRes); - // pCtx[i].aInputElemBuf = ((char *)inputSrc->data) + - // ((int32_t)pRuntimeEnv->offset[i] * pRuntimeEnv->numOfRowsPerPage) + - // pCtx[i].outputBytes * inputIdx; // in case of tag column, the tag information should be extracted from input buffer if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TAG) { tVariantDestroy(&pCtx[i].tag); - tVariantCreateFromBinary(&pCtx[i].tag, pCtx[i].aInputElemBuf, pCtx[i].inputBytes, pCtx[i].inputType); + + int32_t type = pCtx[i].outputType; + if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { + tVariantCreateFromBinary(&pCtx[i].tag, varDataVal(pCtx[i].aInputElemBuf), varDataLen(pCtx[i].aInputElemBuf), type); + } else { + tVariantCreateFromBinary(&pCtx[i].tag, pCtx[i].aInputElemBuf, pCtx[i].inputBytes, pCtx[i].inputType); + } + } } @@ -2875,7 +2583,7 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) { size_t size = taosArrayGetSize(pGroup); - tFilePage **buffer = (tFilePage **)pQuery->sdata; + tFilePage **buffer = pQuery->sdata; int32_t * posList = calloc(size, sizeof(int32_t)); STableQueryInfo **pTableList = malloc(POINTER_BYTES * size); @@ -3005,7 +2713,7 @@ int32_t flushFromResultBuf(SQInfo *pQInfo) { SQuery * pQuery = pRuntimeEnv->pQuery; SDiskbasedResultBuf *pResultBuf = pRuntimeEnv->pResultBuf; - int32_t capacity = (DEFAULT_INTERN_BUF_SIZE - sizeof(tFilePage)) / pQuery->rowSize; + int32_t capacity = (DEFAULT_INTERN_BUF_PAGE_SIZE - sizeof(tFilePage)) / pQuery->rowSize; // the base value for group result, since the maximum number of table for each vnode will not exceed 100,000. int32_t pageId = -1; @@ -3552,14 +3260,14 @@ void restoreIntervalQueryRange(SQueryRuntimeEnv *pRuntimeEnv, STableQueryInfo *p * @param pRuntimeEnv * @param pDataBlockInfo */ -void setExecutionContext(SQInfo *pQInfo, STableId* pTableId, int32_t groupIdx, TSKEY nextKey) { +void setExecutionContext(SQInfo *pQInfo, STableId* pTableId, int32_t groupIndex, TSKEY nextKey) { SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; STableQueryInfo *pTableQueryInfo = pRuntimeEnv->pQuery->current; SWindowResInfo * pWindowResInfo = &pRuntimeEnv->windowResInfo; int32_t GROUPRESULTID = 1; - SWindowResult *pWindowRes = doSetTimeWindowFromKey(pRuntimeEnv, pWindowResInfo, (char *)&groupIdx, sizeof(groupIdx)); + SWindowResult *pWindowRes = doSetTimeWindowFromKey(pRuntimeEnv, pWindowResInfo, (char *)&groupIndex, sizeof(groupIndex)); if (pWindowRes == NULL) { return; } @@ -3589,7 +3297,6 @@ static void setWindowResOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult * for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i]; pCtx->aOutputBuf = getPosInResultPage(pRuntimeEnv, i, pResult); - int32_t functionId = pQuery->pSelectExpr[i].base.functionId; if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) { pCtx->ptsOutputBuf = pRuntimeEnv->pCtx[0].aOutputBuf; @@ -3811,7 +3518,7 @@ static void updateWindowResNumOfRes(SQueryRuntimeEnv *pRuntimeEnv, STableQueryIn // update the number of result for each, only update the number of rows for the corresponding window result. if (pQuery->intervalTime == 0) { - int32_t g = pTableQueryInfo->groupIdx; + int32_t g = pTableQueryInfo->groupIndex; assert(pRuntimeEnv->windowResInfo.size > 0); SWindowResult *pWindowRes = doSetTimeWindowFromKey(pRuntimeEnv, &pRuntimeEnv->windowResInfo, (char *)&g, sizeof(g)); @@ -3841,7 +3548,8 @@ bool queryHasRemainResults(SQueryRuntimeEnv* pRuntimeEnv) { SQuery *pQuery = pRuntimeEnv->pQuery; SFillInfo *pFillInfo = pRuntimeEnv->pFillInfo; - if (pQuery->fillType == TSDB_FILL_NONE) { + // todo refactor + if (pQuery->fillType == TSDB_FILL_NONE || (pQuery->fillType != TSDB_FILL_NONE && isPointInterpoQuery(pQuery))) { assert(pFillInfo == NULL); return false; } @@ -3956,50 +3664,49 @@ int32_t doFillGapsInResults(SQueryRuntimeEnv* pRuntimeEnv, tFilePage **pDst, int } } -void vnodePrintQueryStatistics(SQInfo *pQInfo) { -#if 0 +void queryCostStatis(SQInfo *pQInfo) { SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; +// SQuery *pQuery = pRuntimeEnv->pQuery; - SQuery *pQuery = pRuntimeEnv->pQuery; + SQueryCostInfo *pSummary = &pRuntimeEnv->summary; +// if (pRuntimeEnv->pResultBuf == NULL) { +//// pSummary->tmpBufferInDisk = 0; +// } else { +//// pSummary->tmpBufferInDisk = getResBufSize(pRuntimeEnv->pResultBuf); +// } +// +// qTrace("QInfo:%p cost: comp blocks:%d, size:%d Bytes, elapsed time:%.2f ms", pQInfo, pSummary->readCompInfo, +// pSummary->totalCompInfoSize, pSummary->loadCompInfoUs / 1000.0); +// +// qTrace("QInfo:%p cost: field info: %d, size:%d Bytes, avg size:%.2f Bytes, elapsed time:%.2f ms", pQInfo, +// pSummary->readField, pSummary->totalFieldSize, (double)pSummary->totalFieldSize / pSummary->readField, +// pSummary->loadFieldUs / 1000.0); +// +// qTrace( +// "QInfo:%p cost: file blocks:%d, size:%d Bytes, elapsed time:%.2f ms, skipped:%d, in-memory gen null:%d Bytes", +// pQInfo, pSummary->readDiskBlocks, pSummary->totalBlockSize, pSummary->loadBlocksUs / 1000.0, +// pSummary->skippedFileBlocks, pSummary->totalGenData); + + qTrace("QInfo:%p cost: check blocks:%d, statis:%d, rows:%"PRId64", check rows:%"PRId64, pQInfo, pSummary->dataBlocks, + pSummary->loadBlockStatis, pSummary->dataInRows, pSummary->checkRows); - SQueryCostSummary *pSummary = &pRuntimeEnv->summary; - if (pRuntimeEnv->pResultBuf == NULL) { - pSummary->tmpBufferInDisk = 0; - } else { - pSummary->tmpBufferInDisk = getResBufSize(pRuntimeEnv->pResultBuf); - } - - qTrace("QInfo:%p statis: comp blocks:%d, size:%d Bytes, elapsed time:%.2f ms", pQInfo, pSummary->readCompInfo, - pSummary->totalCompInfoSize, pSummary->loadCompInfoUs / 1000.0); - - qTrace("QInfo:%p statis: field info: %d, size:%d Bytes, avg size:%.2f Bytes, elapsed time:%.2f ms", pQInfo, - pSummary->readField, pSummary->totalFieldSize, (double)pSummary->totalFieldSize / pSummary->readField, - pSummary->loadFieldUs / 1000.0); - - qTrace( - "QInfo:%p statis: file blocks:%d, size:%d Bytes, elapsed time:%.2f ms, skipped:%d, in-memory gen null:%d Bytes", - pQInfo, pSummary->readDiskBlocks, pSummary->totalBlockSize, pSummary->loadBlocksUs / 1000.0, - pSummary->skippedFileBlocks, pSummary->totalGenData); - - qTrace("QInfo:%p statis: cache blocks:%d", pQInfo, pSummary->blocksInCache, 0); - qTrace("QInfo:%p statis: temp file:%d Bytes", pQInfo, pSummary->tmpBufferInDisk); - - qTrace("QInfo:%p statis: file:%d, table:%d", pQInfo, pSummary->numOfFiles, pSummary->numOfTables); - qTrace("QInfo:%p statis: seek ops:%d", pQInfo, pSummary->numOfSeek); - - double total = pSummary->fileTimeUs + pSummary->cacheTimeUs; - double io = pSummary->loadCompInfoUs + pSummary->loadBlocksUs + pSummary->loadFieldUs; +// qTrace("QInfo:%p cost: temp file:%d Bytes", pQInfo, pSummary->tmpBufferInDisk); +// +// qTrace("QInfo:%p cost: file:%d, table:%d", pQInfo, pSummary->numOfFiles, pSummary->numOfTables); +// qTrace("QInfo:%p cost: seek ops:%d", pQInfo, pSummary->numOfSeek); +// +// double total = pSummary->fileTimeUs + pSummary->cacheTimeUs; +// double io = pSummary->loadCompInfoUs + pSummary->loadBlocksUs + pSummary->loadFieldUs; // todo add the intermediate result save cost!! - double computing = total - io; - - qTrace( - "QInfo:%p statis: total elapsed time:%.2f ms, file:%.2f ms(%.2f%), cache:%.2f ms(%.2f%). io:%.2f ms(%.2f%)," - "comput:%.2fms(%.2f%)", - pQInfo, total / 1000.0, pSummary->fileTimeUs / 1000.0, pSummary->fileTimeUs * 100 / total, - pSummary->cacheTimeUs / 1000.0, pSummary->cacheTimeUs * 100 / total, io / 1000.0, io * 100 / total, - computing / 1000.0, computing * 100 / total); -#endif +// double computing = total - io; +// +// qTrace( +// "QInfo:%p cost: total elapsed time:%.2f ms, file:%.2f ms(%.2f%), cache:%.2f ms(%.2f%). io:%.2f ms(%.2f%)," +// "comput:%.2fms(%.2f%)", +// pQInfo, total / 1000.0, pSummary->fileTimeUs / 1000.0, pSummary->fileTimeUs * 100 / total, +// pSummary->cacheTimeUs / 1000.0, pSummary->cacheTimeUs * 100 / total, io / 1000.0, io * 100 / total, +// computing / 1000.0, computing * 100 / total); } static void updateOffsetVal(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pBlockInfo) { @@ -4195,7 +3902,6 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) { return true; } - static void setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery) { SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; SQuery *pQuery = pQInfo->runtimeEnv.pQuery; @@ -4229,12 +3935,13 @@ static void setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery) { if (isFirstLastRowQuery(pQuery)) { pRuntimeEnv->pQueryHandle = tsdbQueryLastRow(tsdb, &cond, &pQInfo->tableIdGroupInfo); + } else if (isPointInterpoQuery(pQuery)) { + pRuntimeEnv->pQueryHandle = tsdbQueryRowsInExternalWindow(tsdb, &cond, &pQInfo->tableIdGroupInfo); } else { pRuntimeEnv->pQueryHandle = tsdbQueryTables(tsdb, &cond, &pQInfo->tableIdGroupInfo); } } - static SFillColInfo* taosCreateFillColInfo(SQuery* pQuery) { int32_t numOfCols = pQuery->numOfOutput; int32_t offset = 0; @@ -4325,9 +4032,6 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool setQueryStatus(pQuery, QUERY_NOT_COMPLETED); -// SPointInterpoSupporter interpInfo = {0}; -// pointInterpSupporterInit(pQuery, &interpInfo); - /* * in case of last_row query without query range, we set the query timestamp to be * STable->lastKey. Otherwise, keep the initial query time range unchanged. @@ -4340,14 +4044,7 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool // } // } - /* - * here we set the value for before and after the specified time into the - * parameter for interpolation query - */ -// pointInterpSupporterSetData(pQInfo, &interpInfo); -// pointInterpSupporterDestroy(&interpInfo); - - if (pQuery->fillType != TSDB_FILL_NONE) { + if (pQuery->fillType != TSDB_FILL_NONE && !isPointInterpoQuery(pQuery)) { SFillColInfo* pColInfo = taosCreateFillColInfo(pQuery); pRuntimeEnv->pFillInfo = taosInitFillInfo(pQuery->order.order, 0, 0, pQuery->rec.capacity, pQuery->numOfOutput, pQuery->slidingTime, pQuery->fillType, pColInfo); @@ -4423,6 +4120,7 @@ static int64_t queryOnDataBlocks(SQInfo *pQInfo) { assert(pTableQueryInfo != NULL); restoreIntervalQueryRange(pRuntimeEnv, pTableQueryInfo); + printf("table:%d, groupIndex:%d, rows:%d\n", pTableQueryInfo->id.tid, pTableQueryInfo->groupIndex, blockInfo.tid); SDataStatis *pStatis = NULL; @@ -4430,7 +4128,7 @@ static int64_t queryOnDataBlocks(SQInfo *pQInfo) { if (!isIntervalQuery(pQuery)) { int32_t step = QUERY_IS_ASC_QUERY(pQuery)? 1:-1; - setExecutionContext(pQInfo, &pTableQueryInfo->id, pTableQueryInfo->groupIdx, blockInfo.window.ekey + step); + setExecutionContext(pQInfo, &pTableQueryInfo->id, pTableQueryInfo->groupIndex, blockInfo.window.ekey + step); } else { // interval query TSKEY nextKey = blockInfo.window.skey; setIntervalQueryRange(pQInfo, nextKey); @@ -4519,57 +4217,67 @@ static void sequentialTableProcess(SQInfo *pQInfo) { size_t numOfGroups = taosArrayGetSize(pQInfo->groupInfo.pGroupList); - if (isPointInterpoQuery(pQuery)) { + if (isPointInterpoQuery(pQuery) || isFirstLastRowQuery(pQuery)) { resetCtxOutputBuf(pRuntimeEnv); assert(pQuery->limit.offset == 0 && pQuery->limit.limit != 0); while (pQInfo->groupIndex < numOfGroups) { SArray* group = taosArrayGetP(pQInfo->groupInfo.pGroupList, pQInfo->groupIndex); - if (isFirstLastRowQuery(pQuery)) { - qTrace("QInfo:%p last_row query on group:%d, total group:%d, current group:%d", pQInfo, pQInfo->groupIndex, - numOfGroups); - - STsdbQueryCond cond = { - .twindow = pQuery->window, - .colList = pQuery->colList, - .order = pQuery->order.order, - .numOfCols = pQuery->numOfCols, - }; - - SArray *g1 = taosArrayInit(1, POINTER_BYTES); - SArray *tx = taosArrayClone(group); - taosArrayPush(g1, &tx); - - STableGroupInfo gp = {.numOfTables = taosArrayGetSize(tx), .pGroupList = g1}; - - // include only current table - if (pRuntimeEnv->pQueryHandle != NULL) { - tsdbCleanupQueryHandle(pRuntimeEnv->pQueryHandle); - pRuntimeEnv->pQueryHandle = NULL; - } - - pRuntimeEnv->pQueryHandle = tsdbQueryLastRow(pQInfo->tsdb, &cond, &gp); - - initCtxOutputBuf(pRuntimeEnv); - setTagVal(pRuntimeEnv, (STableId*) taosArrayGet(tx, 0), pQInfo->tsdb); - - // here we simply set the first table as current table - pQuery->current = ((SGroupItem*) taosArrayGet(group, 0))->info; - scanAllDataBlocks(pRuntimeEnv, pQuery->current->lastKey); - - int64_t numOfRes = getNumOfResult(pRuntimeEnv); - if (numOfRes > 0) { - pQuery->rec.rows += numOfRes; - forwardCtxOutputBuf(pRuntimeEnv, numOfRes); - } - - skipResults(pRuntimeEnv); - pQInfo->groupIndex += 1; - - // enable execution for next table, when handling the projection query - enableExecutionForNextTable(pRuntimeEnv); + qTrace("QInfo:%p last_row query on group:%d, total group:%d, current group:%d", pQInfo, pQInfo->groupIndex, + numOfGroups); + + STsdbQueryCond cond = { + .twindow = pQuery->window, + .colList = pQuery->colList, + .order = pQuery->order.order, + .numOfCols = pQuery->numOfCols, + }; + + SArray *g1 = taosArrayInit(1, POINTER_BYTES); + SArray *tx = taosArrayClone(group); + taosArrayPush(g1, &tx); + + STableGroupInfo gp = {.numOfTables = taosArrayGetSize(tx), .pGroupList = g1}; + + // include only current table + if (pRuntimeEnv->pQueryHandle != NULL) { + tsdbCleanupQueryHandle(pRuntimeEnv->pQueryHandle); + pRuntimeEnv->pQueryHandle = NULL; } + + if (isFirstLastRowQuery(pQuery)) { + pRuntimeEnv->pQueryHandle = tsdbQueryLastRow(pQInfo->tsdb, &cond, &gp); + } else { + pRuntimeEnv->pQueryHandle = tsdbQueryRowsInExternalWindow(pQInfo->tsdb, &cond, &gp); + } + + initCtxOutputBuf(pRuntimeEnv); + + SArray* s = tsdbGetQueriedTableIdList(pRuntimeEnv->pQueryHandle); + assert(taosArrayGetSize(s) >= 1); + + setTagVal(pRuntimeEnv, (STableId*) taosArrayGet(s, 0), pQInfo->tsdb); + + if (isFirstLastRowQuery(pQuery)) { + assert(taosArrayGetSize(s) == 1); + } + + // here we simply set the first table as current table + pQuery->current = ((SGroupItem*) taosArrayGet(group, 0))->info; + scanAllDataBlocks(pRuntimeEnv, pQuery->current->lastKey); + + int64_t numOfRes = getNumOfResult(pRuntimeEnv); + if (numOfRes > 0) { + pQuery->rec.rows += numOfRes; + forwardCtxOutputBuf(pRuntimeEnv, numOfRes); + } + + skipResults(pRuntimeEnv); + pQInfo->groupIndex += 1; + + // enable execution for next table, when handling the projection query + enableExecutionForNextTable(pRuntimeEnv); } } else { /* @@ -4795,7 +4503,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) { } if (pQuery->rec.rows == 0) { - // vnodePrintQueryStatistics(pSupporter); + // queryCostStatis(pSupporter); } qTrace("QInfo:%p current:%lld, total:%lld", pQInfo, pQuery->rec.rows, pQuery->rec.total); @@ -5080,7 +4788,7 @@ static void tableQueryImpl(SQInfo *pQInfo) { } qTrace("QInfo:%p query over, %d rows are returned", pQInfo, pQuery->rec.total); - // vnodePrintQueryStatistics(pSupporter); + queryCostStatis(pQInfo); return; } @@ -5112,6 +4820,10 @@ static void tableQueryImpl(SQInfo *pQInfo) { } else {// todo set the table uid and tid in log qTrace("QInfo:%p query paused, %" PRId64 " rows returned, numOfTotal:%" PRId64 " rows", pQInfo, pQuery->rec.rows, pQuery->rec.total + pQuery->rec.rows); + + if (Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED)) { + queryCostStatis(pQInfo); + } } } @@ -5122,11 +4834,12 @@ static void stableQueryImpl(SQInfo *pQInfo) { int64_t st = taosGetTimestampUs(); if (isIntervalQuery(pQuery) || - (isFixedOutputQuery(pQuery) && (!isPointInterpoQuery(pQuery)) && !isGroupbyNormalCol(pQuery->pGroupbyExpr))) { + (isFixedOutputQuery(pQuery) && (!isPointInterpoQuery(pQuery)) && !isGroupbyNormalCol(pQuery->pGroupbyExpr) && + !isFirstLastRowQuery(pQuery))) { multiTableQueryProcess(pQInfo); } else { assert((pQuery->checkBuffer == 1 && pQuery->intervalTime == 0) || isPointInterpoQuery(pQuery) || - isGroupbyNormalCol(pQuery->pGroupbyExpr)); + isFirstLastRowQuery(pQuery) || isGroupbyNormalCol(pQuery->pGroupbyExpr)); sequentialTableProcess(pQInfo); } @@ -5138,7 +4851,7 @@ static void stableQueryImpl(SQInfo *pQInfo) { if (pQuery->rec.rows == 0) { qTrace("QInfo:%p over, %d tables queried, %d points are returned", pQInfo, pQInfo->groupInfo.numOfTables, pQuery->rec.total); - // vnodePrintQueryStatistics(pSupporter); + // queryCostStatis(pSupporter); } } @@ -5450,9 +5163,9 @@ static int32_t buildAirthmeticExprFromMsg(SExprInfo *pArithExprInfo, SQueryTable return TSDB_CODE_SUCCESS; } -static int32_t createSqlFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo **pSqlFuncExpr, - SSqlFuncMsg **pExprMsg, SColumnInfo* pTagCols) { - *pSqlFuncExpr = NULL; +static int32_t createSqlFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo **pExprInfo, SSqlFuncMsg **pExprMsg, + SColumnInfo* pTagCols) { + *pExprInfo = NULL; int32_t code = TSDB_CODE_SUCCESS; SExprInfo *pExprs = (SExprInfo *)calloc(1, sizeof(SExprInfo) * pQueryMsg->numOfOutput); @@ -5506,8 +5219,6 @@ static int32_t createSqlFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo assert(isValidDataType(pExprs[i].type, pExprs[i].bytes)); } - // get the correct result size for top/bottom query, according to the number of tags columns in selection clause - // TODO refactor for (int32_t i = 0; i < pQueryMsg->numOfOutput; ++i) { pExprs[i].base = *pExprMsg[i]; @@ -5527,7 +5238,7 @@ static int32_t createSqlFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo } tfree(pExprMsg); - *pSqlFuncExpr = pExprs; + *pExprInfo = pExprs; return TSDB_CODE_SUCCESS; } @@ -5646,25 +5357,32 @@ static void doUpdateExprColumnIndex(SQuery *pQuery) { for (int32_t k = 0; k < pQuery->numOfOutput; ++k) { SSqlFuncMsg *pSqlExprMsg = &pQuery->pSelectExpr[k].base; - if (pSqlExprMsg->functionId == TSDB_FUNC_ARITHM || pSqlExprMsg->colInfo.flag == TSDB_COL_TAG) { + if (pSqlExprMsg->functionId == TSDB_FUNC_ARITHM) { continue; } + // todo opt performance SColIndex *pColIndex = &pSqlExprMsg->colInfo; if (!TSDB_COL_IS_TAG(pColIndex->flag)) { - for (int32_t f = 0; f < pQuery->numOfCols; ++f) { + int32_t f = 0; + for (f = 0; f < pQuery->numOfCols; ++f) { if (pColIndex->colId == pQuery->colList[f].colId) { pColIndex->colIndex = f; break; } } + + assert (f < pQuery->numOfCols); } else { - for (int32_t f = 0; f < pQuery->numOfTags; ++f) { + int32_t f = 0; + for (f = 0; f < pQuery->numOfTags; ++f) { if (pColIndex->colId == pQuery->tagColList[f].colId) { pColIndex->colIndex = f; break; } } + + assert(f < pQuery->numOfTags || pColIndex->colId == TSDB_TBNAME_COLUMN_INDEX); } } } @@ -5702,7 +5420,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, pQuery->intervalTime = pQueryMsg->intervalTime; pQuery->slidingTime = pQueryMsg->slidingTime; pQuery->slidingTimeUnit = pQueryMsg->slidingTimeUnit; - pQuery->fillType = pQueryMsg->fillType; + pQuery->fillType = pQueryMsg->fillType; pQuery->numOfTags = pQueryMsg->numOfTags; // todo do not allocate ?? @@ -5784,7 +5502,6 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, STableId id = *(STableId*) taosArrayGet(pa, j); SGroupItem item = { .id = id }; // NOTE: compare STableIdInfo with STableId - // not a problem at present because we only use their 1st int64_t field STableIdInfo* pTableId = taosArraySearch( pTableIdList, &id, compareTableIdInfo); if (pTableId != NULL ) { window.skey = pTableId->key; @@ -5792,7 +5509,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, window.skey = pQueryMsg->window.skey; } item.info = createTableQueryInfo(&pQInfo->runtimeEnv, item.id, window); - item.info->groupIdx = i; + item.info->groupIndex = i; item.info->tableIndex = tableIndex++; taosArrayPush(p1, &item); } @@ -5802,7 +5519,6 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, pQInfo->arrTableIdInfo = taosArrayInit(tableIndex, sizeof(STableIdInfo)); pQuery->pos = -1; - pQuery->window = pQueryMsg->window; if (sem_init(&pQInfo->dataReady, 0, 0) != 0) { @@ -5810,7 +5526,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, goto _cleanup; } - vnodeParametersSafetyCheck(pQuery); + colIdCheck(pQuery); qTrace("qmsg:%p QInfo:%p created", pQueryMsg, pQInfo); return pQInfo; @@ -5875,6 +5591,14 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ sem_post(&pQInfo->dataReady); return TSDB_CODE_SUCCESS; } + + if (pQInfo->groupInfo.numOfTables == 0) { + qTrace("QInfo:%p no table qualified for tag filter, abort query", pQInfo); + setQueryStatus(pQuery, QUERY_COMPLETED); + + sem_post(&pQInfo->dataReady); + return TSDB_CODE_SUCCESS; + } // filter the qualified if ((code = doInitQInfo(pQInfo, pTSBuf, tsdb, vgId, isSTable)) != TSDB_CODE_SUCCESS) { @@ -6108,12 +5832,7 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi // todo handle the error /*int32_t ret =*/tsdbQuerySTableByTagCond(tsdb, id->uid, tagCond, pQueryMsg->tagCondLen, pQueryMsg->tagNameRelType, tbnameCond, &groupInfo, pGroupColIndex, numOfGroupByCols); - if (groupInfo.numOfTables == 0) { // no qualified tables no need to do query - code = TSDB_CODE_SUCCESS; - goto _over; - } } else { - groupInfo.numOfTables = taosArrayGetSize(pTableIdList); SArray* pTableGroup = taosArrayInit(1, POINTER_BYTES); SArray* sa = taosArrayInit(groupInfo.numOfTables, sizeof(STableId)); @@ -6142,7 +5861,6 @@ _over: taosArrayDestroy(pTableIdList); // if failed to add ref for all meters in this query, abort current query - // atomic_fetch_add_32(&vnodeSelectReqNum, 1); return code; } @@ -6155,7 +5873,7 @@ void qTableQuery(qinfo_t qinfo) { SQInfo *pQInfo = (SQInfo *)qinfo; if (pQInfo == NULL || pQInfo->signature != pQInfo) { - qTrace("%p freed abort query", pQInfo); + qTrace("QInfo:%p has been freed, no need to execute", pQInfo); return; } @@ -6268,7 +5986,10 @@ static void buildTagQueryResult(SQInfo* pQInfo) { SQuery * pQuery = pRuntimeEnv->pQuery; size_t num = taosArrayGetSize(pQInfo->groupInfo.pGroupList); - assert(num == 1); // only one group + assert(num == 0 || num == 1); + if (num == 0) { + return; + } SArray* pa = taosArrayGetP(pQInfo->groupInfo.pGroupList, 0); num = taosArrayGetSize(pa); @@ -6320,9 +6041,9 @@ static void buildTagQueryResult(SQInfo* pQInfo) { memcpy(dst, data, varDataTLen(data)); } else {// todo refactor, return the true length of binary|nchar data tsdbGetTableTagVal(pQInfo->tsdb, &item->id, pExprInfo[j].base.colInfo.colId, &type, &bytes, &data); - assert(bytes == pExprInfo[j].bytes && type == pExprInfo[j].type); + assert(bytes <= pExprInfo[j].bytes && type == pExprInfo[j].type); - char* dst = pQuery->sdata[j]->data + i * bytes; + char* dst = pQuery->sdata[j]->data + i * pExprInfo[j].bytes; if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { memcpy(dst, data, varDataTLen(data)); } else { diff --git a/src/query/src/qFilterFunc.c b/src/query/src/qFilterFunc.c index bcc9531c4e..1a95b9fe21 100644 --- a/src/query/src/qFilterFunc.c +++ b/src/query/src/qFilterFunc.c @@ -209,7 +209,7 @@ bool like_str(SColumnFilterElem *pFilter, char *minval, char *maxval) { bool like_nchar(SColumnFilterElem* pFilter, char* minval, char *maxval) { SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; - return WCSPatternMatch((wchar_t*) pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE, &info) == TSDB_PATTERN_MATCH; + return WCSPatternMatch((wchar_t*)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE, &info) == TSDB_PATTERN_MATCH; } //////////////////////////////////////////////////////////////// diff --git a/src/query/src/qUtil.c b/src/query/src/qUtil.c index 2d713e127f..a85cdc274d 100644 --- a/src/query/src/qUtil.c +++ b/src/query/src/qUtil.c @@ -137,11 +137,10 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) { for (int32_t k = 0; k < pWindowResInfo->size; ++k) { SWindowResult *pResult = &pWindowResInfo->pResult[k]; int32_t *p = (int32_t *)taosHashGet(pWindowResInfo->hashList, (const char *)&pResult->window.skey, TSDB_KEYSIZE); + int32_t v = (*p - num); assert(v >= 0 && v <= pWindowResInfo->size); - - taosHashPut(pWindowResInfo->hashList, (const char *)&pResult->window.skey, TSDB_KEYSIZE, (char *)&v, - sizeof(int32_t)); + taosHashPut(pWindowResInfo->hashList, (char *)&pResult->window.skey, TSDB_KEYSIZE, (char *)&v, sizeof(int32_t)); } pWindowResInfo->curIndex = -1; diff --git a/src/query/src/qfill.c b/src/query/src/qfill.c index 36ffc433ce..8c8a50a3d8 100644 --- a/src/query/src/qfill.c +++ b/src/query/src/qfill.c @@ -79,7 +79,7 @@ SFillInfo* taosInitFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_ int32_t rowsize = 0; for (int32_t i = 0; i < numOfCols; ++i) { int32_t bytes = pFillInfo->pFillCol[i].col.bytes; - pFillInfo->pData[i] = calloc(1, sizeof(tFilePage) + bytes * capacity); + pFillInfo->pData[i] = calloc(1, bytes * capacity); rowsize += bytes; } @@ -89,6 +89,8 @@ SFillInfo* taosInitFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_ } pFillInfo->rowSize = rowsize; + pFillInfo->capacityInRows = capacity; + return pFillInfo; } @@ -119,6 +121,17 @@ void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey) pFillInfo->rowIdx = 0; pFillInfo->endKey = endKey; pFillInfo->numOfRows = numOfRows; + + // ensure the space + if (pFillInfo->capacityInRows < numOfRows) { + for(int32_t i = 0; i < pFillInfo->numOfCols; ++i) { + char* tmp = realloc(pFillInfo->pData[i], numOfRows*pFillInfo->pFillCol[i].col.bytes); + assert(tmp != NULL); // todo handle error + + memset(tmp, 0, numOfRows*pFillInfo->pFillCol[i].col.bytes); + pFillInfo->pData[i] = tmp; + } + } } void taosFillCopyInputDataFromFilePage(SFillInfo* pFillInfo, tFilePage** pInput) { @@ -474,11 +487,11 @@ int32_t generateDataBlockImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t nu } int64_t taosGenerateDataBlock(SFillInfo* pFillInfo, tFilePage** output, int32_t capacity) { - int32_t remain = taosNumOfRemainRows(pFillInfo); // todo use iterator? - int32_t rows = taosGetNumOfResultWithFill(pFillInfo, remain, pFillInfo->endKey, capacity); + int32_t remain = taosNumOfRemainRows(pFillInfo); // todo use iterator? + int32_t rows = taosGetNumOfResultWithFill(pFillInfo, remain, pFillInfo->endKey, capacity); + + int32_t numOfRes = generateDataBlockImpl(pFillInfo, output, remain, rows, pFillInfo->pData); + assert(numOfRes == rows); - int32_t numOfRes = generateDataBlockImpl(pFillInfo, output, remain, rows, pFillInfo->pData); - assert(numOfRes == rows); - - return numOfRes; + return numOfRes; } diff --git a/src/query/src/qresultBuf.c b/src/query/src/qresultBuf.c index bdf700c83f..8910d84830 100644 --- a/src/query/src/qresultBuf.c +++ b/src/query/src/qresultBuf.c @@ -5,14 +5,12 @@ #include "tsqlfunction.h" #include "queryLog.h" -#define DEFAULT_INTERN_BUF_SIZE 16384L - int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t size, int32_t rowSize, void* handle) { SDiskbasedResultBuf* pResBuf = calloc(1, sizeof(SDiskbasedResultBuf)); - pResBuf->numOfRowsPerPage = (DEFAULT_INTERN_BUF_SIZE - sizeof(tFilePage)) / rowSize; + pResBuf->numOfRowsPerPage = (DEFAULT_INTERN_BUF_PAGE_SIZE - sizeof(tFilePage)) / rowSize; pResBuf->numOfPages = size; - pResBuf->totalBufSize = pResBuf->numOfPages * DEFAULT_INTERN_BUF_SIZE; + pResBuf->totalBufSize = pResBuf->numOfPages * DEFAULT_INTERN_BUF_PAGE_SIZE; pResBuf->incStep = 4; // init id hash table @@ -33,7 +31,7 @@ int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t si return TSDB_CODE_CLI_NO_DISKSPACE; } - int32_t ret = ftruncate(pResBuf->fd, pResBuf->numOfPages * DEFAULT_INTERN_BUF_SIZE); + int32_t ret = ftruncate(pResBuf->fd, pResBuf->numOfPages * DEFAULT_INTERN_BUF_PAGE_SIZE); if (ret != TSDB_CODE_SUCCESS) { qError("failed to create tmp file: %s on disk. %s", pResBuf->path, strerror(errno)); return TSDB_CODE_CLI_NO_DISKSPACE; @@ -55,7 +53,7 @@ int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t si tFilePage* getResultBufferPageById(SDiskbasedResultBuf* pResultBuf, int32_t id) { assert(id < pResultBuf->numOfPages && id >= 0); - return (tFilePage*)(pResultBuf->pBuf + DEFAULT_INTERN_BUF_SIZE * id); + return (tFilePage*)(pResultBuf->pBuf + DEFAULT_INTERN_BUF_PAGE_SIZE * id); } int32_t getNumOfResultBufGroupId(SDiskbasedResultBuf* pResultBuf) { return taosHashGetSize(pResultBuf->idsTable); } @@ -63,7 +61,7 @@ int32_t getNumOfResultBufGroupId(SDiskbasedResultBuf* pResultBuf) { return taosH int32_t getResBufSize(SDiskbasedResultBuf* pResultBuf) { return pResultBuf->totalBufSize; } static int32_t extendDiskFileSize(SDiskbasedResultBuf* pResultBuf, int32_t numOfPages) { - assert(pResultBuf->numOfPages * DEFAULT_INTERN_BUF_SIZE == pResultBuf->totalBufSize); + assert(pResultBuf->numOfPages * DEFAULT_INTERN_BUF_PAGE_SIZE == pResultBuf->totalBufSize); int32_t ret = munmap(pResultBuf->pBuf, pResultBuf->totalBufSize); pResultBuf->numOfPages += numOfPages; @@ -72,14 +70,14 @@ static int32_t extendDiskFileSize(SDiskbasedResultBuf* pResultBuf, int32_t numOf * disk-based output buffer is exhausted, try to extend the disk-based buffer, the available disk space may * be insufficient */ - ret = ftruncate(pResultBuf->fd, pResultBuf->numOfPages * DEFAULT_INTERN_BUF_SIZE); + ret = ftruncate(pResultBuf->fd, pResultBuf->numOfPages * DEFAULT_INTERN_BUF_PAGE_SIZE); if (ret != 0) { // dError("QInfo:%p failed to create intermediate result output file:%s. %s", pQInfo, pSupporter->extBufFile, // strerror(errno)); return -TSDB_CODE_SERV_NO_DISKSPACE; } - pResultBuf->totalBufSize = pResultBuf->numOfPages * DEFAULT_INTERN_BUF_SIZE; + pResultBuf->totalBufSize = pResultBuf->numOfPages * DEFAULT_INTERN_BUF_PAGE_SIZE; pResultBuf->pBuf = mmap(NULL, pResultBuf->totalBufSize, PROT_READ | PROT_WRITE, MAP_SHARED, pResultBuf->fd, 0); if (pResultBuf->pBuf == MAP_FAILED) { @@ -174,7 +172,7 @@ tFilePage* getNewDataBuf(SDiskbasedResultBuf* pResultBuf, int32_t groupId, int32 tFilePage* page = getResultBufferPageById(pResultBuf, *pageId); // clear memory for the new page - memset(page, 0, DEFAULT_INTERN_BUF_SIZE); + memset(page, 0, DEFAULT_INTERN_BUF_PAGE_SIZE); return page; } diff --git a/src/query/src/tvariant.c b/src/query/src/tvariant.c index c89e9dc5f2..2cf60d3e91 100644 --- a/src/query/src/tvariant.c +++ b/src/query/src/tvariant.c @@ -363,8 +363,6 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) { taosUcs4ToMbs(pVariant->wpz, newSize, pBuf); free(pVariant->wpz); - - /* terminated string */ pBuf[newSize] = 0; } else { taosUcs4ToMbs(pVariant->wpz, newSize, *pDest); @@ -598,7 +596,7 @@ static int32_t convertToBool(tVariant *pVariant, int64_t *pDest) { * * todo handle the return value */ -int32_t tVariantDump(tVariant *pVariant, char *payload, char type) { +int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix) { if (pVariant == NULL || (pVariant->nType != 0 && !isValidDataType(pVariant->nType, pVariant->nLen))) { return -1; } @@ -765,13 +763,30 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, char type) { } case TSDB_DATA_TYPE_BINARY: { - if (pVariant->nType == TSDB_DATA_TYPE_NULL) { - *payload = TSDB_DATA_BINARY_NULL; - } else { - if (pVariant->nType != TSDB_DATA_TYPE_BINARY) { - toBinary(pVariant, &payload, &pVariant->nLen); + if (!includeLengthPrefix) { + if (pVariant->nType == TSDB_DATA_TYPE_NULL) { + *(uint8_t*) payload = TSDB_DATA_BINARY_NULL; } else { - strncpy(payload, pVariant->pz, pVariant->nLen); + if (pVariant->nType != TSDB_DATA_TYPE_BINARY) { + toBinary(pVariant, &payload, &pVariant->nLen); + } else { + strncpy(payload, pVariant->pz, pVariant->nLen); + } + } + } else { + if (pVariant->nType == TSDB_DATA_TYPE_NULL) { + setVardataNull(payload, TSDB_DATA_TYPE_BINARY); + } else { + char *p = varDataVal(payload); + + if (pVariant->nType != TSDB_DATA_TYPE_BINARY) { + toBinary(pVariant, &p, &pVariant->nLen); + } else { + strncpy(p, pVariant->pz, pVariant->nLen); + } + + varDataSetLen(payload, pVariant->nLen); + assert(p == varDataVal(payload)); } } break; @@ -785,15 +800,33 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, char type) { break; } case TSDB_DATA_TYPE_NCHAR: { - if (pVariant->nType == TSDB_DATA_TYPE_NULL) { - *(uint32_t *) payload = TSDB_DATA_NCHAR_NULL; - } else { - if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) { - toNchar(pVariant, &payload, &pVariant->nLen); + if (!includeLengthPrefix) { + if (pVariant->nType == TSDB_DATA_TYPE_NULL) { + *(uint32_t *)payload = TSDB_DATA_NCHAR_NULL; } else { - wcsncpy((wchar_t *)payload, pVariant->wpz, pVariant->nLen); + if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) { + toNchar(pVariant, &payload, &pVariant->nLen); + } else { + wcsncpy((wchar_t *)payload, pVariant->wpz, pVariant->nLen); + } + } + } else { + if (pVariant->nType == TSDB_DATA_TYPE_NULL) { + setVardataNull(payload, TSDB_DATA_TYPE_NCHAR); + } else { + char *p = varDataVal(payload); + + if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) { + toNchar(pVariant, &p, &pVariant->nLen); + } else { + wcsncpy((wchar_t *)p, pVariant->wpz, pVariant->nLen); + } + + varDataSetLen(payload, pVariant->nLen); // the length may be changed after toNchar function called + assert(p == varDataVal(payload)); } } + break; } } diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 297ff31ed9..405f796a5e 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -124,8 +124,7 @@ typedef struct SRpcConn { } SRpcConn; int tsRpcMaxUdpSize = 15000; // bytes -int tsRpcProgressTime = 10; // milliseocnds - +int tsProgressTimer = 100; // not configurable int tsRpcMaxRetry; int tsRpcHeadSize; @@ -204,7 +203,8 @@ static void rpcUnlockConn(SRpcConn *pConn); void *rpcOpen(const SRpcInit *pInit) { SRpcInfo *pRpc; - tsRpcMaxRetry = tsRpcMaxTime * 1000 / tsRpcProgressTime; + tsProgressTimer = tsRpcTimer/2; + tsRpcMaxRetry = tsRpcMaxTime * 1000/tsProgressTimer; tsRpcHeadSize = RPC_MSG_OVERHEAD; tsRpcOverhead = sizeof(SRpcReqContext); @@ -420,13 +420,16 @@ void rpcSendResponse(const SRpcMsg *pRsp) { pConn->rspMsgLen = msgLen; if (pMsg->code == TSDB_CODE_ACTION_IN_PROGRESS) pConn->inTranId--; - rpcUnlockConn(pConn); - + SRpcInfo *pRpc = pConn->pRpc; taosTmrStopA(&pConn->pTimer); - // taosTmrReset(rpcProcessIdleTimer, pRpc->idleTime, pConn, pRpc->tmrCtrl, &pConn->pIdleTimer); + + // set the idle timer to monitor the activity + taosTmrReset(rpcProcessIdleTimer, pRpc->idleTime, pConn, pRpc->tmrCtrl, &pConn->pIdleTimer); rpcSendMsgToPeer(pConn, msg, msgLen); pConn->secured = 1; // connection shall be secured + rpcUnlockConn(pConn); + return; } @@ -683,6 +686,7 @@ static SRpcConn *rpcSetupConnToServer(SRpcReqContext *pContext) { tError("%s %p, failed to set up connection(%s)", pRpc->label, pContext->ahandle, tstrerror(terrno)); } + pConn->tretry = 0; return pConn; } @@ -748,20 +752,28 @@ static int rpcProcessRspHead(SRpcConn *pConn, SRpcHead *pHead) { taosTmrStopA(&pConn->pTimer); pConn->retry = 0; + if (pHead->code == TSDB_CODE_AUTH_REQUIRED && pRpc->spi) { + tTrace("%s, authentication shall be restarted", pConn->info); + pConn->secured = 0; + rpcSendMsgToPeer(pConn, pConn->pReqMsg, pConn->reqMsgLen); + pConn->pTimer = taosTmrStart(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl); + return TSDB_CODE_ALREADY_PROCESSED; + } + if (pHead->code == TSDB_CODE_ACTION_IN_PROGRESS) { if (pConn->tretry <= tsRpcMaxRetry) { - tTrace("%s, peer is still processing the transaction", pConn->info); + tTrace("%s, peer is still processing the transaction, retry:%d", pConn->info, pConn->tretry); pConn->tretry++; rpcSendReqHead(pConn); - taosTmrReset(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl, &pConn->pTimer); + pConn->pTimer = taosTmrStart(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl); return TSDB_CODE_ALREADY_PROCESSED; } else { // peer still in processing, give up - return TSDB_CODE_TOO_SLOW; + tTrace("%s, server processing takes too long time, give up", pConn->info); + pHead->code = TSDB_CODE_TOO_SLOW; } } - pConn->tretry = 0; pConn->outType = 0; pConn->pReqMsg = NULL; pConn->reqMsgLen = 0; @@ -820,7 +832,9 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) { if ( rpcIsReq(pHead->msgType) ) { terrno = rpcProcessReqHead(pConn, pHead); pConn->connType = pRecv->connType; - taosTmrReset(rpcProcessIdleTimer, pRpc->idleTime, pConn, pRpc->tmrCtrl, &pConn->pIdleTimer); + + // client shall send the request within tsRpcTime again, put 20 mseconds tolerance + taosTmrReset(rpcProcessIdleTimer, tsRpcTimer+20, pConn, pRpc->tmrCtrl, &pConn->pIdleTimer); } else { terrno = rpcProcessRspHead(pConn, pHead); } @@ -935,7 +949,7 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) { if ( rpcIsReq(pHead->msgType) ) { rpcMsg.handle = pConn; - taosTmrReset(rpcProcessProgressTimer, tsRpcTimer/2, pConn, pRpc->tmrCtrl, &pConn->pTimer); + pConn->pTimer = taosTmrStart(rpcProcessProgressTimer, tsProgressTimer, pConn, pRpc->tmrCtrl); (*(pRpc->cfp))(&rpcMsg, NULL); } else { // it's a response @@ -943,14 +957,12 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) { rpcMsg.handle = pContext->ahandle; pConn->pContext = NULL; - if (pHead->code == TSDB_CODE_AUTH_REQUIRED) { - pConn->secured = 0; - rpcSendReqToServer(pRpc, pContext); - return; - } - // for UDP, port may be changed by server, the port in ipSet shall be used for cache - rpcAddConnIntoCache(pRpc->pCache, pConn, pConn->peerFqdn, pContext->ipSet.port[pContext->ipSet.inUse], pConn->connType); + if (pHead->code != TSDB_CODE_TOO_SLOW) { + rpcAddConnIntoCache(pRpc->pCache, pConn, pConn->peerFqdn, pContext->ipSet.port[pContext->ipSet.inUse], pConn->connType); + } else { + rpcCloseConn(pConn); + } if (pHead->code == TSDB_CODE_REDIRECT) { pContext->redirect++; @@ -1039,6 +1051,7 @@ static void rpcSendErrorMsgToPeer(SRecvInfo *pRecv, int32_t code) { pReplyHead->sourceId = pRecvHead->destId; pReplyHead->destId = pRecvHead->sourceId; pReplyHead->linkUid = pRecvHead->linkUid; + pReplyHead->ahandle = pRecvHead->ahandle; pReplyHead->code = htonl(code); msgLen = sizeof(SRpcHead); @@ -1095,10 +1108,10 @@ static void rpcSendReqToServer(SRpcInfo *pRpc, SRpcReqContext *pContext) { pConn->reqMsgLen = msgLen; pConn->pContext = pContext; - rpcUnlockConn(pConn); - - taosTmrReset(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl, &pConn->pTimer); rpcSendMsgToPeer(pConn, msg, msgLen); + taosTmrReset(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl, &pConn->pTimer); + + rpcUnlockConn(pConn); } static void rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) { @@ -1172,7 +1185,7 @@ static void rpcProcessRetryTimer(void *param, void *tmrId) { if (pConn->retry < 4) { tTrace("%s, re-send msg:%s to %s:%hu", pConn->info, taosMsg[pConn->outType], pConn->peerFqdn, pConn->peerPort); rpcSendMsgToPeer(pConn, pConn->pReqMsg, pConn->reqMsgLen); - taosTmrReset(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl, &pConn->pTimer); + pConn->pTimer = taosTmrStart(rpcProcessRetryTimer, tsRpcTimer, pConn, pRpc->tmrCtrl); } else { // close the connection tTrace("%s, failed to send msg:%s to %s:%hu", pConn->info, taosMsg[pConn->outType], pConn->peerFqdn, pConn->peerPort); @@ -1225,7 +1238,7 @@ static void rpcProcessProgressTimer(void *param, void *tmrId) { if (pConn->inType && pConn->user[0]) { tTrace("%s, progress timer expired, send progress", pConn->info); rpcSendQuickRsp(pConn, TSDB_CODE_ACTION_IN_PROGRESS); - taosTmrReset(rpcProcessProgressTimer, tsRpcTimer/2, pConn, pRpc->tmrCtrl, &pConn->pTimer); + pConn->pTimer = taosTmrStart(rpcProcessProgressTimer, tsProgressTimer, pConn, pRpc->tmrCtrl); } else { tTrace("%s, progress timer:%p not processed", pConn->info, tmrId); } @@ -1357,15 +1370,17 @@ static int rpcCheckAuthentication(SRpcConn *pConn, char *msg, int msgLen) { if ((pConn->secured && pHead->spi == 0) || (pHead->spi == 0 && pConn->spi == 0)){ // secured link, or no authentication pHead->msgLen = (int32_t)htonl((uint32_t)pHead->msgLen); + // tTrace("%s, secured link, no auth is required", pConn->info); return 0; } if ( !rpcIsReq(pHead->msgType) ) { // for response, if code is auth failure, it shall bypass the auth process code = htonl(pHead->code); - if (code==TSDB_CODE_INVALID_TIME_STAMP || code==TSDB_CODE_AUTH_FAILURE || + if (code==TSDB_CODE_INVALID_TIME_STAMP || code==TSDB_CODE_AUTH_FAILURE || code == TSDB_CODE_AUTH_REQUIRED || code==TSDB_CODE_INVALID_USER || code == TSDB_CODE_NOT_READY) { pHead->msgLen = (int32_t)htonl((uint32_t)pHead->msgLen); + // tTrace("%s, dont check authentication since code is:0x%x", pConn->info, code); return 0; } } @@ -1388,12 +1403,12 @@ static int rpcCheckAuthentication(SRpcConn *pConn, char *msg, int msgLen) { } else { pHead->msgLen = (int32_t)htonl((uint32_t)pHead->msgLen) - sizeof(SRpcDigest); if ( !rpcIsReq(pHead->msgType) ) pConn->secured = 1; // link is secured for client - //tTrace("%s, message is authenticated", pConn->info); + // tTrace("%s, message is authenticated", pConn->info); } } } else { tError("%s, auth spi:%d not matched with received:%d", pConn->info, pConn->spi, pHead->spi); - code = TSDB_CODE_AUTH_FAILURE; + code = pHead->spi ? TSDB_CODE_AUTH_FAILURE : TSDB_CODE_AUTH_REQUIRED; } return code; diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h index 0839e0f8ff..9dd5136c95 100644 --- a/src/tsdb/inc/tsdbMain.h +++ b/src/tsdb/inc/tsdbMain.h @@ -87,6 +87,7 @@ typedef struct STable { struct STable *prev; tstr * name; // NOTE: there a flexible string here char * sql; + void * cqhandle; } STable; #define TSDB_GET_TABLE_LAST_KEY(tb) ((tb)->lastKey) @@ -110,6 +111,7 @@ typedef struct { SMetaFile *mfh; // meta file handle int maxRowBytes; int maxCols; + void * pRepo; } STsdbMeta; // element put in skiplist for each table @@ -118,7 +120,7 @@ typedef struct STableIndexElem { STable* pTable; } STableIndexElem; -STsdbMeta *tsdbInitMeta(char *rootDir, int32_t maxTables); +STsdbMeta *tsdbInitMeta(char *rootDir, int32_t maxTables, void *pRepo); int32_t tsdbFreeMeta(STsdbMeta *pMeta); STSchema * tsdbGetTableSchema(STsdbMeta *pMeta, STable *pTable); STSchema * tsdbGetTableTagSchema(STsdbMeta *pMeta, STable *pTable); diff --git a/src/tsdb/src/tsdbFile.c b/src/tsdb/src/tsdbFile.c index bd5c20bd7a..b07f6eed7f 100644 --- a/src/tsdb/src/tsdbFile.c +++ b/src/tsdb/src/tsdbFile.c @@ -288,7 +288,11 @@ int tsdbCopyBlockDataInFile(SFile *pOutFile, SFile *pInFile, SCompInfo *pCompInf static int compFGroupKey(const void *key, const void *fgroup) { int fid = *(int *)key; SFileGroup *pFGroup = (SFileGroup *)fgroup; - return (fid - pFGroup->fileId); + if (fid == pFGroup->fileId) { + return 0; + } else { + return fid > pFGroup->fileId? 1:-1; + } } static int compFGroup(const void *arg1, const void *arg2) { diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index bddb3fcaff..9c8e57d18a 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -189,9 +189,9 @@ _err: * * @return a TSDB repository handle on success, NULL for failure and the error number is set */ -TsdbRepoT *tsdbOpenRepo(char *tsdbDir, STsdbAppH *pAppH) { +TsdbRepoT *tsdbOpenRepo(char *rootDir, STsdbAppH *pAppH) { char dataDir[128] = "\0"; - if (access(tsdbDir, F_OK | W_OK | R_OK) < 0) { + if (access(rootDir, F_OK | W_OK | R_OK) < 0) { return NULL; } @@ -200,12 +200,12 @@ TsdbRepoT *tsdbOpenRepo(char *tsdbDir, STsdbAppH *pAppH) { return NULL; } - pRepo->rootDir = strdup(tsdbDir); + pRepo->rootDir = strdup(rootDir); tsdbRestoreCfg(pRepo, &(pRepo->config)); if (pAppH) pRepo->appH = *pAppH; - pRepo->tsdbMeta = tsdbInitMeta(tsdbDir, pRepo->config.maxTables); + pRepo->tsdbMeta = tsdbInitMeta(rootDir, pRepo->config.maxTables, pRepo); if (pRepo->tsdbMeta == NULL) { free(pRepo->rootDir); free(pRepo); diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index e320de9827..03394409a7 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -103,7 +103,8 @@ STable *tsdbDecodeTable(void *cont, int contLen) { if (pTable->type == TSDB_STREAM_TABLE) { ptr = taosDecodeString(ptr, &(pTable->sql)); } - + + pTable->lastKey = TSKEY_INITIAL_VAL; return pTable; } @@ -118,7 +119,7 @@ static char* getTagIndexKey(const void* pData) { STSchema* pSchema = tsdbGetTableTagSchema(elem->pMeta, elem->pTable); STColumn* pCol = &pSchema->columns[DEFAULT_TAG_INDEX_COLUMN]; int16_t type = 0; - void * res = tdQueryTagByID(row, pCol->colId,&type); + void * res = tdQueryTagByID(row, pCol->colId, &type); ASSERT(type == pCol->type); return res; } @@ -142,6 +143,7 @@ int tsdbRestoreTable(void *pHandle, void *cont, int contLen) { void tsdbOrgMeta(void *pHandle) { STsdbMeta *pMeta = (STsdbMeta *)pHandle; + STsdbRepo *pRepo = (STsdbRepo *)pMeta->pRepo; for (int i = 1; i < pMeta->maxTables; i++) { STable *pTable = pMeta->tables[i]; @@ -149,13 +151,20 @@ void tsdbOrgMeta(void *pHandle) { tsdbAddTableIntoIndex(pMeta, pTable); } } + + for (int i = 0; i < pMeta->maxTables; i++) { + STable *pTable = pMeta->tables[i]; + if (pTable && pTable->type == TSDB_STREAM_TABLE) { + pTable->cqhandle = (*pRepo->appH.cqCreateFunc)(pRepo->appH.cqH, i, pTable->sql, tsdbGetTableSchema(pMeta, pTable)); + } + } } /** * Initialize the meta handle * ASSUMPTIONS: VALID PARAMETER */ -STsdbMeta *tsdbInitMeta(char *rootDir, int32_t maxTables) { +STsdbMeta *tsdbInitMeta(char *rootDir, int32_t maxTables, void *pRepo) { STsdbMeta *pMeta = (STsdbMeta *)malloc(sizeof(STsdbMeta)); if (pMeta == NULL) return NULL; @@ -165,6 +174,7 @@ STsdbMeta *tsdbInitMeta(char *rootDir, int32_t maxTables) { pMeta->tables = (STable **)calloc(maxTables, sizeof(STable *)); pMeta->maxRowBytes = 0; pMeta->maxCols = 0; + pMeta->pRepo = pRepo; if (pMeta->tables == NULL) { free(pMeta); return NULL; @@ -189,13 +199,16 @@ STsdbMeta *tsdbInitMeta(char *rootDir, int32_t maxTables) { } int32_t tsdbFreeMeta(STsdbMeta *pMeta) { + STsdbRepo *pRepo = (STsdbRepo *)pMeta->pRepo; if (pMeta == NULL) return 0; tsdbCloseMetaFile(pMeta->mfh); for (int i = 1; i < pMeta->maxTables; i++) { if (pMeta->tables[i] != NULL) { - tsdbFreeTable(pMeta->tables[i]); + STable *pTable = pMeta->tables[i]; + if (pTable->type == TSDB_STREAM_TABLE) (*pRepo->appH.cqDropFunc)(pTable->cqhandle); + tsdbFreeTable(pTable); } } @@ -243,30 +256,18 @@ int32_t tsdbGetTableTagVal(TsdbRepoT* repo, STableId* id, int32_t colId, int16_t STsdbMeta* pMeta = tsdbGetMeta(repo); STable* pTable = tsdbGetTableByUid(pMeta, id->uid); - STSchema* pSchema = tsdbGetTableTagSchema(pMeta, pTable); - STColumn* pCol = NULL; + *val = tdQueryTagByID(pTable->tagVal, colId, type); - // todo binary search - for(int32_t col = 0; col < schemaNCols(pSchema); ++col) { - STColumn* p = schemaColAt(pSchema, col); - if (p->colId == colId) { - pCol = p; - break; + if (*val != NULL) { + switch(*type) { + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: *bytes = varDataLen(*val); break; + case TSDB_DATA_TYPE_NULL: *bytes = 0; break; + default: + *bytes = tDataTypeDesc[*type].nSize;break; } } - - if (pCol == NULL) { - return -1; // No matched tags. Maybe the modification of tags has not been done yet. - } - - SDataRow row = (SDataRow)pTable->tagVal; - int16_t tagtype = 0; - char* d = tdQueryTagByID(row, pCol->colId, &tagtype); - //ASSERT((int8_t)tagtype == pCol->type) - *val = d; - *type = pCol->type; - *bytes = pCol->bytes; - + return TSDB_CODE_SUCCESS; } @@ -393,7 +394,9 @@ int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg) { return -1; } } - + + table->lastKey = TSKEY_INITIAL_VAL; + // Register to meta if (newSuper) { tsdbAddTableToMeta(pMeta, super, true); @@ -512,6 +515,7 @@ STable *tsdbGetTableByUid(STsdbMeta *pMeta, uint64_t uid) { } static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx) { + STsdbRepo *pRepo = (STsdbRepo *)pMeta->pRepo; if (pTable->type == TSDB_SUPER_TABLE) { // add super table to the linked list if (pMeta->superList == NULL) { @@ -531,7 +535,7 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx) { tsdbAddTableIntoIndex(pMeta, pTable); } if (pTable->type == TSDB_STREAM_TABLE && addIdx) { - // TODO + pTable->cqhandle = (*pRepo->appH.cqCreateFunc)(pRepo->appH.cqH, pTable->tableId.tid, pTable->sql, tsdbGetTableSchema(pMeta, pTable)); } pMeta->nTables++; diff --git a/src/tsdb/src/tsdbRWHelper.c b/src/tsdb/src/tsdbRWHelper.c index eebe0b6b46..eeb212fe95 100644 --- a/src/tsdb/src/tsdbRWHelper.c +++ b/src/tsdb/src/tsdbRWHelper.c @@ -443,6 +443,11 @@ int tsdbWriteCompIdx(SRWHelper *pHelper) { for (uint32_t i = 0; i < pHelper->config.maxTables; i++) { SCompIdx *pCompIdx = pHelper->pCompIdx + i; if (pCompIdx->offset > 0) { + int drift = POINTER_DISTANCE(buf, pHelper->pBuffer); + if (tsizeof(pHelper->pBuffer) - drift < 128) { + pHelper->pBuffer = trealloc(pHelper->pBuffer, tsizeof(pHelper->pBuffer)*2); + } + buf = POINTER_SHIFT(pHelper->pBuffer, drift); buf = taosEncodeVariant32(buf, i); buf = tsdbEncodeSCompIdx(buf, pCompIdx); } @@ -469,6 +474,7 @@ int tsdbLoadCompIdx(SRWHelper *pHelper, void *target) { ASSERT(pFile->info.offset > TSDB_FILE_HEAD_SIZE); if (lseek(fd, pFile->info.offset, SEEK_SET) < 0) return -1; + if ((pHelper->pBuffer = trealloc(pHelper->pBuffer, pFile->info.len)) == NULL) return -1; if (tread(fd, (void *)(pHelper->pBuffer), pFile->info.len) < pFile->info.len) return -1; if (!taosCheckChecksumWhole((uint8_t *)(pHelper->pBuffer), pFile->info.len)) { diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 2220ebfd88..08804f6ba1 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -95,7 +95,6 @@ typedef struct STsdbQueryHandle { SQueryFilePos cur; // current position int16_t order; STimeWindow window; // the primary query time window that applies to all queries - SCompBlock* pBlock; SDataStatis* statis; // query level statistics, only one table block statistics info exists at any time int32_t numOfBlocks; SArray* pColumns; // column list, SColumnInfoData array list @@ -117,6 +116,12 @@ typedef struct STsdbQueryHandle { } STsdbQueryHandle; static void changeQueryHandleForLastrowQuery(TsdbQueryHandleT pqHandle); +static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle); +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 void tsdbInitDataBlockLoadInfo(SDataBlockLoadInfo* pBlockLoadInfo) { pBlockLoadInfo->slot = -1; @@ -188,9 +193,6 @@ TsdbQueryHandleT* tsdbQueryTables(TsdbRepoT* tsdb, STsdbQueryCond* pCond, STable } } - for(int32_t i = 0; i < numOfCols; ++i) { - } - uTrace("%p total numOfTable:%d in query", pQueryHandle, taosArrayGetSize(pQueryHandle->pTableCheckInfo)); tsdbInitDataBlockLoadInfo(&pQueryHandle->dataBlockLoadInfo); @@ -209,13 +211,29 @@ TsdbQueryHandleT tsdbQueryLastRow(TsdbRepoT *tsdb, STsdbQueryCond *pCond, STable return pQueryHandle; } +SArray* tsdbGetQueriedTableIdList(TsdbQueryHandleT *pHandle) { + assert(pHandle != NULL); + + STsdbQueryHandle *pQueryHandle = (STsdbQueryHandle*) pHandle; + + size_t size = taosArrayGetSize(pQueryHandle->pTableCheckInfo); + SArray* res = taosArrayInit(size, sizeof(STableId)); + + for(int32_t i = 0; i < size; ++i) { + STableCheckInfo* pCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, i); + taosArrayPush(res, &pCheckInfo->tableId); + } + + return res; +} + TsdbQueryHandleT tsdbQueryRowsInExternalWindow(TsdbRepoT *tsdb, STsdbQueryCond* pCond, STableGroupInfo *groupList) { STsdbQueryHandle *pQueryHandle = (STsdbQueryHandle*) tsdbQueryTables(tsdb, pCond, groupList); pQueryHandle->type = TSDB_QUERY_TYPE_EXTERNAL; - pQueryHandle->order = TSDB_ORDER_ASC; +// pQueryHandle->outputCapacity = 2; // only allowed two rows to be loaded -// changeQueryHandleForLastrowQuery(pQueryHandle); + changeQueryHandleForInterpQuery(pQueryHandle); return pQueryHandle; } @@ -328,13 +346,35 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) { (pCheckInfo->lastKey < pHandle->window.ekey && !ASCENDING_TRAVERSE(pHandle->order))) { return false; } + + int32_t step = ASCENDING_TRAVERSE(pHandle->order)? 1:-1; + STimeWindow* win = &pHandle->cur.win; + 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; + pHandle->cur.lastKey = win->ekey + step; + pHandle->cur.mixBlock = true; + if (!ASCENDING_TRAVERSE(pHandle->order)) { + SWAP(win->skey, win->ekey, TSKEY); + } + return true; } static int32_t getFileIdFromKey(TSKEY key, int32_t daysPerFile) { + if (key == TSKEY_INITIAL_VAL) { + return INT32_MIN; + } + int64_t fid = (int64_t)(key / (daysPerFile * tsMsPerDay[0])); // set the starting fileId - if (fid > INT32_MAX) { + if (fid < 0L && llabs(fid) > INT32_MAX) { // data value overflow for INT32 + fid = INT32_MIN; + } + + if (fid > 0L && fid > INT32_MAX) { fid = INT32_MAX; } @@ -472,12 +512,6 @@ static SArray* getDefaultLoadColumns(STsdbQueryHandle* pQueryHandle, bool loadTS return pLocalIdList; } -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; SCompData* data = calloc(1, sizeof(SCompData) + sizeof(SCompCol) * pBlock->numOfCols); @@ -581,13 +615,21 @@ static void handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBlock* } SArray* sa = getDefaultLoadColumns(pQueryHandle, true); + doLoadFileDataBlock(pQueryHandle, pBlock, pCheckInfo); doMergeTwoLevelData(pQueryHandle, pCheckInfo, pBlock, sa); taosArrayDestroy(sa); } else { + /* + * no data in cache, only load data from file + * during the query processing, data in cache will not be checked anymore. + * + * Here the buffer is not enough, so only part of file block can be loaded into memory buffer + */ + assert(pQueryHandle->outputCapacity >= binfo.rows); pQueryHandle->realNumOfRows = binfo.rows; - + cur->rows = binfo.rows; cur->win = binfo.window; cur->mixBlock = false; @@ -622,15 +664,14 @@ static bool loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock handleDataMergeIfNeeded(pQueryHandle, pBlock, pCheckInfo); } } else { //desc order, query ended in current block - if (pQueryHandle->window.ekey > pBlock->keyFirst) { + if (pQueryHandle->window.ekey > pBlock->keyFirst || pCheckInfo->lastKey < pBlock->keyLast) { if (!doLoadFileDataBlock(pQueryHandle, pBlock, pCheckInfo)) { return false; } - - SDataCols* pDataCols = pCheckInfo->pDataCols; + + SDataCols* pTSCol = pQueryHandle->rhelper.pDataCols[0]; if (pCheckInfo->lastKey < pBlock->keyLast) { - cur->pos = - binarySearchForKey(pDataCols->cols[0].pData, pBlock->numOfRows, pCheckInfo->lastKey, pQueryHandle->order); + cur->pos = binarySearchForKey(pTSCol->cols[0].pData, pBlock->numOfRows, pCheckInfo->lastKey, pQueryHandle->order); } else { cur->pos = pBlock->numOfRows - 1; } @@ -1011,7 +1052,7 @@ int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order) { firstPos = 0; lastPos = num - 1; - if (order == 0) { + if (order == TSDB_ORDER_DESC) { // find the first position which is smaller than the key while (1) { if (key >= keyList[lastPos]) return lastPos; @@ -1293,7 +1334,7 @@ static bool getDataBlocksInFiles(STsdbQueryHandle* pQueryHandle) { static bool doHasDataInBuffer(STsdbQueryHandle* pQueryHandle) { size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo); - // todo add assert, the value of numOfTables should be less than the maximum value for each vnode capacity + assert(numOfTables <= ((STsdbRepo*)pQueryHandle->pTsdb)->config.maxTables); while (pQueryHandle->activeIndex < numOfTables) { if (hasMoreDataInCache(pQueryHandle)) { @@ -1307,12 +1348,116 @@ static bool doHasDataInBuffer(STsdbQueryHandle* pQueryHandle) { } // handle data in cache situation -bool tsdbNextDataBlock(TsdbQueryHandleT* pqHandle) { - STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pqHandle; +bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) { + STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pHandle; size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo); assert(numOfTables > 0); + if (pQueryHandle->type == TSDB_QUERY_TYPE_EXTERNAL) { + pQueryHandle->type = TSDB_QUERY_TYPE_ALL; + pQueryHandle->order = TSDB_ORDER_DESC; + + if (!tsdbNextDataBlock(pHandle)) { + return false; + } + + SArray* sa = getDefaultLoadColumns(pQueryHandle, true); + /*SDataBlockInfo* pBlockInfo =*/ tsdbRetrieveDataBlockInfo(pHandle); + /*SArray *pDataBlock = */tsdbRetrieveDataBlock(pHandle, sa); + + if (pQueryHandle->cur.win.ekey == pQueryHandle->window.skey) { + // data already retrieve, discard other data rows and return + int32_t numOfCols = QH_GET_NUM_OF_COLS(pQueryHandle); + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i); + memcpy(pCol->pData, pCol->pData + pCol->info.bytes * (pQueryHandle->cur.rows-1), pCol->info.bytes); + } + + pQueryHandle->cur.win = (STimeWindow){pQueryHandle->window.skey, pQueryHandle->window.skey}; + pQueryHandle->window = pQueryHandle->cur.win; + pQueryHandle->cur.rows = 1; + pQueryHandle->type = TSDB_QUERY_TYPE_EXTERNAL; + return true; + } else { + STsdbQueryHandle* pSecQueryHandle = calloc(1, sizeof(STsdbQueryHandle)); + pSecQueryHandle->order = TSDB_ORDER_ASC; + pSecQueryHandle->window = (STimeWindow) {pQueryHandle->window.skey, INT64_MAX}; + pSecQueryHandle->pTsdb = pQueryHandle->pTsdb; + pSecQueryHandle->type = TSDB_QUERY_TYPE_ALL; + pSecQueryHandle->cur.fid = -1; + pSecQueryHandle->cur.win = TSWINDOW_INITIALIZER; + pSecQueryHandle->checkFiles = true; + pSecQueryHandle->activeIndex = 0; + pSecQueryHandle->outputCapacity = ((STsdbRepo*)pSecQueryHandle->pTsdb)->config.maxRowsPerFileBlock; + + tsdbInitReadHelper(&pSecQueryHandle->rhelper, (STsdbRepo*) pSecQueryHandle->pTsdb); + + // allocate buffer in order to load data blocks from file + int32_t numOfCols = QH_GET_NUM_OF_COLS(pQueryHandle); + + pSecQueryHandle->statis = calloc(numOfCols, sizeof(SDataStatis)); + pSecQueryHandle->pColumns = taosArrayInit(numOfCols, sizeof(SColumnInfoData)); + + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData colInfo = {{0}, 0}; + SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i); + + colInfo.info = pCol->info; + colInfo.pData = calloc(1, EXTRA_BYTES + pQueryHandle->outputCapacity * pCol->info.bytes); + taosArrayPush(pSecQueryHandle->pColumns, &colInfo); + pSecQueryHandle->statis[i].colId = colInfo.info.colId; + } + + size_t si = taosArrayGetSize(pQueryHandle->pTableCheckInfo); + pSecQueryHandle->pTableCheckInfo = taosArrayInit(si, sizeof(STableCheckInfo)); + STsdbMeta* pMeta = tsdbGetMeta(pQueryHandle->pTsdb); + assert(pMeta != NULL); + + for (int32_t j = 0; j < si; ++j) { + STableCheckInfo* pCheckInfo = (STableCheckInfo*) taosArrayGet(pQueryHandle->pTableCheckInfo, j); + + STableCheckInfo info = { + .lastKey = pSecQueryHandle->window.skey, + .tableId = pCheckInfo->tableId, + .pTableObj = pCheckInfo->pTableObj, + }; + + taosArrayPush(pSecQueryHandle->pTableCheckInfo, &info); + } + + tsdbInitDataBlockLoadInfo(&pSecQueryHandle->dataBlockLoadInfo); + tsdbInitCompBlockLoadInfo(&pSecQueryHandle->compBlockLoadInfo); + + bool ret = tsdbNextDataBlock((void*) pSecQueryHandle); + assert(ret); + + /*SDataBlockInfo* pBlockInfo =*/ tsdbRetrieveDataBlockInfo((void*) pSecQueryHandle); + /*SArray *pDataBlock = */tsdbRetrieveDataBlock((void*) pSecQueryHandle, sa); + + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i); + memcpy(pCol->pData, pCol->pData + pCol->info.bytes * (pQueryHandle->cur.rows-1), pCol->info.bytes); + + SColumnInfoData* pCol1 = taosArrayGet(pSecQueryHandle->pColumns, i); + assert(pCol->info.colId == pCol1->info.colId); + + memcpy(pCol->pData + pCol->info.bytes, pCol1->pData, pCol1->info.bytes); + } + + SColumnInfoData* pTSCol = taosArrayGet(pQueryHandle->pColumns, 0); + + pQueryHandle->cur.win = (STimeWindow){((TSKEY*)pTSCol->pData)[0], ((TSKEY*)pTSCol->pData)[1]}; + pQueryHandle->window = pQueryHandle->cur.win; + pQueryHandle->cur.rows = 2; + + tsdbCleanupQueryHandle(pSecQueryHandle); + } + + pQueryHandle->type = TSDB_QUERY_TYPE_EXTERNAL; + return true; + } + if (pQueryHandle->checkFiles) { if (getDataBlocksInFiles(pQueryHandle)) { return true; @@ -1322,7 +1467,6 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pqHandle) { pQueryHandle->checkFiles = false; } - // TODO: opt by using lastKeyOnFile // TODO: opt by consider the scan order return doHasDataInBuffer(pQueryHandle); } @@ -1336,23 +1480,25 @@ void changeQueryHandleForLastrowQuery(TsdbQueryHandleT pqHandle) { // todo consider the query time window, current last_row does not apply the query time window size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo); - TSKEY key = 0; + TSKEY key = TSKEY_INITIAL_VAL; int32_t index = -1; for(int32_t i = 0; i < numOfTables; ++i) { STableCheckInfo* pCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, i); - if (pCheckInfo->pTableObj->lastKey > key) { //todo lastKey should not be 0 by default + if (pCheckInfo->pTableObj->tableId.uid == 12094628167747) { + printf("abc\n"); + } + if (pCheckInfo->pTableObj->lastKey > key) { key = pCheckInfo->pTableObj->lastKey; index = i; } } - // todo, there are no data in all the tables. opt performance if (index == -1) { return; } - // erase all other elements in array list, todo refactor + // erase all other elements in array list size_t size = taosArrayGetSize(pQueryHandle->pTableCheckInfo); for (int32_t i = 0; i < size; ++i) { if (i == index) { @@ -1371,9 +1517,7 @@ void changeQueryHandleForLastrowQuery(TsdbQueryHandleT pqHandle) { } STableCheckInfo info = *(STableCheckInfo*) taosArrayGet(pQueryHandle->pTableCheckInfo, index); - taosArrayDestroy(pQueryHandle->pTableCheckInfo); - - pQueryHandle->pTableCheckInfo = taosArrayInit(1, sizeof(STableCheckInfo)); + taosArrayClear(pQueryHandle->pTableCheckInfo); info.lastKey = key; taosArrayPush(pQueryHandle->pTableCheckInfo, &info); @@ -1382,6 +1526,43 @@ void changeQueryHandleForLastrowQuery(TsdbQueryHandleT pqHandle) { pQueryHandle->window = (STimeWindow) {key, key}; } +static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle) { + // filter the queried time stamp in the first place + STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pHandle; + pQueryHandle->order = TSDB_ORDER_DESC; + + assert(pQueryHandle->window.skey == pQueryHandle->window.ekey); + + // starts from the buffer in case of descending timestamp order check data blocks + // todo consider the query time window, current last_row does not apply the query time window + size_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo); + + int32_t i = 0; + while(i < numOfTables) { + STableCheckInfo* pCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, i); + if (pQueryHandle->window.skey <= pCheckInfo->pTableObj->lastKey && + pCheckInfo->pTableObj->lastKey != TSKEY_INITIAL_VAL) { + break; + } + + i++; + } + + // there are no data in all the tables + if (i == numOfTables) { + return; + } + + STableCheckInfo info = *(STableCheckInfo*) taosArrayGet(pQueryHandle->pTableCheckInfo, i); + taosArrayClear(pQueryHandle->pTableCheckInfo); + + info.lastKey = pQueryHandle->window.skey; + taosArrayPush(pQueryHandle->pTableCheckInfo, &info); + + // update the query time window according to the chosen last timestamp + pQueryHandle->window = (STimeWindow) {info.lastKey, TSKEY_INITIAL_VAL}; +} + static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY maxKey, int maxRowsToRead, TSKEY* skey, TSKEY* ekey, STsdbQueryHandle* pQueryHandle) { int numOfRows = 0; @@ -1466,58 +1647,29 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY return numOfRows; } -// copy data from cache into data block SDataBlockInfo tsdbRetrieveDataBlockInfo(TsdbQueryHandleT* pQueryHandle) { STsdbQueryHandle* pHandle = (STsdbQueryHandle*)pQueryHandle; - - int32_t step = ASCENDING_TRAVERSE(pHandle->order)? 1:-1; + SQueryFilePos* cur = &pHandle->cur; + STable* pTable = NULL; // there are data in file if (pHandle->cur.fid >= 0) { - STableBlockInfo* pBlockInfo = &pHandle->pDataBlockInfo[pHandle->cur.slot]; - STable* pTable = pBlockInfo->pTableCheckInfo->pTableObj; - - SDataBlockInfo blockInfo = { - .uid = pTable->tableId.uid, - .tid = pTable->tableId.tid, - .rows = pHandle->cur.rows, - .window = pHandle->cur.win, - .numOfCols = QH_GET_NUM_OF_COLS(pHandle), - }; - - return blockInfo; + STableBlockInfo* pBlockInfo = &pHandle->pDataBlockInfo[cur->slot]; + pTable = pBlockInfo->pTableCheckInfo->pTableObj; } else { STableCheckInfo* pCheckInfo = taosArrayGet(pHandle->pTableCheckInfo, pHandle->activeIndex); - SQueryFilePos* cur = &pHandle->cur; - - STable* pTable = pCheckInfo->pTableObj; - if (pTable->mem != NULL) { // create mem table iterator if it is not created yet - assert(pCheckInfo->iter != NULL); - STimeWindow* win = &cur->win; - - 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; - cur->lastKey = win->ekey + step; - cur->mixBlock = true; - } - - 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 = pHandle->cur.rows, - .window = pHandle->cur.win, - .numOfCols = QH_GET_NUM_OF_COLS(pHandle), - }; - - return blockInfo; + pTable = pCheckInfo->pTableObj; } + + SDataBlockInfo blockInfo = { + .uid = pTable->tableId.uid, + .tid = pTable->tableId.tid, + .rows = cur->rows, + .window = cur->win, + .numOfCols = QH_GET_NUM_OF_COLS(pHandle), + }; + + return blockInfo; } /* @@ -1536,6 +1688,13 @@ int32_t tsdbRetrieveDataBlockStatisInfo(TsdbQueryHandleT* pQueryHandle, SDataSta ((cur->slot == pHandle->numOfBlocks) && (cur->slot == 0))); STableBlockInfo* pBlockInfo = &pHandle->pDataBlockInfo[cur->slot]; + + // file block with subblocks has no statistics data + if (pBlockInfo->compBlock->numOfSubBlocks > 1) { + *pBlockStatis = NULL; + return TSDB_CODE_SUCCESS; + } + tsdbLoadCompData(&pHandle->rhelper, pBlockInfo->compBlock, NULL); size_t numOfCols = QH_GET_NUM_OF_COLS(pHandle); @@ -1708,12 +1867,7 @@ void filterPrepare(void* expr, void* param) { pInfo->q = (char*) pCond->arr; } else { pInfo->q = calloc(1, pSchema->bytes); - if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) { - tVariantDump(pCond, varDataVal(pInfo->q), pSchema->type); - varDataSetLen(pInfo->q, pCond->nLen); // the length may be changed after dump, so assign its value after dump - } else { - tVariantDump(pCond, pInfo->q, pSchema->type); - } + tVariantDump(pCond, pInfo->q, pSchema->type, true); } } @@ -1843,13 +1997,11 @@ bool indexedNodeFilterFp(const void* pNode, void* param) { val = (char*) elem->pTable->name; type = TSDB_DATA_TYPE_BINARY; } else { -// STSchema* pTSchema = (STSchema*) pInfo->param; // todo table schema is identical to stable schema?? - int16_t type; - // int32_t offset = pTSchema->columns[pInfo->colIndex].offset; - // val = tdGetRowDataOfCol(elem->pTable->tagVal, pInfo->sch.type, TD_DATA_ROW_HEAD_SIZE + offset); - val = tdQueryTagByID(elem->pTable->tagVal, pInfo->sch.colId, &type); - // ASSERT(pInfo->sch.type == type); + int16_t t1; + val = tdQueryTagByID(elem->pTable->tagVal, pInfo->sch.colId, &t1); + assert(pInfo->sch.type == t1); } + //todo :the val is possible to be null, so check it out carefully int32_t ret = 0; if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { diff --git a/src/util/inc/hash.h b/src/util/inc/hash.h index 0a2cbe8baf..137777f3cb 100644 --- a/src/util/inc/hash.h +++ b/src/util/inc/hash.h @@ -30,24 +30,19 @@ typedef void (*_hash_free_fn_t)(void *param); typedef struct SHashNode { char *key; - union { +// union { struct SHashNode * prev; - struct SHashEntry *prev1; - }; - +// struct SHashEntry *prev1; +// }; +// struct SHashNode *next; uint32_t hashVal; // the hash value of key, if hashVal == HASH_VALUE_IN_TRASH, this node is moved to trash uint32_t keyLen; // length of the key char data[]; } SHashNode; -typedef struct SHashEntry { - SHashNode *next; - uint32_t num; -} SHashEntry; - typedef struct SHashObj { - SHashEntry ** hashList; + SHashNode **hashList; size_t capacity; // number of slots size_t size; // number of elements in hash table _hash_fn_t hashFp; // hash function diff --git a/src/util/inc/tutil.h b/src/util/inc/tutil.h index 16bcf7ee32..984df23879 100644 --- a/src/util/inc/tutil.h +++ b/src/util/inc/tutil.h @@ -46,6 +46,7 @@ extern "C" { // Pointer p drift right by b bytes #define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b))) +#define POINTER_DISTANCE(p1, p2) ((char *)(p1) - (char *)(p2)) #ifndef NDEBUG #define ASSERT(x) assert(x) diff --git a/src/util/src/hash.c b/src/util/src/hash.c index f19438159d..93b8e30f1e 100644 --- a/src/util/src/hash.c +++ b/src/util/src/hash.c @@ -83,17 +83,10 @@ static FORCE_INLINE int32_t taosHashCapacity(int32_t length) { int32_t len = MIN(length, HASH_MAX_CAPACITY); uint32_t i = 4; - while (i < len) i = (i << 1U); + while (i < len) i = (i << 1u); return i; } -/** - * inplace update node in hash table - * @param pHashObj hash table object - * @param pNode hash data node - */ -static void doUpdateHashTable(SHashObj *pHashObj, SHashNode *pNode); - /** * Get SHashNode from hashlist, nodes from trash are not included. * @param pHashObj Cache objection @@ -105,10 +98,9 @@ static void doUpdateHashTable(SHashObj *pHashObj, SHashNode *pNode); FORCE_INLINE SHashNode *doGetNodeFromHashTable(SHashObj *pHashObj, const void *key, uint32_t keyLen, uint32_t *hashVal) { uint32_t hash = (*pHashObj->hashFp)(key, keyLen); - int32_t slot = HASH_INDEX(hash, pHashObj->capacity); - SHashEntry *pEntry = pHashObj->hashList[slot]; + int32_t slot = HASH_INDEX(hash, pHashObj->capacity); + SHashNode *pNode = pHashObj->hashList[slot]; - SHashNode *pNode = pEntry->next; while (pNode) { if ((pNode->keyLen == keyLen) && (memcmp(pNode->key, key, keyLen) == 0)) { break; @@ -190,17 +182,13 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool threadsafe) { pHashObj->hashFp = fn; - pHashObj->hashList = (SHashEntry **)calloc(pHashObj->capacity, sizeof(SHashEntry *)); + pHashObj->hashList = (SHashNode **)calloc(pHashObj->capacity, POINTER_BYTES); if (pHashObj->hashList == NULL) { free(pHashObj); uError("failed to allocate memory, reason:%s", strerror(errno)); return NULL; } - for (int32_t i = 0; i < pHashObj->capacity; ++i) { - pHashObj->hashList[i] = calloc(1, sizeof(SHashEntry)); - } - if (threadsafe) { #if defined(LINUX) pHashObj->lock = calloc(1, sizeof(pthread_rwlock_t)); @@ -252,7 +240,18 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da return -1; } - doUpdateHashTable(pHashObj, pNewNode); + if (pNewNode->prev) { + pNewNode->prev->next = pNewNode; + } else { + int32_t slot = HASH_INDEX(pNewNode->hashVal, pHashObj->capacity); + + assert(pHashObj->hashList[slot] == pNode); + pHashObj->hashList[slot] = pNewNode; + } + + if (pNewNode->next) { + (pNewNode->next)->prev = pNewNode; + } } __unlock(pHashObj->lock); @@ -287,24 +286,19 @@ void taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) { } SHashNode *pNext = pNode->next; - if (pNode->prev != NULL) { + if (pNode->prev == NULL) { int32_t slot = HASH_INDEX(val, pHashObj->capacity); - if (pHashObj->hashList[slot]->next == pNode) { - pHashObj->hashList[slot]->next = pNext; - } else { - pNode->prev->next = pNext; - } + assert(pHashObj->hashList[slot] == pNode); + + pHashObj->hashList[slot] = pNext; + } else { + pNode->prev->next = pNext; } - + if (pNext != NULL) { pNext->prev = pNode->prev; } - uint32_t index = HASH_INDEX(pNode->hashVal, pHashObj->capacity); - - SHashEntry *pEntry = pHashObj->hashList[index]; - pEntry->num--; - pHashObj->size--; pNode->next = NULL; @@ -325,8 +319,7 @@ void taosHashCleanup(SHashObj *pHashObj) { if (pHashObj->hashList) { for (int32_t i = 0; i < pHashObj->capacity; ++i) { - SHashEntry *pEntry = pHashObj->hashList[i]; - pNode = pEntry->next; + pNode = pHashObj->hashList[i]; while (pNode) { pNext = pNode->next; @@ -337,8 +330,6 @@ void taosHashCleanup(SHashObj *pHashObj) { free(pNode); pNode = pNext; } - - tfree(pEntry); } free(pHashObj->hashList); @@ -385,13 +376,13 @@ bool taosHashIterNext(SHashMutableIterator *pIter) { assert(pIter->pCur == NULL && pIter->pNext == NULL); while (1) { - SHashEntry *pEntry = pIter->pHashObj->hashList[pIter->entryIndex]; - if (pEntry->next == NULL) { + SHashNode *pEntry = pIter->pHashObj->hashList[pIter->entryIndex]; + if (pEntry == NULL) { pIter->entryIndex++; continue; } - pIter->pCur = pEntry->next; + pIter->pCur = pEntry; if (pIter->pCur->next) { pIter->pNext = pIter->pCur->next; @@ -444,25 +435,25 @@ int32_t taosHashGetMaxOverflowLinkLength(const SHashObj *pHashObj) { int32_t num = 0; for (int32_t i = 0; i < pHashObj->size; ++i) { - SHashEntry *pEntry = pHashObj->hashList[i]; - if (num < pEntry->num) { - num = pEntry->num; + SHashNode *pEntry = pHashObj->hashList[i]; + if (pEntry == NULL) { + continue; + } + + int32_t j = 0; + while(pEntry != NULL) { + pEntry = pEntry->next; + j++; + } + + if (num < j) { + num = j; } } return num; } -void doUpdateHashTable(SHashObj *pHashObj, SHashNode *pNode) { - if (pNode->prev1) { - pNode->prev1->next = pNode; - } - - if (pNode->next) { - (pNode->next)->prev = pNode; - } -} - void taosHashTableResize(SHashObj *pHashObj) { if (pHashObj->size < pHashObj->capacity * HASH_DEFAULT_LOAD_FACTOR) { return; @@ -479,69 +470,53 @@ void taosHashTableResize(SHashObj *pHashObj) { return; } -// int64_t st = taosGetTimestampUs(); - - SHashEntry **pNewEntry = realloc(pHashObj->hashList, sizeof(SHashEntry *) * newSize); - if (pNewEntry == NULL) { + void *pNewEntry = realloc(pHashObj->hashList, POINTER_BYTES * newSize); + if (pNewEntry == NULL) {// todo handle error // uTrace("cache resize failed due to out of memory, capacity remain:%d", pHashObj->capacity); return; } pHashObj->hashList = pNewEntry; - for (int32_t i = pHashObj->capacity; i < newSize; ++i) { - pHashObj->hashList[i] = calloc(1, sizeof(SHashEntry)); - } + memset(&pHashObj->hashList[pHashObj->capacity], 0, POINTER_BYTES * (newSize - pHashObj->capacity)); pHashObj->capacity = newSize; for (int32_t i = 0; i < pHashObj->capacity; ++i) { - SHashEntry *pEntry = pHashObj->hashList[i]; - - pNode = pEntry->next; + pNode = pHashObj->hashList[i]; if (pNode != NULL) { - assert(pNode->prev1 == pEntry && pEntry->num > 0); + assert(pNode->prev == NULL); } while (pNode) { int32_t j = HASH_INDEX(pNode->hashVal, pHashObj->capacity); - if (j == i) { // this key resides in the same slot, no need to relocate it + if (j == i) { // this key locates in the same slot, no need to relocate it pNode = pNode->next; } else { pNext = pNode->next; - // remove from current slot - assert(pNode->prev1 != NULL); - - if (pNode->prev1 == pEntry) { // first node of the overflow linked list - pEntry->next = pNode->next; + if (pNode->prev == NULL) { // first node of the overflow linked list + pHashObj->hashList[i] = pNext; } else { - pNode->prev->next = pNode->next; + pNode->prev->next = pNext; } - pEntry->num--; - assert(pEntry->num >= 0); - - if (pNode->next != NULL) { - (pNode->next)->prev = pNode->prev; + if (pNext != NULL) { + pNext->prev = pNode->prev; } + // clear pointer + pNode->next = NULL; + pNode->prev = NULL; + // added into new slot - pNode->next = NULL; - pNode->prev1 = NULL; - - SHashEntry *pNewIndexEntry = pHashObj->hashList[j]; - - if (pNewIndexEntry->next != NULL) { - assert(pNewIndexEntry->next->prev1 == pNewIndexEntry); - - pNewIndexEntry->next->prev = pNode; + SHashNode *pNew = pHashObj->hashList[j]; + if (pNew != NULL) { + assert(pNew->prev == NULL); + pNew->prev = pNode; } - pNode->next = pNewIndexEntry->next; - pNode->prev1 = pNewIndexEntry; - - pNewIndexEntry->next = pNode; - pNewIndexEntry->num++; + pNode->next = pNew; + pHashObj->hashList[j] = pNode; // continue pNode = pNext; @@ -549,7 +524,6 @@ void taosHashTableResize(SHashObj *pHashObj) { } } -// int64_t et = taosGetTimestampUs(); // uTrace("hash table resize completed, new capacity:%d, load factor:%f, elapsed time:%fms", pHashObj->capacity, // ((double)pHashObj->size) / pHashObj->capacity, (et - st) / 1000.0); } @@ -595,19 +569,17 @@ SHashNode *doUpdateHashNode(SHashNode *pNode, const void *key, size_t keyLen, co void doAddToHashTable(SHashObj *pHashObj, SHashNode *pNode) { assert(pNode != NULL); - int32_t index = HASH_INDEX(pNode->hashVal, pHashObj->capacity); - SHashEntry *pEntry = pHashObj->hashList[index]; + int32_t index = HASH_INDEX(pNode->hashVal, pHashObj->capacity); - pNode->next = pEntry->next; - - if (pEntry->next) { - pEntry->next->prev = pNode; + SHashNode* pEntry = pHashObj->hashList[index]; + if (pEntry != NULL) { + pEntry->prev = pNode; + + pNode->next = pEntry; + pNode->prev = NULL; } - pEntry->next = pNode; - pNode->prev1 = pEntry; - - pEntry->num++; + pHashObj->hashList[index] = pNode; pHashObj->size++; } @@ -616,13 +588,13 @@ SHashNode *getNextHashNode(SHashMutableIterator *pIter) { pIter->entryIndex++; while (pIter->entryIndex < pIter->pHashObj->capacity) { - SHashEntry *pEntry = pIter->pHashObj->hashList[pIter->entryIndex]; - if (pEntry->next == NULL) { + SHashNode *pNode = pIter->pHashObj->hashList[pIter->entryIndex]; + if (pNode == NULL) { pIter->entryIndex++; continue; } - return pEntry->next; + return pNode; } return NULL; diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index cb9f339f6a..f9d306e625 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -92,7 +92,7 @@ int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight) { if (len1 != len2) { return len1 > len2? 1:-1; } else { - int32_t ret = wcsncmp(varDataVal(pLeft), varDataVal(pRight), len1); + int32_t ret = wcsncmp(varDataVal(pLeft), varDataVal(pRight), len1/TSDB_NCHAR_SIZE); if (ret == 0) { return 0; } else { diff --git a/src/util/src/tconfig.c b/src/util/src/tconfig.c index 32a3df844c..203a34fd15 100644 --- a/src/util/src/tconfig.c +++ b/src/util/src/tconfig.c @@ -241,7 +241,12 @@ void taosReadGlobalLogCfg() { wordexp_t full_path; wordexp(configDir, &full_path, 0); - if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) { + if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) { + if (strlen(full_path.we_wordv[0]) > TSDB_FILENAME_LEN - 1) { + printf("\nconfig file: %s path overflow max len %d, all variables are set to default\n", full_path.we_wordv[0], TSDB_FILENAME_LEN - 1); + wordfree(&full_path); + return; + } strcpy(configDir, full_path.we_wordv[0]); } else { printf("configDir:%s not there, use default value: /etc/taos", configDir); diff --git a/src/util/src/tqueue.c b/src/util/src/tqueue.c index 475941dbdb..428c40ef7a 100644 --- a/src/util/src/tqueue.c +++ b/src/util/src/tqueue.c @@ -18,24 +18,24 @@ #include "taoserror.h" #include "tqueue.h" -typedef struct _taos_qnode { +typedef struct STaosQnode { int type; - struct _taos_qnode *next; + struct STaosQnode *next; char item[]; } STaosQnode; -typedef struct _taos_q { +typedef struct STaosQueue { int32_t itemSize; int32_t numOfItems; - struct _taos_qnode *head; - struct _taos_qnode *tail; - struct _taos_q *next; // for queue set - struct _taos_qset *qset; // for queue set + struct STaosQnode *head; + struct STaosQnode *tail; + struct STaosQueue *next; // for queue set + struct STaosQset *qset; // for queue set void *ahandle; // for queue set pthread_mutex_t mutex; } STaosQueue; -typedef struct _taos_qset { +typedef struct STaosQset { STaosQueue *head; STaosQueue *current; pthread_mutex_t mutex; @@ -44,7 +44,7 @@ typedef struct _taos_qset { tsem_t sem; } STaosQset; -typedef struct _taos_qall { +typedef struct STaosQall { STaosQnode *current; STaosQnode *start; int32_t itemSize; @@ -95,6 +95,7 @@ void *taosAllocateQitem(int size) { void taosFreeQitem(void *param) { if (param == NULL) return; + uTrace("item:%p is freed", param); char *temp = (char *)param; temp -= sizeof(STaosQnode); free(temp); @@ -104,6 +105,7 @@ int taosWriteQitem(taos_queue param, int type, void *item) { STaosQueue *queue = (STaosQueue *)param; STaosQnode *pNode = (STaosQnode *)(((char *)item) - sizeof(STaosQnode)); pNode->type = type; + pNode->next = NULL; pthread_mutex_lock(&queue->mutex); @@ -143,7 +145,7 @@ int taosReadQitem(taos_queue param, int *type, void **pitem) { queue->numOfItems--; if (queue->qset) atomic_sub_fetch_32(&queue->qset->numOfItems, 1); code = 1; - uTrace("item:%p is read out from queue, items:%d", *pitem, queue->numOfItems); + uTrace("item:%p is read out from queue:%p, type:%d items:%d", *pitem, *type, queue->numOfItems); } pthread_mutex_unlock(&queue->mutex); @@ -337,6 +339,7 @@ int taosReadQitemFromQset(taos_qset param, int *type, void **pitem, void **phand queue->numOfItems--; atomic_sub_fetch_32(&qset->numOfItems, 1); code = 1; + uTrace("item:%p is read out from queue:%p, type:%d items:%d", *pitem, queue, *type, queue->numOfItems); } pthread_mutex_unlock(&queue->mutex); diff --git a/src/util/src/ttimer.c b/src/util/src/ttimer.c index 68db574d82..55e7da3258 100644 --- a/src/util/src/ttimer.c +++ b/src/util/src/ttimer.c @@ -342,6 +342,7 @@ static void taosTimerLoopFunc(int signo) { int64_t now = taosGetTimestampMs(); for (int i = 0; i < tListLen(wheels); i++) { + tmrTrace("begin processing wheel %d", i); // `expried` is a temporary expire list. // expired timers are first add to this list, then move // to expired queue as a batch to improve performance. @@ -389,6 +390,7 @@ static void taosTimerLoopFunc(int signo) { } addToExpired(expired); + tmrTrace("end processing wheel %d", i); } } diff --git a/src/util/tests/hashTest.cpp b/src/util/tests/hashTest.cpp index b3baedb696..93a1989741 100644 --- a/src/util/tests/hashTest.cpp +++ b/src/util/tests/hashTest.cpp @@ -149,8 +149,8 @@ int main(int argc, char** argv) { } TEST(testCase, hashTest) { -// simpleTest(); -// stringKeyTest(); -// noLockPerformanceTest(); -// multithreadsTest(); + simpleTest(); + stringKeyTest(); + noLockPerformanceTest(); + multithreadsTest(); } \ No newline at end of file diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index b25180f0f0..c2a0e4189f 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -220,6 +220,8 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { appH.appH = (void *)pVnode; appH.notifyStatus = vnodeProcessTsdbStatus; appH.cqH = pVnode->cq; + appH.cqCreateFunc = cqCreate; + appH.cqDropFunc = cqDrop; sprintf(temp, "%s/tsdb", rootDir); pVnode->tsdb = tsdbOpenRepo(temp, &appH); if (pVnode->tsdb == NULL) { @@ -391,14 +393,14 @@ static void vnodeCleanUp(SVnodeObj *pVnode) { pVnode->sync = NULL; } - if (pVnode->wal) - walClose(pVnode->wal); - pVnode->wal = NULL; - if (pVnode->tsdb) tsdbCloseRepo(pVnode->tsdb, 1); pVnode->tsdb = NULL; + if (pVnode->wal) + walClose(pVnode->wal); + pVnode->wal = NULL; + if (pVnode->cq) cqClose(pVnode->cq); pVnode->cq = NULL; @@ -467,6 +469,8 @@ static void vnodeNotifyFileSynced(void *ahandle, uint64_t fversion) { appH.appH = (void *)pVnode; appH.notifyStatus = vnodeProcessTsdbStatus; appH.cqH = pVnode->cq; + appH.cqCreateFunc = cqCreate; + appH.cqDropFunc = cqDrop; pVnode->tsdb = tsdbOpenRepo(rootDir, &appH); } @@ -548,6 +552,7 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) { int len = fread(content, 1, maxLen, fp); if (len <= 0) { vError("vgId:%d, failed to read vnode cfg, content is null", pVnode->vgId); + free(content); return errno; } diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c index 03407a5aa2..c41171a36e 100644 --- a/src/vnode/src/vnodeRead.c +++ b/src/vnode/src/vnodeRead.c @@ -43,7 +43,7 @@ int32_t vnodeProcessRead(void *param, int msgType, void *pCont, int32_t contLen, return TSDB_CODE_MSG_NOT_PROCESSED; if (pVnode->status == TAOS_VN_STATUS_DELETING || pVnode->status == TAOS_VN_STATUS_CLOSING) - return TSDB_CODE_NOT_ACTIVE_VNODE; + return TSDB_CODE_INVALID_VGROUP_ID; return (*vnodeProcessReadMsgFp[msgType])(pVnode, pCont, contLen, ret); } diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 6d65d10335..584aa1bf2f 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -53,7 +53,7 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) { if (pHead->version == 0) { // from client or CQ if (pVnode->status != TAOS_VN_STATUS_READY) - return TSDB_CODE_NOT_ACTIVE_VNODE; + return TSDB_CODE_INVALID_VGROUP_ID; // it may be in deleting or closing state if (pVnode->syncCfg.replica > 1 && pVnode->role != TAOS_SYNC_ROLE_MASTER) return TSDB_CODE_NOT_READY; @@ -139,12 +139,10 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe char *pTagData = pTable->data + totalCols * sizeof(SSchema); int accumBytes = 0; - //dataRow = tdNewDataRowFromSchema(pDestTagSchema); dataRow = tdNewTagRowFromSchema(pDestTagSchema, numOfTags); for (int i = 0; i < numOfTags; i++) { STColumn *pTCol = schemaColAt(pDestTagSchema, i); -// tdAppendColVal(dataRow, pTagData + accumBytes, pTCol->type, pTCol->bytes, pTCol->offset); tdAppendTagColVal(dataRow, pTagData + accumBytes, pTCol->type, pTCol->bytes, pTCol->colId); accumBytes += htons(pSchema[i + numOfColumns].bytes); } diff --git a/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md b/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md index b285fe8155..3477fe9152 100644 --- a/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md +++ b/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md @@ -8,8 +8,8 @@ 3. mkdir debug; cd debug; cmake ..; make ; sudo make install -4. pip install src/connector/python/linux/python2 ; pip3 install - src/connector/python/linux/python3 +4. pip install ../src/connector/python/linux/python2 ; pip3 install + ../src/connector/python/linux/python3 > Note: Both Python2 and Python3 are currently supported by the Python test > framework. Since Python2 is no longer officially supported by Python Software diff --git a/tests/examples/c/demo.c b/tests/examples/c/demo.c index 76bfa5949e..e27c73891f 100644 --- a/tests/examples/c/demo.c +++ b/tests/examples/c/demo.c @@ -16,11 +16,12 @@ // TAOS standard API example. The same syntax as MySQL, but only a subet // to compile: gcc -o demo demo.c -ltaos +#include #include #include #include -#include #include // TAOS header file +#include void taosMsleep(int mseconds); @@ -49,19 +50,52 @@ static int32_t doQuery(TAOS* taos, const char* sql) { return 0; } +void* oneLoader(void* param) { + TAOS* conn = (TAOS*) param; + + for(int32_t i = 0; i < 20000; ++i) { +// doQuery(conn, "show databases"); + doQuery(conn, "use test"); +// doQuery(conn, "describe t12"); +// doQuery(conn, "show tables"); +// doQuery(conn, "create table if not exists abc (ts timestamp, k int)"); +// doQuery(conn, "select * from t12"); + } + + return 0; +} + + +static __attribute__((unused)) void multiThreadTest(int32_t numOfThreads, void* conn) { + pthread_attr_t thattr; + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + + pthread_t* threadId = malloc(sizeof(pthread_t)*numOfThreads); + + for (int i = 0; i < numOfThreads; ++i) { + pthread_create(&threadId[i], NULL, oneLoader, conn); + } + + for (int32_t i = 0; i < numOfThreads; ++i) { + pthread_join(threadId[i], NULL); + } + + pthread_attr_destroy(&thattr); +} + int main(int argc, char *argv[]) { TAOS * taos; char qstr[1024]; TAOS_RES *result; - // connect to server if (argc < 2) { printf("please input server-ip \n"); return 0; } - taos_options(TSDB_OPTION_CONFIGDIR, "~/sec/cfg"); + taos_options(TSDB_OPTION_CONFIGDIR, "/home/lisa/Documents/workspace/TDinternal/community/sim/tsim/cfg"); // init TAOS taos_init(); @@ -73,15 +107,12 @@ int main(int argc, char *argv[]) { } printf("success to connect to server\n"); - doQuery(taos, "create database if not exists test"); - doQuery(taos, "use test"); - doQuery(taos, "select count(*) from m1 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:1:59' interval(500a) fill(value, 99)"); - -// doQuery(taos, "create table t1(ts timestamp, k binary(12), f nchar(2))"); -// for(int32_t i = 0; i< 100000; ++i) { -// doQuery(taos, "select m1.ts,m1.a from m1, m2 where m1.ts=m2.ts and m1.a=m2.b;"); -// usleep(500000); +// multiThreadTest(1, taos); + doQuery(taos, "select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from lm2_db0.lm2_stb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1, -2) group by t1 limit 2 offset 10;"); +// for(int32_t i = 0; i < 100000; ++i) { +// doQuery(taos, "insert into t1 values(now, 2)"); // } +// doQuery(taos, "create table t1(ts timestamp, k binary(12), f nchar(2))"); // doQuery(taos, "insert into tm0 values('2020-1-1 1:1:1', 'abc')"); // doQuery(taos, "create table if not exists tm0 (ts timestamp, k int);"); diff --git a/tests/perftest-scripts/perftest-csv2png.gnuplot b/tests/perftest-scripts/perftest-csv2png.gnuplot new file mode 100644 index 0000000000..9c34ebe403 --- /dev/null +++ b/tests/perftest-scripts/perftest-csv2png.gnuplot @@ -0,0 +1,33 @@ +#!/user/bin/gnuplot +reset +set terminal png + +set title "Performance Test Report" font ",20" + +set ylabel "Time in Seconds" + +set xdata time +set timefmt "%Y%m%d" +set format x "%Y-%m-%d" +set xlabel "Date" + +set style data linespoints + +set terminal pngcairo size 1024,768 enhanced font 'Segoe UI, 10' +set output filename . '.png' +set datafile separator ',' + +set key reverse Left outside +set grid + +# plot 'perftest-influx-report.csv' using 1:2 title "InfluxDB Write", \ +# "" using 1:3 title "InfluxDB Query case1", \ +# "" using 1:4 title "InfluxDB Query case2", \ +# "" using 1:5 title "InfluxDB Query case3", \ +# "" using 1:6 title "InfluxDB Query case4" +# +plot filename . '.csv' using 1:2 title "TDengine Write", \ + "" using 1:3 title "TDengine Query case1", \ + "" using 1:4 title "TDengine Query case2", \ + "" using 1:5 title "TDengine Query case3", \ + "" using 1:6 title "TDengine Query case4" diff --git a/tests/perftest-scripts/perftest-daily.sh b/tests/perftest-scripts/perftest-daily.sh new file mode 100755 index 0000000000..894d9c7905 --- /dev/null +++ b/tests/perftest-scripts/perftest-daily.sh @@ -0,0 +1,95 @@ +#!/bin/bash + +# Coloured Echoes # +function red_echo { echo -e "\033[31m$@\033[0m"; } # +function green_echo { echo -e "\033[32m$@\033[0m"; } # +function yellow_echo { echo -e "\033[33m$@\033[0m"; } # +function white_echo { echo -e "\033[1;37m$@\033[0m"; } # +# Coloured Printfs # +function red_printf { printf "\033[31m$@\033[0m"; } # +function green_printf { printf "\033[32m$@\033[0m"; } # +function yellow_printf { printf "\033[33m$@\033[0m"; } # +function white_printf { printf "\033[1;37m$@\033[0m"; } # +# Debugging Outputs # +function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } # +function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } # +function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } # +function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } # + +function set-Wal { + echo "/etc/taos/taos.cfg walLevel will be set to $1" + sed -i 's/^walLevel.*$/walLevel '"$1"'/g' /etc/taos/taos.cfg +} + +function collectSysInfo { + rm sysinfo.log + grep model /proc/cpuinfo | tail -n1 | tee sysinfo.log + grep cores /proc/cpuinfo | tail -n1 | tee -a sysinfo.log + grep MemTotal /proc/meminfo | tee -a sysinfo.log + grep "^[^#;]" /etc/taos/taos.cfg | tee taos.cfg +} + +function buildTDengine { + cd /root/TDengine + git pull + cd debug + rm -rf * + cmake .. + make > /dev/null + make install +} + +function restartTaosd { + systemctl stop taosd + pkill -KILL -x taosd + sleep 10 + + rm -rf /mnt/var/log/taos/* + rm -rf /mnt/var/lib/taos/* + + taosd 2>&1 > /dev/null & + sleep 10 +} + +function sendReport { + receiver="sdsang@taosdata.com, sangshuduo@gmail.com" + mimebody="MIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n" + + echo -e "to: ${receiver}\nsubject: Perf test report ${today}\n" | \ + (cat - && uuencode perftest-1d-$today.log perftest-1d-$today.log)| \ + (cat - && uuencode perftest-1d-report.csv perftest-1d-report-$today.csv) | \ + (cat - && uuencode perftest-1d-report.png perftest-1d-report-$today.png) | \ + (cat - && uuencode perftest-13d-$today.log perftest-13d-$today.log)| \ + (cat - && uuencode perftest-13d-report.csv perftest-13d-report-$today.csv) | \ + (cat - && uuencode perftest-13d-report.png perftest-13d-report-$today.png) | \ + (cat - && uuencode taosdemo-$today.log taosdemo-$today.log) | \ + (cat - && uuencode taosdemo-report.csv taosdemo-report-$today.csv) | \ + (cat - && uuencode taosdemo-report.png taosdemo-report-$today.png) | \ + (cat - && uuencode sysinfo.log sysinfo.txt) | \ + (cat - && uuencode taos.cfg taos-cfg-$today.txt) | \ + ssmtp "${receiver}" +} + +today=`date +"%Y%m%d"` +cd /root +echo -e "cron-ran-at-${today}" >> cron.log + +echoInfo "Build TDengine" +buildTDengine + +set-Wal "2" + +cd /root +./perftest-tsdb-compare-1d.sh + +cd /root +./perftest-tsdb-compare-13d.sh + +cd /root +./perftest-taosdemo.sh + +collectSysInfo + +echoInfo "Send Report" +sendReport +echoInfo "End of Test" diff --git a/tests/perftest-scripts/perftest-taosdemo.sh b/tests/perftest-scripts/perftest-taosdemo.sh new file mode 100755 index 0000000000..511ec22fec --- /dev/null +++ b/tests/perftest-scripts/perftest-taosdemo.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# Coloured Echoes # +function red_echo { echo -e "\033[31m$@\033[0m"; } # +function green_echo { echo -e "\033[32m$@\033[0m"; } # +function yellow_echo { echo -e "\033[33m$@\033[0m"; } # +function white_echo { echo -e "\033[1;37m$@\033[0m"; } # +# Coloured Printfs # +function red_printf { printf "\033[31m$@\033[0m"; } # +function green_printf { printf "\033[32m$@\033[0m"; } # +function yellow_printf { printf "\033[33m$@\033[0m"; } # +function white_printf { printf "\033[1;37m$@\033[0m"; } # +# Debugging Outputs # +function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } # +function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } # +function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } # +function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } # + +function restartTaosd { + systemctl stop taosd + pkill -KILL -x taosd + sleep 10 + + rm -rf /mnt/var/log/taos/* + rm -rf /mnt/var/lib/taos/* + + taosd 2>&1 > /dev/null & + sleep 10 +} + +function runCreateTableOnly { + echoInfo "Restart Taosd" + restartTaosd + + /usr/bin/time -f "Total: %e" -o totaltime.out bash -c "yes | taosdemo -n 0 2>&1 | tee taosdemo-$today.log" + demoTableOnly=`grep "Total:" totaltime.out|awk '{print $2}'` +} + +function runCreateTableThenInsert { + echoInfo "Restart Taosd" + restartTaosd + + /usr/bin/time -f "Total: %e" -o totaltime.out bash -c "yes | taosdemo 2>&1 | tee -a taosdemo-$today.log" + demoTableAndInsert=`grep "Total:" totaltime.out|awk '{print $2}'` + demoRPS=`grep "records\/second" taosdemo-$today.log | tail -n1 | awk '{print $13}'` +} + +function generateTaosdemoPlot { + echo "${today}, demoTableOnly: ${demoTableOnly}, demoTableAndInsert: ${demoTableAndInsert}" | tee -a taosdemo-$today.log + echo "${today}, ${demoTableOnly}, ${demoTableAndInsert}, ${demoRPS}" >> taosdemo-report.csv + + csvLines=`cat taosdemo-report.csv | wc -l` + + if [ "$csvLines" -gt "10" ]; then + sed -i '1d' taosdemo-report.csv + fi + + gnuplot -p taosdemo-csv2png.gnuplot +} + +today=`date +"%Y%m%d"` + +cd /root +echoInfo "Test Create Table Only " +runCreateTableOnly +echoInfo "Test Create Table then Insert data" +runCreateTableThenInsert +echoInfo "Generate plot for taosdemo" +generateTaosdemoPlot +echoInfo "End of TaosDemo Test" diff --git a/tests/perftest-scripts/perftest-tsdb-compare-13d.sh b/tests/perftest-scripts/perftest-tsdb-compare-13d.sh new file mode 100755 index 0000000000..4b3ed6818c --- /dev/null +++ b/tests/perftest-scripts/perftest-tsdb-compare-13d.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# Coloured Echoes # +function red_echo { echo -e "\033[31m$@\033[0m"; } # +function green_echo { echo -e "\033[32m$@\033[0m"; } # +function yellow_echo { echo -e "\033[33m$@\033[0m"; } # +function white_echo { echo -e "\033[1;37m$@\033[0m"; } # +# Coloured Printfs # +function red_printf { printf "\033[31m$@\033[0m"; } # +function green_printf { printf "\033[32m$@\033[0m"; } # +function yellow_printf { printf "\033[33m$@\033[0m"; } # +function white_printf { printf "\033[1;37m$@\033[0m"; } # +# Debugging Outputs # +function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } # +function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } # +function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } # +function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } # + +function restartTaosd { + systemctl stop taosd + pkill -KILL -x taosd + sleep 10 + + rm -rf /mnt/var/log/taos/* + rm -rf /mnt/var/lib/taos/* + + taosd 2>&1 > /dev/null & + sleep 10 +} + +function runPerfTest13d { + echoInfo "Restart Taosd" + restartTaosd + + cd /home/taos/tliu/timeseriesdatabase-comparisons/build/tsdbcompare + ./runreal-13d-csv.sh 2>&1 | tee /root/perftest-13d-$today.log +} + +function generatePerfPlot13d { + cd /root + + csvLines=`cat perftest-13d-report.csv | wc -l` + + if [ "$csvLines" -gt "10" ]; then + sed -i '1d' perftest-13d-report.csv + fi + + gnuplot -e "filename='perftest-13d-report'" -p perftest-csv2png.gnuplot +} + +today=`date +"%Y%m%d"` +cd /root + +echoInfo "run Performance Test with 13 days data" +runPerfTest13d +echoInfo "Generate plot of 13 days data" +generatePerfPlot13d +echoInfo "End of TSDB-Compare 13-days-data Test" diff --git a/tests/perftest-scripts/perftest-tsdb-compare-1d.sh b/tests/perftest-scripts/perftest-tsdb-compare-1d.sh new file mode 100755 index 0000000000..ebe34cde72 --- /dev/null +++ b/tests/perftest-scripts/perftest-tsdb-compare-1d.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# Coloured Echoes # +function red_echo { echo -e "\033[31m$@\033[0m"; } # +function green_echo { echo -e "\033[32m$@\033[0m"; } # +function yellow_echo { echo -e "\033[33m$@\033[0m"; } # +function white_echo { echo -e "\033[1;37m$@\033[0m"; } # +# Coloured Printfs # +function red_printf { printf "\033[31m$@\033[0m"; } # +function green_printf { printf "\033[32m$@\033[0m"; } # +function yellow_printf { printf "\033[33m$@\033[0m"; } # +function white_printf { printf "\033[1;37m$@\033[0m"; } # +# Debugging Outputs # +function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; } # +function echoInfo { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; } # +function echoWarn { local args="$@"; echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; } # +function echoError { local args="$@"; echo "$(white_brackets "$(red_printf "ERROR")" && echo " ${args}";)" 1>&2; } # + +function restartTaosd { + systemctl stop taosd + pkill -KILL -x taosd + sleep 10 + + rm -rf /mnt/var/log/taos/* + rm -rf /mnt/var/lib/taos/* + + taosd 2>&1 > /dev/null & + sleep 10 +} + +function runPerfTest1d { + echoInfo "Restart Taosd" + restartTaosd + + cd /home/taos/tliu/timeseriesdatabase-comparisons/build/tsdbcompare + ./runreal-1d-csv.sh 2>&1 | tee /root/perftest-1d-$today.log +} + +function generatePerfPlot1d { + cd /root + + csvLines=`cat perftest-1d-report.csv | wc -l` + + if [ "$csvLines" -gt "10" ]; then + sed -i '2d' perftest-1d-report.csv + fi + + gnuplot -e "filename='perftest-1d-report'" -p perftest-csv2png.gnuplot +} + +today=`date +"%Y%m%d"` +cd /root + +echoInfo "run Performance Test with 1 day data" +runPerfTest1d +echoInfo "Generate plot of 1 day data" +generatePerfPlot1d +echoInfo "End of TSDB-Compare 1-day-data Test" diff --git a/tests/perftest-scripts/run-csv.sh b/tests/perftest-scripts/run-csv.sh new file mode 100755 index 0000000000..afa1d5df5d --- /dev/null +++ b/tests/perftest-scripts/run-csv.sh @@ -0,0 +1,209 @@ +#!/bin/bash + + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' +docker rm -f `docker ps -a -q` +#set -x +echo +echo "---------------Generating Data-----------------" +echo +echo "Prepare data for InfluxDB...." +#bin/bulk_data_gen -seed 123 -format influx-bulk -scale-var 100 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" >data/influx.dat +bin/bulk_data_gen -seed 123 -format influx-bulk -sampling-interval 1s -scale-var 10 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" >data/influx.dat + +echo +echo "Prepare data for TDengine...." +#bin/bulk_data_gen -seed 123 -format tdengine -tdschema-file config/TDengineSchema.toml -scale-var 100 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" > data/tdengine.dat +bin/bulk_data_gen -seed 123 -format tdengine -sampling-interval 1s -tdschema-file config/TDengineSchema.toml -scale-var 10 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" > data/tdengine.dat + + + +docker network create --ip-range 172.15.1.255/24 --subnet 172.15.1.1/16 tsdbcomp >>/dev/null 2>&1 + + +TDENGINE=`docker run -d --net tsdbcomp --ip 172.15.1.6 -p 6030:6030 -p 6020:6020 -p 6031:6031 -p 6032:6032 -p 6033:6033 -p 6034:6034 -p 6035:6035 -p 6036:6036 -p 6037:6037 -p 6038:6038 -p 6039:6039 tdengine/tdengine:1.6.4.5` +echo +echo "------------------Writing Data-----------------" +echo +sleep 5 +echo +echo -e "Start test TDengine, result in ${GREEN}Green line${NC}" + +TDENGINERES=`cat data/tdengine.dat |bin/bulk_load_tdengine --url 172.15.1.6:0 --batch-size 300 -do-load -report-tags n1 -workers 20 -fileout=false| grep loaded` +#TDENGINERES=`cat data/tdengine.dat |gunzip|bin/bulk_load_tdengine --url 172.15.1.6:0 --batch-size 300 -do-load -report-tags n1 -workers 10 -fileout=false| grep loaded` +echo +echo -e "${GREEN}TDengine writing result:${NC}" +echo -e "${GREEN}$TDENGINERES${NC}" +DATA=`echo $TDENGINERES|awk '{print($2)}'` +TMP=`echo $TDENGINERES|awk '{print($5)}'` +TDWTM=`echo ${TMP%s*}` + + +INFLUX=`docker run -d -p 8086:8086 --net tsdbcomp --ip 172.15.1.5 influxdb` >>/dev/null 2>&1 +sleep 10 +echo +echo -e "Start test InfluxDB, result in ${GREEN}Green line${NC}" + + +INFLUXRES=`cat data/influx.dat |bin/bulk_load_influx --batch-size=5000 --workers=20 --urls="http://172.15.1.5:8086" | grep loaded` + + +echo +echo -e "${GREEN}InfluxDB writing result:${NC}" +echo -e "${GREEN}$INFLUXRES${NC}" + +TMP=`echo $INFLUXRES|awk '{print($5)}'` +IFWTM=`echo ${TMP%s*}` + +echo +echo "------------------Querying Data-----------------" +echo + +sleep 10 +echo +echo "start query test, query max from 8 hosts group by 1 hour, TDengine" +echo + +#Test case 1 +#测试用例1,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') ; +# a,b,c,d,e,f,g,h are random 8 numbers. +TDQS1=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-all -scale-var 10 -queries 1000 | bin/query_benchmarker_tdengine -urls="http://172.15.1.6:6020" -workers 50 -print-interval 0|grep wall` +echo +echo -e "${GREEN}TDengine query test case 1 result:${NC}" +echo -e "${GREEN}$TDQS1${NC}" +TMP=`echo $TDQS1|awk '{print($4)}'` +TDQ1=`echo ${TMP%s*}` + +#Test case 2 +#测试用例2,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以1小时为粒度,查询每1小时的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') interval(1h); +# a,b,c,d,e,f,g,h are random 8 numbers +TDQS2=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-allbyhr -scale-var 10 -queries 1000 | bin/query_benchmarker_tdengine -urls="http://172.15.1.6:6020" -workers 50 -print-interval 0|grep wall` + +echo +echo -e "${GREEN}TDengine query test case 2 result:${NC}" +echo -e "${GREEN}$TDQS2${NC}" +TMP=`echo $TDQS2|awk '{print($4)}'` +TDQ2=`echo ${TMP%s*}` + +#Test case 3 +#测试用例3,测试用例3,随机查询12个小时的数据,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以10分钟为粒度,查询每10分钟的最大值 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') and time >x and time x and time x and time x and time >/dev/null 2>&1 +docker container rm -f $INFLUX >>/dev/null 2>&1 +docker stop $TDENGINE >>/dev/null 2>&1 +docker container rm -f $TDENGINE >>/dev/null 2>&1 +docker network rm tsdbcomp >>/dev/null 2>&1 +#bulk_query_gen/bulk_query_gen -format influx-http -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_influxdb/query_benchmarker_influxdb -urls="http://172.26.89.231:8086" +#bulk_query_gen/bulk_query_gen -format tdengine -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_tdengine/query_benchmarker_tdengine -urls="http://172.26.89.231:6020" + + +today=`date +"%Y%m%d"` +echo "${today}, ${IFWTM}, ${IFQ1}, ${IFQ2}, ${IFQ3}, ${IFQ4}" >> /root/perftest-influx-report.csv + diff --git a/tests/perftest-scripts/runInfluxdb-13d-csv.sh b/tests/perftest-scripts/runInfluxdb-13d-csv.sh new file mode 100755 index 0000000000..2eb3606868 --- /dev/null +++ b/tests/perftest-scripts/runInfluxdb-13d-csv.sh @@ -0,0 +1,126 @@ +#!/bin/bash + + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' +docker rm -f `docker ps -a -q` +#set -x +echo +echo "---------------Generating Data-----------------" +echo +echo "Prepare data for InfluxDB...." +#bin/bulk_data_gen -seed 123 -format influx-bulk -scale-var 100 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" >data/influx.dat +bin/bulk_data_gen -seed 123 -format influx-bulk -sampling-interval 1s -scale-var 10 -use-case devops -timestamp-start "2018-01-02T00:00:00Z" -timestamp-end "2018-01-15T00:00:00Z" > /mnt/data/influx.dat + +docker network create --ip-range 172.15.1.255/24 --subnet 172.15.1.1/16 tsdbcomp >>/dev/null 2>&1 + +INFLUX=`docker run -d -p 8086:8086 --net tsdbcomp --ip 172.15.1.5 influxdb` >>/dev/null 2>&1 +sleep 10 +echo +echo -e "Start test InfluxDB, result in ${GREEN}Green line${NC}" + + +INFLUXRES=`cat /mnt/data/influx.dat |bin/bulk_load_influx --batch-size=5000 --workers=20 --urls="http://172.15.1.5:8086" | grep loaded` + + +echo +echo -e "${GREEN}InfluxDB writing result:${NC}" +echo -e "${GREEN}$INFLUXRES${NC}" +DATA=`echo $INFLUXRES|awk '{print($2)}'` +TMP=`echo $INFLUXRES|awk '{print($5)}'` +IFWTM=`echo ${TMP%s*}` + +echo +echo "------------------Querying Data-----------------" +echo + +sleep 10 + +echo +echo "start query test, query max from 8 hosts group by 1hour, Influxdb" +echo +#Test case 1 +#测试用例1,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') ; +# a,b,c,d,e,f,g,h are random 8 numbers. +IFQS1=`bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-all -scale-var 10 -queries 1000 | bin/query_benchmarker_influxdb -urls="http://172.15.1.5:8086" -workers 50 -print-interval 0|grep wall` +echo -e "${GREEN}InfluxDB query test case 1 result:${NC}" +echo -e "${GREEN}$IFQS1${NC}" +TMP=`echo $IFQS1|awk '{print($4)}'` +IFQ1=`echo ${TMP%s*}` +#Test case 2 +#测试用例2,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以1小时为粒度,查询每1小时的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') interval(1h); +# a,b,c,d,e,f,g,h are random 8 numbers +IFQS2=`bin/bulk_query_gen -seed 123 -format influx-http -query-type 8-host-allbyhr -scale-var 10 -queries 1000 | bin/query_benchmarker_influxdb -urls="http://172.15.1.5:8086" -workers 50 -print-interval 0|grep wall` +echo -e "${GREEN}InfluxDB query test case 2 result:${NC}" +echo -e "${GREEN}$IFQS2${NC}" +TMP=`echo $IFQS2|awk '{print($4)}'` +IFQ2=`echo ${TMP%s*}` +#Test case 3 +#测试用例3,测试用例3,随机查询12个小时的数据,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以10分钟为粒度,查询每10分钟的最大值 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') and time >x and time x and time > /root/perftest-influxdb-report-13d.csv + +docker stop $INFLUX >>/dev/null 2>&1 +docker container rm -f $INFLUX >>/dev/null 2>&1 +docker network rm tsdbcomp >>/dev/null 2>&1 +#bulk_query_gen/bulk_query_gen -format influx-http -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_influxdb/query_benchmarker_influxdb -urls="http://172.26.89.231:8086" +#bulk_query_gen/bulk_query_gen -format tdengine -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_tdengine/query_benchmarker_tdengine -urls="http://172.26.89.231:6020" + diff --git a/tests/perftest-scripts/runreal-13d-csv.sh b/tests/perftest-scripts/runreal-13d-csv.sh new file mode 100755 index 0000000000..ff7ce41d4b --- /dev/null +++ b/tests/perftest-scripts/runreal-13d-csv.sh @@ -0,0 +1,149 @@ +#!/bin/bash + + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' +#set -x +echo +echo "---------------Generating Data-----------------" +echo + +echo +echo "Prepare data for TDengine...." +#bin/bulk_data_gen -seed 123 -format tdengine -tdschema-file config/TDengineSchema.toml -scale-var 100 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" > data/tdengine.dat +bin/bulk_data_gen -seed 123 -format tdengine -sampling-interval 1s -tdschema-file config/TDengineSchema.toml -scale-var 10 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-14T00:00:00Z" > /mnt/data/tdengine.dat + + +echo +echo -e "Start test TDengine, result in ${GREEN}Green line${NC}" + +for i in {1..5}; do + TDENGINERES=`cat /mnt/data/tdengine.dat |bin/bulk_load_tdengine --url 127.0.0.1:0 --batch-size 5000 -do-load -report-tags n1 -workers 20 -fileout=false| grep loaded` +#TDENGINERES=`cat data/tdengine.dat |gunzip|bin/bulk_load_tdengine --url 127.0.0.1:0 --batch-size 300 -do-load -report-tags n1 -workers 10 -fileout=false| grep loaded` + echo + echo -e "${GREEN}TDengine writing result:${NC}" + echo -e "${GREEN}$TDENGINERES${NC}" + DATA=`echo $TDENGINERES|awk '{print($2)}'` + TMP=`echo $TDENGINERES|awk '{print($5)}'` + TDWTM=`echo ${TMP%s*}` + + [ -z "$TDWTM" ] || break +done + + + +echo +echo "------------------Querying Data-----------------" +echo + +sleep 10 +echo +echo "start query test, query max from 8 hosts group by 1 hour, TDengine" +echo + +#Test case 1 +#测试用例1,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') ; +# a,b,c,d,e,f,g,h are random 8 numbers. +for i in {1..5}; do + TDQS1=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-all -scale-var 10 -queries 1000 | bin/query_benchmarker_tdengine -urls="http://127.0.0.1:6020" -workers 50 -print-interval 0|grep wall` + echo + echo -e "${GREEN}TDengine query test case 1 result:${NC}" + echo -e "${GREEN}$TDQS1${NC}" + TMP=`echo $TDQS1|awk '{print($4)}'` + TDQ1=`echo ${TMP%s*}` + + [ -z "$TDQ1" ] || break +done + +#Test case 2 +#测试用例2,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以1小时为粒度,查询每1小时的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') interval(1h); +# a,b,c,d,e,f,g,h are random 8 numbers +for i in {1..5}; do + TDQS2=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-allbyhr -scale-var 10 -queries 1000 | bin/query_benchmarker_tdengine -urls="http://127.0.0.1:6020" -workers 50 -print-interval 0|grep wall` + + echo + echo -e "${GREEN}TDengine query test case 2 result:${NC}" + echo -e "${GREEN}$TDQS2${NC}" + TMP=`echo $TDQS2|awk '{print($4)}'` + TDQ2=`echo ${TMP%s*}` + + [ -z "$TDQ2" ] || break +done + +#Test case 3 +#测试用例3,测试用例3,随机查询12个小时的数据,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以10分钟为粒度,查询每10分钟的最大值 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') and time >x and time x and time > /root/perftest-13d-report.csv + +#bulk_query_gen/bulk_query_gen -format influx-http -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_influxdb/query_benchmarker_influxdb -urls="http://172.26.89.231:8086" +#bulk_query_gen/bulk_query_gen -format tdengine -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_tdengine/query_benchmarker_tdengine -urls="http://172.26.89.231:6020" diff --git a/tests/perftest-scripts/runreal-1d-csv.sh b/tests/perftest-scripts/runreal-1d-csv.sh new file mode 100755 index 0000000000..5cd113aadf --- /dev/null +++ b/tests/perftest-scripts/runreal-1d-csv.sh @@ -0,0 +1,149 @@ +#!/bin/bash + + +# Color setting +RED='\033[0;31m' +GREEN='\033[1;32m' +GREEN_DARK='\033[0;32m' +GREEN_UNDERLINE='\033[4;32m' +NC='\033[0m' +#set -x +echo +echo "---------------Generating Data-----------------" +echo + +echo +echo "Prepare data for TDengine...." +#bin/bulk_data_gen -seed 123 -format tdengine -tdschema-file config/TDengineSchema.toml -scale-var 100 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" > data/tdengine.dat +bin/bulk_data_gen -seed 123 -format tdengine -sampling-interval 1s -tdschema-file config/TDengineSchema.toml -scale-var 10 -use-case devops -timestamp-start "2018-01-01T00:00:00Z" -timestamp-end "2018-01-02T00:00:00Z" > data/tdengine.dat + + +echo +echo -e "Start test TDengine, result in ${GREEN}Green line${NC}" + +for i in {1..5}; do + TDENGINERES=`cat data/tdengine.dat |bin/bulk_load_tdengine --url 127.0.0.1:0 --batch-size 300 -do-load -report-tags n1 -workers 20 -fileout=false| grep loaded` +#TDENGINERES=`cat data/tdengine.dat |gunzip|bin/bulk_load_tdengine --url 127.0.0.1:0 --batch-size 300 -do-load -report-tags n1 -workers 10 -fileout=false| grep loaded` + echo + echo -e "${GREEN}TDengine writing result:${NC}" + echo -e "${GREEN}$TDENGINERES${NC}" + DATA=`echo $TDENGINERES|awk '{print($2)}'` + TMP=`echo $TDENGINERES|awk '{print($5)}'` + TDWTM=`echo ${TMP%s*}` + + [ -z "$TDWTM" ] || break +done + + + +echo +echo "------------------Querying Data-----------------" +echo + +sleep 10 +echo +echo "start query test, query max from 8 hosts group by 1 hour, TDengine" +echo + +#Test case 1 +#测试用例1,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') ; +# a,b,c,d,e,f,g,h are random 8 numbers. +for i in {1..5}; do + TDQS1=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-all -scale-var 10 -queries 1000 | bin/query_benchmarker_tdengine -urls="http://127.0.0.1:6020" -workers 50 -print-interval 0|grep wall` + echo + echo -e "${GREEN}TDengine query test case 1 result:${NC}" + echo -e "${GREEN}$TDQS1${NC}" + TMP=`echo $TDQS1|awk '{print($4)}'` + TDQ1=`echo ${TMP%s*}` + + [ -z "$TDQ1" ] || break +done + +#Test case 2 +#测试用例2,查询所有数据中,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以1小时为粒度,查询每1小时的最大值。 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') interval(1h); +# a,b,c,d,e,f,g,h are random 8 numbers +for i in {1..5}; do + TDQS2=`bin/bulk_query_gen -seed 123 -format tdengine -query-type 8-host-allbyhr -scale-var 10 -queries 1000 | bin/query_benchmarker_tdengine -urls="http://127.0.0.1:6020" -workers 50 -print-interval 0|grep wall` + + echo + echo -e "${GREEN}TDengine query test case 2 result:${NC}" + echo -e "${GREEN}$TDQS2${NC}" + TMP=`echo $TDQS2|awk '{print($4)}'` + TDQ2=`echo ${TMP%s*}` + + [ -z "$TDQ2" ] || break +done + +#Test case 3 +#测试用例3,测试用例3,随机查询12个小时的数据,用8个hostname标签进行匹配,匹配出这8个hostname对应的模拟服务器CPU数据中的usage_user这个监控数据,以10分钟为粒度,查询每10分钟的最大值 +#select max(usage_user) from cpu where(hostname='host_a' and hostname='host_b'and hostname='host_c'and hostname='host_d'and hostname='host_e'and hostname='host_f' and hostname='host_g'and hostname='host_h') and time >x and time x and time > /root/perftest-1d-report.csv + +#bulk_query_gen/bulk_query_gen -format influx-http -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_influxdb/query_benchmarker_influxdb -urls="http://172.26.89.231:8086" +#bulk_query_gen/bulk_query_gen -format tdengine -query-type 1-host-1-hr -scale-var 10 -queries 1000 | query_benchmarker_tdengine/query_benchmarker_tdengine -urls="http://172.26.89.231:6020" diff --git a/tests/perftest-scripts/taosdemo-csv2png.gnuplot b/tests/perftest-scripts/taosdemo-csv2png.gnuplot new file mode 100644 index 0000000000..9fcd4bb3d9 --- /dev/null +++ b/tests/perftest-scripts/taosdemo-csv2png.gnuplot @@ -0,0 +1,26 @@ +#!/user/bin/gnuplot +reset +set terminal png + +set title "TaosDemo Performance Report" font ",20" + +set ylabel "Time in Seconds" + +set xdata time +set timefmt "%Y%m%d" +set format x "%Y-%m-%d" +set xlabel "Date" + +set style data linespoints + +set terminal pngcairo size 1024,768 enhanced font 'Segoe UI, 10' +set output 'taosdemo-report.png' +set datafile separator ',' + +set key reverse Left outside +set grid + + +plot 'taosdemo-report.csv' using 1:2 title "Create 10,000 Table", \ + "" using 1:3 title "Create 10,000 Table and Insert 100,000 data", \ + "" using 1:4 title "Request Per Second of Insert 100,000 data" diff --git a/tests/pytest/crash_gen.py b/tests/pytest/crash_gen.py index 44c978957e..2e5d84d45f 100755 --- a/tests/pytest/crash_gen.py +++ b/tests/pytest/crash_gen.py @@ -14,6 +14,7 @@ from __future__ import annotations # For type hinting before definition, ref: https://stackoverflow.com/questions/33533148/how-do-i-specify-that-the-return-type-of-a-method-is-the-same-as-the-class-itsel import sys +import traceback # Require Python 3 if sys.version_info[0] < 3: raise Exception("Must be using Python 3") @@ -24,11 +25,13 @@ import copy import threading import random +import time import logging import datetime import textwrap from typing import List +from typing import Dict from util.log import * from util.dnodes import * @@ -45,6 +48,14 @@ logger = None def runThread(wt: WorkerThread): wt.run() +class CrashGenError(Exception): + def __init__(self, msg=None, errno=None): + self.msg = msg + self.errno = errno + + def __str__(self): + return self.msg + class WorkerThread: def __init__(self, pool: ThreadPool, tid, tc: ThreadCoordinator, @@ -63,10 +74,10 @@ class WorkerThread: self._dbConn = DbConn() def logDebug(self, msg): - logger.info(" t[{}] {}".format(self._tid, msg)) + logger.debug(" TRD[{}] {}".format(self._tid, msg)) def logInfo(self, msg): - logger.info(" t[{}] {}".format(self._tid, msg)) + logger.info(" TRD[{}] {}".format(self._tid, msg)) def getTaskExecutor(self): @@ -95,15 +106,19 @@ class WorkerThread: while True: tc = self._tc # Thread Coordinator, the overall master tc.crossStepBarrier() # shared barrier first, INCLUDING the last one - logger.debug("Thread task loop exited barrier...") + logger.debug("[TRD] Worker thread [{}] exited barrier...".format(self._tid)) self.crossStepGate() # then per-thread gate, after being tapped - logger.debug("Thread task loop exited step gate...") + logger.debug("[TRD] Worker thread [{}] exited step gate...".format(self._tid)) if not self._tc.isRunning(): + logger.debug("[TRD] Thread Coordinator not running any more, worker thread now stopping...") break + logger.debug("[TRD] Worker thread [{}] about to fetch task".format(self._tid)) task = tc.fetchTask() + logger.debug("[TRD] Worker thread [{}] about to execute task: {}".format(self._tid, task.__class__.__name__)) task.execute(self) tc.saveExecutedTask(task) + logger.debug("[TRD] Worker thread [{}] finished executing task".format(self._tid)) def verifyThreadSelf(self): # ensure we are called by this own thread if ( threading.get_ident() != self._thread.ident ): @@ -123,7 +138,7 @@ class WorkerThread: self.verifyThreadSelf() # only allowed by ourselves # Wait again at the "gate", waiting to be "tapped" - # logger.debug("Worker thread {} about to cross the step gate".format(self._tid)) + logger.debug("[TRD] Worker thread {} about to cross the step gate".format(self._tid)) self._stepGate.wait() self._stepGate.clear() @@ -133,33 +148,40 @@ class WorkerThread: self.verifyThreadAlive() self.verifyThreadMain() # only allowed for main thread - logger.debug("Tapping worker thread {}".format(self._tid)) + logger.debug("[TRD] Tapping worker thread {}".format(self._tid)) self._stepGate.set() # wake up! time.sleep(0) # let the released thread run a bit - def execSql(self, sql): # not "execute", since we are out side the DB context + def execSql(self, sql): # TODO: expose DbConn directly if ( gConfig.per_thread_db_connection ): return self._dbConn.execute(sql) else: return self._tc.getDbState().getDbConn().execute(sql) - def querySql(self, sql): # not "execute", since we are out side the DB context + def getDbConn(self): if ( gConfig.per_thread_db_connection ): - return self._dbConn.query(sql) + return self._dbConn else: - return self._tc.getDbState().getDbConn().query(sql) - + return self._tc.getDbState().getDbConn() + + # def querySql(self, sql): # not "execute", since we are out side the DB context + # if ( gConfig.per_thread_db_connection ): + # return self._dbConn.query(sql) + # else: + # return self._tc.getDbState().getDbConn().query(sql) + class ThreadCoordinator: - def __init__(self, pool, wd: WorkDispatcher, dbState): + def __init__(self, pool, dbState): self._curStep = -1 # first step is 0 self._pool = pool - self._wd = wd + # self._wd = wd self._te = None # prepare for every new step self._dbState = dbState self._executedTasks: List[Task] = [] # in a given step self._lock = threading.RLock() # sync access for a few things self._stepBarrier = threading.Barrier(self._pool.numThreads + 1) # one barrier for all threads + self._execStats = ExecutionStats() def getTaskExecutor(self): return self._te @@ -176,41 +198,63 @@ class ThreadCoordinator: # Coordinate all threads step by step self._curStep = -1 # not started yet maxSteps = gConfig.max_steps # type: ignore - while(self._curStep < maxSteps): - print(".", end="", flush=True) - logger.debug("Main thread going to sleep") + self._execStats.startExec() # start the stop watch + failed = False + while(self._curStep < maxSteps-1 and not failed): # maxStep==10, last curStep should be 9 + if not gConfig.debug: + print(".", end="", flush=True) # print this only if we are not in debug mode + logger.debug("[TRD] Main thread going to sleep") # Now ready to enter a step self.crossStepBarrier() # let other threads go past the pool barrier, but wait at the thread gate self._stepBarrier.reset() # Other worker threads should now be at the "gate" # At this point, all threads should be pass the overall "barrier" and before the per-thread "gate" - self._dbState.transition(self._executedTasks) # at end of step, transiton the DB state + try: + self._dbState.transition(self._executedTasks) # at end of step, transiton the DB state + except taos.error.ProgrammingError as err: + if ( err.msg == 'network unavailable' ): # broken DB connection + logger.info("DB connection broken, execution failed") + traceback.print_stack() + failed = True + self._te = None # Not running any more + self._execStats.registerFailure("Broken DB Connection") + # continue # don't do that, need to tap all threads at end, and maybe signal them to stop + else: + raise + finally: + pass + self.resetExecutedTasks() # clear the tasks after we are done # Get ready for next step - logger.info("<-- Step {} finished".format(self._curStep)) + logger.debug("<-- Step {} finished".format(self._curStep)) self._curStep += 1 # we are about to get into next step. TODO: race condition here! logger.debug("\r\n--> Step {} starts with main thread waking up".format(self._curStep)) # Now not all threads had time to go to sleep # A new TE for the new step - self._te = TaskExecutor(self._curStep) + if not failed: # only if not failed + self._te = TaskExecutor(self._curStep) - logger.debug("Main thread waking up at step {}, tapping worker threads".format(self._curStep)) # Now not all threads had time to go to sleep + logger.debug("[TRD] Main thread waking up at step {}, tapping worker threads".format(self._curStep)) # Now not all threads had time to go to sleep self.tapAllThreads() logger.debug("Main thread ready to finish up...") - self.crossStepBarrier() # Cross it one last time, after all threads finish - self._stepBarrier.reset() - logger.debug("Main thread in exclusive zone...") - self._te = None # No more executor, time to end - logger.debug("Main thread tapping all threads one last time...") - self.tapAllThreads() # Let the threads run one last time + if not failed: # only in regular situations + self.crossStepBarrier() # Cross it one last time, after all threads finish + self._stepBarrier.reset() + logger.debug("Main thread in exclusive zone...") + self._te = None # No more executor, time to end + logger.debug("Main thread tapping all threads one last time...") + self.tapAllThreads() # Let the threads run one last time + logger.debug("Main thread joining all threads") self._pool.joinAll() # Get all threads to finish + logger.info("All worker thread finished") + self._execStats.endExec() - logger.info("All threads finished") - print("\r\nFinished") + def logStats(self): + self._execStats.logStats() def tapAllThreads(self): # in a deterministic manner wakeSeq = [] @@ -219,7 +263,7 @@ class ThreadCoordinator: wakeSeq.append(i) else: wakeSeq.insert(0, i) - logger.info("Waking up threads: {}".format(str(wakeSeq))) + logger.debug("[TRD] Main thread waking up worker thread: {}".format(str(wakeSeq))) # TODO: set dice seed to a deterministic value for i in wakeSeq: self._pool.threadList[i].tapStepGate() # TODO: maybe a bit too deep?! @@ -233,11 +277,15 @@ class ThreadCoordinator: raise RuntimeError("Cannot fetch task when not running") # return self._wd.pickTask() # Alternatively, let's ask the DbState for the appropriate task - dbState = self.getDbState() - tasks = dbState.getTasksAtState() - i = Dice.throw(len(tasks)) - # return copy.copy(tasks[i]) # Needs a fresh copy, to save execution results, etc. - return tasks[i].clone() + # dbState = self.getDbState() + # tasks = dbState.getTasksAtState() # TODO: create every time? + # nTasks = len(tasks) + # i = Dice.throw(nTasks) + # logger.debug(" (dice:{}/{}) ".format(i, nTasks)) + # # return copy.copy(tasks[i]) # Needs a fresh copy, to save execution results, etc. + # return tasks[i].clone() # TODO: still necessary? + taskType = self.getDbState().pickTaskType() # pick a task type for current state + return taskType(self.getDbState(), self._execStats) # create a task from it def resetExecutedTasks(self): self._executedTasks = [] # should be under single thread @@ -253,7 +301,7 @@ class ThreadPool: self.maxSteps = maxSteps self.funcSequencer = funcSequencer # Internal class variables - self.dispatcher = WorkDispatcher(dbState) + # self.dispatcher = WorkDispatcher(dbState) # Obsolete? self.curStep = 0 self.threadList = [] # self.stepGate = threading.Condition() # Gate to hold/sync all threads @@ -362,7 +410,7 @@ class DbConn: # Get the connection/cursor ready self._cursor.execute('reset query cache') - # self._cursor.execute('use db') + # self._cursor.execute('use db') # note we do this in _findCurrenState # Open connection self._tdSql = TDSql() @@ -390,166 +438,93 @@ class DbConn: def execute(self, sql): if ( not self.isOpen ): raise RuntimeError("Cannot execute database commands until connection is open") - return self._tdSql.execute(sql) + logger.debug("[SQL] Executing SQL: {}".format(sql)) + nRows = self._tdSql.execute(sql) + logger.debug("[SQL] Execution Result, nRows = {}, SQL = {}".format(nRows, sql)) + return nRows - def query(self, sql) -> int : # return number of rows retrieved + def query(self, sql) : # return rows affected if ( not self.isOpen ): raise RuntimeError("Cannot query database until connection is open") - return self._tdSql.query(sql) + logger.debug("[SQL] Executing SQL: {}".format(sql)) + nRows = self._tdSql.query(sql) + logger.debug("[SQL] Execution Result, nRows = {}, SQL = {}".format(nRows, sql)) + return nRows + # results are in: return self._tdSql.queryResult + def getQueryResult(self): + return self._tdSql.queryResult -# State of the database as we believe it to be -class DbState(): + def _queryAny(self, sql) : # actual query result as an int + if ( not self.isOpen ): + raise RuntimeError("Cannot query database until connection is open") + tSql = self._tdSql + nRows = tSql.query(sql) + if nRows != 1 : + raise RuntimeError("Unexpected result for query: {}, rows = {}".format(sql, nRows)) + if tSql.queryRows != 1 or tSql.queryCols != 1: + raise RuntimeError("Unexpected result set for query: {}".format(sql)) + return tSql.queryResult[0][0] + + def queryScalar(self, sql) -> int : + return self._queryAny(sql) + + def queryString(self, sql) -> str : + return self._queryAny(sql) + +class AnyState: STATE_INVALID = -1 - STATE_EMPTY = 1 # nothing there, no even a DB - STATE_DB_ONLY = 2 # we have a DB, but nothing else - STATE_TABLE_ONLY = 3 # we have a table, but totally empty - STATE_HAS_DATA = 4 # we have some data in the table + STATE_EMPTY = 0 # nothing there, no even a DB + STATE_DB_ONLY = 1 # we have a DB, but nothing else + STATE_TABLE_ONLY = 2 # we have a table, but totally empty + STATE_HAS_DATA = 3 # we have some data in the table + _stateNames = ["Invalid", "Empty", "DB_Only", "Table_Only", "Has_Data"] + + STATE_VAL_IDX = 0 + CAN_CREATE_DB = 1 + CAN_DROP_DB = 2 + CAN_CREATE_FIXED_SUPER_TABLE = 3 + CAN_DROP_FIXED_SUPER_TABLE = 4 + CAN_ADD_DATA = 5 + CAN_READ_DATA = 6 def __init__(self): - self.tableNumQueue = LinearQueue() - self._lastTick = datetime.datetime(2019, 1, 1) # initial date time tick - self._lastInt = 0 # next one is initial integer - self._lock = threading.RLock() - self._state = self.STATE_INVALID - - # self.openDbServerConnection() - self._dbConn = DbConn() - try: - self._dbConn.open() # may throw taos.error.ProgrammingError: disconnected - except taos.error.ProgrammingError as err: - # print("Error type: {}, msg: {}, value: {}".format(type(err), err.msg, err)) - if ( err.msg == 'disconnected' ): # cannot open DB connection - print("Cannot establish DB connection, please re-run script without parameter, and follow the instructions.") - sys.exit() - else: - raise - except: - print("[=]Unexpected exception") - raise - self._dbConn.resetDb() # drop and recreate DB - self._state = self.STATE_EMPTY # initial state, the result of above + self._info = self.getInfo() - def getDbConn(self): - return self._dbConn + def __str__(self): + return self._stateNames[self._info[self.STATE_VAL_IDX] + 1] # -1 hack to accomodate the STATE_INVALID case - def pickAndAllocateTable(self): # pick any table, and "use" it - return self.tableNumQueue.pickAndAllocate() + def getInfo(self): + raise RuntimeError("Must be overriden by child classes") - def addTable(self): - with self._lock: - tIndex = self.tableNumQueue.push() - return tIndex - - def getFixedTableName(self): - return "fixed_table" - - def releaseTable(self, i): # return the table back, so others can use it - self.tableNumQueue.release(i) - - def getNextTick(self): - with self._lock: # prevent duplicate tick - self._lastTick += datetime.timedelta(0, 1) # add one second to it - return self._lastTick - - def getNextInt(self): - with self._lock: - self._lastInt += 1 - return self._lastInt - - def getTableNameToDelete(self): - tblNum = self.tableNumQueue.pop() # TODO: race condition! - if ( not tblNum ): # maybe false - return False - - return "table_{}".format(tblNum) - - def execSql(self, sql): # using the main DB connection - return self._dbConn.execute(sql) - - def cleanUp(self): - self._dbConn.close() - - def getTasksAtState(self): - tasks = [] - tasks.append(ReadFixedDataTask(self)) # always - if ( self._state == self.STATE_EMPTY ): - tasks.append(CreateDbTask(self)) - tasks.append(CreateFixedTableTask(self)) - elif ( self._state == self.STATE_DB_ONLY ): - tasks.append(DropDbTask(self)) - tasks.append(CreateFixedTableTask(self)) - tasks.append(AddFixedDataTask(self)) - elif ( self._state == self.STATE_TABLE_ONLY ): - tasks.append(DropFixedTableTask(self)) - tasks.append(AddFixedDataTask(self)) - elif ( self._state == self.STATE_HAS_DATA ) : # same as above. TODO: adjust - tasks.append(DropFixedTableTask(self)) - tasks.append(AddFixedDataTask(self)) + def equals(self, other): + if isinstance(other, int): + return self.getValIndex() == other + elif isinstance(other, AnyState): + return self.getValIndex() == other.getValIndex() else: - raise RuntimeError("Unexpected DbState state: {}".format(self._state)) - return tasks + raise RuntimeError("Unexpected comparison, type = {}".format(type(other))) - def transition(self, tasks): - if ( len(tasks) == 0 ): # before 1st step, or otherwise empty - return # do nothing - if ( self._state == self.STATE_EMPTY ): - # self.assertNoSuccess(tasks, ReadFixedDataTask) # some read may be successful, since we might be creating a table - if ( self.hasSuccess(tasks, CreateDbTask) ): - self.assertAtMostOneSuccess(tasks, CreateDbTask) # param is class - self._state = self.STATE_DB_ONLY - if ( self.hasSuccess(tasks, CreateFixedTableTask )): - self._state = self.STATE_TABLE_ONLY - # else: # no successful table creation, not much we can say, as it is step 2 - else: # did not create db - self.assertNoTask(tasks, CreateDbTask) # because we did not have such task - # self.assertNoSuccess(tasks, CreateDbTask) # not necessary, since we just verified no such task - self.assertNoSuccess(tasks, CreateFixedTableTask) - - elif ( self._state == self.STATE_DB_ONLY ): - self.assertAtMostOneSuccess(tasks, DropDbTask) - self.assertIfExistThenSuccess(tasks, DropDbTask) - self.assertAtMostOneSuccess(tasks, CreateFixedTableTask) - # Nothing to be said about adding data task - if ( self.hasSuccess(tasks, DropDbTask) ): # dropped the DB - # self.assertHasTask(tasks, DropDbTask) # implied by hasSuccess - self.assertAtMostOneSuccess(tasks, DropDbTask) - self._state = self.STATE_EMPTY - elif ( self.hasSuccess(tasks, CreateFixedTableTask) ): # did not drop db, create table success - # self.assertHasTask(tasks, CreateFixedTableTask) # tried to create table - self.assertAtMostOneSuccess(tasks, CreateFixedTableTask) # at most 1 attempt is successful - self.assertNoTask(tasks, DropDbTask) # should have have tried - if ( not self.hasSuccess(tasks, AddFixedDataTask) ): # just created table, no data yet - # can't say there's add-data attempts, since they may all fail - self._state = self.STATE_TABLE_ONLY - else: - self._state = self.STATE_HAS_DATA - else: # no success in dropping db tasks, no success in create fixed table, not acceptable - raise RuntimeError("Unexpected no-success scenario") + def verifyTasksToState(self, tasks, newState): + raise RuntimeError("Must be overriden by child classes") - elif ( self._state == self.STATE_TABLE_ONLY ): - if ( self.hasSuccess(tasks, DropFixedTableTask) ): - self.assertAtMostOneSuccess(tasks, DropFixedTableTask) - self._state = self.STATE_DB_ONLY - elif ( self.hasSuccess(tasks, AddFixedDataTask) ): # no success dropping the table - self.assertNoTask(tasks, DropFixedTableTask) - self._state = self.STATE_HAS_DATA - else: # did not drop table, did not insert data, that is impossible - raise RuntimeError("Unexpected no-success scenarios") + def getValIndex(self): + return self._info[self.STATE_VAL_IDX] - elif ( self._state == self.STATE_HAS_DATA ): # Same as above, TODO: adjust - if ( self.hasSuccess(tasks, DropFixedTableTask) ): - self.assertAtMostOneSuccess(tasks, DropFixedTableTask) - self._state = self.STATE_DB_ONLY - elif ( self.hasSuccess(tasks, AddFixedDataTask) ): # no success dropping the table - self.assertNoTask(tasks, DropFixedTableTask) - self._state = self.STATE_HAS_DATA - else: # did not drop table, did not insert data, that is impossible - raise RuntimeError("Unexpected no-success scenarios") - - else: - raise RuntimeError("Unexpected DbState state: {}".format(self._state)) - logger.debug("New DB state is: {}".format(self._state)) + def getValue(self): + return self._info[self.STATE_VAL_IDX] + def canCreateDb(self): + return self._info[self.CAN_CREATE_DB] + def canDropDb(self): + return self._info[self.CAN_DROP_DB] + def canCreateFixedSuperTable(self): + return self._info[self.CAN_CREATE_FIXED_SUPER_TABLE] + def canDropFixedSuperTable(self): + return self._info[self.CAN_DROP_FIXED_SUPER_TABLE] + def canAddData(self): + return self._info[self.CAN_ADD_DATA] + def canReadData(self): + return self._info[self.CAN_READ_DATA] def assertAtMostOneSuccess(self, tasks, cls): sCnt = 0 @@ -557,7 +532,7 @@ class DbState(): if not isinstance(task, cls): continue if task.isSuccess(): - task.logDebug("Task success found") + # task.logDebug("Task success found") sCnt += 1 if ( sCnt >= 2 ): raise RuntimeError("Unexpected more than 1 success with task: {}".format(cls)) @@ -577,7 +552,7 @@ class DbState(): def assertNoTask(self, tasks, cls): for task in tasks : if isinstance(task, cls): - raise RuntimeError("Unexpected task: {}".format(cls)) + raise CrashGenError("This task: {}, is not expected to be present, given the success/failure of others".format(cls.__name__)) def assertNoSuccess(self, tasks, cls): for task in tasks : @@ -593,6 +568,312 @@ class DbState(): return True return False + def hasTask(self, tasks, cls): + for task in tasks : + if isinstance(task, cls): + return True + return False + +class StateInvalid(AnyState): + def getInfo(self): + return [ + self.STATE_INVALID, + False, False, # can create/drop Db + False, False, # can create/drop fixed table + False, False, # can insert/read data with fixed table + ] + + # def verifyTasksToState(self, tasks, newState): + +class StateEmpty(AnyState): + def getInfo(self): + return [ + self.STATE_EMPTY, + True, False, # can create/drop Db + False, False, # can create/drop fixed table + False, False, # can insert/read data with fixed table + ] + + def verifyTasksToState(self, tasks, newState): + if ( self.hasSuccess(tasks, CreateDbTask) ): # at EMPTY, if there's succes in creating DB + if ( not self.hasTask(tasks, DropDbTask) ) : # and no drop_db tasks + self.assertAtMostOneSuccess(tasks, CreateDbTask) # we must have at most one. TODO: compare numbers + +class StateDbOnly(AnyState): + def getInfo(self): + return [ + self.STATE_DB_ONLY, + False, True, + True, False, + False, False, + ] + + def verifyTasksToState(self, tasks, newState): + self.assertAtMostOneSuccess(tasks, DropDbTask) # not true in massively parralel cases + self.assertIfExistThenSuccess(tasks, DropDbTask) + # self.assertAtMostOneSuccess(tasks, CreateFixedTableTask) # not true in massively parrallel cases + # Nothing to be said about adding data task + if ( self.hasSuccess(tasks, DropDbTask) ): # dropped the DB + # self.assertHasTask(tasks, DropDbTask) # implied by hasSuccess + self.assertAtMostOneSuccess(tasks, DropDbTask) + # self._state = self.STATE_EMPTY + elif ( self.hasSuccess(tasks, CreateFixedSuperTableTask) ): # did not drop db, create table success + # self.assertHasTask(tasks, CreateFixedTableTask) # tried to create table + self.assertAtMostOneSuccess(tasks, CreateFixedSuperTableTask) # at most 1 attempt is successful + self.assertNoTask(tasks, DropDbTask) # should have have tried + # if ( not self.hasSuccess(tasks, AddFixedDataTask) ): # just created table, no data yet + # # can't say there's add-data attempts, since they may all fail + # self._state = self.STATE_TABLE_ONLY + # else: + # self._state = self.STATE_HAS_DATA + # What about AddFixedData? + # elif ( self.hasSuccess(tasks, AddFixedDataTask) ): + # self._state = self.STATE_HAS_DATA + # else: # no success in dropping db tasks, no success in create fixed table? read data should also fail + # # raise RuntimeError("Unexpected no-success scenario") # We might just landed all failure tasks, + # self._state = self.STATE_DB_ONLY # no change + +class StateSuperTableOnly(AnyState): + def getInfo(self): + return [ + self.STATE_TABLE_ONLY, + False, True, + False, True, + True, True, + ] + + def verifyTasksToState(self, tasks, newState): + if ( self.hasSuccess(tasks, DropFixedSuperTableTask) ): # we are able to drop the table + self.assertAtMostOneSuccess(tasks, DropFixedSuperTableTask) + # self._state = self.STATE_DB_ONLY + # elif ( self.hasSuccess(tasks, AddFixedDataTask) ): # no success dropping the table, but added data + # self.assertNoTask(tasks, DropFixedTableTask) # not true in massively parrallel cases + # self._state = self.STATE_HAS_DATA + # elif ( self.hasSuccess(tasks, ReadFixedDataTask) ): # no success in prev cases, but was able to read data + # self.assertNoTask(tasks, DropFixedTableTask) + # self.assertNoTask(tasks, AddFixedDataTask) + # self._state = self.STATE_TABLE_ONLY # no change + # else: # did not drop table, did not insert data, did not read successfully, that is impossible + # raise RuntimeError("Unexpected no-success scenarios") + # TODO: need to revamp!! + +class StateHasData(AnyState): + def getInfo(self): + return [ + self.STATE_HAS_DATA, + False, True, + False, True, + True, True, + ] + + def verifyTasksToState(self, tasks, newState): + if ( newState.equals(AnyState.STATE_EMPTY) ): + self.hasSuccess(tasks, DropDbTask) + self.assertAtMostOneSuccess(tasks, DropDbTask) # TODO: dicy + elif ( newState.equals(AnyState.STATE_DB_ONLY) ): # in DB only + if ( not self.hasTask(tasks, CreateDbTask)): # without a create_db task + self.assertNoTask(tasks, DropDbTask) # we must have drop_db task + self.hasSuccess(tasks, DropFixedSuperTableTask) + self.assertAtMostOneSuccess(tasks, DropFixedSuperTableTask) # TODO: dicy + elif ( newState.equals(AnyState.STATE_TABLE_ONLY) ): # data deleted + self.assertNoTask(tasks, DropDbTask) + self.assertNoTask(tasks, DropFixedSuperTableTask) + self.assertNoTask(tasks, AddFixedDataTask) + # self.hasSuccess(tasks, DeleteDataTasks) + else: + self.assertNoTask(tasks, DropDbTask) + self.assertNoTask(tasks, DropFixedSuperTableTask) + self.assertIfExistThenSuccess(tasks, ReadFixedDataTask) + + +# State of the database as we believe it to be +class DbState(): + + def __init__(self): + self.tableNumQueue = LinearQueue() + self._lastTick = datetime.datetime(2019, 1, 1) # initial date time tick + self._lastInt = 0 # next one is initial integer + self._lock = threading.RLock() + + self._state = StateInvalid() # starting state + self._stateWeights = [1,3,5,10] # indexed with value of STATE_EMPTY, STATE_DB_ONLY, etc. + + # self.openDbServerConnection() + self._dbConn = DbConn() + try: + self._dbConn.open() # may throw taos.error.ProgrammingError: disconnected + except taos.error.ProgrammingError as err: + # print("Error type: {}, msg: {}, value: {}".format(type(err), err.msg, err)) + if ( err.msg == 'disconnected' ): # cannot open DB connection + print("Cannot establish DB connection, please re-run script without parameter, and follow the instructions.") + sys.exit() + else: + raise + except: + print("[=] Unexpected exception") + raise + self._dbConn.resetDb() # drop and recreate DB + self._state = StateEmpty() # initial state, the result of above + + def getDbConn(self): + return self._dbConn + + def pickAndAllocateTable(self): # pick any table, and "use" it + return self.tableNumQueue.pickAndAllocate() + + def addTable(self): + with self._lock: + tIndex = self.tableNumQueue.push() + return tIndex + + def getFixedSuperTableName(self): + return "fs_table" + + def releaseTable(self, i): # return the table back, so others can use it + self.tableNumQueue.release(i) + + def getNextTick(self): + with self._lock: # prevent duplicate tick + self._lastTick += datetime.timedelta(0, 1) # add one second to it + return self._lastTick + + def getNextInt(self): + with self._lock: + self._lastInt += 1 + return self._lastInt + + def getNextBinary(self): + return "Los_Angeles_{}".format(self.getNextInt()) + + def getNextFloat(self): + return 0.9 + self.getNextInt() + + def getTableNameToDelete(self): + tblNum = self.tableNumQueue.pop() # TODO: race condition! + if ( not tblNum ): # maybe false + return False + + return "table_{}".format(tblNum) + + def cleanUp(self): + self._dbConn.close() + + # May be slow, use cautionsly... + def getTaskTypesAtState(self): + allTaskClasses = StateTransitionTask.__subclasses__() # all state transition tasks + firstTaskTypes = [] + for tc in allTaskClasses: + # t = tc(self) # create task object + if tc.canBeginFrom(self._state): + firstTaskTypes.append(tc) + # now we have all the tasks that can begin directly from the current state, let's figure out the INDIRECT ones + taskTypes = firstTaskTypes.copy() # have to have these + for task1 in firstTaskTypes: # each task type gathered so far + endState = task1.getEndState() # figure the end state + if endState == None: + continue + for tc in allTaskClasses: # what task can further begin from there? + if tc.canBeginFrom(endState) and (tc not in firstTaskTypes): + taskTypes.append(tc) # gather it + + if len(taskTypes) <= 0: + raise RuntimeError("No suitable task types found for state: {}".format(self._state)) + logger.debug("[OPS] Tasks found for state {}: {}".format(self._state, taskTypes)) + return taskTypes + + # tasks.append(ReadFixedDataTask(self)) # always for everybody + # if ( self._state == self.STATE_EMPTY ): + # tasks.append(CreateDbTask(self)) + # tasks.append(CreateFixedTableTask(self)) + # elif ( self._state == self.STATE_DB_ONLY ): + # tasks.append(DropDbTask(self)) + # tasks.append(CreateFixedTableTask(self)) + # tasks.append(AddFixedDataTask(self)) + # elif ( self._state == self.STATE_TABLE_ONLY ): + # tasks.append(DropFixedTableTask(self)) + # tasks.append(AddFixedDataTask(self)) + # elif ( self._state == self.STATE_HAS_DATA ) : # same as above. TODO: adjust + # tasks.append(DropFixedTableTask(self)) + # tasks.append(AddFixedDataTask(self)) + # else: + # raise RuntimeError("Unexpected DbState state: {}".format(self._state)) + # return tasks + + def pickTaskType(self): + taskTypes = self.getTaskTypesAtState() # all the task types we can choose from at curent state + weights = [] + for tt in taskTypes: + endState = tt.getEndState() + if endState != None : + weights.append(self._stateWeights[endState.getValIndex()]) # TODO: change to a method + else: + weights.append(10) # read data task, default to 10: TODO: change to a constant + i = self._weighted_choice_sub(weights) + # logger.debug(" (weighted random:{}/{}) ".format(i, len(taskTypes))) + return taskTypes[i] + + def _weighted_choice_sub(self, weights): # ref: https://eli.thegreenplace.net/2010/01/22/weighted-random-generation-in-python/ + rnd = random.random() * sum(weights) # TODO: use our dice to ensure it being determinstic? + for i, w in enumerate(weights): + rnd -= w + if rnd < 0: + return i + + def _findCurrentState(self): + dbc = self._dbConn + ts = time.time() + if dbc.query("show databases") == 0 : # no database?! + # logger.debug("Found EMPTY state") + logger.debug("[STT] empty database found, between {} and {}".format(ts, time.time())) + return StateEmpty() + dbc.execute("use db") # did not do this when openning connection + if dbc.query("show tables") == 0 : # no tables + # logger.debug("Found DB ONLY state") + logger.debug("[STT] DB_ONLY found, between {} and {}".format(ts, time.time())) + return StateDbOnly() + if dbc.query("SELECT * FROM db.{}".format(self.getFixedSuperTableName()) ) == 0 : # no data + # logger.debug("Found TABLE_ONLY state") + logger.debug("[STT] SUPER_TABLE_ONLY found, between {} and {}".format(ts, time.time())) + return StateSuperTableOnly() + else: + # logger.debug("Found HAS_DATA state") + logger.debug("[STT] HAS_DATA found, between {} and {}".format(ts, time.time())) + return StateHasData() + + def transition(self, tasks): + if ( len(tasks) == 0 ): # before 1st step, or otherwise empty + return # do nothing + + self._dbConn.execute("show dnodes") # this should show up in the server log, separating steps + + # Generic Checks, first based on the start state + if self._state.canCreateDb(): + self._state.assertIfExistThenSuccess(tasks, CreateDbTask) + # self.assertAtMostOneSuccess(tasks, CreateDbTask) # not really, in case of multiple creation and drops + + if self._state.canDropDb(): + self._state.assertIfExistThenSuccess(tasks, DropDbTask) + # self.assertAtMostOneSuccess(tasks, DropDbTask) # not really in case of drop-create-drop + + # if self._state.canCreateFixedTable(): + # self.assertIfExistThenSuccess(tasks, CreateFixedTableTask) # Not true, DB may be dropped + # self.assertAtMostOneSuccess(tasks, CreateFixedTableTask) # not really, in case of create-drop-create + + # if self._state.canDropFixedTable(): + # self.assertIfExistThenSuccess(tasks, DropFixedTableTask) # Not True, the whole DB may be dropped + # self.assertAtMostOneSuccess(tasks, DropFixedTableTask) # not really in case of drop-create-drop + + # if self._state.canAddData(): + # self.assertIfExistThenSuccess(tasks, AddFixedDataTask) # not true actually + + # if self._state.canReadData(): + # Nothing for sure + + newState = self._findCurrentState() + logger.debug("[STT] New DB state determined: {}".format(newState)) + self._state.verifyTasksToState(tasks, newState) # can old state move to new state through the tasks? + self._state = newState + class TaskExecutor(): def __init__(self, curStep): self._curStep = curStep @@ -614,10 +895,11 @@ class Task(): @classmethod def allocTaskNum(cls): - cls.taskSn += 1 - return cls.taskSn + Task.taskSn += 1 # IMPORTANT: cannot use cls.taskSn, since each sub class will have a copy + # logger.debug("Allocating taskSN: {}".format(Task.taskSn)) + return Task.taskSn - def __init__(self, dbState: DbState): + def __init__(self, dbState: DbState, execStats: ExecutionStats): self._dbState = dbState self._workerThread = None self._err = None @@ -626,19 +908,22 @@ class Task(): # Assign an incremental task serial number self._taskNum = self.allocTaskNum() + # logger.debug("Creating new task {}...".format(self._taskNum)) + + self._execStats = execStats def isSuccess(self): return self._err == None - def clone(self): - newTask = self.__class__(self._dbState) + def clone(self): # TODO: why do we need this again? + newTask = self.__class__(self._dbState, self._execStats) return newTask def logDebug(self, msg): - self._workerThread.logDebug("s[{}.{}] {}".format(self._curStep, self._taskNum, msg)) + self._workerThread.logDebug("Step[{}.{}] {}".format(self._curStep, self._taskNum, msg)) def logInfo(self, msg): - self._workerThread.logInfo("s[{}.{}] {}".format(self._curStep, self._taskNum, msg)) + self._workerThread.logInfo("Step[{}.{}] {}".format(self._curStep, self._taskNum, msg)) def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): raise RuntimeError("To be implemeted by child classes, class name: {}".format(self.__class__.__name__)) @@ -652,29 +937,228 @@ class Task(): self.logDebug("[-] executing task {}...".format(self.__class__.__name__)) self._err = None + self._execStats.beginTaskType(self.__class__.__name__) # mark beginning try: self._executeInternal(te, wt) # TODO: no return value? except taos.error.ProgrammingError as err: - self.logDebug("[=]Taos Execution exception: {0}".format(err)) + self.logDebug("[=] Taos library exception: errno={}, msg: {}".format(err.errno, err)) self._err = err except: - self.logDebug("[=]Unexpected exception") + self.logDebug("[=] Unexpected exception") raise + self._execStats.endTaskType(self.__class__.__name__, self.isSuccess()) - self.logDebug("[X] task execution completed, {}, status: {}".format(self.__class__.__name__, "Success" if self.isSuccess() else "Failure")) + self.logDebug("[X] task execution completed, {}, status: {}".format(self.__class__.__name__, "Success" if self.isSuccess() else "Failure")) + self._execStats.incExecCount(self.__class__.__name__, self.isSuccess()) # TODO: merge with above. def execSql(self, sql): return self._dbState.execute(sql) -class CreateDbTask(Task): - def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): - wt.execSql("create database db") + +class ExecutionStats: + def __init__(self): + self._execTimes: Dict[str, [int, int]] = {} # total/success times for a task + self._tasksInProgress = 0 + self._lock = threading.Lock() + self._firstTaskStartTime = None + self._execStartTime = None + self._elapsedTime = 0.0 # total elapsed time + self._accRunTime = 0.0 # accumulated run time + + self._failed = False + self._failureReason = None + + def startExec(self): + self._execStartTime = time.time() + + def endExec(self): + self._elapsedTime = time.time() - self._execStartTime + + def incExecCount(self, klassName, isSuccess): # TODO: add a lock here + if klassName not in self._execTimes: + self._execTimes[klassName] = [0, 0] + t = self._execTimes[klassName] # tuple for the data + t[0] += 1 # index 0 has the "total" execution times + if isSuccess: + t[1] += 1 # index 1 has the "success" execution times + + def beginTaskType(self, klassName): + with self._lock: + if self._tasksInProgress == 0 : # starting a new round + self._firstTaskStartTime = time.time() # I am now the first task + self._tasksInProgress += 1 + + def endTaskType(self, klassName, isSuccess): + with self._lock: + self._tasksInProgress -= 1 + if self._tasksInProgress == 0 : # all tasks have stopped + self._accRunTime += (time.time() - self._firstTaskStartTime) + self._firstTaskStartTime = None + + def registerFailure(self, reason): + self._failed = True + self._failureReason = reason + + def logStats(self): + logger.info("----------------------------------------------------------------------") + logger.info("| Crash_Gen test {}, with the following stats:". + format("FAILED (reason: {})".format(self._failureReason) if self._failed else "SUCCEEDED")) + logger.info("| Task Execution Times (success/total):") + execTimesAny = 0 + for k, n in self._execTimes.items(): + execTimesAny += n[0] + logger.info("| {0:<24}: {1}/{2}".format(k,n[1],n[0])) + + logger.info("| Total Tasks Executed (success or not): {} ".format(execTimesAny)) + logger.info("| Total Tasks In Progress at End: {}".format(self._tasksInProgress)) + logger.info("| Total Task Busy Time (elapsed time when any task is in progress): {:.3f} seconds".format(self._accRunTime)) + logger.info("| Average Per-Task Execution Time: {:.3f} seconds".format(self._accRunTime/execTimesAny)) + logger.info("| Total Elapsed Time (from wall clock): {:.3f} seconds".format(self._elapsedTime)) + logger.info("----------------------------------------------------------------------") + + + +class StateTransitionTask(Task): + # @classmethod + # def getAllTaskClasses(cls): # static + # return cls.__subclasses__() + @classmethod + def getInfo(cls): # each sub class should supply their own information + raise RuntimeError("Overriding method expected") + + # @classmethod + # def getBeginStates(cls): + # return cls.getInfo()[0] + + @classmethod + def getEndState(cls): # returning the class name + return cls.getInfo()[0] + + @classmethod + def canBeginFrom(cls, state: AnyState): + # return state.getValue() in cls.getBeginStates() + raise RuntimeError("must be overriden") + + def execute(self, wt: WorkerThread): + super().execute(wt) + + + +class CreateDbTask(StateTransitionTask): + @classmethod + def getInfo(cls): + return [ + # [AnyState.STATE_EMPTY], # can begin from + StateDbOnly() # end state + ] + + @classmethod + def canBeginFrom(cls, state: AnyState): + return state.canCreateDb() + + def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): + wt.execSql("create database db") + +class DropDbTask(StateTransitionTask): + @classmethod + def getInfo(cls): + return [ + # [AnyState.STATE_DB_ONLY, AnyState.STATE_TABLE_ONLY, AnyState.STATE_HAS_DATA], + StateEmpty() + ] + + @classmethod + def canBeginFrom(cls, state: AnyState): + return state.canDropDb() -class DropDbTask(Task): def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): wt.execSql("drop database db") + logger.debug("[OPS] database dropped at {}".format(time.time())) -class CreateTableTask(Task): +class CreateFixedSuperTableTask(StateTransitionTask): + @classmethod + def getInfo(cls): + return [ + # [AnyState.STATE_DB_ONLY], + StateSuperTableOnly() + ] + + @classmethod + def canBeginFrom(cls, state: AnyState): + return state.canCreateFixedSuperTable() + + def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): + tblName = self._dbState.getFixedSuperTableName() + wt.execSql("create table db.{} (ts timestamp, speed int) tags (b binary(20), f float) ".format(tblName)) + # No need to create the regular tables, INSERT will do that automatically + + +class ReadFixedDataTask(StateTransitionTask): + @classmethod + def getInfo(cls): + return [ + # [AnyState.STATE_TABLE_ONLY, AnyState.STATE_HAS_DATA], + None # meaning doesn't affect state + ] + + @classmethod + def canBeginFrom(cls, state: AnyState): + return state.canReadData() + + def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): + sTbName = self._dbState.getFixedSuperTableName() + dbc = wt.getDbConn() + dbc.query("select TBNAME from db.{}".format(sTbName)) # TODO: analyze result set later + rTables = dbc.getQueryResult() + # print("rTables[0] = {}, type = {}".format(rTables[0], type(rTables[0]))) + for rTbName in rTables : # regular tables + dbc.query("select * from db.{}".format(rTbName[0])) # TODO: check success failure + + # tdSql.query(" cars where tbname in ('carzero', 'carone')") + +class DropFixedSuperTableTask(StateTransitionTask): + @classmethod + def getInfo(cls): + return [ + # [AnyState.STATE_TABLE_ONLY, AnyState.STATE_HAS_DATA], + StateDbOnly() # meaning doesn't affect state + ] + + @classmethod + def canBeginFrom(cls, state: AnyState): + return state.canDropFixedSuperTable() + + def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): + tblName = self._dbState.getFixedSuperTableName() + wt.execSql("drop table db.{}".format(tblName)) + +class AddFixedDataTask(StateTransitionTask): + @classmethod + def getInfo(cls): + return [ + # [AnyState.STATE_TABLE_ONLY, AnyState.STATE_HAS_DATA], + StateHasData() + ] + + @classmethod + def canBeginFrom(cls, state: AnyState): + return state.canAddData() + + def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): + ds = self._dbState + wt.execSql("use db") # TODO: seems to be an INSERT bug to require this + for i in range(10): # 0 to 9 + sql = "insert into db.reg_table_{} using {} tags ('{}', {}) values ('{}', {});".format( + i, + ds.getFixedSuperTableName(), + ds.getNextBinary(), ds.getNextFloat(), + ds.getNextTick(), ds.getNextInt()) + wt.execSql(sql) + + +#---------- Non State-Transition Related Tasks ----------# + +class CreateTableTask(Task): def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): tIndex = self._dbState.addTable() self.logDebug("Creating a table {} ...".format(tIndex)) @@ -682,17 +1166,6 @@ class CreateTableTask(Task): self.logDebug("Table {} created.".format(tIndex)) self._dbState.releaseTable(tIndex) -class CreateFixedTableTask(Task): - def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): - tblName = self._dbState.getFixedTableName() - wt.execSql("create table db.{} (ts timestamp, speed int)".format(tblName)) - -class ReadFixedDataTask(Task): - def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): - tblName = self._dbState.getFixedTableName() - self._numRows = wt.querySql("select * from db.{}".format(tblName)) # save the result for later - # tdSql.query(" cars where tbname in ('carzero', 'carone')") - class DropTableTask(Task): def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): tableName = self._dbState.getTableNameToDelete() @@ -702,10 +1175,7 @@ class DropTableTask(Task): self.logInfo("Dropping a table db.{} ...".format(tableName)) wt.execSql("drop table db.{}".format(tableName)) -class DropFixedTableTask(Task): - def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): - tblName = self._dbState.getFixedTableName() - wt.execSql("drop table db.{}".format(tblName)) + class AddDataTask(Task): def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): @@ -716,16 +1186,11 @@ class AddDataTask(Task): self.logInfo("No table found to add data, skipping...") return sql = "insert into db.table_{} values ('{}', {});".format(tIndex, ds.getNextTick(), ds.getNextInt()) - self.logDebug("Executing SQL: {}".format(sql)) + self.logDebug("[SQL] Executing SQL: {}".format(sql)) wt.execSql(sql) ds.releaseTable(tIndex) - self.logDebug("Finished adding data") + self.logDebug("[OPS] Finished adding data") -class AddFixedDataTask(Task): - def _executeInternal(self, te: TaskExecutor, wt: WorkerThread): - ds = self._dbState - sql = "insert into db.table_{} values ('{}', {});".format(ds.getFixedTableName(), ds.getNextTick(), ds.getNextInt()) - wt.execSql(sql) # Deterministic random number generator class Dice(): @@ -760,28 +1225,45 @@ class Dice(): # Anyone needing to carry out work should simply come here -class WorkDispatcher(): - def __init__(self, dbState): - # self.totalNumMethods = 2 - self.tasks = [ - CreateTableTask(dbState), - DropTableTask(dbState), - AddDataTask(dbState), - ] +# class WorkDispatcher(): +# def __init__(self, dbState): +# # self.totalNumMethods = 2 +# self.tasks = [ +# # CreateTableTask(dbState), # Obsolete +# # DropTableTask(dbState), +# # AddDataTask(dbState), +# ] - def throwDice(self): - max = len(self.tasks) - 1 - dRes = random.randint(0, max) - # logger.debug("Threw the dice in range [{},{}], and got: {}".format(0,max,dRes)) - return dRes +# def throwDice(self): +# max = len(self.tasks) - 1 +# dRes = random.randint(0, max) +# # logger.debug("Threw the dice in range [{},{}], and got: {}".format(0,max,dRes)) +# return dRes - def pickTask(self): - dice = self.throwDice() - return self.tasks[dice] +# def pickTask(self): +# dice = self.throwDice() +# return self.tasks[dice] - def doWork(self, workerThread): - task = self.pickTask() - task.execute(workerThread) +# def doWork(self, workerThread): +# task = self.pickTask() +# task.execute(workerThread) + +class LoggingFilter(logging.Filter): + def filter(self, record: logging.LogRecord): + if ( record.levelno >= logging.INFO ) : + return True # info or above always log + + msg = record.msg + # print("type = {}, value={}".format(type(msg), msg)) + # sys.exit() + + # Commenting out below to adjust... + + # if msg.startswith("[TRD]"): + # return False + return True + + def main(): # Super cool Python argument library: https://docs.python.org/3/library/argparse.html @@ -810,9 +1292,12 @@ def main(): sys.exit() global logger - logger = logging.getLogger('myApp') + logger = logging.getLogger('CrashGen') + logger.addFilter(LoggingFilter()) if ( gConfig.debug ): logger.setLevel(logging.DEBUG) # default seems to be INFO + else: + logger.setLevel(logging.INFO) ch = logging.StreamHandler() logger.addHandler(ch) @@ -820,12 +1305,21 @@ def main(): Dice.seed(0) # initial seeding of dice tc = ThreadCoordinator( ThreadPool(dbState, gConfig.num_threads, gConfig.max_steps, 0), - WorkDispatcher(dbState), + # WorkDispatcher(dbState), # Obsolete? dbState ) + + # Sandbox testing code + # dbc = dbState.getDbConn() + # while True: + # rows = dbc.query("show databases") + # print("Rows: {}, time={}".format(rows, time.time())) + tc.run() - dbState.cleanUp() - logger.info("Finished running thread pool") + tc.logStats() + dbState.cleanUp() + + # logger.info("Crash_Gen execution finished") if __name__ == "__main__": main() diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index cceb17b0de..bf3523dc0f 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -1,4 +1,6 @@ #!/bin/bash +ulimit -c unlimited + python3 ./test.py -f insert/basic.py python3 ./test.py -f insert/int.py python3 ./test.py -f insert/float.py diff --git a/tests/pytest/query/filterCombo.py b/tests/pytest/query/filterCombo.py index c25b6156b8..c9c7ade73e 100644 --- a/tests/pytest/query/filterCombo.py +++ b/tests/pytest/query/filterCombo.py @@ -49,7 +49,8 @@ class TDTestCase: tdSql.error("select * from db.st where ts > '2020-05-13 10:00:00.002' OR tagtype < 2") # illegal condition - tdSql.error("select * from db.st where ts != '2020-05-13 10:00:00.002' OR tagtype < 2") + tdSql.error("select * from db.st where ts != '2020-05-13 10:00:00.002' OR tagtype < 2") + tdSql.error("select * from db.st where tagtype <> 1 OR tagtype < 2") def stop(self): tdSql.close() diff --git a/tests/pytest/query/queryError.py b/tests/pytest/query/queryError.py index d0515ef34d..95924f48cc 100644 --- a/tests/pytest/query/queryError.py +++ b/tests/pytest/query/queryError.py @@ -41,13 +41,12 @@ class TDTestCase: ('2020-05-13 10:00:00.002', 3, 'third') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first'), ('2020-05-13 10:00:00.004', 2, 'second'), ('2020-05-13 10:00:00.005', 3, 'third')""") - """Error expected here, but no errors + # query first .. as .. tdSql.error("select first(*) as one from st") # query last .. as .. - tdSql.error("select last(*) as latest from st") - """ + tdSql.error("select last(*) as latest from st") # query last row .. as .. tdSql.error("select last_row as latest from st") diff --git a/tests/pytest/query/queryNormal.py b/tests/pytest/query/queryNormal.py index 3ca9c1d135..442661f72a 100644 --- a/tests/pytest/query/queryNormal.py +++ b/tests/pytest/query/queryNormal.py @@ -31,14 +31,22 @@ class TDTestCase: tdSql.execute("create table stb1 (ts timestamp, c1 int, c2 float) tags(t1 int, t2 binary(10), t3 nchar(10))") tdSql.execute("insert into tb1 using stb1 tags(1,'tb1', '表1') values ('2020-04-18 15:00:00.000', 1, 0.1), ('2020-04-18 15:00:01.000', 2, 0.1)") tdSql.execute("insert into tb2 using stb1 tags(2,'tb2', '表2') values ('2020-04-18 15:00:02.000', 3, 2.1), ('2020-04-18 15:00:03.000', 4, 2.2)") - - # join 2 tables -- bug exists - # tdSql.query("select * from tb1 a, tb2 b where a.ts = b.ts") - # tdSql.checkRows(1) + + # inner join --- bug + tdSql.query("select * from tb1 a, tb2 b where a.ts = b.ts") + tdSql.checkRows(1) # join 3 tables -- bug exists - # tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_p.id, stb_p.dscrption, stb_p.pressure,stb_v.velocity from stb_p, stb_t, stb_v where stb_p.ts=stb_t.ts and stb_p.ts=stb_v.ts and stb_p.id = stb_t.id") + tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_p.id, stb_p.dscrption, stb_p.pressure,stb_v.velocity from stb_p, stb_t, stb_v where stb_p.ts=stb_t.ts and stb_p.ts=stb_v.ts and stb_p.id = stb_t.id") + # query show stable + tdSql.query("show stables") + tdSql.checkRows(1) + + # query show tables + tdSql.query("show table") + tdSql.checkRows(2) + # query count tdSql.query("select count(*) from stb1") tdSql.checkData(0, 0, 4) @@ -51,6 +59,10 @@ class TDTestCase: tdSql.query("select last(*) from stb1") tdSql.checkData(0, 1, 4) + # query last_row + tdSql.query("select last_row(*) from stb1") + tdSql.checkData(0, 1, 4) + # query as tdSql.query("select t2 as number from stb1") tdSql.checkRows(2) @@ -63,6 +75,10 @@ class TDTestCase: tdSql.query("select last(*) as end from stb1") tdSql.checkData(0, 1, 4) + # query last_row ... as + tdSql.query("select last_row(*) as end from stb1") + tdSql.checkData(0, 1, 4) + # query group .. by tdSql.query("select sum(c1), t2 from stb1 group by t2") tdSql.checkRows(2) @@ -75,6 +91,34 @@ class TDTestCase: tdSql.query("select * from stb1 limit 2 offset 3") tdSql.checkRows(1) + # query ... alias for table ---- bug + tdSql.query("select t.ts from tb1 t") + tdSql.checkRows(2) + + # query ... tbname + tdSql.query("select tbname from stb1") + tdSql.checkRows(2) + + # query ... tbname count ---- bug + tdSql.query("select count(tbname) from stb1") + tdSql.checkRows(2) + + # query ... select database ---- bug + tdSql.query("SELECT database()") + tdSql.checkRows(1) + + # query ... select client_version ---- bug + tdSql.query("SELECT client_version()") + tdSql.checkRows(1) + + # query ... select server_version ---- bug + tdSql.query("SELECT server_version()") + tdSql.checkRows(1) + + # query ... select server_status ---- bug + tdSql.query("SELECT server_status()") + tdSql.checkRows(1) + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/pytest/random-test/random-test-multi-threading.py b/tests/pytest/random-test/random-test-multi-threading.py new file mode 100644 index 0000000000..c6ccc44372 --- /dev/null +++ b/tests/pytest/random-test/random-test-multi-threading.py @@ -0,0 +1,215 @@ +################################################################### +# 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 +import threading + +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * + +current_tb = "" +last_tb = "" +written = 0 + + +class Test (threading.Thread): + def __init__(self, threadId, name, sleepTime): + threading.Thread.__init__(self) + self.threadId = threadId + self.name = name + self.sleepTime = sleepTime + + self.threadLock = threading.Lock() + + def create_table(self): + global current_tb + global last_tb + global written + + tdLog.info("create a table") + current_tb = "tb%d" % int(round(time.time() * 1000)) + tdLog.info("current table %s" % current_tb) + + if (current_tb == last_tb): + return + else: + tdSql.execute( + 'create table %s (ts timestamp, speed int)' % + current_tb) + last_tb = current_tb + written = 0 + + def insert_data(self): + global current_tb + global last_tb + global written + + tdLog.info("will insert data to table") + if (current_tb == ""): + tdLog.info("no table, create first") + self.create_table() + + tdLog.info("insert data to table") + for i in range(0, 10): + self.threadLock.acquire() + insertRows = 1000 + tdLog.info("insert %d rows to %s" % (insertRows, current_tb)) + + for j in range(0, insertRows): + ret = tdSql.execute( + 'insert into %s values (now + %dm, %d)' % + (current_tb, j, j)) + written = written + 1 + self.threadLock.release() + + def query_data(self): + global current_tb + global last_tb + global written + + if (written > 0): + tdLog.info("query data from table") + tdSql.query("select * from %s" % last_tb) + tdSql.checkRows(written) + + def create_stable(self): + global current_tb + global last_tb + global written + + tdLog.info("create a super table") + + def restart_database(self): + global current_tb + global last_tb + global written + + tdLog.info("restart databae") + tdDnodes.stop(1) + tdDnodes.start(1) + tdLog.sleep(5) + + def force_restart(self): + global current_tb + global last_tb + global written + + tdLog.info("force restart database") + tdDnodes.forcestop(1) + tdDnodes.start(1) + tdLog.sleep(5) + + def drop_table(self): + global current_tb + global last_tb + global written + + for i in range(0, 10): + self.threadLock.acquire() + + tdLog.info("current_tb %s" % current_tb) + + if (current_tb != ""): + tdLog.info("drop current tb %s" % current_tb) + tdSql.execute("drop table %s" % current_tb) + current_tb = "" + last_tb = "" + written = 0 + tdLog.sleep(self.sleepTime) + self.threadLock.release() + + def reset_query_cache(self): + global current_tb + global last_tb + global written + + tdLog.info("reset query cache") + tdSql.execute("reset query cache") + tdLog.sleep(1) + + def reset_database(self): + global current_tb + global last_tb + global written + + tdLog.info("reset database") + tdDnodes.forcestop(1) + tdDnodes.deploy(1) + current_tb = "" + last_tb = "" + written = 0 + tdDnodes.start(1) + tdSql.prepare() + + def delete_datafiles(self): + global current_tb + global last_tb + global written + + tdLog.info("delete data files") + dnodesDir = tdDnodes.getDnodesRootDir() + dataDir = dnodesDir + '/dnode1/*' + deleteCmd = 'rm -rf %s' % dataDir + os.system(deleteCmd) + + current_tb = "" + last_tb = "" + written = 0 + tdDnodes.start(1) + tdSql.prepare() + + def run(self): + switch = { + 1: self.create_table, + 2: self.insert_data, + 3: self.query_data, + 4: self.create_stable, + 5: self.restart_database, + 6: self.force_restart, + 7: self.drop_table, + 8: self.reset_query_cache, + 9: self.reset_database, + 10: self.delete_datafiles, + } + + switch.get(self.threadId, lambda: "ERROR")() + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + + test1 = Test(2, "insert_data", 1) + test2 = Test(7, "drop_table", 2) + + test1.start() + test2.start() + test1.join() + test2.join() + + tdLog.info("end of test") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/smoketest.sh b/tests/pytest/smoketest.sh index 57a9a67936..1c51da397e 100755 --- a/tests/pytest/smoketest.sh +++ b/tests/pytest/smoketest.sh @@ -1,4 +1,6 @@ #!/bin/bash +ulimit -c unlimited + # insert python3 ./test.py $1 -f insert/basic.py python3 ./test.py $1 -s && sleep 1 @@ -56,10 +58,4 @@ python3 ./test.py $1 -s && sleep 1 #query python3 ./test.py $1 -f query/filter.py python3 ./test.py $1 -s && sleep 1 -python3 ./test.py $1 -f query/filterCombo.py -python3 ./test.py $1 -s && sleep 1 -python3 ./test.py $1 -f query/queryNormal.py -python3 ./test.py $1 -s && sleep 1 -python3 ./test.py $1 -f query/queryError.py -python3 ./test.py $1 -s && sleep 1 diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 998c996ca2..4c839d87a3 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -38,9 +38,9 @@ class TDSimClient: tdLog.exit(cmd) def deploy(self): - self.logDir = "%s/pysim/psim/log" % (self.path,) - self.cfgDir = "%s/pysim/psim/cfg" % (self.path) - self.cfgPath = "%s/pysim/psim/cfg/taos.cfg" % (self.path) + self.logDir = "%s/sim/psim/log" % (self.path,) + self.cfgDir = "%s/sim/psim/cfg" % (self.path) + self.cfgPath = "%s/sim/psim/cfg/taos.cfg" % (self.path) cmd = "rm -rf " + self.logDir if os.system(cmd) != 0: @@ -113,10 +113,10 @@ class TDDnode: return totalSize def deploy(self): - self.logDir = "%s/pysim/dnode%d/log" % (self.path, self.index) - self.dataDir = "%s/pysim/dnode%d/data" % (self.path, self.index) - self.cfgDir = "%s/pysim/dnode%d/cfg" % (self.path, self.index) - self.cfgPath = "%s/pysim/dnode%d/cfg/taos.cfg" % ( + self.logDir = "%s/sim/dnode%d/log" % (self.path, self.index) + self.dataDir = "%s/sim/dnode%d/data" % (self.path, self.index) + self.cfgDir = "%s/sim/dnode%d/cfg" % (self.path, self.index) + self.cfgPath = "%s/sim/dnode%d/cfg/taos.cfg" % ( self.path, self.index) cmd = "rm -rf " + self.dataDir @@ -163,7 +163,7 @@ class TDDnode: self.cfg("clog", "1") self.cfg("statusInterval", "1") self.cfg("numOfTotalVnodes", "64") - self.cfg("numOfMPeers", "3") + self.cfg("numOfMnodes", "3") self.cfg("numOfThreadsPerCore", "2.0") self.cfg("monitor", "0") self.cfg("maxVnodeConnections", "30000") @@ -298,11 +298,11 @@ class TDDnode: tdLog.exit(cmd) def getDnodeRootDir(self, index): - dnodeRootDir = "%s/pysim/psim/dnode%d" % (self.path, index) + dnodeRootDir = "%s/sim/psim/dnode%d" % (self.path, index) return dnodeRootDir def getDnodesRootDir(self): - dnodesRootDir = "%s/pysim/psim" % (self.path) + dnodesRootDir = "%s/sim/psim" % (self.path) return dnodesRootDir @@ -455,7 +455,7 @@ class TDDnodes: # tdLog.exit(cmd) def getDnodesRootDir(self): - dnodesRootDir = "%s/pysim" % (self.path) + dnodesRootDir = "%s/sim" % (self.path) return dnodesRootDir def getSimCfgPath(self): diff --git a/tests/script/general/alter/count.sim b/tests/script/general/alter/count.sim index 11b2f6e244..4728433dd2 100644 --- a/tests/script/general/alter/count.sim +++ b/tests/script/general/alter/count.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 -system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 print ========= start dnode1 as master diff --git a/tests/script/general/alter/import.sim b/tests/script/general/alter/import.sim index 801e716e8c..0ad52373fc 100644 --- a/tests/script/general/alter/import.sim +++ b/tests/script/general/alter/import.sim @@ -3,7 +3,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 -system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 print ========= start dnode1 as master diff --git a/tests/script/general/db/backup/keep.sim b/tests/script/general/db/backup/keep.sim index f48ce0e414..156b32ba4c 100644 --- a/tests/script/general/db/backup/keep.sim +++ b/tests/script/general/db/backup/keep.sim @@ -9,9 +9,9 @@ system sh/deploy.sh -n dnode3 -i 3 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 dnode1 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 diff --git a/tests/script/general/db/delete_reuse1.sim b/tests/script/general/db/delete_reuse1.sim index 75a4cfaff0..7b8687d340 100644 --- a/tests/script/general/db/delete_reuse1.sim +++ b/tests/script/general/db/delete_reuse1.sim @@ -10,10 +10,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 diff --git a/tests/script/general/db/delete_reuse2.sim b/tests/script/general/db/delete_reuse2.sim index 103242ee1b..d27a54ad95 100644 --- a/tests/script/general/db/delete_reuse2.sim +++ b/tests/script/general/db/delete_reuse2.sim @@ -10,10 +10,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 diff --git a/tests/script/general/db/delete_writing1.sim b/tests/script/general/db/delete_writing1.sim index 01914e91a8..96783be030 100644 --- a/tests/script/general/db/delete_writing1.sim +++ b/tests/script/general/db/delete_writing1.sim @@ -10,10 +10,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 diff --git a/tests/script/general/import/basic.sim b/tests/script/general/import/basic.sim index b6e064c845..07febb2bd5 100644 --- a/tests/script/general/import/basic.sim +++ b/tests/script/general/import/basic.sim @@ -4,10 +4,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 diff --git a/tests/script/general/import/commit.sim b/tests/script/general/import/commit.sim index 93bd93cf21..36d201e9ef 100644 --- a/tests/script/general/import/commit.sim +++ b/tests/script/general/import/commit.sim @@ -4,10 +4,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 @@ -78,7 +78,8 @@ sleep 5000 print ========= step4 sql select * from ic2db.tb; -if $rows != 13 then +if $rows != 13 then + print expect 13, actual:$rows return -1 endi diff --git a/tests/script/general/import/large.sim b/tests/script/general/import/large.sim index 751eef785b..5bf05a57fb 100644 --- a/tests/script/general/import/large.sim +++ b/tests/script/general/import/large.sim @@ -4,10 +4,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 diff --git a/tests/script/general/import/replica1.sim b/tests/script/general/import/replica1.sim index 771f2a8cbb..c212e8723e 100644 --- a/tests/script/general/import/replica1.sim +++ b/tests/script/general/import/replica1.sim @@ -5,10 +5,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 diff --git a/tests/script/general/parser/create_db.sim b/tests/script/general/parser/create_db.sim index 7b08d942fd..2fbe03c093 100644 --- a/tests/script/general/parser/create_db.sim +++ b/tests/script/general/parser/create_db.sim @@ -108,10 +108,10 @@ $cache = 16 # 16MB $ablocks = 100 $tblocks = 32 # max=512, automatically trimmed when exceeding $ctime = 36000 # 10 hours -$wal = 0 # valid value is 0, 1, 2 +$wal = 1 # valid value is 1, 2 $comp = 1 # max=32, automatically trimmed when exceeding -sql create database $db replica $replica days $days keep $keep maxrows $rows_db cache $cache ctime $ctime wal $wal comp $comp +sql create database $db replica $replica days $days keep $keep maxrows $rows_db cache $cache blocks 4 ctime $ctime wal $wal comp $comp sql show databases if $rows != 1 then return -1 @@ -129,18 +129,15 @@ if $data06 != 365,365,365 then return -1 endi print data08 = $data08 -if $data08 != $rows_db then +if $data08 != $cache then + print expect $cache, actual:$data08 return -1 endi -if $data09 != $cache then +if $data09 != 4 then return -1 endi -sql drop database $db -# ablocks_smaller_than_tblocks -#$ablocks = 50 -#$tblocks = 100 -#sql_error create database $db ablocks $ablocks tblocks $tblocks +sql drop database $db ## param range tests # replica [1,3] @@ -160,14 +157,11 @@ sql_error create database $db maxrows 199 #sql_error create database $db maxrows 10001 # cache [100, 10485760] -sql_error create database $db cache 99 +sql_error create database $db cache 0 #sql_error create database $db cache 10485761 -# ablocks [overwriten by 4*maxtablesPerVnode, 409600] -sql_error create database $db ablocks -1 -#sql_error create database $db ablocks 409601 -# tblocks [32, 4096 overwriten by 4096 if exceeds, Note added:2018-10-24] +# blocks [32, 4096 overwriten by 4096 if exceeds, Note added:2018-10-24] #sql_error create database $db tblocks 31 #sql_error create database $db tblocks 4097 @@ -175,9 +169,10 @@ sql_error create database $db ablocks -1 sql_error create database $db ctime 29 sql_error create database $db ctime 40961 -# wal {0, 1} +# wal {1, 2} +sql_error create database $db wal 0 sql_error create database $db wal -1 -#sql_error create database $db wal 2 +sql_error create database $db wal 3 # comp {0, 1, 2} sql_error create database $db comp -1 diff --git a/tests/script/general/parser/interp_test.sim b/tests/script/general/parser/interp_test.sim index 3e6d5de85b..8bffae4af6 100644 --- a/tests/script/general/parser/interp_test.sim +++ b/tests/script/general/parser/interp_test.sim @@ -117,6 +117,7 @@ $tb = $tbPrefix . 0 return -1 endi if $data01 != NULL then + print expect NULL, actual $data01 return -1 endi if $data02 != NULL then @@ -213,6 +214,7 @@ $tb = $tbPrefix . 0 return -1 endi if $data03 != 0.00000 then + print expect 0.00000, actual:$data03 return -1 endi # if $data04 != NULL then diff --git a/tests/script/general/parser/limit1_stb.sim b/tests/script/general/parser/limit1_stb.sim index e69d6ab14f..a1f9aabd9d 100644 --- a/tests/script/general/parser/limit1_stb.sim +++ b/tests/script/general/parser/limit1_stb.sim @@ -400,6 +400,7 @@ endi $limit = $totalNum / 2 sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit $limit offset 0 if $rows != 6 then + print expect 6, actual:$rows return -1 endi if $data00 != 9 then diff --git a/tests/script/general/parser/testSuite.sim b/tests/script/general/parser/testSuite.sim index ac867c9f7f..cc95246f06 100644 --- a/tests/script/general/parser/testSuite.sim +++ b/tests/script/general/parser/testSuite.sim @@ -8,38 +8,38 @@ #sleep 2000 #run general/parser/auto_create_tb_drop_tb.sim -sleep 2000 -run general/parser/col_arithmetic_operation.sim -sleep 2000 -run general/parser/columnValue.sim -sleep 2000 -run general/parser/commit.sim -sleep 2000 -run general/parser/create_db.sim -sleep 2000 -run general/parser/create_mt.sim -sleep 2000 -run general/parser/create_tb.sim -sleep 2000 -run general/parser/dbtbnameValidate.sim -sleep 2000 -run general/parser/import_commit1.sim -sleep 2000 -run general/parser/import_commit2.sim -sleep 2000 -run general/parser/import_commit3.sim -sleep 2000 -run general/parser/insert_tb.sim -sleep 2000 -run general/parser/first_last.sim -sleep 2000 -run general/parser/import_file.sim -sleep 2000 -run general/parser/lastrow.sim -sleep 2000 -run general/parser/nchar.sim -sleep 2000 -run general/parser/null_char.sim +#sleep 2000 +#run general/parser/col_arithmetic_operation.sim +#sleep 2000 +#run general/parser/columnValue.sim +#sleep 2000 +#run general/parser/commit.sim +#sleep 2000 +#run general/parser/create_db.sim +#sleep 2000 +#run general/parser/create_mt.sim +#sleep 2000 +#run general/parser/create_tb.sim +#sleep 2000 +#run general/parser/dbtbnameValidate.sim +#sleep 2000 +#run general/parser/import_commit1.sim +#sleep 2000 +#run general/parser/import_commit2.sim +#sleep 2000 +#run general/parser/import_commit3.sim +#sleep 2000 +#run general/parser/insert_tb.sim +#sleep 2000 +#run general/parser/first_last.sim +#sleep 2000 +##run general/parser/import_file.sim +#sleep 2000 +#run general/parser/lastrow.sim +#sleep 2000 +#run general/parser/nchar.sim +#sleep 2000 +##run general/parser/null_char.sim sleep 2000 run general/parser/single_row_in_tb.sim sleep 2000 @@ -62,20 +62,23 @@ sleep 2000 run general/parser/tbnameIn.sim sleep 2000 run general/parser/projection_limit_offset.sim - sleep 2000 run general/parser/limit2.sim -sleep 2000 -run general/parser/slimit.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/where.sim +sleep 2000 +run general/parser/slimit.sim +sleep 2000 +run general/parser/select_with_tags.sim sleep 2000 run general/parser/interp.sim + +sleep 2000 +run general/parser/tags_dynamically_specifiy.sim sleep 2000 run general/parser/set_tag_vals.sim @@ -86,8 +89,6 @@ run general/parser/stream_on_sys.sim sleep 2000 run general/parser/stream.sim -sleep 2000 -run general/parser/where.sim sleep 2000 #run general/parser/repeatAlter.sim sleep 2000 @@ -97,11 +98,8 @@ run general/parser/join.sim sleep 2000 run general/parser/join_multivnode.sim -sleep 2000 -run general/parser/select_with_tags.sim sleep 2000 run general/parser/groupby.sim - sleep 2000 run general/parser/binary_escapeCharacter.sim sleep 2000 diff --git a/tests/script/general/parser/where.sim b/tests/script/general/parser/where.sim index de2312f2b9..4d86b50f38 100644 --- a/tests/script/general/parser/where.sim +++ b/tests/script/general/parser/where.sim @@ -29,23 +29,23 @@ $i = 0 while $i < $tbNum $tb = $tbPrefix . $i sql create table $tb using $mt tags( $i ) - + $x = 0 while $x < $rowNum - $ms = $x . m + $ms = $x . m $c = $x / 100 $c = $c * 100 $c = $x - $c - $binary = 'binary . $c + $binary = 'binary . $c $binary = $binary . ' - $nchar = 'nchar . $c + $nchar = 'nchar . $c $nchar = $nchar . ' - sql insert into $tb values (now + $ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + sql insert into $tb values (now + $ms , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) $x = $x + 1 - endw - + endw + $i = $i + 1 -endw +endw sleep 100 @@ -78,12 +78,16 @@ sql select tbname from $mt where t1 < 2 if $rows != 2 then return -1 endi + +print $tbPrefix $tb = $tbPrefix . 0 -if $data00 != $tb then +if $data00 != wh_tb1 then + print expect wh_tb1, actual:$data00 return -1 endi $tb = $tbPrefix . 1 -if $data10 != $tb then +if $data10 != wh_tb0 then + print expect wh_tb0, actual:$data00 return -1 endi diff --git a/tests/script/general/table/delete_reuse1.sim b/tests/script/general/table/delete_reuse1.sim index 4727796a62..753d1e8a35 100644 --- a/tests/script/general/table/delete_reuse1.sim +++ b/tests/script/general/table/delete_reuse1.sim @@ -9,10 +9,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 diff --git a/tests/script/general/table/delete_reuse2.sim b/tests/script/general/table/delete_reuse2.sim index 9dfc0c5d4e..1c74399348 100644 --- a/tests/script/general/table/delete_reuse2.sim +++ b/tests/script/general/table/delete_reuse2.sim @@ -9,10 +9,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 diff --git a/tests/script/general/table/delete_writing.sim b/tests/script/general/table/delete_writing.sim index ac056f2212..853637967d 100644 --- a/tests/script/general/table/delete_writing.sim +++ b/tests/script/general/table/delete_writing.sim @@ -9,10 +9,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 diff --git a/tests/script/general/user/authority.sim b/tests/script/general/user/authority.sim index 7ae8c6f1a4..71f185043b 100644 --- a/tests/script/general/user/authority.sim +++ b/tests/script/general/user/authority.sim @@ -63,4 +63,4 @@ sql close sql connect sleep 2000 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index dc8c564fd9..b2416611cf 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -1,5 +1,3 @@ -cd ../../debug; cmake .. -cd ../../debug; make cd ../../../debug; cmake .. cd ../../../debug; make @@ -61,7 +59,7 @@ 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 +#not test ./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 @@ -235,77 +233,78 @@ cd ../../../debug; make ./test.sh -f general/vector/table_query.sim ./test.sh -f general/vector/table_time.sim -./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 -f unique/account/account_create.sim +./test.sh -f unique/account/account_delete.sim +./test.sh -f unique/account/account_len.sim +./test.sh -f unique/account/authority.sim +./test.sh -f unique/account/basic.sim +./test.sh -f unique/account/paras.sim +./test.sh -f unique/account/pass_alter.sim +./test.sh -f unique/account/pass_len.sim +./test.sh -f unique/account/usage.sim +./test.sh -f unique/account/user_create.sim +./test.sh -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 -f unique/big/balance.sim +./test.sh -f unique/big/maxvnodes.sim +./test.sh -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 -f unique/cluster/balance1.sim +./test.sh -f unique/cluster/balance2.sim +./test.sh -f unique/cluster/balance3.sim +./test.sh -f unique/cluster/cache.sim -./test.sh -u -f unique/column/replica3.sim +./test.sh -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 -f unique/db/commit.sim +./test.sh -f unique/db/delete.sim +./test.sh -f unique/db/delete_part.sim +./test.sh -f unique/db/replica_add12.sim +./test.sh -f unique/db/replica_add13.sim +./test.sh -f unique/db/replica_add23.sim +./test.sh -f unique/db/replica_reduce21.sim +./test.sh -f unique/db/replica_reduce32.sim +./test.sh -f unique/db/replica_reduce31.sim +./test.sh -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 -f unique/dnode/alternativeRole.sim +./test.sh -f unique/dnode/balance1.sim +./test.sh -f unique/dnode/balance2.sim +./test.sh -f unique/dnode/balance3.sim +./test.sh -f unique/dnode/balancex.sim +./test.sh -f unique/dnode/offline1.sim +./test.sh -f unique/dnode/offline2.sim +./test.sh -f unique/dnode/remove1.sim +./test.sh -f unique/dnode/remove2.sim +./test.sh -f unique/dnode/vnode_clean.sim -./test.sh -u -f unique/http/admin.sim -./test.sh -u -f unique/http/opentsdb.sim +./test.sh -f unique/http/admin.sim +./test.sh -f unique/http/opentsdb.sim -./test.sh -u -f unique/import/replica2.sim -./test.sh -u -f unique/import/replica3.sim +./test.sh -f unique/import/replica2.sim +./test.sh -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 -f unique/stable/balance_replica1.sim +./test.sh -f unique/stable/dnode2_stop.sim +./test.sh -f unique/stable/dnode2.sim +./test.sh -f unique/stable/dnode3.sim +./test.sh -f unique/stable/replica2_dnode4.sim +./test.sh -f unique/stable/replica2_vnode3.sim +./test.sh -f unique/stable/replica3_dnode6.sim +./test.sh -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 -f unique/mnode/mgmt22.sim +./test.sh -f unique/mnode/mgmt23.sim +./test.sh -f unique/mnode/mgmt24.sim +./test.sh -f unique/mnode/mgmt25.sim +./test.sh -f unique/mnode/mgmt26.sim +./test.sh -f unique/mnode/mgmt33.sim +./test.sh -f unique/mnode/mgmt34.sim +./test.sh -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 +./test.sh -f unique/vnode/many.sim +./test.sh -f unique/vnode/replica2_basic2.sim +./test.sh -f unique/vnode/replica2_repeat.sim +./test.sh -f unique/vnode/replica3_basic.sim +./test.sh -f unique/vnode/replica3_repeat.sim +./test.sh -f unique/vnode/replica3_vgroup.sim diff --git a/tests/script/jenkins/sync.txt b/tests/script/jenkins/sync.txt index 934680b7c0..4f194cde93 100644 --- a/tests/script/jenkins/sync.txt +++ b/tests/script/jenkins/sync.txt @@ -1,79 +1,77 @@ -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 -f unique/account/account_create.sim +./test.sh -f unique/account/account_delete.sim +./test.sh -f unique/account/account_len.sim +./test.sh -f unique/account/authority.sim +./test.sh -f unique/account/basic.sim +./test.sh -f unique/account/paras.sim +./test.sh -f unique/account/pass_alter.sim +./test.sh -f unique/account/pass_len.sim +./test.sh -f unique/account/usage.sim +./test.sh -f unique/account/user_create.sim +./test.sh -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 -f unique/big/balance.sim +./test.sh -f unique/big/maxvnodes.sim +./test.sh -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 -f unique/cluster/balance1.sim +./test.sh -f unique/cluster/balance2.sim +./test.sh -f unique/cluster/balance3.sim +./test.sh -f unique/cluster/cache.sim -./test.sh -u -f unique/column/replica3.sim +./test.sh -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 -f unique/db/commit.sim +./test.sh -f unique/db/delete.sim +./test.sh -f unique/db/delete_part.sim +./test.sh -f unique/db/replica_add12.sim +./test.sh -f unique/db/replica_add13.sim +./test.sh -f unique/db/replica_add23.sim +./test.sh -f unique/db/replica_reduce21.sim +./test.sh -f unique/db/replica_reduce32.sim +./test.sh -f unique/db/replica_reduce31.sim +./test.sh -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 -f unique/dnode/balance1.sim +./test.sh -f unique/dnode/balance2.sim +./test.sh -f unique/dnode/balance3.sim +./test.sh -f unique/dnode/balancex.sim +./test.sh -f unique/dnode/offline1.sim +./test.sh -f unique/dnode/offline2.sim +./test.sh -f unique/dnode/remove1.sim +./test.sh -f unique/dnode/remove2.sim +./test.sh -f unique/dnode/vnode_clean.sim -./test.sh -u -f unique/http/admin.sim -./test.sh -u -f unique/http/opentsdb.sim +./test.sh -f unique/http/admin.sim +./test.sh -f unique/http/opentsdb.sim -./test.sh -u -f unique/import/replica2.sim -./test.sh -u -f unique/import/replica3.sim +./test.sh -f unique/import/replica2.sim +./test.sh -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 -f unique/stable/balance_replica1.sim +./test.sh -f unique/stable/dnode2_stop.sim +./test.sh -f unique/stable/dnode2.sim +./test.sh -f unique/stable/dnode3.sim +./test.sh -f unique/stable/replica2_dnode4.sim +./test.sh -f unique/stable/replica2_vnode3.sim +./test.sh -f unique/stable/replica3_dnode6.sim +./test.sh -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 -f unique/mnode/mgmt22.sim +./test.sh -f unique/mnode/mgmt23.sim +./test.sh -f unique/mnode/mgmt24.sim +./test.sh -f unique/mnode/mgmt25.sim +./test.sh -f unique/mnode/mgmt26.sim +./test.sh -f unique/mnode/mgmt33.sim +./test.sh -f unique/mnode/mgmt34.sim +./test.sh -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 +./test.sh -f unique/vnode/many.sim +./test.sh -f unique/vnode/replica2_basic2.sim +./test.sh -f unique/vnode/replica2_repeat.sim +./test.sh -f unique/vnode/replica3_basic.sim +./test.sh -f unique/vnode/replica3_repeat.sim +./test.sh -f unique/vnode/replica3_vgroup.sim diff --git a/tests/script/sh/cfg.sh b/tests/script/sh/cfg.sh index f28b401b78..0705343fec 100755 --- a/tests/script/sh/cfg.sh +++ b/tests/script/sh/cfg.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash if [ $# != 6 ]; then echo "argument list need input : " @@ -33,10 +33,19 @@ SCRIPT_DIR=`dirname $0` cd $SCRIPT_DIR/../ SCRIPT_DIR=`pwd` -cd ../../ +TDINTERNAL="TDinternal" +if [[ "$SCRIPT_DIR" == *"$TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + TAOS_DIR=`pwd` -BUILD_DIR=$TAOS_DIR/debug/build +BIN_DIR=`find . -name "taosd"|grep bin| cut -d '/' --fields=2,3` + +BUILD_DIR=$TAOS_DIR/$BIN_DIR + SIM_DIR=$TAOS_DIR/sim NODE_DIR=$SIM_DIR/$NODE_NAME diff --git a/tests/script/sh/clear.sh b/tests/script/sh/clear.sh index 3be31d15f9..73d022d4f3 100755 --- a/tests/script/sh/clear.sh +++ b/tests/script/sh/clear.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash echo "Executing clear.sh" @@ -36,12 +36,20 @@ cd $SCRIPT_DIR/../ SCRIPT_DIR=`pwd` echo "SCRIPT_DIR: $SCRIPT_DIR" -cd ../../ +TDINTERNAL="TDinternal" +if [[ "$SCRIPT_DIR" == *"$TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + TAOS_DIR=`pwd` -BUILD_DIR=$TAOS_DIR/debug/build -SIM_DIR=$TAOS_DIR/sim +BIN_DIR=`find . -name "taosd"|grep bin| cut -d '/' --fields=2,3` +BUILD_DIR=$TAOS_DIR/$BIN_DIR + +SIM_DIR=$TAOS_DIR/sim NODE_DIR=$SIM_DIR/$NODE_NAME EXE_DIR=$BUILD_DIR/bin CFG_DIR=$NODE_DIR/cfg @@ -111,7 +119,7 @@ echo "clog 0" >> $TAOS_CFG echo "statusInterval 1" >> $TAOS_CFG echo "numOfTotalVnodes 4" >> $TAOS_CFG echo "asyncLog 0" >> $TAOS_CFG -echo "numOfMPeers 1" >> $TAOS_CFG +echo "numOfMnodes 1" >> $TAOS_CFG echo "locale en_US.UTF-8" >> $TAOS_CFG diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index db40fb0457..e1669ac3d7 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash echo "Executing deploy.sh" @@ -31,10 +31,19 @@ cd $SCRIPT_DIR/../ SCRIPT_DIR=`pwd` echo "SCRIPT_DIR: $SCRIPT_DIR" -cd ../../ +TDINTERNAL="TDinternal" +if [[ "$SCRIPT_DIR" == *"$TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + TAOS_DIR=`pwd` -BUILD_DIR=$TAOS_DIR/debug/build +BIN_DIR=`find . -name "taosd"|grep bin| cut -d '/' --fields=2,3` + +BUILD_DIR=$TAOS_DIR/$BIN_DIR + SIM_DIR=$TAOS_DIR/sim NODE_DIR=$SIM_DIR/$NODE_NAME @@ -119,7 +128,7 @@ echo "clog 2" >> $TAOS_CFG echo "statusInterval 1" >> $TAOS_CFG echo "numOfTotalVnodes 4" >> $TAOS_CFG echo "asyncLog 0" >> $TAOS_CFG -echo "numOfMPeers 1" >> $TAOS_CFG +echo "numOfMnodes 1" >> $TAOS_CFG echo "locale en_US.UTF-8" >> $TAOS_CFG echo "anyIp 0" >> $TAOS_CFG diff --git a/tests/script/sh/exec.sh b/tests/script/sh/exec.sh index f3fcd0325f..ebfe8861b0 100755 --- a/tests/script/sh/exec.sh +++ b/tests/script/sh/exec.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # if [ $# != 4 || $# != 5 ]; then # echo "argument list need input : " @@ -42,10 +42,19 @@ SCRIPT_DIR=`dirname $0` cd $SCRIPT_DIR/../ SCRIPT_DIR=`pwd` -cd ../../ +TDINTERNAL="TDinternal" +if [[ "$SCRIPT_DIR" == *"$TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + TAOS_DIR=`pwd` -BUILD_DIR=$TAOS_DIR/debug/build +BIN_DIR=`find . -name "taosd"|grep bin| cut -d '/' --fields=2,3` + +BUILD_DIR=$TAOS_DIR/$BIN_DIR + SIM_DIR=$TAOS_DIR/sim NODE_DIR=$SIM_DIR/$NODE_NAME EXE_DIR=$BUILD_DIR/bin @@ -86,9 +95,9 @@ else if [ -n "$PID" ]; then if [ "$SIGNAL" = "SIGINT" ]; then echo killed by signal - sudo kill -sigint $PID + kill -sigint $PID else - sudo kill -9 $PID + kill -9 $PID fi fi fi diff --git a/tests/script/sh/exec_tarbitrator.sh b/tests/script/sh/exec_tarbitrator.sh index cb0a8858cb..4da00dff43 100755 --- a/tests/script/sh/exec_tarbitrator.sh +++ b/tests/script/sh/exec_tarbitrator.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # if [ $# != 2 || $# != 3 ]; then # echo "argument list need input : " @@ -39,10 +39,19 @@ SCRIPT_DIR=`dirname $0` cd $SCRIPT_DIR/../ SCRIPT_DIR=`pwd` -cd ../../ +TDINTERNAL="TDinternal" +if [[ "$SCRIPT_DIR" == *"$TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + TAOS_DIR=`pwd` -BUILD_DIR=$TAOS_DIR/../debug/build +BIN_DIR=`find . -name "taosd"|grep bin| cut -d '/' --fields=2,3` + +BUILD_DIR=$TAOS_DIR/$BIN_DIR + SIM_DIR=$TAOS_DIR/sim NODE_DIR=$SIM_DIR/arbitrator EXE_DIR=$BUILD_DIR/bin @@ -57,8 +66,8 @@ else #relative path PID=`ps -ef|grep tarbitrator | grep -v grep | awk '{print $2}'` if [ -n "$PID" ]; then - sudo kill -9 $PID - sudo pkill -9 tarbitrator + kill -9 $PID + pkill -9 tarbitrator fi fi diff --git a/tests/script/sh/exec_up.sh b/tests/script/sh/exec_up.sh deleted file mode 100755 index abe2822450..0000000000 --- a/tests/script/sh/exec_up.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/sh - -# if [ $# != 4 || $# != 5 ]; then - # echo "argument list need input : " - # echo " -n nodeName" - # echo " -s start/stop" - # echo " -c clear" - # exit 1 -# fi - -NODE_NAME= -EXEC_OPTON= -CLEAR_OPTION="false" -while getopts "n:s:u:x:ct" arg -do - case $arg in - n) - NODE_NAME=$OPTARG - ;; - s) - EXEC_OPTON=$OPTARG - ;; - c) - CLEAR_OPTION="clear" - ;; - t) - SHELL_OPTION="true" - ;; - u) - USERS=$OPTARG - ;; - x) - SIGNAL=$OPTARG - ;; - ?) - echo "unkown argument" - ;; - esac -done - -SCRIPT_DIR=`dirname $0` -cd $SCRIPT_DIR/../ -SCRIPT_DIR=`pwd` - -cd ../../ -TAOS_DIR=`pwd` - -BUILD_DIR=$TAOS_DIR/../debug/build -SIM_DIR=$TAOS_DIR/sim -NODE_DIR=$SIM_DIR/$NODE_NAME -EXE_DIR=$BUILD_DIR/bin -CFG_DIR=$NODE_DIR/cfg -LOG_DIR=$NODE_DIR/log -DATA_DIR=$NODE_DIR/data -MGMT_DIR=$NODE_DIR/data/mgmt -TSDB_DIR=$NODE_DIR/data/tsdb - -TAOS_CFG=$NODE_DIR/cfg/taos.cfg - -echo ------------ $EXEC_OPTON $NODE_NAME - -TAOS_FLAG=$SIM_DIR/tsim/flag -if [ -f "$TAOS_FLAG" ]; then - EXE_DIR=/usr/local/bin/taos -fi - -if [ "$CLEAR_OPTION" = "clear" ]; then - echo rm -rf $MGMT_DIR $TSDB_DIR - rm -rf $TSDB_DIR - rm -rf $MGMT_DIR -fi - -if [ "$EXEC_OPTON" = "start" ]; then - echo "ExcuteCmd:" $EXE_DIR/taosd -c $CFG_DIR - - if [ "$SHELL_OPTION" = "true" ]; then - nohup valgrind --log-file=${LOG_DIR}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & - else - nohup $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & - fi - - #TT=`date +%s` - #mkdir ${LOG_DIR}/${TT} - #echo valgrind --log-file=${LOG_DIR}/${TT}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR - #nohup valgrind --log-file=${LOG_DIR}/${TT}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & - -else - #relative path - RCFG_DIR=sim/$NODE_NAME/cfg - PID=`ps -ef|grep taosd | grep $RCFG_DIR | grep -v grep | awk '{print $2}'` - if [ -n "$PID" ]; then - if [ "$SIGNAL" = "SIGINT" ]; then - echo killed by signal - sudo kill -sigint $PID - else - sudo kill -9 $PID - fi - fi -fi - diff --git a/tests/script/test.sh b/tests/script/test.sh index 984eb13c4c..f5485bd881 100755 --- a/tests/script/test.sh +++ b/tests/script/test.sh @@ -40,9 +40,20 @@ cd . # Get responsible directories CODE_DIR=`dirname $0` CODE_DIR=`pwd` -cd ../../ + +TDINTERNAL="TDinternal" +if [[ "$CODE_DIR" == *"$TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + TOP_DIR=`pwd` -BUILD_DIR=$TOP_DIR/debug/build + +BIN_DIR=`find . -name "taosd"|grep bin| cut -d '/' --fields=2,3` + +BUILD_DIR=$TOP_DIR/$BIN_DIR + SIM_DIR=$TOP_DIR/sim if [ $ASYNC -eq 0 ]; then @@ -51,11 +62,6 @@ else PROGRAM="$BUILD_DIR/bin/tsim -a" fi -if [ $UNIQUE -eq 0 ]; then - PROGRAM=$BUILD_DIR/bin/tsim -else - PROGRAM="$TOP_DIR/../debug/build/bin/tsim" -fi PRG_DIR=$SIM_DIR/tsim CFG_DIR=$PRG_DIR/cfg diff --git a/tests/script/tmp/mnodes.sim b/tests/script/tmp/mnodes.sim index 38d99bd214..67f3648f64 100644 --- a/tests/script/tmp/mnodes.sim +++ b/tests/script/tmp/mnodes.sim @@ -2,6 +2,6 @@ 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 3 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 diff --git a/tests/script/tmp/prepare.sim b/tests/script/tmp/prepare.sim index be9e255eb8..a71401d6e4 100644 --- a/tests/script/tmp/prepare.sim +++ b/tests/script/tmp/prepare.sim @@ -10,10 +10,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 diff --git a/tests/script/unique/account/account_create.sim b/tests/script/unique/account/account_create.sim index 1966e1a7ce..9eecceb39d 100644 --- a/tests/script/unique/account/account_create.sim +++ b/tests/script/unique/account/account_create.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -77,4 +77,4 @@ if $rows != 1 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/account_delete.sim b/tests/script/unique/account/account_delete.sim index 40075dc1a6..564512228e 100644 --- a/tests/script/unique/account/account_delete.sim +++ b/tests/script/unique/account/account_delete.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -96,4 +96,4 @@ if $rows != 1 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/account_len.sim b/tests/script/unique/account/account_len.sim index 81d0f0bfb1..75636be513 100644 --- a/tests/script/unique/account/account_len.sim +++ b/tests/script/unique/account/account_len.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -89,4 +89,4 @@ if $rows != 3 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/authority.sim b/tests/script/unique/account/authority.sim index 2bb61cb0f2..2270c28887 100644 --- a/tests/script/unique/account/authority.sim +++ b/tests/script/unique/account/authority.sim @@ -2,7 +2,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -344,4 +344,4 @@ sql drop database d2 sql drop database d3 sql drop database d4 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/basic.sim b/tests/script/unique/account/basic.sim index adbc84d766..0861c9305b 100644 --- a/tests/script/unique/account/basic.sim +++ b/tests/script/unique/account/basic.sim @@ -1,6 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -43,4 +43,4 @@ endi print $data00 $data01 $data02 print $data10 $data11 $data22 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/paras.sim b/tests/script/unique/account/paras.sim index 70a423f70f..60c08b21e9 100644 --- a/tests/script/unique/account/paras.sim +++ b/tests/script/unique/account/paras.sim @@ -1,6 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -111,4 +111,4 @@ if $data16 != 0.000/10.000 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/pass_alter.sim b/tests/script/unique/account/pass_alter.sim index 644548be0b..bf939acce3 100644 --- a/tests/script/unique/account/pass_alter.sim +++ b/tests/script/unique/account/pass_alter.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -113,4 +113,4 @@ sql drop account oroot sql drop user read sql drop user write -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/pass_len.sim b/tests/script/unique/account/pass_len.sim index 370ea94200..1dd0a616f2 100644 --- a/tests/script/unique/account/pass_len.sim +++ b/tests/script/unique/account/pass_len.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -78,4 +78,4 @@ if $rows != 3 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/usage.sim b/tests/script/unique/account/usage.sim index 63c3d49f43..c1c5d75728 100644 --- a/tests/script/unique/account/usage.sim +++ b/tests/script/unique/account/usage.sim @@ -1,6 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -57,4 +57,4 @@ endi print =============== check grant sql_error create database d6 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/user_create.sim b/tests/script/unique/account/user_create.sim index 2a64786225..029bda22ea 100644 --- a/tests/script/unique/account/user_create.sim +++ b/tests/script/unique/account/user_create.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -81,4 +81,4 @@ step42: sql drop user read -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/account/user_len.sim b/tests/script/unique/account/user_len.sim index 1163ac2e4b..91a5ebfaab 100644 --- a/tests/script/unique/account/user_len.sim +++ b/tests/script/unique/account/user_len.sim @@ -1,7 +1,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -91,4 +91,4 @@ if $rows != 1 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim b/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim index eabaefd678..34d7981e8a 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim @@ -5,11 +5,11 @@ system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode4 -i 4 system sh/deploy.sh -n dnode5 -i 5 -system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode5 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/cfg.sh -n dnode2 -c walLevel -v 1 @@ -56,13 +56,13 @@ print ============== step0: start tarbitrator system sh/exec_tarbitrator.sh -s start print ============== step1: start dnode1, only deploy mnode -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect print ============== step2: start dnode2/dnode3 and add into cluster, then create database, create table , and insert data -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start sleep 1000 sql create dnode $hostname2 sql create dnode $hostname3 @@ -108,7 +108,7 @@ if $data00 != $totalRows then endi print ============== step3: add one new dnode4 expect auto balancing -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start sql create dnode $hostname4 sleep 10000 sql select count(*) from $stb @@ -119,7 +119,7 @@ endi print ============== step4: stop dnode3, after offlineThreshold, dnode3 will be dropped for cluster -system sh/exec_up.sh -n dnode3 -s stop +system sh/exec.sh -n dnode3 -s stop sql select count(*) from $stb print data00 $data00 if $data00 != $totalRows then @@ -182,7 +182,7 @@ endi print ============== step5: start dnode5 and add into cluster , drop database sql drop database $db sleep 1000 -system sh/exec_up.sh -n dnode5 -s start +system sh/exec.sh -n dnode5 -s start sql create dnode $hostname5 sleep 3000 wait_dnode5: diff --git a/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim b/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim index d1b4a2ec72..dd6cdfdcf2 100644 --- a/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim +++ b/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim @@ -3,9 +3,9 @@ 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 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/cfg.sh -n dnode2 -c walLevel -v 1 @@ -24,7 +24,7 @@ system sh/exec_tarbitrator.sh -s start print ============== step1: replica is 1, and start 1 dnode -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -58,7 +58,7 @@ while $i < $tblNum endw print ============== step2: add 1 new dnode, expect balanced -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname2 # expect after balanced, 2 vondes in dnode1, 1 vonde in dnode2 @@ -81,7 +81,7 @@ if $data2_2 != 1 then endi print ============== step4: stop dnode1, and wait dnode2 master -system sh/exec_up.sh -n dnode1 -s stop +system sh/exec.sh -n dnode1 -s stop $x = 0 loop_wait: diff --git a/tests/script/unique/big/balance.sim b/tests/script/unique/big/balance.sim index 5259f415c8..09fca14931 100644 --- a/tests/script/unique/big/balance.sim +++ b/tests/script/unique/big/balance.sim @@ -20,7 +20,7 @@ system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 1000 print =============== prepare data -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -87,7 +87,7 @@ endi print ========== step1 sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start $x = 0 show1: @@ -142,7 +142,7 @@ endi print ========== step2 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 10000 print ========== step3 @@ -170,7 +170,7 @@ if $data2_3 != 2 then goto show3 endi -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sql reset query cache sleep 1000 @@ -226,7 +226,7 @@ if $data2_3 != null then goto show4 endi -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT sql reset query cache sleep 1000 @@ -262,7 +262,7 @@ if $data00 != $totalNum then endi print ========== step5 -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start sql create dnode $hostname4 sleep 3000 @@ -319,11 +319,11 @@ if $data00 != $totalNum then goto show5 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/big/maxvnodes.sim b/tests/script/unique/big/maxvnodes.sim index f019ea607c..ab93474a43 100644 --- a/tests/script/unique/big/maxvnodes.sim +++ b/tests/script/unique/big/maxvnodes.sim @@ -15,7 +15,7 @@ system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v $totalVnodes print ========== prepare data -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect sql create database db blocks 2 cache 1 maxTables $maxTables @@ -45,7 +45,7 @@ endi print ========== step3 sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start $x = 0 show3: @@ -78,11 +78,11 @@ endi return -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/big/restartSpeed.sim b/tests/script/unique/big/restartSpeed.sim index 5ab77f5fa6..94c687d329 100644 --- a/tests/script/unique/big/restartSpeed.sim +++ b/tests/script/unique/big/restartSpeed.sim @@ -15,7 +15,7 @@ system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v $totalVnodes print ========== prepare data -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect sql create database db blocks 2 cache 1 maxTables $maxTables @@ -33,11 +33,11 @@ while $x < $totalRows endw -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/big/tcp.sim b/tests/script/unique/big/tcp.sim index 590035c0f8..38cb667ec0 100644 --- a/tests/script/unique/big/tcp.sim +++ b/tests/script/unique/big/tcp.sim @@ -14,7 +14,7 @@ system sh/cfg.sh -n dnode1 -c adminDebugFlag -v 131 system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 system sh/cfg.sh -n dnode1 -c debugFlag -v 131 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect print ======================== dnode1 start @@ -104,11 +104,11 @@ while $i < 10 $i = $i + 1 endw -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/cluster/balance1.sim b/tests/script/unique/cluster/balance1.sim index 9130493a93..80dfd81e34 100644 --- a/tests/script/unique/cluster/balance1.sim +++ b/tests/script/unique/cluster/balance1.sim @@ -17,14 +17,14 @@ system sh/cfg.sh -n dnode6 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode7 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode8 -c numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode1 -c numOfMpeers -v 3 -system sh/cfg.sh -n dnode2 -c numOfMpeers -v 3 -system sh/cfg.sh -n dnode3 -c numOfMpeers -v 3 -system sh/cfg.sh -n dnode4 -c numOfMpeers -v 3 -system sh/cfg.sh -n dnode5 -c numOfMpeers -v 3 -system sh/cfg.sh -n dnode6 -c numOfMpeers -v 3 -system sh/cfg.sh -n dnode7 -c numOfMpeers -v 3 -system sh/cfg.sh -n dnode8 -c numOfMpeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode6 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode7 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode8 -c numOfMnodes -v 3 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 @@ -46,7 +46,7 @@ system sh/cfg.sh -n dnode8 -c wallevel -v 1 print ============== step1 print ========= start dnode1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create database c_b1_d1 maxTables 4 @@ -85,7 +85,7 @@ print ============================== step2 print ========= start dnode2 sleep 2000 sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 5000 $x = 0 @@ -162,9 +162,9 @@ print dnode4 ==> $dnode4Role print ============================== step5 print ========= add dnode2 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 3000 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sql create dnode $hostname3 sleep 9000 @@ -251,7 +251,7 @@ endi print ============================== step9 sql create dnode $hostname4 -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start sleep 9000 $x = 0 @@ -333,7 +333,7 @@ sql_error create table c_b1_t5 (t timestamp, i int) -x error3 print ============================== step13 sql create dnode $hostname5 -system sh/exec_up.sh -n dnode5 -s start +system sh/exec.sh -n dnode5 -s start sleep 9000 sql show mnodes @@ -381,7 +381,7 @@ endi print ============================== step14 sql create dnode $hostname6 -system sh/exec_up.sh -n dnode6 -s start +system sh/exec.sh -n dnode6 -s start sleep 15000 sql create database c_b1_d7 maxTables 4 @@ -554,11 +554,11 @@ if $data41 != 85 then endi print ============================================ over= -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/cluster/balance2.sim b/tests/script/unique/cluster/balance2.sim index 56c0d538b6..bb27a2aadb 100644 --- a/tests/script/unique/cluster/balance2.sim +++ b/tests/script/unique/cluster/balance2.sim @@ -17,14 +17,14 @@ system sh/cfg.sh -n dnode6 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode7 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode8 -c numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode1 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode5 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode6 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode7 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode8 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode6 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode7 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode8 -c numOfMnodes -v 3 system sh/cfg.sh -n dnode1 -c wallevel -v 1 system sh/cfg.sh -n dnode2 -c wallevel -v 1 @@ -46,14 +46,14 @@ system sh/cfg.sh -n dnode8 -c mnodeEqualVnodeNum -v 0 print ============== step1 print ========= start dnode1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sleep 4001 sql create dnode $hostname2 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start sleep 4001 sql create database c_b2_d1 replica 2 maxTables 4 @@ -148,12 +148,12 @@ print dnode2 ==> $dnode2Role print dnode3 ==> $dnode3Role print dnode4 ==> $dnode4Role -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT print ============================== step3 print ========= start dnode4 sql create dnode $hostname4 -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start sleep 10000 $x = 0 @@ -259,12 +259,12 @@ if $dnode4Role != slave then return -1 endi -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT print ============================== step5 print ========= start dnode3 sql create dnode $hostname5 -system sh/exec_up.sh -n dnode5 -s start +system sh/exec.sh -n dnode5 -s start sleep 9000 $x = 0 @@ -301,7 +301,7 @@ print dnode4 ==> $dnode4Role print dnode5 ==> $dnode5Role print ============================== step6 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT print stop dnode1 and sleep 10000 sleep 10000 @@ -322,7 +322,7 @@ if $dnode1Role != offline then endi print ============================== step6.1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start $x = 0 show6: @@ -357,7 +357,7 @@ print dnode1 ==> $dnode1Role print dnode4 ==> $dnode4Role print dnode5 ==> $dnode5Role -#system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +#system sh/exec.sh -n dnode1 -s stop -x SIGINT print ============================== step12 print ========= check data @@ -421,11 +421,11 @@ if $data41 != 35 then endi print ============================================ over -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/cluster/balance3.sim b/tests/script/unique/cluster/balance3.sim index 346f027526..77eba2a2a5 100644 --- a/tests/script/unique/cluster/balance3.sim +++ b/tests/script/unique/cluster/balance3.sim @@ -18,14 +18,14 @@ system sh/cfg.sh -n dnode6 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode7 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode8 -c numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode1 -c numOfMpeers -v 3 -system sh/cfg.sh -n dnode2 -c numOfMpeers -v 3 -system sh/cfg.sh -n dnode3 -c numOfMpeers -v 3 -system sh/cfg.sh -n dnode4 -c numOfMpeers -v 3 -system sh/cfg.sh -n dnode5 -c numOfMpeers -v 3 -system sh/cfg.sh -n dnode6 -c numOfMpeers -v 3 -system sh/cfg.sh -n dnode7 -c numOfMpeers -v 3 -system sh/cfg.sh -n dnode8 -c numOfMpeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode6 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode7 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode8 -c numOfMnodes -v 3 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 @@ -47,14 +47,14 @@ system sh/cfg.sh -n dnode8 -c wallevel -v 1 print ============== step1 print ========= start dnode1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sleep 2001 sql create dnode $hostname2 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start sleep 3001 sql create database c_b3_d1 replica 3 @@ -117,7 +117,7 @@ endi print ============================== step2 print ========= start dnode4 sql create dnode $hostname4 -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start sleep 9000 $x = 0 @@ -176,11 +176,11 @@ if $dnode4Vnodes != 3 then goto show3 endi -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT print ============================== step4 sql create dnode $hostname5 -system sh/exec_up.sh -n dnode5 -s start +system sh/exec.sh -n dnode5 -s start sleep 10000 $x = 0 @@ -239,11 +239,11 @@ if $dnode4Vnodes != 3 then goto show5 endi -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT print ============================== step6 sql create dnode $hostname6 -system sh/exec_up.sh -n dnode6 -s start +system sh/exec.sh -n dnode6 -s start sleep 9000 $x = 0 @@ -302,11 +302,11 @@ if $dnode4Vnodes != null then goto show7 endi -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT print ============================== step8 sql create dnode $hostname7 -system sh/exec_up.sh -n dnode7 -s start +system sh/exec.sh -n dnode7 -s start sleep 9000 $x = 0 @@ -332,7 +332,7 @@ endi print ============================== step9 print ========= drop dnode1 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT print stop dnode1 and sleep 10000 sleep 10000 @@ -353,7 +353,7 @@ if $dnode1Role != offline then endi print ============================== step9.1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start $x = 0 show9: @@ -380,7 +380,7 @@ if $dnode7Vnodes != 3 then goto show9 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT print ============================== step11 print ========= add db4 @@ -428,7 +428,7 @@ if $dnode7Vnodes != 4 then goto show11 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT print ============================== step13 sql reset query cache @@ -492,11 +492,11 @@ if $data41 != 35 then endi print ============================================ over -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/column/replica3.sim b/tests/script/unique/column/replica3.sim index 4e45edc02d..c21f71dc2c 100644 --- a/tests/script/unique/column/replica3.sim +++ b/tests/script/unique/column/replica3.sim @@ -6,16 +6,16 @@ system sh/deploy.sh -n dnode3 -i 3 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 dnode1 -c numofMpeers -v 3 -system sh/cfg.sh -n dnode2 -c numofMpeers -v 3 -system sh/cfg.sh -n dnode3 -c numofMpeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start sql create database db replica 3 sql use db @@ -33,11 +33,11 @@ sql_error create database d1 replica 2 wal 0 sql create database d2 replica 1 wal 0 sql_error alter database d2 replica 2 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/commit.sim b/tests/script/unique/db/commit.sim index 95a6b92bb2..98256b01dc 100644 --- a/tests/script/unique/db/commit.sim +++ b/tests/script/unique/db/commit.sim @@ -6,21 +6,21 @@ system sh/deploy.sh -n dnode3 -i 3 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 dnode1 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 print ========= start dnode1 as master -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sleep 3000 print ========= start other dnodes sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 3000 print ======== step1 create db @@ -47,9 +47,9 @@ if $data01 != 40 then endi print ======== step2 stop dnode -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 5000 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 3000 sql select * from tb order by ts desc @@ -98,9 +98,9 @@ if $data01 != 40 then endi print ======== step5 stop dnode -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 5000 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 3000 sql select * from tb @@ -115,11 +115,11 @@ if $data01 != 40 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/delete.sim b/tests/script/unique/db/delete.sim index 5688333d20..d9b6e8a9f9 100644 --- a/tests/script/unique/db/delete.sim +++ b/tests/script/unique/db/delete.sim @@ -6,21 +6,21 @@ system sh/deploy.sh -n dnode3 -i 3 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 dnode1 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 10 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 10 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 10 print ========= start dnodes -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start print ======== step1 sql create database db replica 3 blocks 2 maxtables 1000 @@ -65,14 +65,14 @@ endi print ======== step3 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT sleep 1000 -system sh/exec_up.sh -n dnode1 -s start -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start $x = 0 step3: @@ -90,11 +90,11 @@ endi sleep 1000 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/delete_part.sim b/tests/script/unique/db/delete_part.sim index 1bd103137b..ac84382be4 100644 --- a/tests/script/unique/db/delete_part.sim +++ b/tests/script/unique/db/delete_part.sim @@ -9,10 +9,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 @@ -30,11 +30,11 @@ system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 print ========= start dnodes -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start $loop = 0 begin: @@ -137,14 +137,14 @@ begin: print ======== step2 $loop - system sh/exec_up.sh -n dnode2 -s stop + system sh/exec.sh -n dnode2 -s stop sleep 1000 print ==> drop database $db sql drop database $db print ======== step3 $loop sleep 2000 - system sh/exec_up.sh -n dnode2 -s start + system sh/exec.sh -n dnode2 -s start sleep 15000 sql show dnodes @@ -175,11 +175,11 @@ begin: goto begin -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/replica_add12.sim b/tests/script/unique/db/replica_add12.sim index ce7121db2e..ff0dffe0e2 100644 --- a/tests/script/unique/db/replica_add12.sim +++ b/tests/script/unique/db/replica_add12.sim @@ -10,10 +10,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 @@ -26,12 +26,12 @@ system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 print ========= start dnodes -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 3000 print ======== step1 @@ -145,7 +145,7 @@ sql reset query cache sleep 2000 print ========= step5 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 5000 sql select * from d1.t1 @@ -196,7 +196,7 @@ if $rows != 2 then endi print ========= step6 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 5000 sql insert into d1.t1 values(now, 3) @@ -226,7 +226,7 @@ endi print ========= step61 -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT sleep 5000 sql_error insert into d1.t1 values(now, 3) @@ -255,7 +255,7 @@ if $rows != 3 then endi print ========= step7 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 5000 sql insert into d1.t1 values(now, 5) @@ -283,11 +283,11 @@ if $rows != 4 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/replica_add13.sim b/tests/script/unique/db/replica_add13.sim index b2bfef2b58..1b5a01a9fd 100644 --- a/tests/script/unique/db/replica_add13.sim +++ b/tests/script/unique/db/replica_add13.sim @@ -10,10 +10,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 @@ -26,14 +26,14 @@ system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 print ========= start dnodes -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sql create dnode $hostname4 -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start sleep 3000 print ======== step1 @@ -139,7 +139,7 @@ endi print ========= step5 sql reset query cache sleep 1000 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 5000 sql insert into d1.t1 values(1589529000013, 3) @@ -168,9 +168,9 @@ if $rows != 3 then endi print ========= step6 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 5000 -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT sleep 3000 sql insert into d1.t1 values(1589529000014, 4) @@ -203,9 +203,9 @@ if $rows != 4 then endi print ========= step7 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 5000 -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT sleep 3000 sql insert into d1.t1 values(1589529000015, 5) @@ -234,9 +234,9 @@ if $rows != 5 then endi print ========= step8 -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start sleep 5000 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 3000 sql insert into d1.t1 values(1589529000016, 6) @@ -264,11 +264,11 @@ if $rows != 6 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/replica_add23.sim b/tests/script/unique/db/replica_add23.sim index 6df09d0cac..67131173d9 100644 --- a/tests/script/unique/db/replica_add23.sim +++ b/tests/script/unique/db/replica_add23.sim @@ -10,10 +10,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 @@ -26,14 +26,14 @@ system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 print ========= start dnodes -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sql create dnode $hostname4 -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start sleep 3000 print ======== step1 @@ -140,7 +140,7 @@ sql reset query cache sleep 1000 print ========= step5 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 5000 sql insert into d1.t1 values(1588262400003, 3) @@ -169,9 +169,9 @@ if $rows != 3 then endi print ========= step6 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 5000 -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT sleep 5000 sql insert into d1.t1 values(1588262400004, 4) @@ -200,9 +200,9 @@ if $rows != 4 then endi print ========= step7 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 5000 -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT sleep 5000 sql insert into d1.t1 values(1588262400005, 5) @@ -231,9 +231,9 @@ if $rows != 5 then endi print ========= step8 -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start sleep 5000 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 5000 sql insert into d1.t1 values(1588262400006, 6) @@ -261,11 +261,11 @@ if $rows != 6 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/replica_part.sim b/tests/script/unique/db/replica_part.sim index 6a41c430ea..0de5732853 100644 --- a/tests/script/unique/db/replica_part.sim +++ b/tests/script/unique/db/replica_part.sim @@ -7,9 +7,9 @@ system sh/deploy.sh -n dnode3 -i 3 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 dnode1 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 @@ -18,12 +18,12 @@ system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 print ========= start dnodes -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 3000 print ======== step1 @@ -63,7 +63,7 @@ if $rows != 1 then endi print ========= step2 alter db -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 5000 sql alter database d1 replica 2 sql alter database d2 replica 2 @@ -72,7 +72,7 @@ sql alter database d4 replica 2 sleep 5000 print ========= step3 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 10000 print ========= step4 @@ -102,7 +102,7 @@ if $rows != 2 then endi print ========= step5 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 5000 sql reset query cache @@ -118,9 +118,9 @@ sql insert into d4.t4 values(now, 3) -x s4 s4: print ========= step6 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 5000 -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT sleep 5000 sql insert into d1.t1 values(now, 4) -x s5 @@ -133,7 +133,7 @@ sql insert into d4.t4 values(now, 4) -x s8 s8: print ========= step7 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 5000 sql insert into d1.t1 values(now, 5) @@ -146,11 +146,11 @@ sql select * from d2.t2 sql select * from d3.t3 sql select * from d4.t4 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/replica_reduce21.sim b/tests/script/unique/db/replica_reduce21.sim index 931382d8c4..9dc5abcd0d 100644 --- a/tests/script/unique/db/replica_reduce21.sim +++ b/tests/script/unique/db/replica_reduce21.sim @@ -7,9 +7,9 @@ system sh/deploy.sh -n dnode3 -i 3 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 dnode1 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 @@ -18,10 +18,10 @@ system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 print ========= start dnodes -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 3000 print ======== step1 @@ -117,7 +117,7 @@ if $rows != 2 then endi print ======== step9 stop dnode2 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 3000 sql insert into d5.t5 values(now, 3) @@ -145,11 +145,11 @@ if $rows != 3 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/replica_reduce31.sim b/tests/script/unique/db/replica_reduce31.sim index 22c89d91b9..af9bcb17bc 100644 --- a/tests/script/unique/db/replica_reduce31.sim +++ b/tests/script/unique/db/replica_reduce31.sim @@ -7,9 +7,9 @@ system sh/deploy.sh -n dnode3 -i 3 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 dnode1 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 @@ -18,12 +18,12 @@ system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 print ========= start dnodes -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 3000 print ======== step1 @@ -139,7 +139,7 @@ if $rows != 3 then endi print ========= step4 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 5000 sql reset query cache @@ -155,9 +155,9 @@ sql insert into d4.t4 values(now, 4) -x step4 step4: print ========= step5 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 5000 -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT sleep 5000 sql insert into d1.t1 values(now, 5) -x step5 @@ -170,7 +170,7 @@ sql insert into d4.t4 values(now, 5) -x step8 step8: print ========= step6 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 5000 sql insert into d1.t1 values(now, 6) @@ -183,11 +183,11 @@ sql select * from d2.t2 sql select * from d3.t3 sql select * from d4.t4 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/replica_reduce32.sim b/tests/script/unique/db/replica_reduce32.sim index 54069cb133..bc08911a7c 100644 --- a/tests/script/unique/db/replica_reduce32.sim +++ b/tests/script/unique/db/replica_reduce32.sim @@ -7,9 +7,9 @@ system sh/deploy.sh -n dnode3 -i 3 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 dnode1 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 @@ -18,12 +18,12 @@ system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 print ========= start dnodes -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 3000 print ======== step1 @@ -99,7 +99,7 @@ sql reset query cache sleep 1000 print ========= step4 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 5000 sql insert into d1.t1 values(now, 3) -x step1 @@ -117,10 +117,10 @@ sql select * from d3.t3 sql select * from d4.t4 print ========= step5 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 5000 -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT sleep 5000 sql reset query cache @@ -136,7 +136,7 @@ sql insert into d4.t4 values(now, 3) -x step41 step41: print ========= step6 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 5000 sql insert into d1.t1 values(now, 5) @@ -156,11 +156,11 @@ print d3.t3 $rows sql select * from d4.t4 print d4.t4 $rows -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/alternativeRole.sim b/tests/script/unique/dnode/alternativeRole.sim new file mode 100644 index 0000000000..e123ffa426 --- /dev/null +++ b/tests/script/unique/dnode/alternativeRole.sim @@ -0,0 +1,91 @@ +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 alternativeRole -v 1 +system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 +system sh/cfg.sh -n dnode3 -c alternativeRole -v 0 + +system sh/cfg.sh -n dnode1 -c wallevel -v 1 +system sh/cfg.sh -n dnode2 -c wallevel -v 1 +system sh/cfg.sh -n dnode3 -c wallevel -v 1 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 + +print ========== step1 +system sh/exec.sh -n dnode1 -s start +sql connect +sql create dnode $hostname2 +system sh/exec.sh -n dnode2 -s start +sleep 3000 +sql create dnode $hostname3 +system sh/exec.sh -n dnode3 -s start +sleep 3000 + +sql show dnodes +print dnode1 $data5_1 +print dnode1 $data5_2 +print dnode1 $data5_3 + +if $data5_1 != mnode then + return -1 +endi +if $data5_2 != vnode then + return -1 +endi +if $data5_3 != any then + return -1 +endi + +sql show mnodes +print dnode1 ==> $data2_1 +print dnode2 ==> $data2_2 +print dnode3 ==> $data2_3 +if $data2_1 != master then + return -1 +endi +if $data2_2 != null then + return -1 +endi +if $data2_3 != slave then + return -1 +endi + +print ========== step2 +sql create database d1 maxTables 4 +sql create table d1.t1 (ts timestamp, i int) +sql create table d1.t2 (ts timestamp, i int) +sql create table d1.t3 (ts timestamp, i int) +sql create table d1.t4 (ts timestamp, i int) +sql create table d1.t5 (ts timestamp, i int) +sql create table d1.t6 (ts timestamp, i int) +sql create table d1.t7 (ts timestamp, i int) +sql create table d1.t8 (ts timestamp, i int) + +sql show dnodes +print dnode1 $data2_1 +print dnode2 $data2_2 +print dnode3 $data2_3 + +if $data2_1 != 0 then + return -1 +endi +if $data2_2 != 1 then + return -1 +endi +if $data2_3 != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/balance1.sim b/tests/script/unique/dnode/balance1.sim index a6be723d7c..5b1615dc28 100644 --- a/tests/script/unique/dnode/balance1.sim +++ b/tests/script/unique/dnode/balance1.sim @@ -26,7 +26,7 @@ system sh/cfg.sh -n dnode3 -c wallevel -v 2 system sh/cfg.sh -n dnode4 -c wallevel -v 2 print ========== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sleep 3000 @@ -47,7 +47,7 @@ endi print ========== step2 sleep 2000 sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start $x = 0 show2: @@ -110,11 +110,11 @@ if $rows != 1 then goto show4 endi -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT print ========== step5 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start $x = 0 show5: @@ -164,7 +164,7 @@ endi print ========== step7 sql create dnode $hostname4 -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start $x = 0 show7: @@ -250,7 +250,7 @@ if $data2_4 != 4 then goto show9 endi -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT sql reset query cache sleep 1000 @@ -328,11 +328,11 @@ if $data41 != 45 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/balance2.sim b/tests/script/unique/dnode/balance2.sim index c60ac14517..374e3dd5ba 100644 --- a/tests/script/unique/dnode/balance2.sim +++ b/tests/script/unique/dnode/balance2.sim @@ -19,13 +19,13 @@ system sh/cfg.sh -n dnode4 -c wallevel -v 1 system sh/cfg.sh -n dnode5 -c wallevel -v 1 print ========== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start sleep 3000 sql create database d1 replica 2 maxTables 4 @@ -83,11 +83,11 @@ if $data2_3 != 2 then goto show2 endi -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT print ========== step3 sql create dnode $hostname4 -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start $x = 0 show3: @@ -144,7 +144,7 @@ endi print ========== step5 sql create dnode $hostname5 -system sh/exec_up.sh -n dnode5 -s start +system sh/exec.sh -n dnode5 -s start $x = 0 show5: @@ -209,7 +209,7 @@ if $data2_5 != 3 then goto show6 endi -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sql reset query cache sleep 1000 @@ -269,11 +269,11 @@ if $data41 != 35 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/balance3.sim b/tests/script/unique/dnode/balance3.sim index f0bf0c7c2b..786b4404ba 100644 --- a/tests/script/unique/dnode/balance3.sim +++ b/tests/script/unique/dnode/balance3.sim @@ -22,15 +22,15 @@ system sh/cfg.sh -n dnode5 -c wallevel -v 1 system sh/cfg.sh -n dnode6 -c wallevel -v 1 print ========== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start sleep 3000 sql create database d1 replica 3 maxTables 4 @@ -98,11 +98,11 @@ if $data2_4 != 2 then goto show2 endi -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT print ========== step sql create dnode $hostname5 -system sh/exec_up.sh -n dnode5 -s start +system sh/exec.sh -n dnode5 -s start $x = 0 show3: @@ -178,7 +178,7 @@ endi print ========== step5 sql create dnode $hostname6 system sh/deploy.sh -n dnode6 -i 6 -system sh/exec_up.sh -n dnode6 -s start +system sh/exec.sh -n dnode6 -s start $x = 0 show5: @@ -238,7 +238,7 @@ if $data2_5 != 3 then goto show6 endi -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT sql reset query cache sleep 1000 @@ -298,11 +298,11 @@ if $data41 != 35 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/balancex.sim b/tests/script/unique/dnode/balancex.sim index 14b0982678..fdb20434ff 100644 --- a/tests/script/unique/dnode/balancex.sim +++ b/tests/script/unique/dnode/balancex.sim @@ -16,7 +16,7 @@ system sh/cfg.sh -n dnode3 -c wallevel -v 1 system sh/cfg.sh -n dnode4 -c wallevel -v 1 print ========== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sleep 3000 @@ -44,7 +44,7 @@ endi print ========== step2 sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start $x = 0 show2: @@ -92,7 +92,7 @@ endi print ========== step3 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start $x = 0 show4: @@ -139,7 +139,7 @@ if $data2_3 != 3 then goto show5 endi -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sql reset query cache sleep 1000 @@ -199,11 +199,11 @@ if $data41 != 35 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/basic1.sim b/tests/script/unique/dnode/basic1.sim index 43a55b6106..5382e88e53 100644 --- a/tests/script/unique/dnode/basic1.sim +++ b/tests/script/unique/dnode/basic1.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/exec_up.sh -n dnode1 -s start -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start sql connect print =============== show dnodes diff --git a/tests/script/unique/dnode/monitor_bug.sim b/tests/script/unique/dnode/monitor_bug.sim index a20185240f..519aae6ca9 100644 --- a/tests/script/unique/dnode/monitor_bug.sim +++ b/tests/script/unique/dnode/monitor_bug.sim @@ -13,7 +13,7 @@ system sh/cfg.sh -n dnode1 -c monitor -v 1 system sh/cfg.sh -n dnode2 -c monitor -v 0 print ========== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sleep 5000 @@ -25,7 +25,7 @@ endi print ========== step2 sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start $x = 0 show2: diff --git a/tests/script/unique/dnode/offline1.sim b/tests/script/unique/dnode/offline1.sim index 9d068e8358..02d03dee97 100644 --- a/tests/script/unique/dnode/offline1.sim +++ b/tests/script/unique/dnode/offline1.sim @@ -21,10 +21,10 @@ system sh/cfg.sh -n dnode2 -c wallevel -v 1 system sh/cfg.sh -n dnode3 -c wallevel -v 1 print ========== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 3000 sql show dnodes @@ -39,7 +39,7 @@ if $data4_2 != ready then endi print ========== step2 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 8000 sql show dnodes @@ -67,11 +67,11 @@ if $data4_2 != null then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/offline2.sim b/tests/script/unique/dnode/offline2.sim index e9c1218e1f..6db6ca4013 100644 --- a/tests/script/unique/dnode/offline2.sim +++ b/tests/script/unique/dnode/offline2.sim @@ -21,10 +21,10 @@ system sh/cfg.sh -n dnode2 -c wallevel -v 1 system sh/cfg.sh -n dnode3 -c wallevel -v 1 print ========== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 3000 sql create database d1 replica 2 maxTables 4 @@ -43,7 +43,7 @@ if $data4_2 != ready then endi print ========== step2 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 8000 sql show dnodes @@ -73,8 +73,8 @@ endi print ========== step4 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode2 -s start sql drop dnode $hostname2 sleep 5000 @@ -109,11 +109,11 @@ if $rows != 1 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/remove1.sim b/tests/script/unique/dnode/remove1.sim index 2eb1fe4ae7..5c4d30e728 100644 --- a/tests/script/unique/dnode/remove1.sim +++ b/tests/script/unique/dnode/remove1.sim @@ -16,7 +16,7 @@ system sh/cfg.sh -n dnode3 -c wallevel -v 1 system sh/cfg.sh -n dnode4 -c wallevel -v 1 print ========== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -44,7 +44,7 @@ endi print ========== step2 sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 9000 sql create database d3 replica 2 maxTables 4 @@ -91,7 +91,7 @@ print dnode2 openVnodes $data2_2 print ========== step4 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start $x = 0 show4: @@ -109,11 +109,11 @@ if $data2_2 != null then goto show4 endi -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT print ========== step5 sql create dnode $hostname4 -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start $x = 0 show5: @@ -195,11 +195,11 @@ if $data41 != 35 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/remove2.sim b/tests/script/unique/dnode/remove2.sim index db77a8e05d..76c5fbb08e 100644 --- a/tests/script/unique/dnode/remove2.sim +++ b/tests/script/unique/dnode/remove2.sim @@ -16,7 +16,7 @@ system sh/cfg.sh -n dnode3 -c wallevel -v 2 system sh/cfg.sh -n dnode4 -c wallevel -v 2 print ========== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -44,7 +44,7 @@ endi print ========== step2 sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 9000 sql create database d3 replica 2 maxTables 4 @@ -74,7 +74,7 @@ if $data2_2 != 3 then endi print ========== step3 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sql drop dnode $hostname2 sleep 4000 @@ -84,7 +84,7 @@ print dnode2 openVnodes $data2_2 print ========== step4 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 5000 @@ -97,7 +97,7 @@ if $data2_3 != 0 then endi print ============ step 4.1 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start $x = 0 show4: @@ -146,11 +146,11 @@ if $data41 != 35 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/vnode_clean.sim b/tests/script/unique/dnode/vnode_clean.sim index d42fbf4e2d..6ab63bd94f 100644 --- a/tests/script/unique/dnode/vnode_clean.sim +++ b/tests/script/unique/dnode/vnode_clean.sim @@ -16,7 +16,7 @@ system sh/cfg.sh -n dnode3 -c wallevel -v 1 system sh/cfg.sh -n dnode4 -c wallevel -v 1 print ========== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create database d1 maxTables 4 @@ -35,7 +35,7 @@ endi print ========== step2 sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start $x = 0 show2: @@ -98,12 +98,12 @@ if $rows != 1 then goto show4 endi -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT print ========== step5 sleep 2000 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start $x = 0 show5: @@ -143,7 +143,7 @@ endi print ========== step7 sql create dnode $hostname4 -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start $x = 0 show7: @@ -222,7 +222,7 @@ if $data2_4 != 4 then goto show9 endi -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT print ========== step10 sql select * from d1.t1 order by t desc @@ -297,11 +297,11 @@ if $data41 != 45 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/http/admin.sim b/tests/script/unique/http/admin.sim index 51307af00e..3a480b6ebe 100644 --- a/tests/script/unique/http/admin.sim +++ b/tests/script/unique/http/admin.sim @@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c http -v 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 #system sh/cfg.sh -n dnode1 -c adminRowLimit -v 10 system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sleep 3000 @@ -179,11 +179,11 @@ print =============== step8 - monitor dbs # return -1 # endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/http/opentsdb.sim b/tests/script/unique/http/opentsdb.sim index 4e126c4e60..827f02bc1f 100644 --- a/tests/script/unique/http/opentsdb.sim +++ b/tests/script/unique/http/opentsdb.sim @@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c http -v 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -238,11 +238,11 @@ if $system_content != @{"status":"succ","head":["count(*)"],"data":[[8]],"rows": return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/import/replica2.sim b/tests/script/unique/import/replica2.sim index 3f21fcf00d..f2836fe470 100644 --- a/tests/script/unique/import/replica2.sim +++ b/tests/script/unique/import/replica2.sim @@ -5,10 +5,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 @@ -26,12 +26,12 @@ 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 +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create database ir2db replica 2 days 7 sql use ir2db @@ -95,9 +95,9 @@ if $rows != 14 then endi print ================== dnode restart -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 5000 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 5000 sql select * from tb; if $rows != 14 then @@ -162,9 +162,9 @@ if $rows != 35 then endi print ================= step10 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 5000 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 5000 sql select * from tb; print $rows @@ -192,9 +192,9 @@ if $rows != 49 then endi print ================= step13 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 5000 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 5000 print ================= step14 @@ -213,20 +213,20 @@ if $rows != 52 then endi print ================= step15 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 5000 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 5000 if $rows != 52 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/import/replica3.sim b/tests/script/unique/import/replica3.sim index 8eb2df9942..b4e4a2191e 100644 --- a/tests/script/unique/import/replica3.sim +++ b/tests/script/unique/import/replica3.sim @@ -5,10 +5,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 @@ -26,14 +26,14 @@ 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 +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sql create database ir3db replica 3 days 7 @@ -98,9 +98,9 @@ if $rows != 14 then endi print ================== dnode restart -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 5000 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 5000 sql select * from tb; if $rows != 14 then @@ -165,9 +165,9 @@ if $rows != 35 then endi print ================= step10 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 5000 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 5000 sql select * from tb; print $rows @@ -195,9 +195,9 @@ if $rows != 49 then endi print ================= step13 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 5000 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 5000 print ================= step14 @@ -216,20 +216,20 @@ if $rows != 52 then endi print ================= step15 -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT sleep 5000 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 5000 if $rows != 52 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt22.sim b/tests/script/unique/mnode/mgmt22.sim index c6ea026af9..08fe8d346a 100644 --- a/tests/script/unique/mnode/mgmt22.sim +++ b/tests/script/unique/mnode/mgmt22.sim @@ -3,12 +3,12 @@ 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 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 print ============== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -20,7 +20,7 @@ if $data2_1 != master then endi print ============== step2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname2 $x = 0 @@ -46,7 +46,7 @@ sql_error drop dnode $hostname1 -x error1 print should not drop master print ============== step4 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 2000 sql_error show mnodes print error of no master @@ -56,7 +56,7 @@ sql_error drop dnode $hostname1 print error of no master print ============== step6 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 2000 sql close sql connect @@ -80,7 +80,7 @@ if $data2_2 != slave then endi print ============== step7 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sql create dnode $hostname3 sleep 5000 @@ -106,11 +106,11 @@ if $data3_3 != null then goto show7 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt23.sim b/tests/script/unique/mnode/mgmt23.sim index 8c144dd0c4..7e60ab908b 100644 --- a/tests/script/unique/mnode/mgmt23.sim +++ b/tests/script/unique/mnode/mgmt23.sim @@ -3,12 +3,12 @@ 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 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 print ============== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql show mnodes @@ -19,7 +19,7 @@ if $data2_1 != master then endi print ============== step2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname2 $x = 0 @@ -41,7 +41,7 @@ if $data2_2 != slave then endi print ============== step3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sql create dnode $hostname3 sleep 8000 @@ -85,14 +85,14 @@ if $dnode3Role != slave then return -1 endi -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s stop print ============== step5 sleep 2000 sql create dnode $hostname2 system sh/deploy.sh -n dnode2 -i 2 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 -system sh/exec_up.sh -n dnode2 -s start +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/exec.sh -n dnode2 -s start sleep 8000 sql show mnodes @@ -114,7 +114,7 @@ if $dnode3Role != slave then endi print ============== step6 -system sh/exec_up.sh -n dnode1 -s stop +system sh/exec.sh -n dnode1 -s stop sleep 10000 sql_error show mnodes @@ -122,11 +122,11 @@ sql_error show mnodes print ============== step7 sql_error drop dnode $hostname1 -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt24.sim b/tests/script/unique/mnode/mgmt24.sim index 4813d96f5f..a7bcc59ac0 100644 --- a/tests/script/unique/mnode/mgmt24.sim +++ b/tests/script/unique/mnode/mgmt24.sim @@ -3,12 +3,12 @@ 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 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 print ============== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql show mnodes @@ -19,7 +19,7 @@ if $data2_1 != master then endi print ============== step2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname2 $x = 0 @@ -41,7 +41,7 @@ if $data2_2 != slave then endi print ============== step3 -system sh/exec_up.sh -n dnode1 -s stop +system sh/exec.sh -n dnode1 -s stop sleep 2000 sql_error show mnodes @@ -49,7 +49,7 @@ print ============== step4 sql_error drop dnode $hostname1 print ============== step5 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql_error create dnode $hostname1 sql close @@ -74,11 +74,11 @@ if $data2_2 != slave then goto step5 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt25.sim b/tests/script/unique/mnode/mgmt25.sim index 8c8eeba466..9cca9c8448 100644 --- a/tests/script/unique/mnode/mgmt25.sim +++ b/tests/script/unique/mnode/mgmt25.sim @@ -3,12 +3,12 @@ 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 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 print ============== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql show mnodes @@ -19,7 +19,7 @@ if $data2_1 != master then endi print ============== step2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname2 $x = 0 @@ -41,7 +41,7 @@ if $data2_2 != slave then endi print ============== step3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sql create dnode $hostname3 sleep 6000 @@ -85,11 +85,11 @@ if $dnode3Role != slave then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt26.sim b/tests/script/unique/mnode/mgmt26.sim index 373a0abaed..9b534cca06 100644 --- a/tests/script/unique/mnode/mgmt26.sim +++ b/tests/script/unique/mnode/mgmt26.sim @@ -3,12 +3,12 @@ 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 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 print ============== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql show mnodes @@ -19,7 +19,7 @@ if $data2_1 != master then endi print ============== step2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname2 $x = 0 @@ -41,7 +41,7 @@ if $data2_2 != slave then endi print ============== step3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sql create dnode $hostname3 sleep 6000 @@ -87,11 +87,11 @@ if $dnode3Role != slave then endi print ============== step5 -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s stop system sh/deploy.sh -n dnode2 -i 2 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 sleep 5000 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname2 sleep 6000 @@ -113,11 +113,11 @@ if $dnode3Role != slave then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt33.sim b/tests/script/unique/mnode/mgmt33.sim index e3a62a2d22..205e1b05d3 100644 --- a/tests/script/unique/mnode/mgmt33.sim +++ b/tests/script/unique/mnode/mgmt33.sim @@ -3,12 +3,12 @@ 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 3 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 print ============== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql show mnodes @@ -26,7 +26,7 @@ if $data3_3 != null then endi print ============== step2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname2 sleep 8000 @@ -49,7 +49,7 @@ if $dnode3Role != null then endi print ============== step3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sql create dnode $hostname3 sleep 8000 @@ -93,12 +93,12 @@ if $dnode3Role != slave then return -1 endi -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s stop sleep 3000 system sh/deploy.sh -n dnode2 -i 2 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 -system sh/exec_up.sh -n dnode2 -s start +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/exec.sh -n dnode2 -s start print ============== step5 sql create dnode $hostname2 @@ -123,7 +123,7 @@ if $dnode3Role != slave then endi print ============== step6 -system sh/exec_up.sh -n dnode1 -s stop +system sh/exec.sh -n dnode1 -s stop sleep 10000 sql show mnodes @@ -166,11 +166,11 @@ endi # return -1 #endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmt34.sim b/tests/script/unique/mnode/mgmt34.sim index 4409c825c8..96e3133d76 100644 --- a/tests/script/unique/mnode/mgmt34.sim +++ b/tests/script/unique/mnode/mgmt34.sim @@ -5,13 +5,13 @@ 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 numOfMPeers -v 3 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 print ============== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -30,7 +30,7 @@ if $data3_3 != null then endi print ============== step2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname2 sleep 8000 @@ -58,7 +58,7 @@ if $dnode4Role != null then endi print ============== step3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sql create dnode $hostname3 sleep 8000 @@ -87,7 +87,7 @@ endi print ============== step4 -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start sql create dnode $hostname4 sleep 8000 @@ -141,12 +141,12 @@ if $dnode4Role != slave then return -1 endi -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s stop sleep 3000 system sh/deploy.sh -n dnode2 -i 2 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 -system sh/exec_up.sh -n dnode2 -s start +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/exec.sh -n dnode2 -s start print ============== step6 sql create dnode $hostname2 @@ -176,7 +176,7 @@ if $dnode4Role != slave then endi print ============== step7 -system sh/exec_up.sh -n dnode1 -s stop +system sh/exec.sh -n dnode1 -s stop sleep 4000 sql show mnodes @@ -220,11 +220,11 @@ endi # return -1 #endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmtr2.sim b/tests/script/unique/mnode/mgmtr2.sim index 625e42a334..1fba912d49 100644 --- a/tests/script/unique/mnode/mgmtr2.sim +++ b/tests/script/unique/mnode/mgmtr2.sim @@ -3,12 +3,12 @@ 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 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2 print ============== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect @@ -37,22 +37,22 @@ sql create dnode $hostname3 print ============== step3 print ========= start dnode2 and dnode3 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 1000 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 8000 -system sh/exec_up.sh -n dnode2 -s stop -system sh/exec_up.sh -n dnode3 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop sleep 4000 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start sleep 4000 -system sh/exec_up.sh -n dnode2 -s stop -system sh/exec_up.sh -n dnode3 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop sleep 4000 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start print ============== step4 sql show mnodes @@ -74,11 +74,11 @@ if $dnode3Role != null then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/balance_replica1.sim b/tests/script/unique/stable/balance_replica1.sim index 4269c2fc7f..35b5efe154 100644 --- a/tests/script/unique/stable/balance_replica1.sim +++ b/tests/script/unique/stable/balance_replica1.sim @@ -23,7 +23,7 @@ $totalNum = 200 print ============== step1 print ========= start dnode1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect $i = 0 @@ -78,7 +78,7 @@ if $dnode2Vnodes != null then endi print =============== step3 start dnode2 sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 8000 $x = 0 @@ -135,11 +135,11 @@ if $rows != 2600 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/dnode2.sim b/tests/script/unique/stable/dnode2.sim index 2d894c6542..ce80792082 100644 --- a/tests/script/unique/stable/dnode2.sim +++ b/tests/script/unique/stable/dnode2.sim @@ -7,12 +7,12 @@ 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 system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start $x = 0 createDnode: @@ -194,11 +194,11 @@ if $rows != 0 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/dnode2_stop.sim b/tests/script/unique/stable/dnode2_stop.sim index 0cf13fa286..0a801d9c7e 100644 --- a/tests/script/unique/stable/dnode2_stop.sim +++ b/tests/script/unique/stable/dnode2_stop.sim @@ -7,11 +7,11 @@ 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 system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start $x = 0 createDnode: @@ -73,7 +73,7 @@ endi sleep 100 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT print =============== step2 sql select count(*) from $mt -x step2 @@ -84,7 +84,7 @@ sql select count(tbcol) from $mt -x step21 return -1 step21: -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 10000 print =============== step3 @@ -147,11 +147,11 @@ if $rows != 0 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/dnode3.sim b/tests/script/unique/stable/dnode3.sim index 8025b180d8..714927c1bd 100644 --- a/tests/script/unique/stable/dnode3.sim +++ b/tests/script/unique/stable/dnode3.sim @@ -11,14 +11,14 @@ system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start $x = 0 createDnode: @@ -222,11 +222,11 @@ if $rows != 0 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/replica2_dnode4.sim b/tests/script/unique/stable/replica2_dnode4.sim index b96535fccd..b40d5d378b 100644 --- a/tests/script/unique/stable/replica2_dnode4.sim +++ b/tests/script/unique/stable/replica2_dnode4.sim @@ -15,16 +15,16 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start $x = 0 createDnode: @@ -212,11 +212,11 @@ if $rows != 0 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/replica2_vnode3.sim b/tests/script/unique/stable/replica2_vnode3.sim index c7882d7a96..6acdec7394 100644 --- a/tests/script/unique/stable/replica2_vnode3.sim +++ b/tests/script/unique/stable/replica2_vnode3.sim @@ -7,11 +7,11 @@ 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 system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start $x = 0 createDnode: @@ -191,11 +191,11 @@ if $rows != 0 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/replica3_dnode6.sim b/tests/script/unique/stable/replica3_dnode6.sim index 0dc81999ca..6ae6cbde2c 100644 --- a/tests/script/unique/stable/replica3_dnode6.sim +++ b/tests/script/unique/stable/replica3_dnode6.sim @@ -27,7 +27,7 @@ system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode6 -c maxtablesPerVnode -v 4 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 @@ -35,11 +35,11 @@ sql create dnode $hostname3 sql create dnode $hostname4 sql create dnode $hostname5 sql create dnode $hostname6 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start -system sh/exec_up.sh -n dnode4 -s start -system sh/exec_up.sh -n dnode5 -s start -system sh/exec_up.sh -n dnode6 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +system sh/exec.sh -n dnode6 -s start $x = 0 createDnode: @@ -239,11 +239,11 @@ if $rows != 0 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stable/replica3_vnode3.sim b/tests/script/unique/stable/replica3_vnode3.sim index fe310aa0f7..80372d25a5 100644 --- a/tests/script/unique/stable/replica3_vnode3.sim +++ b/tests/script/unique/stable/replica3_vnode3.sim @@ -16,16 +16,16 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start $x = 0 createDnode: $x = $x + 1 @@ -213,11 +213,11 @@ if $rows != 0 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/stream/metrics_balance.sim b/tests/script/unique/stream/metrics_balance.sim index 6ca5de96f6..e306da3cce 100644 --- a/tests/script/unique/stream/metrics_balance.sim +++ b/tests/script/unique/stream/metrics_balance.sim @@ -18,8 +18,8 @@ system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4 system sh/cfg.sh -n dnode1 -c tableMetaKeepTimer -v 5 system sh/cfg.sh -n dnode2 -c tableMetaKeepTimer -v 5 -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 dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 $dbPrefix = db $tbPrefix = tb diff --git a/tests/script/unique/stream/metrics_vnode_stop.sim b/tests/script/unique/stream/metrics_vnode_stop.sim index 4f85d75e7f..1f9cab48e5 100644 --- a/tests/script/unique/stream/metrics_vnode_stop.sim +++ b/tests/script/unique/stream/metrics_vnode_stop.sim @@ -6,8 +6,8 @@ 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 numOfMPeers -v 2 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 system sh/exec.sh -n dnode1 -s start sql connect diff --git a/tests/script/unique/stream/table_balance.sim b/tests/script/unique/stream/table_balance.sim index 9cb87557d1..992b4c08ee 100644 --- a/tests/script/unique/stream/table_balance.sim +++ b/tests/script/unique/stream/table_balance.sim @@ -16,8 +16,8 @@ system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 0 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 0 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -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 dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 $dbPrefix = tb_db $tbPrefix = tb_tb diff --git a/tests/script/unique/stream/table_move.sim b/tests/script/unique/stream/table_move.sim index 41fbcae4ce..0f264ade33 100644 --- a/tests/script/unique/stream/table_move.sim +++ b/tests/script/unique/stream/table_move.sim @@ -40,10 +40,10 @@ system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode1 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 3 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 1000 system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 1000 diff --git a/tests/script/unique/stream/table_vnode_stop.sim b/tests/script/unique/stream/table_vnode_stop.sim index 8528ee6755..16350949b1 100644 --- a/tests/script/unique/stream/table_vnode_stop.sim +++ b/tests/script/unique/stream/table_vnode_stop.sim @@ -6,8 +6,8 @@ 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 numOfMPeers -v 2 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2 system sh/exec.sh -n dnode1 -s start sql connect diff --git a/tests/script/unique/vnode/many.sim b/tests/script/unique/vnode/many.sim index 2b4ec01c2d..bd07d5f171 100644 --- a/tests/script/unique/vnode/many.sim +++ b/tests/script/unique/vnode/many.sim @@ -8,10 +8,10 @@ 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 numofMpeers -v 1 -system sh/cfg.sh -n dnode2 -c numofMpeers -v 1 -system sh/cfg.sh -n dnode3 -c numofMpeers -v 1 -system sh/cfg.sh -n dnode4 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 @@ -20,13 +20,13 @@ 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 system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start sleep 3000 print ========= step1 @@ -57,22 +57,22 @@ run_back unique/vnode/back_insert_many.sim sleep 5000 print ======== step3 -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s stop sleep 5000 $x = 0 loop: print ======== step4 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 5000 -system sh/exec_up.sh -n dnode3 -s stop +system sh/exec.sh -n dnode3 -s stop sleep 5000 print ======== step5 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 5000 -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s stop sleep 5000 print ======== step6 @@ -113,11 +113,11 @@ if $x < 2 then goto loop endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica2_basic2.sim b/tests/script/unique/vnode/replica2_basic2.sim index 114ac9b29f..5bd35159d5 100644 --- a/tests/script/unique/vnode/replica2_basic2.sim +++ b/tests/script/unique/vnode/replica2_basic2.sim @@ -10,10 +10,10 @@ 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 numOfMPeers -v 1 -system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1 -system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 @@ -26,13 +26,13 @@ system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 print ========= start dnodes -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect sql create dnode $hostname2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sql create dnode $hostname3 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 3000 sql reset query cache @@ -130,7 +130,7 @@ if $rows != 2 then endi print ========= step3 -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep 5000 #sql insert into d1.t1 values(now, 3) @@ -159,9 +159,9 @@ if $rows != 2 then endi print ========= step4 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 5000 -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT sleep 5000 #sql insert into d1.t1 values(now, 4) @@ -190,7 +190,7 @@ if $rows != 2 then endi print ========= step5 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 5000 sql insert into d1.t1 values(now, 5) @@ -218,11 +218,11 @@ if $rows != 3 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica2_repeat.sim b/tests/script/unique/vnode/replica2_repeat.sim index 57f51316ad..73e71c149e 100644 --- a/tests/script/unique/vnode/replica2_repeat.sim +++ b/tests/script/unique/vnode/replica2_repeat.sim @@ -8,21 +8,21 @@ 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 numofMpeers -v 1 -system sh/cfg.sh -n dnode2 -c numofMpeers -v 1 -system sh/cfg.sh -n dnode3 -c numofMpeers -v 1 -system sh/cfg.sh -n dnode4 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start sleep 3000 print ========= step1 @@ -37,22 +37,22 @@ run_back unique/vnode/back_insert.sim sleep 3000 print ======== step3 -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s stop sleep 5000 $x = 0 loop: print ======== step4 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 5000 -system sh/exec_up.sh -n dnode3 -s stop +system sh/exec.sh -n dnode3 -s stop sleep 5000 print ======== step5 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 5000 -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s stop sleep 5000 print ======== step6 @@ -71,11 +71,11 @@ if $x < 2 then goto loop endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica3_basic.sim b/tests/script/unique/vnode/replica3_basic.sim index 62910b947a..ab5bebb50d 100644 --- a/tests/script/unique/vnode/replica3_basic.sim +++ b/tests/script/unique/vnode/replica3_basic.sim @@ -6,16 +6,16 @@ system sh/deploy.sh -n dnode3 -i 3 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 dnode1 -c numofMpeers -v 3 -system sh/cfg.sh -n dnode2 -c numofMpeers -v 3 -system sh/cfg.sh -n dnode3 -c numofMpeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start sleep 3000 $N = 10 @@ -48,7 +48,7 @@ if $rows != $expect then endi print =================== step 3 -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s stop sleep 2000 $y = $x + $N $expect = $N * 2 @@ -65,7 +65,7 @@ if $rows != $expect then endi print =================== step 4 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 2000 $y = $x + $N $expect = $N * 3 @@ -82,7 +82,7 @@ if $rows != $expect then endi print =================== step 5 -system sh/exec_up.sh -n dnode3 -s stop +system sh/exec.sh -n dnode3 -s stop sleep 2000 $y = $x + $N $expect = $N * 4 @@ -99,7 +99,7 @@ if $rows != $expect then endi print =================== step 6 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 2000 $y = $x + $N $expect = $N * 5 @@ -116,7 +116,7 @@ return -1 endi print =================== step 7 -system sh/exec_up.sh -n dnode1 -s stop +system sh/exec.sh -n dnode1 -s stop sleep 2000 $y = $x + $N $expect = $N * 6 @@ -133,7 +133,7 @@ return -1 endi print =================== step 8 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sleep 2000 $y = $x + $N $expect = $N * 7 @@ -149,11 +149,11 @@ if $rows != $expect then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica3_repeat.sim b/tests/script/unique/vnode/replica3_repeat.sim index a6f423bf9a..9c3d5bbf09 100644 --- a/tests/script/unique/vnode/replica3_repeat.sim +++ b/tests/script/unique/vnode/replica3_repeat.sim @@ -8,24 +8,24 @@ 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 numofMpeers -v 1 -system sh/cfg.sh -n dnode2 -c numofMpeers -v 1 -system sh/cfg.sh -n dnode3 -c numofMpeers -v 1 -system sh/cfg.sh -n dnode4 -c numofMpeers -v 1 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 sql create dnode $hostname3 sql create dnode $hostname4 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start sleep 3000 print ========= step1 @@ -40,28 +40,28 @@ run_back unique/vnode/back_insert.sim sleep 3000 print ======== step3 -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s stop sleep 5000 $x = 0 loop: print ======== step4 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec.sh -n dnode2 -s start sleep 5000 -system sh/exec_up.sh -n dnode3 -s stop +system sh/exec.sh -n dnode3 -s stop sleep 5000 print ======== step5 -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode3 -s start sleep 5000 -system sh/exec_up.sh -n dnode4 -s stop +system sh/exec.sh -n dnode4 -s stop sleep 5000 print ======== step6 -system sh/exec_up.sh -n dnode4 -s start +system sh/exec.sh -n dnode4 -s start sleep 5000 -system sh/exec_up.sh -n dnode2 -s stop +system sh/exec.sh -n dnode2 -s stop sleep 5000 print ======== step7 @@ -80,11 +80,11 @@ if $x < 2 then goto loop endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica3_vgroup.sim b/tests/script/unique/vnode/replica3_vgroup.sim index 6315a4335c..09ca261a06 100644 --- a/tests/script/unique/vnode/replica3_vgroup.sim +++ b/tests/script/unique/vnode/replica3_vgroup.sim @@ -6,16 +6,16 @@ system sh/deploy.sh -n dnode3 -i 3 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 dnode1 -c numofMpeers -v 3 -system sh/cfg.sh -n dnode2 -c numofMpeers -v 3 -system sh/cfg.sh -n dnode3 -c numofMpeers -v 3 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec.sh -n dnode1 -s start sql connect sql create dnode $hostname2 sql create dnode $hostname3 -system sh/exec_up.sh -n dnode2 -s start -system sh/exec_up.sh -n dnode3 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start sleep 3000 $N = 10 @@ -61,11 +61,11 @@ if $rows != $expect then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -x SIGINT -system sh/exec_up.sh -n dnode2 -s stop -x SIGINT -system sh/exec_up.sh -n dnode3 -s stop -x SIGINT -system sh/exec_up.sh -n dnode4 -s stop -x SIGINT -system sh/exec_up.sh -n dnode5 -s stop -x SIGINT -system sh/exec_up.sh -n dnode6 -s stop -x SIGINT -system sh/exec_up.sh -n dnode7 -s stop -x SIGINT -system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +system sh/exec.sh -n dnode6 -s stop -x SIGINT +system sh/exec.sh -n dnode7 -s stop -x SIGINT +system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/test-all.sh b/tests/test-all.sh index a56b5eeef7..fdc607ed66 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -9,10 +9,10 @@ NC='\033[0m' echo "### run TSIM script ###" cd script -./test.sh -f basicSuite.sim 2>&1 | grep 'success\|failed\|fault' | grep -v 'default' | tee out.txt +./test.sh -f basicSuite.sim 2>&1 | grep 'success\|failed\|fault' | grep -v 'default' | tee out.log -totalSuccess=`grep 'success' out.txt | wc -l` -totalBasic=`grep success out.txt | grep Suite | wc -l` +totalSuccess=`grep 'success' out.log | wc -l` +totalBasic=`grep success out.log | grep Suite | wc -l` if [ "$totalSuccess" -gt "0" ]; then totalSuccess=`expr $totalSuccess - $totalBasic` @@ -20,7 +20,7 @@ fi echo -e "${GREEN} ### Total $totalSuccess TSIM case(s) succeed! ### ${NC}" -totalFailed=`grep 'failed\|fault' out.txt | wc -l` +totalFailed=`grep 'failed\|fault' out.log | wc -l` # echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}" if [ "$totalFailed" -ne "0" ]; then @@ -33,17 +33,17 @@ echo "### run Python script ###" cd ../pytest if [ "$1" == "cron" ]; then - ./fulltest.sh 2>&1 | grep 'successfully executed\|failed\|fault' | grep -v 'default'| tee pytest-out.txt + ./fulltest.sh 2>&1 | grep 'successfully executed\|failed\|fault' | grep -v 'default'| tee pytest-out.log else - ./smoketest.sh 2>&1 | grep 'successfully executed\|failed\|fault' | grep -v 'default'| tee pytest-out.txt + ./smoketest.sh 2>&1 | grep 'successfully executed\|failed\|fault' | grep -v 'default'| tee pytest-out.log fi -totalPySuccess=`grep 'successfully executed' pytest-out.txt | wc -l` +totalPySuccess=`grep 'successfully executed' pytest-out.log | wc -l` if [ "$totalPySuccess" -gt "0" ]; then echo -e "${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}" fi -totalPyFailed=`grep 'failed\|fault' pytest-out.txt | wc -l` +totalPyFailed=`grep 'failed\|fault' pytest-out.log | wc -l` if [ "$totalPyFailed" -ne "0" ]; then echo -e "${RED} ### Total $totalPyFailed python case(s) failed! ### ${NC}" # exit $totalPyFailed