提交 cbab8f42 编写于 作者: C Cary Xu

Merge branch '3.0' into feature/TD-11274-3.0

...@@ -103,6 +103,7 @@ typedef struct SIndefRowsFuncLogicNode { ...@@ -103,6 +103,7 @@ typedef struct SIndefRowsFuncLogicNode {
SLogicNode node; SLogicNode node;
SNodeList* pFuncs; SNodeList* pFuncs;
bool isTailFunc; bool isTailFunc;
bool isUniqueFunc;
} SIndefRowsFuncLogicNode; } SIndefRowsFuncLogicNode;
typedef struct SInterpFuncLogicNode { typedef struct SInterpFuncLogicNode {
......
...@@ -50,6 +50,7 @@ typedef struct SExprNode { ...@@ -50,6 +50,7 @@ typedef struct SExprNode {
char aliasName[TSDB_COL_NAME_LEN]; char aliasName[TSDB_COL_NAME_LEN];
char userAlias[TSDB_COL_NAME_LEN]; char userAlias[TSDB_COL_NAME_LEN];
SArray* pAssociation; SArray* pAssociation;
bool orderAlias;
} SExprNode; } SExprNode;
typedef enum EColumnType { COLUMN_TYPE_COLUMN = 1, COLUMN_TYPE_TAG, COLUMN_TYPE_TBNAME } EColumnType; typedef enum EColumnType { COLUMN_TYPE_COLUMN = 1, COLUMN_TYPE_TAG, COLUMN_TYPE_TBNAME } EColumnType;
......
...@@ -48,6 +48,8 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo ...@@ -48,6 +48,8 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
// @pSource one execution location of this group of datasource subplans // @pSource one execution location of this group of datasource subplans
int32_t qSetSubplanExecutionNode(SSubplan* pSubplan, int32_t groupId, SDownstreamSourceNode* pSource); int32_t qSetSubplanExecutionNode(SSubplan* pSubplan, int32_t groupId, SDownstreamSourceNode* pSource);
int32_t qClearSubplanExecutionNode(SSubplan* pSubplan, int32_t groupId);
// Convert to subplan to string for the scheduler to send to the executor // Convert to subplan to string for the scheduler to send to the executor
int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen); int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen);
int32_t qStringToSubplan(const char* pStr, SSubplan** pSubplan); int32_t qStringToSubplan(const char* pStr, SSubplan** pSubplan);
......
...@@ -271,19 +271,19 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t ...@@ -271,19 +271,19 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
#define qDebug(...) \ #define qDebug(...) \
do { \ do { \
if (qDebugFlag & DEBUG_DEBUG) { \ if (qDebugFlag & DEBUG_DEBUG) { \
taosPrintLog("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \ taosPrintLog("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
} \ } \
} while (0) } while (0)
#define qTrace(...) \ #define qTrace(...) \
do { \ do { \
if (qDebugFlag & DEBUG_TRACE) { \ if (qDebugFlag & DEBUG_TRACE) { \
taosPrintLog("QRY ", DEBUG_TRACE, qDebugFlag, __VA_ARGS__); \ taosPrintLog("QRY ", DEBUG_TRACE, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
} \ } \
} while (0) } while (0)
#define qDebugL(...) \ #define qDebugL(...) \
do { \ do { \
if (qDebugFlag & DEBUG_DEBUG) { \ if (qDebugFlag & DEBUG_DEBUG) { \
taosPrintLongString("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \ taosPrintLongString("QRY ", DEBUG_DEBUG, tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__); \
} \ } \
} while (0) } while (0)
......
...@@ -1052,7 +1052,8 @@ static int32_t translateUniqueMode(SFunctionNode* pFunc, char* pErrBuf, int32_t ...@@ -1052,7 +1052,8 @@ static int32_t translateUniqueMode(SFunctionNode* pFunc, char* pErrBuf, int32_t
SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0);
if (!nodesExprHasColumn(pPara)) { if (!nodesExprHasColumn(pPara)) {
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "The parameters of %s must contain columns", isUnique ? "UNIQUE" : "MODE"); return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "The parameters of %s must contain columns",
isUnique ? "UNIQUE" : "MODE");
} }
pFunc->node.resType = ((SExprNode*)pPara)->resType; pFunc->node.resType = ((SExprNode*)pPara)->resType;
...@@ -1228,19 +1229,19 @@ static int32_t translateSubstr(SFunctionNode* pFunc, char* pErrBuf, int32_t len) ...@@ -1228,19 +1229,19 @@ static int32_t translateSubstr(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
// The number of parameters has been limited by the syntax definition // The number of parameters has been limited by the syntax definition
//uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; // uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
// The function return type has been set during syntax parsing // The function return type has been set during syntax parsing
uint8_t para2Type = pFunc->node.resType.type; uint8_t para2Type = pFunc->node.resType.type;
//if (para2Type != TSDB_DATA_TYPE_BIGINT && para2Type != TSDB_DATA_TYPE_UBIGINT && // if (para2Type != TSDB_DATA_TYPE_BIGINT && para2Type != TSDB_DATA_TYPE_UBIGINT &&
// para2Type != TSDB_DATA_TYPE_VARCHAR && para2Type != TSDB_DATA_TYPE_NCHAR && // para2Type != TSDB_DATA_TYPE_VARCHAR && para2Type != TSDB_DATA_TYPE_NCHAR &&
// para2Type != TSDB_DATA_TYPE_TIMESTAMP) { // para2Type != TSDB_DATA_TYPE_TIMESTAMP) {
// return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); // return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
//} // }
//if ((para2Type == TSDB_DATA_TYPE_TIMESTAMP && IS_VAR_DATA_TYPE(para1Type)) || // if ((para2Type == TSDB_DATA_TYPE_TIMESTAMP && IS_VAR_DATA_TYPE(para1Type)) ||
// (para2Type == TSDB_DATA_TYPE_BINARY && para1Type == TSDB_DATA_TYPE_NCHAR)) { // (para2Type == TSDB_DATA_TYPE_BINARY && para1Type == TSDB_DATA_TYPE_NCHAR)) {
// return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); // return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
//} // }
int32_t para2Bytes = pFunc->node.resType.bytes; int32_t para2Bytes = pFunc->node.resType.bytes;
if (IS_VAR_DATA_TYPE(para2Type)) { if (IS_VAR_DATA_TYPE(para2Type)) {
...@@ -1890,7 +1891,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -1890,7 +1891,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{ {
.name = "first", .name = "first",
.type = FUNCTION_TYPE_FIRST, .type = FUNCTION_TYPE_FIRST,
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC,
.translateFunc = translateFirstLast, .translateFunc = translateFirstLast,
.getEnvFunc = getFirstLastFuncEnv, .getEnvFunc = getFirstLastFuncEnv,
.initFunc = functionSetup, .initFunc = functionSetup,
...@@ -1925,7 +1926,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -1925,7 +1926,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{ {
.name = "last", .name = "last",
.type = FUNCTION_TYPE_LAST, .type = FUNCTION_TYPE_LAST,
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC,
.translateFunc = translateFirstLast, .translateFunc = translateFirstLast,
.getEnvFunc = getFirstLastFuncEnv, .getEnvFunc = getFirstLastFuncEnv,
.initFunc = functionSetup, .initFunc = functionSetup,
...@@ -2117,7 +2118,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -2117,7 +2118,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{ {
.name = "unique", .name = "unique",
.type = FUNCTION_TYPE_UNIQUE, .type = FUNCTION_TYPE_UNIQUE,
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | .classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC |
FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC | FUNC_MGT_FORBID_GROUP_BY_FUNC, FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC | FUNC_MGT_FORBID_GROUP_BY_FUNC,
.translateFunc = translateUnique, .translateFunc = translateUnique,
.getEnvFunc = getUniqueFuncEnv, .getEnvFunc = getUniqueFuncEnv,
......
...@@ -100,6 +100,7 @@ static int32_t exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) { ...@@ -100,6 +100,7 @@ static int32_t exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) {
COPY_OBJECT_FIELD(resType, sizeof(SDataType)); COPY_OBJECT_FIELD(resType, sizeof(SDataType));
COPY_CHAR_ARRAY_FIELD(aliasName); COPY_CHAR_ARRAY_FIELD(aliasName);
COPY_CHAR_ARRAY_FIELD(userAlias); COPY_CHAR_ARRAY_FIELD(userAlias);
COPY_SCALAR_FIELD(orderAlias);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -1500,7 +1500,8 @@ typedef struct SCollectFuncsCxt { ...@@ -1500,7 +1500,8 @@ typedef struct SCollectFuncsCxt {
static EDealRes collectFuncs(SNode* pNode, void* pContext) { static EDealRes collectFuncs(SNode* pNode, void* pContext) {
SCollectFuncsCxt* pCxt = (SCollectFuncsCxt*)pContext; SCollectFuncsCxt* pCxt = (SCollectFuncsCxt*)pContext;
if (QUERY_NODE_FUNCTION == nodeType(pNode) && pCxt->classifier(((SFunctionNode*)pNode)->funcId)) { if (QUERY_NODE_FUNCTION == nodeType(pNode) && pCxt->classifier(((SFunctionNode*)pNode)->funcId) &&
!(((SExprNode*)pNode)->orderAlias)) {
pCxt->errCode = nodesListStrictAppend(pCxt->pFuncs, nodesCloneNode(pNode)); pCxt->errCode = nodesListStrictAppend(pCxt->pFuncs, nodesCloneNode(pNode));
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR); return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
} }
......
...@@ -1355,25 +1355,6 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode ...@@ -1355,25 +1355,6 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode
return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR; return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR;
} }
static EDealRes rewriteExprToGroupKeyFunc(STranslateContext* pCxt, SNode** pNode) {
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
if (NULL == pFunc) {
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
return DEAL_RES_ERROR;
}
strcpy(pFunc->functionName, "_group_key");
strcpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName);
pCxt->errCode = nodesListMakeAppend(&pFunc->pParameterList, *pNode);
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
*pNode = (SNode*)pFunc;
pCxt->errCode = fmGetFuncInfo(pFunc, pCxt->msgBuf.buf, pCxt->msgBuf.len);
}
pCxt->pCurrSelectStmt->hasAggFuncs = true;
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
}
static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
SCheckExprForGroupByCxt* pCxt = (SCheckExprForGroupByCxt*)pContext; SCheckExprForGroupByCxt* pCxt = (SCheckExprForGroupByCxt*)pContext;
if (!nodesIsExprNode(*pNode) || isAliasColumn(*pNode)) { if (!nodesIsExprNode(*pNode) || isAliasColumn(*pNode)) {
...@@ -1393,7 +1374,13 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { ...@@ -1393,7 +1374,13 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
SNode* pGroupNode = NULL; SNode* pGroupNode = NULL;
FOREACH(pGroupNode, getGroupByList(pCxt->pTranslateCxt)) { FOREACH(pGroupNode, getGroupByList(pCxt->pTranslateCxt)) {
if (nodesEqualNode(getGroupByNode(pGroupNode), *pNode)) { if (nodesEqualNode(getGroupByNode(pGroupNode), *pNode)) {
return rewriteExprToGroupKeyFunc(pCxt->pTranslateCxt, pNode); return DEAL_RES_IGNORE_CHILD;
}
}
SNode* pPartKey = NULL;
FOREACH(pPartKey, pCxt->pTranslateCxt->pCurrSelectStmt->pPartitionByList) {
if (nodesEqualNode(pPartKey, *pNode)) {
return DEAL_RES_IGNORE_CHILD;
} }
} }
if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) { if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) {
...@@ -1451,25 +1438,6 @@ static int32_t rewriteColsToSelectValFunc(STranslateContext* pCxt, SSelectStmt* ...@@ -1451,25 +1438,6 @@ static int32_t rewriteColsToSelectValFunc(STranslateContext* pCxt, SSelectStmt*
return pCxt->errCode; return pCxt->errCode;
} }
static EDealRes rewriteExprsToGroupKeyFuncImpl(SNode** pNode, void* pContext) {
STranslateContext* pCxt = pContext;
SNode* pPartKey = NULL;
FOREACH(pPartKey, pCxt->pCurrSelectStmt->pPartitionByList) {
if (nodesEqualNode(pPartKey, *pNode)) {
return rewriteExprToGroupKeyFunc(pCxt, pNode);
}
}
return DEAL_RES_CONTINUE;
}
static int32_t rewriteExprsToGroupKeyFunc(STranslateContext* pCxt, SSelectStmt* pSelect) {
nodesRewriteExprs(pSelect->pProjectionList, rewriteExprsToGroupKeyFuncImpl, pCxt);
if (TSDB_CODE_SUCCESS == pCxt->errCode && !pSelect->isDistinct) {
nodesRewriteExprs(pSelect->pOrderByList, rewriteExprsToGroupKeyFuncImpl, pCxt);
}
return pCxt->errCode;
}
typedef struct CheckAggColCoexistCxt { typedef struct CheckAggColCoexistCxt {
STranslateContext* pTranslateCxt; STranslateContext* pTranslateCxt;
bool existAggFunc; bool existAggFunc;
...@@ -1529,9 +1497,6 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) ...@@ -1529,9 +1497,6 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
if (cxt.existIndefiniteRowsFunc && cxt.existCol) { if (cxt.existIndefiniteRowsFunc && cxt.existCol) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
} }
if (cxt.existAggFunc && NULL != pSelect->pPartitionByList) {
return rewriteExprsToGroupKeyFunc(pCxt, pSelect);
}
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -2408,54 +2373,6 @@ static EDealRes rewriteSeletcValueFunc(STranslateContext* pCxt, SNode** pNode) { ...@@ -2408,54 +2373,6 @@ static EDealRes rewriteSeletcValueFunc(STranslateContext* pCxt, SNode** pNode) {
return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR; return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR;
} }
static EDealRes rewriteUniqueFunc(SNode** pNode, void* pContext) {
SRwriteUniqueCxt* pCxt = pContext;
if (QUERY_NODE_FUNCTION == nodeType(*pNode)) {
SFunctionNode* pFunc = (SFunctionNode*)*pNode;
if (FUNCTION_TYPE_UNIQUE == pFunc->funcType) {
SNode* pExpr = nodesListGetNode(pFunc->pParameterList, 0);
NODES_CLEAR_LIST(pFunc->pParameterList);
strcpy(((SExprNode*)pExpr)->aliasName, ((SExprNode*)*pNode)->aliasName);
nodesDestroyNode(*pNode);
*pNode = pExpr;
pCxt->pExpr = pExpr;
return DEAL_RES_IGNORE_CHILD;
} else if (FUNCTION_TYPE_SELECT_VALUE == pFunc->funcType) {
return rewriteSeletcValueFunc(pCxt->pTranslateCxt, pNode);
}
}
return DEAL_RES_CONTINUE;
}
static SNode* createGroupingSet(SNode* pExpr) {
SGroupingSetNode* pGroupingSet = (SGroupingSetNode*)nodesMakeNode(QUERY_NODE_GROUPING_SET);
if (NULL == pGroupingSet) {
return NULL;
}
pGroupingSet->groupingSetType = GP_TYPE_NORMAL;
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pGroupingSet->pParameterList, nodesCloneNode(pExpr))) {
nodesDestroyNode((SNode*)pGroupingSet);
return NULL;
}
return (SNode*)pGroupingSet;
}
// from: select unique(expr), col1 + col2 from t where_clause partition_by_clause order_by_clause ...
// to: select expr, first(col1) + first(col2) from t where_clause partition_by_clause group by expr order_by_clause ...
static int32_t rewriteUniqueStmt(STranslateContext* pCxt, SSelectStmt* pSelect) {
if (!pSelect->hasUniqueFunc) {
return TSDB_CODE_SUCCESS;
}
SRwriteUniqueCxt cxt = {.pTranslateCxt = pCxt, .pExpr = NULL};
nodesRewriteExprs(pSelect->pProjectionList, rewriteUniqueFunc, &cxt);
if (TSDB_CODE_SUCCESS == cxt.pTranslateCxt->errCode) {
cxt.pTranslateCxt->errCode = nodesListMakeStrictAppend(&pSelect->pGroupByList, createGroupingSet(cxt.pExpr));
}
pSelect->hasIndefiniteRowsFunc = false;
return cxt.pTranslateCxt->errCode;
}
typedef struct SReplaceOrderByAliasCxt { typedef struct SReplaceOrderByAliasCxt {
STranslateContext* pTranslateCxt; STranslateContext* pTranslateCxt;
SNodeList* pProjectionList; SNodeList* pProjectionList;
...@@ -2474,6 +2391,7 @@ static EDealRes replaceOrderByAliasImpl(SNode** pNode, void* pContext) { ...@@ -2474,6 +2391,7 @@ static EDealRes replaceOrderByAliasImpl(SNode** pNode, void* pContext) {
pCxt->pTranslateCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; pCxt->pTranslateCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
return DEAL_RES_ERROR; return DEAL_RES_ERROR;
} }
((SExprNode*)pNew)->orderAlias = true;
nodesDestroyNode(*pNode); nodesDestroyNode(*pNode);
*pNode = pNew; *pNode = pNew;
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
...@@ -2529,9 +2447,6 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect ...@@ -2529,9 +2447,6 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = translateInterp(pCxt, pSelect); code = translateInterp(pCxt, pSelect);
} }
if (TSDB_CODE_SUCCESS == code) {
code = rewriteUniqueStmt(pCxt, pSelect);
}
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = rewriteTimelineFunc(pCxt, pSelect); code = rewriteTimelineFunc(pCxt, pSelect);
} }
......
...@@ -232,8 +232,6 @@ TEST_F(ParserSelectTest, groupBySemanticCheck) { ...@@ -232,8 +232,6 @@ TEST_F(ParserSelectTest, groupBySemanticCheck) {
run("SELECT COUNT(*) cnt, c1 FROM t1 WHERE c1 > 0", TSDB_CODE_PAR_NOT_SINGLE_GROUP); run("SELECT COUNT(*) cnt, c1 FROM t1 WHERE c1 > 0", TSDB_CODE_PAR_NOT_SINGLE_GROUP);
run("SELECT COUNT(*) cnt, c2 FROM t1 WHERE c1 > 0 GROUP BY c1", TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION); run("SELECT COUNT(*) cnt, c2 FROM t1 WHERE c1 > 0 GROUP BY c1", TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION);
run("SELECT COUNT(*) cnt, c2 FROM t1 WHERE c1 > 0 PARTITION BY c2 GROUP BY c1",
TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION);
} }
TEST_F(ParserSelectTest, orderBy) { TEST_F(ParserSelectTest, orderBy) {
......
...@@ -437,6 +437,33 @@ static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr) ...@@ -437,6 +437,33 @@ static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr)
return pCol; return pCol;
} }
static SNode* createGroupingSetNode(SNode* pExpr) {
SGroupingSetNode* pGroupingSet = (SGroupingSetNode*)nodesMakeNode(QUERY_NODE_GROUPING_SET);
if (NULL == pGroupingSet) {
return NULL;
}
pGroupingSet->groupingSetType = GP_TYPE_NORMAL;
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pGroupingSet->pParameterList, nodesCloneNode(pExpr))) {
nodesDestroyNode((SNode*)pGroupingSet);
return NULL;
}
return (SNode*)pGroupingSet;
}
static int32_t createGroupKeysFromPartKeys(SNodeList* pPartKeys, SNodeList** pOutput) {
SNodeList* pGroupKeys = NULL;
SNode* pPartKey = NULL;
FOREACH(pPartKey, pPartKeys) {
int32_t code = nodesListMakeStrictAppend(&pGroupKeys, createGroupingSetNode(pPartKey));
if (TSDB_CODE_SUCCESS != code) {
nodesDestroyList(pGroupKeys);
return code;
}
}
*pOutput = pGroupKeys;
return TSDB_CODE_SUCCESS;
}
static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
if (!pSelect->hasAggFuncs && NULL == pSelect->pGroupByList) { if (!pSelect->hasAggFuncs && NULL == pSelect->pGroupByList) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -459,10 +486,18 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, ...@@ -459,10 +486,18 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
code = rewriteExprsForSelect(pAgg->pAggFuncs, pSelect, SQL_CLAUSE_GROUP_BY); code = rewriteExprsForSelect(pAgg->pAggFuncs, pSelect, SQL_CLAUSE_GROUP_BY);
} }
if (NULL != pSelect->pPartitionByList) {
code = createGroupKeysFromPartKeys(pSelect->pPartitionByList, &pAgg->pGroupKeys);
}
if (NULL != pSelect->pGroupByList) { if (NULL != pSelect->pGroupByList) {
pAgg->pGroupKeys = nodesCloneList(pSelect->pGroupByList); if (NULL != pAgg->pGroupKeys) {
if (NULL == pAgg->pGroupKeys) { code = nodesListStrictAppendList(pAgg->pGroupKeys, nodesCloneList(pSelect->pGroupByList));
code = TSDB_CODE_OUT_OF_MEMORY; } else {
pAgg->pGroupKeys = nodesCloneList(pSelect->pGroupByList);
if (NULL == pAgg->pGroupKeys) {
code = TSDB_CODE_OUT_OF_MEMORY;
}
} }
} }
...@@ -508,6 +543,7 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt ...@@ -508,6 +543,7 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt
} }
pIdfRowsFunc->isTailFunc = pSelect->hasTailFunc; pIdfRowsFunc->isTailFunc = pSelect->hasTailFunc;
pIdfRowsFunc->isUniqueFunc = pSelect->hasUniqueFunc;
// indefinite rows functions and _select_values functions // indefinite rows functions and _select_values functions
int32_t code = nodesCollectFuncs(pSelect, SQL_CLAUSE_SELECT, fmIsVectorFunc, &pIdfRowsFunc->pFuncs); int32_t code = nodesCollectFuncs(pSelect, SQL_CLAUSE_SELECT, fmIsVectorFunc, &pIdfRowsFunc->pFuncs);
...@@ -809,7 +845,8 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel ...@@ -809,7 +845,8 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
} }
static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
if (NULL == pSelect->pPartitionByList) { if (NULL == pSelect->pPartitionByList || (pSelect->hasAggFuncs && NULL == pSelect->pWindow) ||
NULL != pSelect->pGroupByList) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -987,6 +987,7 @@ static int32_t smaIndexOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogi ...@@ -987,6 +987,7 @@ static int32_t smaIndexOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogi
code = smaIndexOptApplyIndex(pLogicSubplan, pScan, pIndex, pSmaCols, wstrartIndex); code = smaIndexOptApplyIndex(pLogicSubplan, pScan, pIndex, pSmaCols, wstrartIndex);
taosArrayDestroyEx(pScan->pSmaIndexes, smaIndexOptDestroySmaIndex); taosArrayDestroyEx(pScan->pSmaIndexes, smaIndexOptDestroySmaIndex);
pScan->pSmaIndexes = NULL; pScan->pSmaIndexes = NULL;
pCxt->optimized = true;
break; break;
} }
} }
...@@ -1033,12 +1034,30 @@ static SNodeList* partTagsGetPartKeys(SLogicNode* pNode) { ...@@ -1033,12 +1034,30 @@ static SNodeList* partTagsGetPartKeys(SLogicNode* pNode) {
} }
} }
static SNodeList* partTagsGetFuncs(SLogicNode* pNode) {
if (QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode)) {
return NULL;
} else {
return ((SAggLogicNode*)pNode)->pAggFuncs;
}
}
static bool partTagsOptAreSupportedFuncs(SNodeList* pFuncs) {
SNode* pFunc = NULL;
FOREACH(pFunc, pFuncs) {
if (fmIsIndefiniteRowsFunc(((SFunctionNode*)pFunc)->funcId) && !fmIsSelectFunc(((SFunctionNode*)pFunc)->funcId)) {
return false;
}
}
return true;
}
static bool partTagsOptMayBeOptimized(SLogicNode* pNode) { static bool partTagsOptMayBeOptimized(SLogicNode* pNode) {
if (!partTagsIsOptimizableNode(pNode)) { if (!partTagsIsOptimizableNode(pNode)) {
return false; return false;
} }
return !partTagsOptHasCol(partTagsGetPartKeys(pNode)); return !partTagsOptHasCol(partTagsGetPartKeys(pNode)) && partTagsOptAreSupportedFuncs(partTagsGetFuncs(pNode));
} }
static EDealRes partTagsOptRebuildTbanmeImpl(SNode** pNode, void* pContext) { static EDealRes partTagsOptRebuildTbanmeImpl(SNode** pNode, void* pContext) {
...@@ -1064,6 +1083,59 @@ static int32_t partTagsOptRebuildTbanme(SNodeList* pPartKeys) { ...@@ -1064,6 +1083,59 @@ static int32_t partTagsOptRebuildTbanme(SNodeList* pPartKeys) {
return code; return code;
} }
static SNode* partTagsCreateWrapperFunc(const char* pFuncName, SNode* pNode) {
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
if (NULL == pFunc) {
return NULL;
}
strcpy(pFunc->functionName, pFuncName);
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
SColumnNode* pCol = (SColumnNode*)pNode;
sprintf(pFunc->node.aliasName, "%s.%s", pCol->tableAlias, pCol->colName);
} else {
strcpy(pFunc->node.aliasName, ((SExprNode*)pNode)->aliasName);
}
int32_t code = nodesListMakeStrictAppend(&pFunc->pParameterList, nodesCloneNode(pNode));
if (TSDB_CODE_SUCCESS == code) {
code = fmGetFuncInfo(pFunc, NULL, 0);
}
if (TSDB_CODE_SUCCESS != code) {
nodesDestroyNode((SNode*)pFunc);
return NULL;
}
return (SNode*)pFunc;
}
static bool partTagsHasIndefRowsSelectFunc(SNodeList* pFuncs) {
SNode* pFunc = NULL;
FOREACH(pFunc, pFuncs) {
if (fmIsIndefiniteRowsFunc(((SFunctionNode*)pFunc)->funcId)) {
return true;
}
}
return false;
}
static int32_t partTagsRewriteGroupTagsToFuncs(SNodeList* pGroupTags, SNodeList* pAggFuncs) {
bool hasIndefRowsSelectFunc = partTagsHasIndefRowsSelectFunc(pAggFuncs);
int32_t code = TSDB_CODE_SUCCESS;
SNode* pNode = NULL;
FOREACH(pNode, pGroupTags) {
if (hasIndefRowsSelectFunc) {
code = nodesListStrictAppend(pAggFuncs, partTagsCreateWrapperFunc("_select_value", pNode));
} else {
code = nodesListStrictAppend(pAggFuncs, partTagsCreateWrapperFunc("_group_key", pNode));
}
if (TSDB_CODE_SUCCESS != code) {
break;
}
}
return code;
}
static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) {
SLogicNode* pNode = optFindPossibleNode(pLogicSubplan->pNode, partTagsOptMayBeOptimized); SLogicNode* pNode = optFindPossibleNode(pLogicSubplan->pNode, partTagsOptMayBeOptimized);
if (NULL == pNode) { if (NULL == pNode) {
...@@ -1080,15 +1152,17 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub ...@@ -1080,15 +1152,17 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
nodesDestroyNode((SNode*)pNode); nodesDestroyNode((SNode*)pNode);
} }
} else { } else {
SNode* pGroupKey = NULL; SAggLogicNode* pAgg = (SAggLogicNode*)pNode;
FOREACH(pGroupKey, ((SAggLogicNode*)pNode)->pGroupKeys) { SNode* pGroupKey = NULL;
FOREACH(pGroupKey, pAgg->pGroupKeys) {
code = nodesListMakeStrictAppend( code = nodesListMakeStrictAppend(
&pScan->pGroupTags, nodesCloneNode(nodesListGetNode(((SGroupingSetNode*)pGroupKey)->pParameterList, 0))); &pScan->pGroupTags, nodesCloneNode(nodesListGetNode(((SGroupingSetNode*)pGroupKey)->pParameterList, 0)));
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {
break; break;
} }
} }
NODES_DESTORY_LIST(((SAggLogicNode*)pNode)->pGroupKeys); NODES_DESTORY_LIST(pAgg->pGroupKeys);
code = partTagsRewriteGroupTagsToFuncs(pScan->pGroupTags, pAgg->pAggFuncs);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = partTagsOptRebuildTbanme(pScan->pGroupTags); code = partTagsOptRebuildTbanme(pScan->pGroupTags);
...@@ -1125,7 +1199,8 @@ static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) { ...@@ -1125,7 +1199,8 @@ static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) {
} }
SProjectLogicNode* pProjectNode = (SProjectLogicNode*)pNode; SProjectLogicNode* pProjectNode = (SProjectLogicNode*)pNode;
if (NULL != pProjectNode->node.pLimit || NULL != pProjectNode->node.pSlimit) { if (NULL != pProjectNode->node.pLimit || NULL != pProjectNode->node.pSlimit ||
NULL != pProjectNode->node.pConditions) {
return false; return false;
} }
...@@ -1163,6 +1238,7 @@ static int32_t eliminateProjOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* ...@@ -1163,6 +1238,7 @@ static int32_t eliminateProjOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan*
NODES_CLEAR_LIST(pProjectNode->node.pChildren); NODES_CLEAR_LIST(pProjectNode->node.pChildren);
nodesDestroyNode((SNode*)pProjectNode); nodesDestroyNode((SNode*)pProjectNode);
} }
pCxt->optimized = true;
return code; return code;
} }
...@@ -1306,6 +1382,7 @@ static int32_t rewriteTailOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL ...@@ -1306,6 +1382,7 @@ static int32_t rewriteTailOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL
nodesDestroyNode((SNode*)pSort); nodesDestroyNode((SNode*)pSort);
nodesDestroyNode((SNode*)pProject); nodesDestroyNode((SNode*)pProject);
} }
pCxt->optimized = true;
return code; return code;
} }
...@@ -1344,6 +1421,7 @@ static int32_t eliminateSetOpOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* ...@@ -1344,6 +1421,7 @@ static int32_t eliminateSetOpOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan*
pSetOpNode->pChildren = NULL; pSetOpNode->pChildren = NULL;
ERASE_NODE(pSetOpNode->pParent->pChildren); ERASE_NODE(pSetOpNode->pParent->pChildren);
pCxt->optimized = true;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
} }
...@@ -1360,15 +1438,192 @@ static int32_t eliminateSetOpOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLo ...@@ -1360,15 +1438,192 @@ static int32_t eliminateSetOpOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLo
return eliminateSetOpOptimizeImpl(pCxt, pLogicSubplan, pSetOpNode); return eliminateSetOpOptimizeImpl(pCxt, pLogicSubplan, pSetOpNode);
} }
//=================================================================================================================== static bool rewriteUniqueOptMayBeOptimized(SLogicNode* pNode) {
return QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC == nodeType(pNode) && ((SIndefRowsFuncLogicNode*)pNode)->isUniqueFunc;
}
static SNode* rewriteUniqueOptCreateGroupingSet(SNode* pExpr) {
SGroupingSetNode* pGroupingSet = (SGroupingSetNode*)nodesMakeNode(QUERY_NODE_GROUPING_SET);
if (NULL == pGroupingSet) {
return NULL;
}
pGroupingSet->groupingSetType = GP_TYPE_NORMAL;
SExprNode* pGroupExpr = (SExprNode*)nodesCloneNode(pExpr);
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pGroupingSet->pParameterList, (SNode*)pGroupExpr)) {
nodesDestroyNode((SNode*)pGroupingSet);
return NULL;
}
return (SNode*)pGroupingSet;
}
static SNode* rewriteUniqueOptCreateFirstFunc(SFunctionNode* pSelectValue, SNode* pCol) {
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
if (NULL == pFunc) {
return NULL;
}
strcpy(pFunc->functionName, "first");
if (NULL != pSelectValue) {
sprintf(pFunc->node.aliasName, "%s", pSelectValue->node.aliasName);
} else {
sprintf(pFunc->node.aliasName, "%s.%p", pFunc->functionName, pFunc);
}
int32_t code = nodesListMakeStrictAppend(&pFunc->pParameterList, nodesCloneNode(pCol));
if (TSDB_CODE_SUCCESS == code) {
code = fmGetFuncInfo(pFunc, NULL, 0);
}
if (TSDB_CODE_SUCCESS != code) {
nodesDestroyNode((SNode*)pFunc);
return NULL;
}
return (SNode*)pFunc;
}
static int32_t rewriteUniqueOptCreateAgg(SIndefRowsFuncLogicNode* pIndef, SLogicNode** pOutput) {
SAggLogicNode* pAgg = (SAggLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_AGG);
if (NULL == pAgg) {
return TSDB_CODE_OUT_OF_MEMORY;
}
TSWAP(pAgg->node.pChildren, pIndef->node.pChildren);
pAgg->node.precision = pIndef->node.precision;
int32_t code = TSDB_CODE_SUCCESS;
bool hasSelectPrimaryKey = false;
SNode* pPrimaryKey = NULL;
SNode* pNode = NULL;
FOREACH(pNode, pIndef->pFuncs) {
SFunctionNode* pFunc = (SFunctionNode*)pNode;
SNode* pExpr = nodesListGetNode(pFunc->pParameterList, 0);
if (FUNCTION_TYPE_UNIQUE == pFunc->funcType) {
pPrimaryKey = nodesListGetNode(pFunc->pParameterList, 1);
code = nodesListMakeStrictAppend(&pAgg->pGroupKeys, rewriteUniqueOptCreateGroupingSet(pExpr));
} else if (PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pExpr)->colId) { // _select_value(ts) => first(ts)
hasSelectPrimaryKey = true;
code = nodesListMakeStrictAppend(&pAgg->pAggFuncs, rewriteUniqueOptCreateFirstFunc(pFunc, pExpr));
} else { // _select_value(other_col)
code = nodesListMakeStrictAppend(&pAgg->pAggFuncs, nodesCloneNode(pNode));
}
if (TSDB_CODE_SUCCESS != code) {
break;
}
}
if (TSDB_CODE_SUCCESS == code) {
code = createColumnByRewriteExprs(pAgg->pGroupKeys, &pAgg->node.pTargets);
}
if (TSDB_CODE_SUCCESS == code && NULL != pAgg->pAggFuncs) {
code = createColumnByRewriteExprs(pAgg->pAggFuncs, &pAgg->node.pTargets);
}
if (TSDB_CODE_SUCCESS == code && !hasSelectPrimaryKey && NULL != pAgg->pAggFuncs) {
code = nodesListMakeStrictAppend(&pAgg->pAggFuncs, rewriteUniqueOptCreateFirstFunc(NULL, pPrimaryKey));
}
if (TSDB_CODE_SUCCESS == code) {
*pOutput = (SLogicNode*)pAgg;
} else {
nodesDestroyNode((SNode*)pAgg);
}
return code;
}
static SNode* rewriteUniqueOptCreateProjectCol(SFunctionNode* pFunc) {
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
if (NULL == pCol) {
return NULL;
}
pCol->node.resType = pFunc->node.resType;
if (FUNCTION_TYPE_UNIQUE == pFunc->funcType) {
SExprNode* pExpr = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0);
if (QUERY_NODE_COLUMN == nodeType(pExpr)) {
strcpy(pCol->tableAlias, ((SColumnNode*)pExpr)->tableAlias);
strcpy(pCol->colName, ((SColumnNode*)pExpr)->colName);
} else {
strcpy(pCol->colName, pExpr->aliasName);
}
} else {
strcpy(pCol->colName, pFunc->node.aliasName);
}
strcpy(pCol->node.aliasName, pFunc->node.aliasName);
return (SNode*)pCol;
}
static int32_t rewriteUniqueOptCreateProject(SIndefRowsFuncLogicNode* pIndef, SLogicNode** pOutput) {
SProjectLogicNode* pProject = (SProjectLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PROJECT);
if (NULL == pProject) {
return TSDB_CODE_OUT_OF_MEMORY;
}
TSWAP(pProject->node.pTargets, pIndef->node.pTargets);
pProject->node.precision = pIndef->node.precision;
int32_t code = TSDB_CODE_SUCCESS;
SNode* pNode = NULL;
FOREACH(pNode, pIndef->pFuncs) {
code = nodesListMakeStrictAppend(&pProject->pProjections, rewriteUniqueOptCreateProjectCol((SFunctionNode*)pNode));
if (TSDB_CODE_SUCCESS != code) {
break;
}
}
if (TSDB_CODE_SUCCESS == code) {
*pOutput = (SLogicNode*)pProject;
} else {
nodesDestroyNode((SNode*)pProject);
}
return code;
}
static int32_t rewriteUniqueOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan,
SIndefRowsFuncLogicNode* pIndef) {
SLogicNode* pAgg = NULL;
SLogicNode* pProject = NULL;
int32_t code = rewriteUniqueOptCreateAgg(pIndef, &pAgg);
if (TSDB_CODE_SUCCESS == code) {
code = rewriteUniqueOptCreateProject(pIndef, &pProject);
}
if (TSDB_CODE_SUCCESS == code) {
code = nodesListMakeAppend(&pProject->pChildren, (SNode*)pAgg);
pAgg->pParent = pProject;
pAgg = NULL;
}
if (TSDB_CODE_SUCCESS == code) {
code = replaceLogicNode(pLogicSubplan, (SLogicNode*)pIndef, pProject);
}
if (TSDB_CODE_SUCCESS == code) {
nodesDestroyNode((SNode*)pIndef);
} else {
nodesDestroyNode((SNode*)pAgg);
nodesDestroyNode((SNode*)pProject);
}
pCxt->optimized = true;
return code;
}
static int32_t rewriteUniqueOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) {
SIndefRowsFuncLogicNode* pIndef =
(SIndefRowsFuncLogicNode*)optFindPossibleNode(pLogicSubplan->pNode, rewriteUniqueOptMayBeOptimized);
if (NULL == pIndef) {
return TSDB_CODE_SUCCESS;
}
return rewriteUniqueOptimizeImpl(pCxt, pLogicSubplan, pIndef);
}
// merge projects // merge projects
static bool mergeProjectsMayBeOptimized(SLogicNode* pNode) { static bool mergeProjectsMayBeOptimized(SLogicNode* pNode) {
if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren)) { if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren)) {
return false; return false;
} }
SLogicNode *pChild = (SLogicNode*)nodesListGetNode(pNode->pChildren, 0); SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pNode->pChildren, 0);
if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pChild) || 1 < LIST_LENGTH(pChild->pChildren) || if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pChild) || 1 < LIST_LENGTH(pChild->pChildren) ||
NULL != pChild->pConditions || NULL != pNode->pLimit || NULL != pNode->pSlimit) { NULL != pChild->pConditions || NULL != pChild->pLimit || NULL != pChild->pSlimit) {
return false; return false;
} }
return true; return true;
...@@ -1376,12 +1631,12 @@ static bool mergeProjectsMayBeOptimized(SLogicNode* pNode) { ...@@ -1376,12 +1631,12 @@ static bool mergeProjectsMayBeOptimized(SLogicNode* pNode) {
typedef struct SMergeProjectionsContext { typedef struct SMergeProjectionsContext {
SProjectLogicNode* pChildProj; SProjectLogicNode* pChildProj;
int32_t errCode; int32_t errCode;
} SMergeProjectionsContext; } SMergeProjectionsContext;
static EDealRes mergeProjectionsExpr(SNode** pNode, void* pContext) { static EDealRes mergeProjectionsExpr(SNode** pNode, void* pContext) {
SMergeProjectionsContext* pCxt = pContext; SMergeProjectionsContext* pCxt = pContext;
SProjectLogicNode* pChildProj = pCxt->pChildProj; SProjectLogicNode* pChildProj = pCxt->pChildProj;
if (QUERY_NODE_COLUMN == nodeType(*pNode)) { if (QUERY_NODE_COLUMN == nodeType(*pNode)) {
SNode* pTarget; SNode* pTarget;
FOREACH(pTarget, ((SLogicNode*)pChildProj)->pTargets) { FOREACH(pTarget, ((SLogicNode*)pChildProj)->pTargets) {
...@@ -1406,7 +1661,7 @@ static EDealRes mergeProjectionsExpr(SNode** pNode, void* pContext) { ...@@ -1406,7 +1661,7 @@ static EDealRes mergeProjectionsExpr(SNode** pNode, void* pContext) {
} }
static int32_t mergeProjectsOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SLogicNode* pSelfNode) { static int32_t mergeProjectsOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SLogicNode* pSelfNode) {
SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pSelfNode->pChildren, 0); SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pSelfNode->pChildren, 0);
SMergeProjectionsContext cxt = {.pChildProj = (SProjectLogicNode*)pChild, .errCode = TSDB_CODE_SUCCESS}; SMergeProjectionsContext cxt = {.pChildProj = (SProjectLogicNode*)pChild, .errCode = TSDB_CODE_SUCCESS};
nodesRewriteExprs(((SProjectLogicNode*)pSelfNode)->pProjections, mergeProjectionsExpr, &cxt); nodesRewriteExprs(((SProjectLogicNode*)pSelfNode)->pProjections, mergeProjectionsExpr, &cxt);
...@@ -1425,6 +1680,7 @@ static int32_t mergeProjectsOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* ...@@ -1425,6 +1680,7 @@ static int32_t mergeProjectsOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan*
NODES_CLEAR_LIST(pChild->pChildren); NODES_CLEAR_LIST(pChild->pChildren);
} }
nodesDestroyNode((SNode*)pChild); nodesDestroyNode((SNode*)pChild);
pCxt->optimized = true;
return code; return code;
} }
...@@ -1447,23 +1703,37 @@ static const SOptimizeRule optimizeRuleSet[] = { ...@@ -1447,23 +1703,37 @@ static const SOptimizeRule optimizeRuleSet[] = {
{.pName = "MergeProjects", .optimizeFunc = mergeProjectsOptimize}, {.pName = "MergeProjects", .optimizeFunc = mergeProjectsOptimize},
{.pName = "EliminateProject", .optimizeFunc = eliminateProjOptimize}, {.pName = "EliminateProject", .optimizeFunc = eliminateProjOptimize},
{.pName = "EliminateSetOperator", .optimizeFunc = eliminateSetOpOptimize}, {.pName = "EliminateSetOperator", .optimizeFunc = eliminateSetOpOptimize},
{.pName = "RewriteTail", .optimizeFunc = rewriteTailOptimize} {.pName = "RewriteTail", .optimizeFunc = rewriteTailOptimize},
{.pName = "RewriteUnique", .optimizeFunc = rewriteUniqueOptimize}
}; };
// clang-format on // clang-format on
static const int32_t optimizeRuleNum = (sizeof(optimizeRuleSet) / sizeof(SOptimizeRule)); static const int32_t optimizeRuleNum = (sizeof(optimizeRuleSet) / sizeof(SOptimizeRule));
static void dumpLogicSubplan(const char* pRuleName, SLogicSubplan* pSubplan) {
char* pStr = NULL;
nodesNodeToString((SNode*)pSubplan, false, &pStr, NULL);
qDebugL("apply optimize %s rule: %s", pRuleName, pStr);
taosMemoryFree(pStr);
}
static int32_t applyOptimizeRule(SPlanContext* pCxt, SLogicSubplan* pLogicSubplan) { static int32_t applyOptimizeRule(SPlanContext* pCxt, SLogicSubplan* pLogicSubplan) {
SOptimizeContext cxt = {.pPlanCxt = pCxt, .optimized = false}; SOptimizeContext cxt = {.pPlanCxt = pCxt, .optimized = false};
bool optimized = false;
do { do {
cxt.optimized = false; optimized = false;
for (int32_t i = 0; i < optimizeRuleNum; ++i) { for (int32_t i = 0; i < optimizeRuleNum; ++i) {
cxt.optimized = false;
int32_t code = optimizeRuleSet[i].optimizeFunc(&cxt, pLogicSubplan); int32_t code = optimizeRuleSet[i].optimizeFunc(&cxt, pLogicSubplan);
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {
return code; return code;
} }
if (cxt.optimized) {
optimized = true;
dumpLogicSubplan(optimizeRuleSet[i].pName, pLogicSubplan);
}
} }
} while (cxt.optimized); } while (optimized);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -1237,7 +1237,7 @@ static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule)); ...@@ -1237,7 +1237,7 @@ static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule));
static void dumpLogicSubplan(const char* pRuleName, SLogicSubplan* pSubplan) { static void dumpLogicSubplan(const char* pRuleName, SLogicSubplan* pSubplan) {
char* pStr = NULL; char* pStr = NULL;
nodesNodeToString((SNode*)pSubplan, false, &pStr, NULL); nodesNodeToString((SNode*)pSubplan, false, &pStr, NULL);
qDebugL("apply %s rule: %s", pRuleName, pStr); qDebugL("apply split %s rule: %s", pRuleName, pStr);
taosMemoryFree(pStr); taosMemoryFree(pStr);
} }
......
...@@ -85,6 +85,11 @@ int32_t qSetSubplanExecutionNode(SSubplan* subplan, int32_t groupId, SDownstream ...@@ -85,6 +85,11 @@ int32_t qSetSubplanExecutionNode(SSubplan* subplan, int32_t groupId, SDownstream
return setSubplanExecutionNode(subplan->pNode, groupId, pSource); return setSubplanExecutionNode(subplan->pNode, groupId, pSource);
} }
int32_t qClearSubplanExecutionNode(SSubplan* pSubplan, int32_t groupId) {
// todo
return TSDB_CODE_FAILED;
}
int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen) { int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen) {
if (SUBPLAN_TYPE_MODIFY == pSubplan->subplanType && NULL == pSubplan->pNode) { if (SUBPLAN_TYPE_MODIFY == pSubplan->subplanType && NULL == pSubplan->pNode) {
SDataInserterNode* insert = (SDataInserterNode*)pSubplan->pDataSink; SDataInserterNode* insert = (SDataInserterNode*)pSubplan->pDataSink;
......
...@@ -56,6 +56,8 @@ TEST_F(PlanBasicTest, uniqueFunc) { ...@@ -56,6 +56,8 @@ TEST_F(PlanBasicTest, uniqueFunc) {
run("SELECT UNIQUE(c2 + 10) FROM t1 WHERE c1 > 10"); run("SELECT UNIQUE(c2 + 10) FROM t1 WHERE c1 > 10");
run("SELECT UNIQUE(c2 + 10), c2 FROM t1 WHERE c1 > 10");
run("SELECT UNIQUE(c2 + 10), ts, c2 FROM t1 WHERE c1 > 10"); run("SELECT UNIQUE(c2 + 10), ts, c2 FROM t1 WHERE c1 > 10");
run("SELECT UNIQUE(c1) a FROM t1 ORDER BY a"); run("SELECT UNIQUE(c1) a FROM t1 ORDER BY a");
...@@ -75,6 +77,8 @@ TEST_F(PlanBasicTest, tailFunc) { ...@@ -75,6 +77,8 @@ TEST_F(PlanBasicTest, tailFunc) {
run("SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 LIMIT 5"); run("SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 LIMIT 5");
run("SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 PARTITION BY c1 LIMIT 5"); run("SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 PARTITION BY c1 LIMIT 5");
run("SELECT TAIL(c1, 2, 1) FROM st1s1 UNION ALL SELECT c1 FROM st1s2");
} }
TEST_F(PlanBasicTest, interpFunc) { TEST_F(PlanBasicTest, interpFunc) {
...@@ -97,6 +101,16 @@ TEST_F(PlanBasicTest, lastRowFunc) { ...@@ -97,6 +101,16 @@ TEST_F(PlanBasicTest, lastRowFunc) {
run("SELECT LAST_ROW(c1) FROM st1"); run("SELECT LAST_ROW(c1) FROM st1");
} }
TEST_F(PlanBasicTest, sampleFunc) {
useDb("root", "test");
run("SELECT SAMPLE(c1, 10) FROM t1");
run("SELECT SAMPLE(c1, 10) FROM st1");
run("SELECT SAMPLE(c1, 10) FROM st1 PARTITION BY TBNAME");
}
TEST_F(PlanBasicTest, withoutFrom) { TEST_F(PlanBasicTest, withoutFrom) {
useDb("root", "test"); useDb("root", "test");
......
...@@ -20,7 +20,7 @@ using namespace std; ...@@ -20,7 +20,7 @@ using namespace std;
class PlanOptimizeTest : public PlannerTestBase {}; class PlanOptimizeTest : public PlannerTestBase {};
TEST_F(PlanOptimizeTest, optimizeScanData) { TEST_F(PlanOptimizeTest, scanPath) {
useDb("root", "test"); useDb("root", "test");
run("SELECT COUNT(*) FROM t1"); run("SELECT COUNT(*) FROM t1");
...@@ -32,7 +32,7 @@ TEST_F(PlanOptimizeTest, optimizeScanData) { ...@@ -32,7 +32,7 @@ TEST_F(PlanOptimizeTest, optimizeScanData) {
run("SELECT PERCENTILE(c1, 40), COUNT(*) FROM t1"); run("SELECT PERCENTILE(c1, 40), COUNT(*) FROM t1");
} }
TEST_F(PlanOptimizeTest, ConditionPushDown) { TEST_F(PlanOptimizeTest, pushDownCondition) {
useDb("root", "test"); useDb("root", "test");
run("SELECT ts, c1 FROM st1 WHERE tag1 > 4"); run("SELECT ts, c1 FROM st1 WHERE tag1 > 4");
...@@ -42,9 +42,11 @@ TEST_F(PlanOptimizeTest, ConditionPushDown) { ...@@ -42,9 +42,11 @@ TEST_F(PlanOptimizeTest, ConditionPushDown) {
run("SELECT ts, c1 FROM st1 WHERE tag1 > 4 AND tag2 = 'hello'"); run("SELECT ts, c1 FROM st1 WHERE tag1 > 4 AND tag2 = 'hello'");
run("SELECT ts, c1 FROM st1 WHERE tag1 > 4 AND tag2 = 'hello' AND c1 > 10"); run("SELECT ts, c1 FROM st1 WHERE tag1 > 4 AND tag2 = 'hello' AND c1 > 10");
run("SELECT ts, c1 FROM (SELECT * FROM st1) WHERE tag1 > 4");
} }
TEST_F(PlanOptimizeTest, orderByPrimaryKey) { TEST_F(PlanOptimizeTest, sortPrimaryKey) {
useDb("root", "test"); useDb("root", "test");
run("SELECT c1 FROM t1 ORDER BY ts"); run("SELECT c1 FROM t1 ORDER BY ts");
......
...@@ -1488,18 +1488,6 @@ char* syncNode2SimpleStr(const SSyncNode* pSyncNode) { ...@@ -1488,18 +1488,6 @@ char* syncNode2SimpleStr(const SSyncNode* pSyncNode) {
pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy,
pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, pSyncNode->changing, pSyncNode->restoreFinish); pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, pSyncNode->changing, pSyncNode->restoreFinish);
/*
snprintf(s, len,
"syncNode: vgId:%d, term:%lu, commit:%ld, state:%d %s, standby:%d, "
"lc:%lu, "
"lc-user:%lu, "
"ems:%d, replica-num:%d, restore:%d, changing:%d",
pSyncNode->vgId, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, pSyncNode->state,
syncUtilState2String(pSyncNode->state), pSyncNode->pRaftCfg->isStandBy, pSyncNode->electTimerLogicClock,
pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS, pSyncNode->replicaNum,
pSyncNode->restoreFinish, pSyncNode->changing);
*/
return s; return s;
} }
......
...@@ -683,7 +683,16 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { ...@@ -683,7 +683,16 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
needRsp = true; needRsp = true;
} else { } else {
ASSERT(0); // error log
do {
char logBuf[96];
snprintf(logBuf, sizeof(logBuf), "snapshot receiver recv error seq:%d, my ack:%d", pMsg->seq, pReceiver->ack);
char *eventLog = snapshotReceiver2SimpleStr(pReceiver, logBuf);
syncNodeErrorLog(pSyncNode, eventLog);
taosMemoryFree(eventLog);
} while (0);
return -1;
} }
// send ack // send ack
...@@ -764,8 +773,8 @@ int32_t syncNodeOnSnapshotRspCb(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) { ...@@ -764,8 +773,8 @@ int32_t syncNodeOnSnapshotRspCb(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) {
} else { } else {
do { do {
char logBuf[64]; char logBuf[96];
snprintf(logBuf, sizeof(logBuf), "error ack, recv ack:%d, my seq:%d", pMsg->ack, pSender->seq); snprintf(logBuf, sizeof(logBuf), "snapshot sender recv error ack:%d, my seq:%d", pMsg->ack, pSender->seq);
char *eventLog = snapshotSender2SimpleStr(pSender, logBuf); char *eventLog = snapshotSender2SimpleStr(pSender, logBuf);
syncNodeErrorLog(pSyncNode, eventLog); syncNodeErrorLog(pSyncNode, eventLog);
taosMemoryFree(eventLog); taosMemoryFree(eventLog);
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
./test.sh -f tsim/user/privilege_sysinfo.sim ./test.sh -f tsim/user/privilege_sysinfo.sim
## ---- db ## ---- db
./test.sh -f tsim/db/create_all_options.sim
./test.sh -f tsim/db/alter_option.sim ./test.sh -f tsim/db/alter_option.sim
./test.sh -f tsim/db/alter_replica_13.sim ./test.sh -f tsim/db/alter_replica_13.sim
./test.sh -f tsim/db/alter_replica_31.sim ./test.sh -f tsim/db/alter_replica_31.sim
...@@ -17,12 +16,23 @@ ...@@ -17,12 +16,23 @@
./test.sh -f tsim/db/basic3.sim ./test.sh -f tsim/db/basic3.sim
./test.sh -f tsim/db/basic6.sim ./test.sh -f tsim/db/basic6.sim
./test.sh -f tsim/db/basic7.sim ./test.sh -f tsim/db/basic7.sim
#./test.sh -f tsim/db/commit.sim
./test.sh -f tsim/db/create_all_options.sim
#./test.sh -f tsim/db/delete_part.sim
#./test.sh -f tsim/db/delete.sim
./test.sh -f tsim/db/error1.sim ./test.sh -f tsim/db/error1.sim
#./test.sh -f tsim/db/replica_add13.sim
#./test.sh -f tsim/db/replica_part.sim
#./test.sh -f tsim/db/replica_reduce31.sim
./test.sh -f tsim/db/taosdlog.sim ./test.sh -f tsim/db/taosdlog.sim
# ---- dnode # ---- dnode
./test.sh -f tsim/dnode/balance_replica1.sim ./test.sh -f tsim/dnode/balance_replica1.sim
./test.sh -f tsim/dnode/balance_replica3.sim ./test.sh -f tsim/dnode/balance_replica3.sim
./test.sh -f tsim/dnode/balance1.sim
./test.sh -f tsim/dnode/balance2.sim
./test.sh -f tsim/dnode/balance3.sim
./test.sh -f tsim/dnode/balancex.sim
./test.sh -f tsim/dnode/create_dnode.sim ./test.sh -f tsim/dnode/create_dnode.sim
./test.sh -f tsim/dnode/drop_dnode_has_mnode.sim ./test.sh -f tsim/dnode/drop_dnode_has_mnode.sim
./test.sh -f tsim/dnode/drop_dnode_has_qnode_snode.sim ./test.sh -f tsim/dnode/drop_dnode_has_qnode_snode.sim
...@@ -30,11 +40,13 @@ ...@@ -30,11 +40,13 @@
./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica3.sim ./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica3.sim
./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim ./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim
./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim ./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim
./test.sh -f tsim/dnode/offline_reason.sim
./test.sh -f tsim/dnode/redistribute_vgroup_replica1.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica1.sim
./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v2.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v2.sim
./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v3.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v3.sim
./test.sh -f tsim/dnode/vnode_clean.sim
# ---- insert # ---- insert
./test.sh -f tsim/insert/basic0.sim ./test.sh -f tsim/insert/basic0.sim
...@@ -156,6 +168,13 @@ ...@@ -156,6 +168,13 @@
# --- valgrind # --- valgrind
./test.sh -f tsim/valgrind/checkError.sim -v ./test.sh -f tsim/valgrind/checkError.sim -v
# --- vnode
#./test.sh -f tsim/vnode/replica3_basic.sim
#./test.sh -f tsim/vnode/replica3_repeat.sim
./test.sh -f tsim/vnode/replica3_vgroup.sim
#./test.sh -f tsim/vnode/replica3_many.sim
#./test.sh -f tsim/vnode/replica3_import.sim
# --- sync # --- sync
./test.sh -f tsim/sync/3Replica1VgElect.sim ./test.sh -f tsim/sync/3Replica1VgElect.sim
./test.sh -f tsim/sync/3Replica5VgElect.sim ./test.sh -f tsim/sync/3Replica5VgElect.sim
......
#!/bin/bash
echo "Executing move_dnode.sh"
UNAME_BIN=`which uname`
OS_TYPE=`$UNAME_BIN`
SCRIPT_DIR=`dirname $0`
cd $SCRIPT_DIR/../
SCRIPT_DIR=`pwd`
echo "SCRIPT_DIR: $SCRIPT_DIR"
IN_TDINTERNAL="community"
if [[ "$SCRIPT_DIR" == *"$IN_TDINTERNAL"* ]]; then
cd ../../..
else
cd ../../
fi
TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
if [[ "$OS_TYPE" != "Darwin" ]]; then
cut_opt="--field="
else
cut_opt="-f "
fi
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then
BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3`
else
BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2`
fi
BUILD_DIR=$TAOS_DIR/$BIN_DIR/build
SIM_DIR=$TAOS_DIR/sim
NODE_DIR=$SIM_DIR/$NODE_NAME
if [ -d "$SIM_DIR/$2" ];then
rm -rf $SIM_DIR/$2
fi
mv $SIM_DIR/$1 $SIM_DIR/$2
if [[ $2 =~ "dnode2" ]];then
sed -i 's/serverPort 7100/serverPort 7200/g' $SIM_DIR/$2/cfg/taos.cfg
sed -i 's/dnode1/dnode2/g' $SIM_DIR/$2/cfg/taos.cfg
sed -i 's/7100/7200/g' $SIM_DIR/$2/data/dnode/dnodeEps.json
elif [[ $2 =~ "dnode4" ]];then
sed -i 's/serverPort 7100/serverPort 7400/g' $SIM_DIR/$2/cfg/taos.cfg
sed -i 's/dnode1/dnode4/g' $SIM_DIR/$2/cfg/taos.cfg
sed -i 's/7100/7400/g' $SIM_DIR/dnode2/data/dnode/dnodeEps.json
sed -i 's/7100/7400/g' $SIM_DIR/dnode3/data/dnode/dnodeEps.json
sed -i 's/7100/7400/g' $SIM_DIR/$2/data/dnode/dnodeEps.json
fi
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4 system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c supportVnodes -v 4
system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 system sh/cfg.sh -n dnode2 -c supportVnodes -v 4
system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 system sh/cfg.sh -n dnode3 -c supportVnodes -v 4
system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 system sh/cfg.sh -n dnode4 -c supportVnodes -v 4
system sh/cfg.sh -n dnode4 -c balanceInterval -v 10
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/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 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 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
print ========== step1 print ========== step1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sql connect sql connect
sql create database d1 sql create database d1 vgroups 1
sql create table d1.t1 (t timestamp, i int) sql create table d1.t1 (t timestamp, i int)
sql insert into d1.t1 values(now+1s, 15) sql insert into d1.t1 values(now+1s, 15)
sql insert into d1.t1 values(now+2s, 14) sql insert into d1.t1 values(now+2s, 14)
...@@ -43,35 +21,49 @@ sql insert into d1.t1 values(now+4s, 12) ...@@ -43,35 +21,49 @@ sql insert into d1.t1 values(now+4s, 12)
sql insert into d1.t1 values(now+5s, 11) sql insert into d1.t1 values(now+5s, 11)
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
if $data2_1 != 1 then if $data(1)[2] != 1 then
return -1 return -1
endi endi
print ========== step2 print ========== step2
sql create dnode $hostname2 sql create dnode $hostname port 7200
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
$x = 0 $x = 0
show2: step2:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 20 then if $x == 10 then
print ====> dnode not ready!
return -1 return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 openVnodes $data2_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $data2_1 != 0 then if $rows != 2 then
goto show2 return -1
endi
if $data(1)[4] != ready then
goto step2
endi
if $data(2)[4] != ready then
goto step2
endi
sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(2)[2]
if $data(1)[2] != 0 then
return -1
endi endi
if $data2_2 != 1 then if $data(2)[2] != 1 then
goto show2 return -1
endi endi
print ========== step3 print ========== step3
sql create database d2 sql create database d2 vgroups 1
sql create table d2.t2 (t timestamp, i int) sql create table d2.t2 (t timestamp, i int)
sql insert into d2.t2 values(now+1s, 25) sql insert into d2.t2 values(now+1s, 25)
sql insert into d2.t2 values(now+2s, 24) sql insert into d2.t2 values(now+2s, 24)
...@@ -80,69 +72,67 @@ sql insert into d2.t2 values(now+4s, 22) ...@@ -80,69 +72,67 @@ sql insert into d2.t2 values(now+4s, 22)
sql insert into d2.t2 values(now+5s, 21) sql insert into d2.t2 values(now+5s, 21)
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode2 openVnodes $data(2)[2]
if $data2_1 != 0 then if $data(1)[2] != 0 then
return -1 return -1
endi endi
if $data2_2 != 2 then if $data(2)[2] != 2 then
return -1 return -1
endi endi
print ========== step4 print ========== step4
sql drop dnode $hostname2 sql drop dnode 2
$x = 0
show4:
$x = $x + 1
sleep 2000
if $x == 10 then
return -1
endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode2 openVnodes $data(2)[2]
if $data2_1 != 2 then if $data(1)[2] != 2 then
goto show4 return -1
endi
if $data2_2 != null then
goto show4
endi endi
if $rows != 1 then if $data(2)[2] != null then
goto show4 return -1
endi endi
system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT
print ========== step5 print ========== step5
sql create dnode $hostname3 sql create dnode $hostname port 7300
system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode3 -s start
$x = 0 $x = 0
show5: step5:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 30 then if $x == 10 then
print ====> dnode not ready!
return -1 return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 openVnodes $data2_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
print dnode3 openVnodes $data2_3 if $rows != 2 then
if $data2_1 != 0 then return -1
goto show5
endi endi
if $data2_2 != null then if $data(1)[4] != ready then
goto show5 goto step5
endi endi
if $data2_3 != 2 then if $data(3)[4] != ready then
goto show5 goto step5
endi
sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(3)[2]
if $data(1)[2] != 1 then
return -1
endi
if $data(3)[2] != 1 then
return -1
endi endi
print ========== step6 print ========== step6
sql create database d3 sql create database d3 vgroups 1
sql create table d3.t3 (t timestamp, i int) sql create table d3.t3 (t timestamp, i int)
sql insert into d3.t3 values(now+1s, 35) sql insert into d3.t3 values(now+1s, 35)
sql insert into d3.t3 values(now+2s, 34) sql insert into d3.t3 values(now+2s, 34)
...@@ -151,52 +141,46 @@ sql insert into d3.t3 values(now+4s, 32) ...@@ -151,52 +141,46 @@ sql insert into d3.t3 values(now+4s, 32)
sql insert into d3.t3 values(now+5s, 31) sql insert into d3.t3 values(now+5s, 31)
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode2 openVnodes $data(3)[2]
print dnode3 openVnodes $data2_3 if $data(1)[2] != 1 then
if $data2_1 != 0 then
return -1 return -1
endi endi
if $data2_2 != null then if $data(3)[2] != 2 then
return -1
endi
if $data2_3 != 3 then
return -1 return -1
endi endi
print ========== step7 print ========== step7
sql create dnode $hostname4 sql create dnode $hostname port 7400
system sh/exec.sh -n dnode4 -s start system sh/exec.sh -n dnode4 -s start
$x = 0 $x = 0
show7: step7:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 20 then if $x == 10 then
return -1 print ====> dnode not ready!
return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 openVnodes $data2_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
print dnode3 openVnodes $data2_3 print ===> $data20 $data21 $data22 $data23 $data24 $data25
print dnode4 openVnodes $data2_4 if $rows != 3 then
if $data2_1 != 0 then return -1
goto show7
endi endi
if $data2_2 != null then if $data(1)[4] != ready then
goto show7 goto step7
endi endi
if $data2_3 != 2 then if $data(3)[4] != ready then
goto show7 goto step7
endi endi
if $data2_4 != 1 then if $data(4)[4] != ready then
goto show7 goto step7
endi endi
print ========== step8 print ========== step8
sql create database d4 sql create database d4 vgroups 1
sql create table d4.t4 (t timestamp, i int) sql create table d4.t4 (t timestamp, i int)
sql insert into d4.t4 values(now+1s, 45) sql insert into d4.t4 values(now+1s, 45)
sql insert into d4.t4 values(now+2s, 44) sql insert into d4.t4 values(now+2s, 44)
...@@ -205,56 +189,32 @@ sql insert into d4.t4 values(now+4s, 42) ...@@ -205,56 +189,32 @@ sql insert into d4.t4 values(now+4s, 42)
sql insert into d4.t4 values(now+5s, 41) sql insert into d4.t4 values(now+5s, 41)
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode2 openVnodes $data(3)[2]
print dnode3 openVnodes $data2_3 print dnode2 openVnodes $data(4)[2]
print dnode4 openVnodes $data2_4 if $data(1)[2] != 1 then
if $data2_1 != 0 then
return -1 return -1
endi endi
if $data2_2 != null then if $data(3)[2] != 2 then
return -1 return -1
endi endi
if $data2_3 != 2 then if $data(4)[2] != 1 then
return -1
endi
if $data2_4 != 2 then
return -1 return -1
endi endi
print ========== step9 print ========== step9
sql drop dnode $hostname3 sql drop dnode 3
$x = 0
show9:
$x = $x + 1
sleep 2000
if $x == 10 then
return -1
endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode2 openVnodes $data(4)[2]
print dnode3 openVnodes $data2_3 if $data(1)[2] != 2 then
print dnode4 openVnodes $data2_4 return -1
if $data2_1 != 0 then
goto show9
endi
if $data2_2 != null then
goto show9
endi
if $data2_3 != null then
goto show9
endi endi
if $data2_4 != 4 then if $data(4)[2] != 2 then
goto show9 return -1
endi endi
system sh/exec.sh -n dnode3 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT
sql reset query cache sql reset query cache
sleep 100 sleep 100
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4 system sh/deploy.sh -n dnode4 -i 4
system sh/deploy.sh -n dnode5 -i 5 system sh/deploy.sh -n dnode5 -i 5
system sh/cfg.sh -n dnode1 -c supportVnodes -v 4
system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 system sh/cfg.sh -n dnode2 -c supportVnodes -v 4
system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 system sh/cfg.sh -n dnode3 -c supportVnodes -v 4
system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 system sh/cfg.sh -n dnode4 -c supportVnodes -v 4
system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 system sh/cfg.sh -n dnode5 -c supportVnodes -v 4
system sh/cfg.sh -n dnode5 -c balanceInterval -v 10
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/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -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/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4
print ========== step1 print ========== step1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sql connect sql connect
sql create dnode $hostname2 sql create dnode $hostname port 7200
sql create dnode $hostname3 sql create dnode $hostname port 7300
sql create dnode $hostname4
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start
$x = 0 $x = 0
step1: step1:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 10 then if $x == 10 then
print ====> dnode not ready!
return -1 return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 $data4_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 $data4_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
print dnode3 $data4_3 print ===> $data20 $data21 $data22 $data23 $data24 $data25
print dnode4 $data4_4 if $rows != 3 then
return -1
if $data4_1 != ready then
goto step1
endi endi
if $data4_2 != ready then if $data(1)[4] != ready then
goto step1 goto step1
endi endi
if $data4_3 != ready then if $data(2)[4] != ready then
goto step1 goto step1
endi endi
if $data4_4 != ready then if $data(3)[4] != ready then
goto step1 goto step1
endi endi
print ========== step2 print ========== step2
sql create database d1 replica 3 vgroups 1
sql create database d1 replica 3
sql create table d1.t1 (t timestamp, i int) sql create table d1.t1 (t timestamp, i int)
sql insert into d1.t1 values(now+1s, 15) sql insert into d1.t1 values(now+1s, 15)
sql insert into d1.t1 values(now+2s, 14) sql insert into d1.t1 values(now+2s, 14)
...@@ -71,7 +53,7 @@ sql insert into d1.t1 values(now+3s, 13) ...@@ -71,7 +53,7 @@ sql insert into d1.t1 values(now+3s, 13)
sql insert into d1.t1 values(now+4s, 12) sql insert into d1.t1 values(now+4s, 12)
sql insert into d1.t1 values(now+5s, 11) sql insert into d1.t1 values(now+5s, 11)
sql create database d2 replica 3 sql create database d2 replica 3 vgroups 1
sql create table d2.t2 (t timestamp, i int) sql create table d2.t2 (t timestamp, i int)
sql insert into d2.t2 values(now+1s, 25) sql insert into d2.t2 values(now+1s, 25)
sql insert into d2.t2 values(now+2s, 24) sql insert into d2.t2 values(now+2s, 24)
...@@ -79,7 +61,7 @@ sql insert into d2.t2 values(now+3s, 23) ...@@ -79,7 +61,7 @@ sql insert into d2.t2 values(now+3s, 23)
sql insert into d2.t2 values(now+4s, 22) sql insert into d2.t2 values(now+4s, 22)
sql insert into d2.t2 values(now+5s, 21) sql insert into d2.t2 values(now+5s, 21)
sql create database d3 replica 3 sql create database d3 replica 3 vgroups 1
sql create table d3.t3 (t timestamp, i int) sql create table d3.t3 (t timestamp, i int)
sql insert into d3.t3 values(now+1s, 35) sql insert into d3.t3 values(now+1s, 35)
sql insert into d3.t3 values(now+2s, 34) sql insert into d3.t3 values(now+2s, 34)
...@@ -87,7 +69,7 @@ sql insert into d3.t3 values(now+3s, 33) ...@@ -87,7 +69,7 @@ sql insert into d3.t3 values(now+3s, 33)
sql insert into d3.t3 values(now+4s, 32) sql insert into d3.t3 values(now+4s, 32)
sql insert into d3.t3 values(now+5s, 31) sql insert into d3.t3 values(now+5s, 31)
sql create database d4 replica 3 sql create database d4 replica 3 vgroups 1
sql create table d4.t4 (t timestamp, i int) sql create table d4.t4 (t timestamp, i int)
sql insert into d4.t4 values(now+1s, 45) sql insert into d4.t4 values(now+1s, 45)
sql insert into d4.t4 values(now+2s, 44) sql insert into d4.t4 values(now+2s, 44)
...@@ -96,190 +78,129 @@ sql insert into d4.t4 values(now+4s, 42) ...@@ -96,190 +78,129 @@ sql insert into d4.t4 values(now+4s, 42)
sql insert into d4.t4 values(now+5s, 41) sql insert into d4.t4 values(now+5s, 41)
print ========== step2.1 print ========== step2.1
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode2 openVnodes $data(2)[2]
print dnode3 openVnodes $data2_3 print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data2_4 if $data(1)[2] != 4 then
if $data2_1 != 0 then
return -1 return -1
endi endi
if $data2_2 != 4 then if $data(2)[2] != 4 then
return -1 return -1
endi endi
if $data2_3 != 4 then if $data(3)[2] != 4 then
return -1
endi
if $data2_4 != 4 then
return -1
endi
sql show d1.vgroups;
print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 4 then
return -1
endi
sql show d2.vgroups;
print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 3 then
return -1
endi
sql show d3.vgroups;
print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 2 then
return -1
endi
sql show d4.vgroups;
print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 4 then
return -1 return -1
endi endi
print ========== step3 print ========== step3
sql create dnode $hostname5 sql create dnode $hostname port 7400
sql create dnode $hostname port 7500
system sh/exec.sh -n dnode4 -s start
system sh/exec.sh -n dnode5 -s start system sh/exec.sh -n dnode5 -s start
$x = 0 $x = 0
show3: step3:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 40 then if $x == 10 then
return -1 print ====> dnode not ready!
return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 openVnodes $data2_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
print dnode3 openVnodes $data2_3 print ===> $data20 $data21 $data22 $data23 $data24 $data25
print dnode4 openVnodes $data2_4 print ===> $data30 $data31 $data32 $data33 $data34 $data35
print dnode5 openVnodes $data2_5 print ===> $data40 $data41 $data42 $data43 $data44 $data45
if $rows != 5 then
if $data2_2 != 3 then return -1
goto show3
endi endi
if $data2_3 != 3 then if $data(1)[4] != ready then
goto show3 goto step3
endi endi
if $data2_4 != 3 then if $data(2)[4] != ready then
goto show3 goto step3
endi endi
if $data2_5 != 3 then if $data(3)[4] != ready then
goto show3 goto step3
endi endi
if $data(4)[4] != ready then
sql show d1.vgroups; goto step3
print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 5 then
return -1
endi endi
if $data03 != 3 then if $data(5)[4] != ready then
goto show3 goto step3
endi endi
sql show d2.vgroups; sql balance vgroup
print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 sql show dnodes
if $data04 != 5 then print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data(2)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
print dnode5 openVnodes $data(5)[2]
if $data(1)[2] != 2 then
return -1 return -1
endi endi
if $data03 != 3 then if $data(2)[2] != 3 then
goto show3
endi
sql show d3.vgroups;
print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 2 then
return -1 return -1
endi endi
if $data03 != 3 then if $data(3)[2] != 3 then
goto show3 return -1
endi endi
if $data(4)[2] != 2 then
sql show d4.vgroups;
print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 4 then
return -1 return -1
endi endi
if $data03 != 3 then if $data(5)[2] != 2 then
goto show3 return -1
endi endi
print ========== step4 print ========== step4
sql drop dnode $hostname2 sql drop dnode 2
$x = 0
show4:
$x = $x + 1
sleep 1000
if $x == 40 then
return -1
endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode3 openVnodes $data(3)[2]
print dnode3 openVnodes $data2_3 print dnode4 openVnodes $data(4)[2]
print dnode4 openVnodes $data2_4 print dnode5 openVnodes $data(5)[2]
print dnode5 openVnodes $data2_5 if $data(1)[2] != 2 then
if $data2_2 != null then
goto show4
endi
if $data2_3 != 4 then
goto show4
endi
if $data2_4 != 4 then
goto show4
endi
if $data2_5 != 4 then
goto show4
endi
sql show d1.vgroups;
print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 5 then
return -1 return -1
endi endi
if $data03 != 3 then if $data(3)[2] != 3 then
goto show4 return -1
endi endi
if $data(4)[2] != 4 then
sql show d2.vgroups;
print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 3 then
return -1 return -1
endi endi
if $data03 != 3 then if $data(5)[2] != 3 then
goto show4 return -1
endi endi
sql show d3.vgroups; system sh/exec.sh -n dnode2 -s stop -x SIGINT
print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 4 then print ========== step5
sql drop dnode 3
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
print dnode5 openVnodes $data(5)[2]
if $data(1)[2] != 4 then
return -1 return -1
endi endi
if $data03 != 3 then if $data(3)[2] != null then
goto show4 return -1
endi endi
if $data(4)[2] != 4 then
sql show d4.vgroups;
print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 4 then
return -1 return -1
endi endi
if $data03 != 3 then if $data(5)[2] != 4 then
goto show4 return -1
endi endi
sql reset query cache sql reset query cache
sleep 100 sleep 100
system sh/exec.sh -n dnode3 -s stop -x SIGINT
print ========== step5 print ========== step6
sql select * from d1.t1 order by t desc sql select * from d1.t1 order by t desc
print $data01 $data11 $data21 $data31 $data41 print $data01 $data11 $data21 $data31 $data41
if $data01 != 11 then if $data01 != 11 then
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4 system sh/deploy.sh -n dnode4 -i 4
system sh/deploy.sh -n dnode5 -i 5 system sh/deploy.sh -n dnode5 -i 5
system sh/deploy.sh -n dnode6 -i 6 system sh/deploy.sh -n dnode6 -i 6
system sh/cfg.sh -n dnode1 -c supportVnodes -v 4
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c supportVnodes -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode3 -c supportVnodes -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode4 -c supportVnodes -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode5 -c supportVnodes -v 4
system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode6 -c supportVnodes -v 4
system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 4
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 dnode4 -c wallevel -v 1
system sh/cfg.sh -n dnode5 -c wallevel -v 1
system sh/cfg.sh -n dnode6 -c wallevel -v 1
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/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode6 -c maxTablesPerVnode -v 4
print ========== step1 print ========== step1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sql connect sql connect
sql create dnode $hostname2 sql create dnode $hostname port 7200
sql create dnode $hostname3 sql create dnode $hostname port 7300
sql create dnode $hostname4 sql create dnode $hostname port 7400
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start system sh/exec.sh -n dnode4 -s start
$x = 0 $x = 0
step1: step10:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 10 then if $x == 10 then
print ====> dnode not ready!
return -1 return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 $data4_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 $data4_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
print dnode3 $data4_3 print ===> $data20 $data21 $data22 $data23 $data24 $data25
print dnode4 $data4_4 print ===> $data30 $data31 $data32 $data33 $data34 $data35
if $rows != 4 then
return -1
endi
if $data(1)[4] != ready then
goto step10
endi
if $data(2)[4] != ready then
goto step10
endi
if $data(3)[4] != ready then
goto step10
endi
if $data(4)[4] != ready then
goto step10
endi
if $data4_1 != ready then sql create database d1 replica 3 vgroups 1
goto step1 $x = 0
step11:
$x = $x + 1
sleep 1000
if $x == 60 then
print ====> db not ready!
return -1
endi
sql show d1.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
$leaderExist = 0
if $rows != 1 then
return -1
endi
if $data(2)[4] == leader then
$leaderExist = 1
endi endi
if $data4_2 != ready then if $data(2)[6] == leader then
goto step1 $leaderExist = 1
endi endi
if $data4_3 != ready then if $data(2)[8] == leader then
goto step1 $leaderExist = 1
endi endi
if $data4_4 != ready then if $leaderExist != 1 then
goto step1 goto step11
endi
sql create database d2 replica 3 vgroups 1
$x = 0
step12:
$x = $x + 1
sleep 1000
if $x == 60 then
print ====> d2 not ready!
return -1
endi
sql show d2.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
$leaderExist = 0
if $rows != 1 then
return -1
endi
if $data(3)[4] == leader then
$leaderExist = 1
endi
if $data(3)[6] == leader then
$leaderExist = 1
endi
if $data(3)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step12
endi endi
sql create database d1 replica 3
sql create table d1.t1 (t timestamp, i int) sql create table d1.t1 (t timestamp, i int)
sql insert into d1.t1 values(now+1s, 15) sql insert into d1.t1 values(now+1s, 15)
sql insert into d1.t1 values(now+2s, 14) sql insert into d1.t1 values(now+2s, 14)
...@@ -73,7 +115,6 @@ sql insert into d1.t1 values(now+3s, 13) ...@@ -73,7 +115,6 @@ sql insert into d1.t1 values(now+3s, 13)
sql insert into d1.t1 values(now+4s, 12) sql insert into d1.t1 values(now+4s, 12)
sql insert into d1.t1 values(now+5s, 11) sql insert into d1.t1 values(now+5s, 11)
sql create database d2 replica 3
sql create table d2.t2 (t timestamp, i int) sql create table d2.t2 (t timestamp, i int)
sql insert into d2.t2 values(now+1s, 25) sql insert into d2.t2 values(now+1s, 25)
sql insert into d2.t2 values(now+2s, 24) sql insert into d2.t2 values(now+2s, 24)
...@@ -82,92 +123,99 @@ sql insert into d2.t2 values(now+4s, 22) ...@@ -82,92 +123,99 @@ sql insert into d2.t2 values(now+4s, 22)
sql insert into d2.t2 values(now+5s, 21) sql insert into d2.t2 values(now+5s, 21)
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode2 openVnodes $data(2)[2]
print dnode3 openVnodes $data2_3 print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data2_4 print dnode4 openVnodes $data(4)[2]
if $data(1)[2] != 0 then
if $data2_1 != 0 then
return -1 return -1
endi endi
if $data2_2 != 2 then if $data(2)[2] != 2 then
return -1 return -1
endi endi
if $data2_3 != 2 then if $data(3)[2] != 2 then
return -1 return -1
endi endi
if $data2_4 != 2 then if $data(4)[2] != 2 then
return -1 return -1
endi endi
print ========== step2 print ========== step2
sql drop dnode $hostname2 sql drop dnode 2
$x = 0
show2:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode2 openVnodes $data(2)[2]
print dnode3 openVnodes $data2_3 print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data2_4 print dnode4 openVnodes $data(4)[2]
if $data(1)[2] != 2 then
if $data2_1 != 2 then return -1
goto show2
endi endi
if $data2_2 != null then if $data(2)[2] != null then
goto show2 return -1
endi endi
if $data2_3 != 2 then if $data(3)[2] != 2 then
goto show2 return -1
endi endi
if $data2_4 != 2 then if $data(4)[2] != 2 then
goto show2 return -1
endi endi
system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT
print ========== step
sql create dnode $hostname5 print ========== step3
sql create dnode $hostname port 7500
system sh/exec.sh -n dnode5 -s start system sh/exec.sh -n dnode5 -s start
$x = 0 $x = 0
show3: step3:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 60 then if $x == 10 then
return -1 print ====> dnode not ready!
return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 openVnodes $data2_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
print dnode3 openVnodes $data2_3 print ===> $data20 $data21 $data22 $data23 $data24 $data25
print dnode4 openVnodes $data2_4 print ===> $data30 $data31 $data32 $data33 $data34 $data35
print dnode5 openVnodes $data2_5 if $rows != 4 then
return -1
if $data2_1 != 0 then
goto show3
endi endi
if $data2_2 != null then if $data(1)[4] != ready then
goto show3 goto step3
endi endi
if $data2_3 != 2 then if $data(3)[4] != ready then
goto show3 goto step3
endi endi
if $data2_4 != 2 then if $data(4)[4] != ready then
goto show3 goto step3
endi endi
if $data2_5 != 2 then if $data(5)[4] != ready then
goto show3 goto step3
endi
sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
print dnode5 openVnodes $data(5)[2]
if $data(1)[2] != 1 then
return -1
endi
if $data(3)[2] != 2 then
return -1
endi
if $data(4)[2] != 2 then
return -1
endi
if $data(5)[2] != 1 then
return -1
endi endi
print ========== step4 print ========== step4
sql create database d3 replica 3 sql create database d3 replica 3 vgroups 1
sql create table d3.t3 (t timestamp, i int) sql create table d3.t3 (t timestamp, i int)
sql insert into d3.t3 values(now+1s, 35) sql insert into d3.t3 values(now+1s, 35)
sql insert into d3.t3 values(now+2s, 34) sql insert into d3.t3 values(now+2s, 34)
...@@ -175,97 +223,106 @@ sql insert into d3.t3 values(now+3s, 33) ...@@ -175,97 +223,106 @@ sql insert into d3.t3 values(now+3s, 33)
sql insert into d3.t3 values(now+4s, 32) sql insert into d3.t3 values(now+4s, 32)
sql insert into d3.t3 values(now+5s, 31) sql insert into d3.t3 values(now+5s, 31)
$x = 0
show4:
$x = $x + 1
sleep 1000
if $x == 30 then
return -1
endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode3 openVnodes $data(3)[2]
print dnode3 openVnodes $data2_3 print dnode4 openVnodes $data(4)[2]
print dnode4 openVnodes $data2_4 print dnode5 openVnodes $data(5)[2]
print dnode5 openVnodes $data2_5 if $data(1)[2] != 1 then
return -1
if $data2_1 != 0 then
goto show4
endi
if $data2_2 != null then
goto show4
endi endi
if $data2_3 != 3 then if $data(3)[2] != 3 then
goto show4 return -1
endi endi
if $data2_4 != 3 then if $data(4)[2] != 3 then
goto show4 return -1
endi endi
if $data2_5 != 3 then if $data(5)[2] != 2 then
goto show4 return -1
endi endi
print ========== step5 print ========== step5
sql create dnode $hostname6 sql create dnode $hostname port 7600
system sh/exec.sh -n dnode6 -s start system sh/exec.sh -n dnode6 -s start
$x = 0 $x = 0
show5: step5:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 20 then if $x == 10 then
return -1 print ====> dnode not ready!
return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode6 openVnodes $data2_6 print ===> $data10 $data11 $data12 $data13 $data14 $data15
print dnode3 openVnodes $data2_3 print ===> $data20 $data21 $data22 $data23 $data24 $data25
print dnode4 openVnodes $data2_4 print ===> $data30 $data31 $data32 $data33 $data34 $data35
print dnode5 openVnodes $data2_5 print ===> $data40 $data41 $data42 $data43 $data44 $data45
if $rows != 5 then
if $data2_1 != 0 then return -1
goto show5 endi
if $data(1)[4] != ready then
goto step5
endi
if $data(3)[4] != ready then
goto step5
endi endi
if $data2_6 != 2 then if $data(4)[4] != ready then
goto show5 goto step5
endi
if $data(5)[4] != ready then
goto step5
endi
if $data(6)[4] != ready then
goto step5
endi endi
sleep 8000 sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
print dnode5 openVnodes $data(5)[2]
print dnode5 openVnodes $data(6)[2]
if $data(1)[2] != 1 then
return -1
endi
if $data(3)[2] != 2 then
return -1
endi
if $data(4)[2] != 2 then
return -1
endi
if $data(5)[2] != 2 then
return -1
endi
if $data(6)[2] != 2 then
return -1
endi
print ========== step6 print ========== step6
sql drop dnode $hostname3 sql drop dnode 3
$x = 0
show6:
$x = $x + 1
sleep 1000
if $x == 30 then
return -1
endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode6 openVnodes $data2_6 print dnode3 openVnodes $data(3)[2]
print dnode3 openVnodes $data2_3 print dnode4 openVnodes $data(4)[2]
print dnode4 openVnodes $data2_4 print dnode5 openVnodes $data(5)[2]
print dnode5 openVnodes $data2_5 print dnode5 openVnodes $data(6)[2]
if $data(1)[2] != 2 then
if $data2_1 != 0 then return -1
goto show6
endi endi
if $data2_6 != 3 then if $data(3)[2] != null then
goto show6 return -1
endi endi
if $data2_3 != null then if $data(4)[2] != 2 then
goto show6 return -1
endi endi
if $data2_4 != 3 then if $data(5)[2] != 3 then
goto show6 return -1
endi endi
if $data2_5 != 3 then if $data(6)[2] != 2 then
goto show6 return -1
endi endi
system sh/exec.sh -n dnode3 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4 system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c supportVnodes -v 4
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode2 -c supportVnodes -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode3 -c supportVnodes -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4 system sh/cfg.sh -n dnode4 -c supportVnodes -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
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 dnode4 -c wallevel -v 1
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
print ========== step1 print ========== step1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sql connect sql connect
sql create database d1 sql create database d1 vgroups 1
sql create table d1.t1 (t timestamp, i int) sql create table d1.t1 (t timestamp, i int)
sql insert into d1.t1 values(now+1s, 15) sql insert into d1.t1 values(now+1s, 15)
sql insert into d1.t1 values(now+2s, 14) sql insert into d1.t1 values(now+2s, 14)
...@@ -32,7 +20,7 @@ sql insert into d1.t1 values(now+3s, 13) ...@@ -32,7 +20,7 @@ sql insert into d1.t1 values(now+3s, 13)
sql insert into d1.t1 values(now+4s, 12) sql insert into d1.t1 values(now+4s, 12)
sql insert into d1.t1 values(now+5s, 11) sql insert into d1.t1 values(now+5s, 11)
sql create database d2 sql create database d2 vgroups 1
sql create table d2.t2 (t timestamp, i int) sql create table d2.t2 (t timestamp, i int)
sql insert into d2.t2 values(now+1s, 25) sql insert into d2.t2 values(now+1s, 25)
sql insert into d2.t2 values(now+2s, 24) sql insert into d2.t2 values(now+2s, 24)
...@@ -41,36 +29,59 @@ sql insert into d2.t2 values(now+4s, 22) ...@@ -41,36 +29,59 @@ sql insert into d2.t2 values(now+4s, 22)
sql insert into d2.t2 values(now+5s, 21) sql insert into d2.t2 values(now+5s, 21)
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
if $data2_1 != 2 then if $data(1)[2] != 2 then
return -1 return -1
endi endi
print ========== step2 print ========== step2
sql create dnode $hostname2 sql create dnode $hostname port 7200
sql create dnode $hostname port 7300
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
$x = 0 $x = 0
step2: step2:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 10 then if $x == 10 then
print ====> dnode not ready!
return -1 return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 $data4_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 $data4_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
print dnode3 $data4_3 print ===> $data20 $data21 $data22 $data23 $data24 $data25
print dnode4 $data4_4 if $rows != 3 then
return -1
if $data4_1 != ready then endi
if $data(1)[4] != ready then
goto step2
endi
if $data(2)[4] != ready then
goto step2 goto step2
endi endi
if $data4_2 != ready then if $data(3)[4] != ready then
goto step2 goto step2
endi endi
sql create database d3 replica 2 sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(2)[2]
print dnode2 openVnodes $data(3)[2]
if $data(1)[2] != 0 then
return -1
endi
if $data(2)[2] != 1 then
return -1
endi
if $data(3)[2] != 1 then
return -1
endi
print ========== step3
sql create database d3 replica 3 vgroups 1
sql create table d3.t3 (t timestamp, i int) sql create table d3.t3 (t timestamp, i int)
sql insert into d3.t3 values(now+1s, 35) sql insert into d3.t3 values(now+1s, 35)
sql insert into d3.t3 values(now+2s, 34) sql insert into d3.t3 values(now+2s, 34)
...@@ -78,90 +89,96 @@ sql insert into d3.t3 values(now+3s, 33) ...@@ -78,90 +89,96 @@ sql insert into d3.t3 values(now+3s, 33)
sql insert into d3.t3 values(now+4s, 32) sql insert into d3.t3 values(now+4s, 32)
sql insert into d3.t3 values(now+5s, 31) sql insert into d3.t3 values(now+5s, 31)
$x = 0
show2:
$x = $x + 1
sleep 2000
if $x == 10 then
return -1
endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode2 openVnodes $data(2)[2]
if $data2_1 != 1 then print dnode2 openVnodes $data(3)[2]
goto show2 if $data(1)[2] != 1 then
return -1
endi
if $data(2)[2] != 2 then
return -1
endi endi
if $data2_2 != 3 then if $data(3)[2] != 2 then
goto show2 return -1
endi endi
print ========== step3 print ========== step3
sql create dnode $hostname port 7400
system sh/exec.sh -n dnode4 -s start
$x = 0 $x = 0
show3: step3:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 20 then if $x == 10 then
return -1 print ====> dnode not ready!
return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 openVnodes $data2_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
print ========== step4 print ===> $data30 $data31 $data32 $data33 $data34 $data35
sql create dnode $hostname3 if $rows != 4 then
system sh/exec.sh -n dnode3 -s start return -1
sql drop dnode $hostname2 endi
if $data(1)[4] != ready then
goto step3
endi
if $data(2)[4] != ready then
goto step3
endi
if $data(3)[4] != ready then
goto step3
endi
if $data(4)[4] != ready then
goto step3
endi
$x = 0 sql balance vgroup
show4:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode2 openVnodes $data(2)[2]
print dnode3 openVnodes $data2_3 print dnode2 openVnodes $data(3)[2]
if $data2_2 != null then print dnode2 openVnodes $data(4)[2]
goto show4 if $data(1)[2] != 0 then
return -1
endi
if $data(2)[2] != 2 then
return -1
endi
if $data(3)[2] != 2 then
return -1
endi
if $data(4)[2] != 1 then
return -1
endi endi
system sh/exec.sh -n dnode2 -s stop -x SIGINT
print ========== step5 print ========== step5
sql create dnode $hostname4 sql drop dnode 2
system sh/exec.sh -n dnode4 -s start
$x = 0
show5:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode2 openVnodes $data(2)[2]
print dnode3 openVnodes $data2_3 print dnode2 openVnodes $data(3)[2]
print dnode4 openVnodes $data2_4 print dnode2 openVnodes $data(4)[2]
if $data2_1 != 0 then if $data(1)[2] != 1 then
goto show5 return -1
endi endi
if $data2_2 != null then if $data(2)[2] != null then
goto show5 return -1
endi endi
if $data2_3 != 2 then if $data(3)[2] != 2 then
goto show5 return -1
endi endi
if $data2_4 != 2 then if $data(4)[2] != 2 then
goto show5 return -1
endi endi
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sql reset query cache
sleep 100
print ========== step6 print ========== step6
sql select * from d1.t1 order by t desc sql select * from d1.t1 order by t desc
print $data01 $data11 $data21 $data31 $data41 print $data01 $data11 $data21 $data31 $data41
...@@ -224,4 +241,4 @@ system sh/exec.sh -n dnode4 -s stop -x SIGINT ...@@ -224,4 +241,4 @@ system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT system sh/exec.sh -n dnode5 -s stop -x SIGINT
system sh/exec.sh -n dnode6 -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 dnode7 -s stop -x SIGINT
system sh/exec.sh -n dnode8 -s stop -x SIGINT system sh/exec.sh -n dnode8 -s stop -x SIGINT
\ No newline at end of file
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode2 -i 2
print ========== step1 print ========== step1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sql connect sql connect
sql create dnode $hostname2 sql create dnode $hostname port 7200
sql show dnodes sql show dnodes
print dnode1 off: $data7_1 print dnode1 off: $data(1)[6]
print dnode2 off: $data7_2 print dnode2 off: $data(2)[6]
if $data7_2 != @status not received@ then
if $data(2)[6] != @status not received@ then
return -1 return -1
endi endi
...@@ -19,26 +19,28 @@ print ========== step2 ...@@ -19,26 +19,28 @@ print ========== step2
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
$x = 0 $x = 0
step1: step2:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 10 then if $x == 10 then
print ====> dnode not ready!
return -1 return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 $data4_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 $data4_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 2 then
if $data4_1 != ready then return -1
goto step1 endi
if $data(1)[4] != ready then
goto step2
endi endi
if $data4_2 != ready then if $data(2)[4] != ready then
goto step1 goto step2
endi endi
print ========== step3 print ========== step3
system sh/exec.sh -n dnode2 -s stop system sh/exec.sh -n dnode2 -s stop
$x = 0 $x = 0
step3: step3:
...@@ -48,30 +50,22 @@ step3: ...@@ -48,30 +50,22 @@ step3:
return -1 return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 off: $data7_1 print dnode1 off: $data(1)[6]
print dnode2 off: $data7_2 print dnode2 off: $data(2)[6]
if $data7_2 != @status msg timeout@ then if $data(2)[6] != @status msg timeout@ then
goto step3 goto step3
endi endi
print ========== step4 print ========== step4
sql drop dnode $hostname2 sql drop dnode 2
$x = 0
step4:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes sql show dnodes
if $rows != 1 then if $rows != 1 then
goto step4 return -1
endi endi
print ========== step5 print ========== step5
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
sql create dnode $hostname2 sql create dnode $hostname port 7200
$x = 0 $x = 0
step5: step5:
...@@ -82,17 +76,17 @@ step5: ...@@ -82,17 +76,17 @@ step5:
endi endi
sql show dnodes sql show dnodes
print dnode1 off: $data7_1 print dnode1 off: $data(1)[6]
print dnode2 off: $data7_3 print dnode2 off: $data(3)[6]
if $data7_3 != @dnodeId not match@ then if $data(3)[6] != @dnodeId not match@ then
goto step5 goto step5
endi endi
print ========== step6 print ========== step6
system sh/deploy.sh -n dnode4 -i 4 system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 3 system sh/cfg.sh -n dnode4 -c statusInterval -v 4
system sh/exec.sh -n dnode4 -s start system sh/exec.sh -n dnode4 -s start
sql create dnode $hostname4 sql create dnode $hostname port 7400
$x = 0 $x = 0
step6: step6:
...@@ -103,17 +97,18 @@ step6: ...@@ -103,17 +97,18 @@ step6:
endi endi
sql show dnodes sql show dnodes
print dnode1 off: $data7_1 print dnode1 off: $data(1)[6]
print dnode4 off: $data7_4 print dnode2 off: $data(3)[6]
if $data7_4 != @mnEqualVn not match@ then print dnode3 off: $data(4)[6]
if $data(4)[6] != @interval not match@ then
goto step6 goto step6
endi endi
print ========== step7 print ========== step7
system sh/deploy.sh -n dnode5 -i 5 system sh/deploy.sh -n dnode5 -i 5
system sh/cfg.sh -n dnode5 -c statusInterval -v 3 system sh/cfg.sh -n dnode5 -c locale -v zn_CH.UTF-8
system sh/exec.sh -n dnode5 -s start system sh/exec.sh -n dnode5 -s start
sql create dnode $hostname5 sql create dnode $hostname port 7500
$x = 0 $x = 0
step7: step7:
...@@ -124,17 +119,19 @@ step7: ...@@ -124,17 +119,19 @@ step7:
endi endi
sql show dnodes sql show dnodes
print dnode1 off: $data7_1 print dnode1 off: $data(1)[6]
print dnode5 off: $data7_5 print dnode3 off: $data(3)[6]
if $data7_5 != @interval not match@ then print dnode4 off: $data(4)[6]
print dnode5 off: $data(5)[6]
if $data(5)[6] != @locale not match@ then
goto step7 goto step7
endi endi
print ========== step8 print ========== step8
system sh/deploy.sh -n dnode6 -i 6 system sh/deploy.sh -n dnode6 -i 6
system sh/cfg.sh -n dnode6 -c balance -v 0 system sh/cfg.sh -n dnode6 -c charset -v UTF-16
system sh/exec.sh -n dnode6 -s start system sh/exec.sh -n dnode6 -s start
sql create dnode $hostname6 sql create dnode $hostname port 7600
$x = 0 $x = 0
step8: step8:
...@@ -145,54 +142,15 @@ step8: ...@@ -145,54 +142,15 @@ step8:
endi endi
sql show dnodes sql show dnodes
print dnode1 off: $data7_1 print dnode1 off: $data(1)[6]
print dnode6 off: $data7_6 print dnode3 off: $data(3)[6]
if $data7_6 != @balance not match@ then print dnode4 off: $data(4)[6]
print dnode5 off: $data(5)[6]
print dnode6 off: $data(6)[6]
if $data(6)[6] != @charset not match@ then
goto step8 goto step8
endi endi
print ========== step9
system sh/deploy.sh -n dnode7 -i 7
system sh/cfg.sh -n dnode7 -c maxTablesPerVnode -v 3000
system sh/exec.sh -n dnode7 -s start
sql create dnode $hostname7
$x = 0
step9:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 off: $data7_1
print dnode7 off: $data7_7
if $data7_7 != @maxTabPerVn not match@ then
goto step9
endi
print ========== step10
system sh/deploy.sh -n dnode8 -i 8
system sh/cfg.sh -n dnode8 -c maxVgroupsPerDb -v 3
system sh/exec.sh -n dnode8 -s start
sql create dnode $hostname8
$x = 0
step10:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 off: $data7_1
print dnode8 off: $data7_8
if $data7_8 != @maxVgPerDb not match@ then
goto step10
endi
system sh/exec.sh -n dnode1 -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 dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4 system sh/deploy.sh -n dnode4 -i 4
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/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 dnode4 -c wallevel -v 1
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
print ========== step1 print ========== step1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sql connect sql connect
sql create database d1 sql create database d1 vgroups 1
sql create table d1.t1 (t timestamp, i int) sql create table d1.t1 (t timestamp, i int)
sql insert into d1.t1 values(now+1s, 15) sql insert into d1.t1 values(now+1s, 15)
sql insert into d1.t1 values(now+2s, 14) sql insert into d1.t1 values(now+2s, 14)
...@@ -33,34 +17,49 @@ sql insert into d1.t1 values(now+4s, 12) ...@@ -33,34 +17,49 @@ sql insert into d1.t1 values(now+4s, 12)
sql insert into d1.t1 values(now+5s, 11) sql insert into d1.t1 values(now+5s, 11)
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
if $data2_1 != 1 then if $data(1)[2] != 1 then
return -1 return -1
endi endi
print ========== step2 print ========== step2
sql create dnode $hostname2 sql create dnode $hostname port 7200
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
$x = 0 $x = 0
show2: step2:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 20 then if $x == 10 then
return -1 print ====> dnode not ready!
return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 openVnodes $data2_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $data2_1 != 0 then if $rows != 2 then
goto show2 return -1
endi endi
if $data2_2 != 1 then if $data(1)[4] != ready then
goto show2 goto step2
endi
if $data(2)[4] != ready then
goto step2
endi
sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(2)[2]
if $data(1)[2] != 0 then
return -1
endi
if $data(2)[2] != 1 then
return -1
endi endi
print ========== step3 print ========== step3
sql create database d2 sql create database d2 vgroups 1
sql create table d2.t2 (t timestamp, i int) sql create table d2.t2 (t timestamp, i int)
sql insert into d2.t2 values(now+1s, 25) sql insert into d2.t2 values(now+1s, 25)
...@@ -69,65 +68,68 @@ sql insert into d2.t2 values(now+3s, 23) ...@@ -69,65 +68,68 @@ sql insert into d2.t2 values(now+3s, 23)
sql insert into d2.t2 values(now+4s, 22) sql insert into d2.t2 values(now+4s, 22)
sql insert into d2.t2 values(now+5s, 21) sql insert into d2.t2 values(now+5s, 21)
$x = 0
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode2 openVnodes $data(2)[2]
if $data2_1 != 0 then if $data(1)[2] != 0 then
return -1 return -1
endi endi
if $data2_2 != 2 then if $data(2)[2] != 2 then
return -1 return -1
endi endi
print ========== step4 print ========== step4
sql drop dnode $hostname2 sql drop dnode 2
$x = 0
show4:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_2 print dnode2 openVnodes $data(2)[2]
if $data2_1 != 2 then if $data(1)[2] != 2 then
goto show4 return -1
endi
if $data2_2 != null then
goto show4
endi endi
if $rows != 1 then if $data(2)[2] != null then
goto show4 return -1
endi endi
system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT
print ========== step5 print ========== step5
sql create dnode $hostname3 sql create dnode $hostname port 7300
system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode3 -s start
$x = 0 $x = 0
show5: step5:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 40 then if $x == 10 then
return -1 print ====> dnode not ready!
return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode3 openVnodes $data2_3 print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $data2_1 != 0 then if $rows != 2 then
goto show5 return -1
endi
if $data(1)[4] != ready then
goto step5
endi
if $data(3)[4] != ready then
goto step5
endi
sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(3)[2]
if $data(1)[2] != 1 then
return -1
endi endi
if $data2_3 != 2 then if $data(3)[2] != 1 then
goto show5 return -1
endi endi
print ========== step6 print ========== step6
sql create database d3 sql create database d3 vgroups 1
sql create table d3.t3 (t timestamp, i int) sql create table d3.t3 (t timestamp, i int)
sql insert into d3.t3 values(now+1s, 35) sql insert into d3.t3 values(now+1s, 35)
sql insert into d3.t3 values(now+2s, 34) sql insert into d3.t3 values(now+2s, 34)
...@@ -136,43 +138,61 @@ sql insert into d3.t3 values(now+4s, 32) ...@@ -136,43 +138,61 @@ sql insert into d3.t3 values(now+4s, 32)
sql insert into d3.t3 values(now+5s, 31) sql insert into d3.t3 values(now+5s, 31)
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data2_3 print dnode2 openVnodes $data(3)[2]
if $data2_1 != 0 then if $data(1)[2] != 1 then
return -1 return -1
endi endi
if $data2_3 != 3 then if $data(3)[2] != 2 then
return -1 return -1
endi endi
print ========== step7 print ========== step7
sql create dnode $hostname4 sql create dnode $hostname port 7400
system sh/exec.sh -n dnode4 -s start system sh/exec.sh -n dnode4 -s start
$x = 0 $x = 0
show7: step7:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 40 then if $x == 10 then
print ====> dnode not ready!
return -1 return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode3 openVnodes $data2_3 print ===> $data10 $data11 $data12 $data13 $data14 $data15
print dnode4 openVnodes $data2_4 print ===> $data20 $data21 $data22 $data23 $data24 $data25
if $data2_1 != 0 then if $rows != 3 then
goto show7 return -1
endi
if $data(1)[4] != ready then
goto step7
endi endi
if $data2_3 != 2 then if $data(3)[4] != ready then
goto show7 goto step7
endi endi
if $data2_4 != 1 then if $data(4)[4] != ready then
goto show7 goto step7
endi
sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(3)[2]
print dnode2 openVnodes $data(4)[2]
if $data(1)[2] != 0 then
return -1
endi
if $data(3)[2] != 2 then
return -1
endi
if $data(4)[2] != 1 then
return -1
endi endi
print ========== step8 print ========== step8
sql create database d4 sql create database d4 vgroups 1
sql create table d4.t4 (t timestamp, i int) sql create table d4.t4 (t timestamp, i int)
sql insert into d4.t4 values(now+1s, 45) sql insert into d4.t4 values(now+1s, 45)
sql insert into d4.t4 values(now+2s, 44) sql insert into d4.t4 values(now+2s, 44)
...@@ -180,53 +200,39 @@ sql insert into d4.t4 values(now+3s, 43) ...@@ -180,53 +200,39 @@ sql insert into d4.t4 values(now+3s, 43)
sql insert into d4.t4 values(now+4s, 42) sql insert into d4.t4 values(now+4s, 42)
sql insert into d4.t4 values(now+5s, 41) sql insert into d4.t4 values(now+5s, 41)
$x = 0
show8:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data2_3 print dnode2 openVnodes $data(3)[2]
print dnode4 openVnodes $data2_4 print dnode2 openVnodes $data(4)[2]
if $data2_1 != 0 then if $data(1)[2] != 0 then
goto show8 return -1
endi endi
if $data2_3 != 2 then if $data(3)[2] != 2 then
goto show8 return -1
endi endi
if $data2_4 != 2 then if $data(4)[2] != 2 then
goto show8 return -1
endi endi
print ========== step9 print ========== step9
sql drop dnode $hostname3 sql drop dnode 3
$x = 0
show9:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show dnodes sql show dnodes
print dnode1 openVnodes $data2_1 print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data2_3 print dnode2 openVnodes $data(3)[2]
print dnode4 openVnodes $data2_4 print dnode2 openVnodes $data(4)[2]
if $data2_1 != 0 then if $data(1)[2] != 1 then
goto show9 return -1
endi endi
if $data2_3 != null then if $data(3)[2] != null then
goto show9 return -1
endi endi
if $data2_4 != 4 then if $data(4)[2] != 3 then
goto show9 return -1
endi endi
system sh/exec.sh -n dnode3 -s stop system sh/exec.sh -n dnode3 -s stop -x SIGINT
sql reset query cache
sleep 100
print ========== step10 print ========== step10
sql select * from d1.t1 order by t desc sql select * from d1.t1 order by t desc
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3 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 numOfMnodes -v 3
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3
print ========== step0
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sql connect sql connect
sql create dnode $hostname2
sql create dnode $hostname3 sql create dnode $hostname port 7200
sql create dnode $hostname port 7300
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode3 -s start
$x = 0 $x = 0
step1: step01:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 10 then if $x == 10 then
print ====> dnode not ready!
return -1 return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 $data4_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 $data4_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
print dnode3 $data4_3 print ===> $data20 $data21 $data22 $data23 $data24 $data25
if $rows != 3 then
if $data4_1 != ready then return -1
goto step1
endi endi
if $data4_2 != ready then if $data(1)[4] != ready then
goto step1 goto step01
endi endi
if $data4_3 != ready then if $data(2)[4] != ready then
goto step1 goto step01
endi
if $data(3)[4] != ready then
goto step01
endi endi
sql create mnode on dnode 2
sql create mnode on dnode 3
$x = 0
step02:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show mnodes sql show mnodes
print mnode1 $data2_1 print $data(1)[0] $data(1)[1] $data(1)[2]
print mnode1 $data2_2 print $data(2)[0] $data(2)[1] $data(2)[2]
print mnode1 $data2_3 print $data(3)[0] $data(3)[1] $data(3)[2]
if $data2_1 != master then
goto step1 if $rows != 3 then
return -1
endi endi
if $data2_2 != slave then if $data(1)[0] != 1 then
goto step1 return -1
endi endi
if $data2_3 != slave then if $data(1)[2] != leader then
goto step1 return -1
endi
if $data(2)[0] != 2 then
return -1
endi
if $data(2)[2] != follower then
goto step02
endi
if $data(3)[0] != 3 then
return -1
endi
if $data(3)[2] != follower then
goto step02
endi endi
$N = 10 $N = 10
...@@ -59,13 +79,37 @@ $table = table_r3 ...@@ -59,13 +79,37 @@ $table = table_r3
$db = db1 $db = db1
print =================== step 1 print =================== step 1
sql create database $db replica 3 vgroups 1
sql use $db
$x = 0
step1:
$x = $x + 1
sleep 1000
if $x == 60 then
print ====> db not ready!
return -1
endi
sql show vgroups -x step1
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
$leaderExist = 0
if $data(2)[4] == leader then
$leaderExist = 1
endi
if $data(2)[6] == leader then
$leaderExist = 1
endi
if $data(2)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step1
endi
sql create database $db replica 3
sql use $db sql use $db
sql create table $table (ts timestamp, speed int) sql create table $table (ts timestamp, speed int)
sleep 3001
print =================== step 2 print =================== step2
$x = 1 $x = 1
$y = $x + $N $y = $x + $N
$expect = $N $expect = $N
...@@ -81,9 +125,32 @@ if $rows != $expect then ...@@ -81,9 +125,32 @@ if $rows != $expect then
return -1 return -1
endi endi
print =================== step 3 print =================== step3
system sh/exec.sh -n dnode2 -s stop system sh/exec.sh -n dnode2 -s stop
sleep 2000 $x = 0
step3:
$x = $x + 1
sleep 1000
if $x == 60 then
print ====> db not ready!
return -1
endi
sql show vgroups -x step3
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
$leaderExist = 0
if $data(2)[4] == leader then
$leaderExist = 1
endi
if $data(2)[6] == leader then
$leaderExist = 1
endi
if $data(2)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step3
endi
$y = $x + $N $y = $x + $N
$expect = $N * 2 $expect = $N * 2
while $x < $y while $x < $y
...@@ -92,27 +159,35 @@ while $x < $y ...@@ -92,27 +159,35 @@ while $x < $y
$x = $x + 1 $x = $x + 1
endw endw
sql select * from $table
print sql select * from $table -> $rows points print sql select * from $table -> $rows points
if $rows != $expect then #if $rows != $expect then
return -1 # return -1
endi #endi
print =================== step 4 print =================== step4
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
$x = 0 $x = 0
step4: step4:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 40 then if $x == 60 then
return -1 print ====> db not ready!
return -1
endi endi
sql show vgroups -x step4
sql show db1.vgroups print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print online vnodes $data03 $leaderExist = 0
if $data03 != 3 then if $data(2)[4] == leader then
goto step4 $leaderExist = 1
endi
if $data(2)[6] == leader then
$leaderExist = 1
endi
if $data(2)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step4
endi endi
$y = $x + $N $y = $x + $N
...@@ -125,12 +200,36 @@ endw ...@@ -125,12 +200,36 @@ endw
sql select * from $table sql select * from $table
print sql select * from $table -> $rows points print sql select * from $table -> $rows points
if $rows != $expect then #if $rows != $expect then
return -1 # return -1
endi #endi
print =================== step 5 print =================== step5
system sh/exec.sh -n dnode3 -s stop system sh/exec.sh -n dnode3 -s stop
$x = 0
step5:
$x = $x + 1
sleep 1000
if $x == 60 then
print ====> db not ready!
return -1
endi
sql show vgroups -x step5
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
$leaderExist = 0
if $data(2)[4] == leader then
$leaderExist = 1
endi
if $data(2)[6] == leader then
$leaderExist = 1
endi
if $data(2)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step5
endi
$y = $x + $N $y = $x + $N
$expect = $N * 4 $expect = $N * 4
while $x < $y while $x < $y
...@@ -141,25 +240,34 @@ endw ...@@ -141,25 +240,34 @@ endw
sql select * from $table sql select * from $table
print sql select * from $table -> $rows points print sql select * from $table -> $rows points
if $rows != $expect then #if $rows != $expect then
return -1 # return -1
endi #endi
print =================== step 6 print =================== step6
system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode3 -s start
$x = 0 $x = 0
step6: step6:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 40 then if $x == 60 then
return -1 print ====> db not ready!
return -1
endi endi
sql show vgroups -x step6
sql show db1.vgroups print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print online vnodes $data03 $leaderExist = 0
if $data03 != 3 then if $data(2)[4] == leader then
goto step6 $leaderExist = 1
endi
if $data(2)[6] == leader then
$leaderExist = 1
endi
if $data(2)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step6
endi endi
$y = $x + $N $y = $x + $N
...@@ -171,13 +279,37 @@ $x = $x + 1 ...@@ -171,13 +279,37 @@ $x = $x + 1
endw endw
sql select * from $table sql select * from $table
print sql select * from $table -> $rows points print sql select * from $table -> $rows points
if $rows != $expect then #if $rows != $expect then
return -1 # return -1
endi #endi
print =================== step 7 print =================== step7
system sh/exec.sh -n dnode1 -s stop system sh/exec.sh -n dnode1 -s stop
$x = 0
step7:
$x = $x + 1
sleep 1000
if $x == 60 then
print ====> db not ready!
return -1
endi
sql show vgroups -x step7
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
$leaderExist = 0
if $data(2)[4] == leader then
$leaderExist = 1
endi
if $data(2)[6] == leader then
$leaderExist = 1
endi
if $data(2)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step7
endi
$y = $x + $N $y = $x + $N
$expect = $N * 6 $expect = $N * 6
while $x < $y while $x < $y
...@@ -187,26 +319,35 @@ $x = $x + 1 ...@@ -187,26 +319,35 @@ $x = $x + 1
endw endw
sql select * from $table sql select * from $table
print sql select * from $table -> $rows points print sql select * from $table -> $rows points
if $rows != $expect then #if $rows != $expect then
return -1 # return -1
endi #endi
print =================== step 8 print =================== step 8
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
$x = 0 $x = 0
step8: step8:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 40 then if $x == 60 then
return -1 print ====> db not ready!
return -1
endi endi
sql show vgroups -x step8
sql show db1.vgroups print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print online vnodes $data03 $leaderExist = 0
if $data03 != 3 then if $data(2)[4] == leader then
goto step8 $leaderExist = 1
endi
if $data(2)[6] == leader then
$leaderExist = 1
endi
if $data(2)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step8
endi endi
$y = $x + $N $y = $x + $N
...@@ -217,17 +358,11 @@ while $x < $y ...@@ -217,17 +358,11 @@ while $x < $y
$x = $x + 1 $x = $x + 1
endw endw
sql select * from $table
print sql select * from $table -> $rows points print sql select * from $table -> $rows points
if $rows != $expect then #if $rows != $expect then
return -1 # return -1
endi #endi
system sh/exec.sh -n dnode1 -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 dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT \ No newline at end of file
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
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4 system sh/deploy.sh -n dnode4 -i 4
system sh/deploy.sh -n dnode5 -i 5
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 system sh/deploy.sh -n dnode6 -i 6
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode1 -c supportVnodes -v 4
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode2 -c supportVnodes -v 4
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 system sh/cfg.sh -n dnode3 -c supportVnodes -v 4
system sh/cfg.sh -n dnode4 -c supportVnodes -v 4
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10 system sh/cfg.sh -n dnode5 -c supportVnodes -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10 system sh/cfg.sh -n dnode6 -c supportVnodes -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 10 print ========== step1
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode3 -c walLevel -v 2
system sh/cfg.sh -n dnode4 -c walLevel -v 2
print ========= start dnode1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sql connect sql connect
sql create dnode $hostname2 sql create dnode $hostname port 7200
sql create dnode $hostname3 sql create dnode $hostname port 7300
sql create dnode $hostname port 7400
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start
$x = 0 $x = 0
step1: stepa:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 10 then if $x == 10 then
print ====> dnode not ready!
return -1 return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 $data4_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 $data4_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
print dnode3 $data4_3 print ===> $data20 $data21 $data22 $data23 $data24 $data25
print dnode4 $data4_4 print ===> $data30 $data31 $data32 $data33 $data34 $data35
if $rows != 4 then
if $data4_1 != ready then return -1
goto step1 endi
if $data(1)[4] != ready then
goto stepa
endi endi
if $data4_2 != ready then if $data(2)[4] != ready then
goto step1 goto stepa
endi endi
if $data4_3 != ready then if $data(3)[4] != ready then
goto step1 goto stepa
endi
if $data(4)[4] != ready then
goto stepa
endi endi
sql create database ir3db replica 3 duration 7 sql create database ir3db replica 3 duration 7 vgroups 1
sql use ir3db sql use ir3db
$x = 0
stepb:
$x = $x + 1
sleep 1000
if $x == 60 then
print ====> db not ready!
return -1
endi
sql show vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
$leaderExist = 0
if $rows != 1 then
return -1
endi
if $data(2)[4] == leader then
$leaderExist = 1
endi
if $data(2)[6] == leader then
$leaderExist = 1
endi
if $data(2)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto stepb
endi
sql create table tb(ts timestamp, i bigint) sql create table tb(ts timestamp, i bigint)
print ================= step1 print ================= step1
sql import into tb values(1520000010000, 1520000010000) sql insert into tb values(1520000010000, 1520000010000)
sql select * from tb; sql select * from tb;
print $rows print $rows
if $rows != 1 then if $rows != 1 then
...@@ -87,9 +108,9 @@ if $rows != 3 then ...@@ -87,9 +108,9 @@ if $rows != 3 then
endi endi
print ================= step4 print ================= step4
sql import into tb values(1520000009000, 1520000009000) sql insert into tb values(1520000009000, 1520000009000)
sql import into tb values(1520000015000, 1520000015000) sql insert into tb values(1520000015000, 1520000015000)
sql import into tb values(1520000030000, 1520000030000) sql insert into tb values(1520000030000, 1520000030000)
sql select * from tb; sql select * from tb;
print $rows print $rows
if $rows != 6 then if $rows != 6 then
...@@ -108,44 +129,50 @@ if $rows != 9 then ...@@ -108,44 +129,50 @@ if $rows != 9 then
endi endi
print ================= step6 print ================= step6
sql import into tb values(1520000007000, 1520000007000) sql insert into tb values(1520000007000, 1520000007000)
sql import into tb values(1520000012000, 1520000012000) sql insert into tb values(1520000012000, 1520000012000)
sql import into tb values(1520000023000, 1520000023000) sql insert into tb values(1520000023000, 1520000023000)
sql import into tb values(1520000034000, 1520000034000) sql insert into tb values(1520000034000, 1520000034000)
sql import into tb values(1520000050000, 1520000050000) sql insert into tb values(1520000050000, 1520000050000)
sql select * from tb; sql select * from tb;
print $rows print $rows
if $rows != 14 then if $rows != 14 then
return -1 return -1
endi endi
print ================== dnode restart print ================== step7
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 dnode1 -s start system sh/exec.sh -n dnode2 -s start
$x = 0 $x = 0
a4: step7:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 40 then if $x == 60 then
return -1 print ====> db not ready!
return -1
endi endi
sql show vgroups sql show vgroups -x step7
print online vnodes $data03 print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 3 then $leaderExist = 0
goto a4 if $data(2)[4] == leader then
$leaderExist = 1
endi endi
if $data(2)[6] == leader then
sql select * from tb; $leaderExist = 1
if $rows != 14 then endi
return -1 if $data(2)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step7
endi endi
print ================= step7 print ================= step7
sql import into tb values(1520000007001, 1520000007001) sql insert into tb values(1520000007001, 1520000007001)
sql import into tb values(1520000012001, 1520000012001) sql insert into tb values(1520000012001, 1520000012001)
sql import into tb values(1520000023001, 1520000023001) sql insert into tb values(1520000023001, 1520000023001)
sql import into tb values(1520000034001, 1520000034001) sql insert into tb values(1520000034001, 1520000034001)
sql import into tb values(1520000050001, 1520000050001) sql insert into tb values(1520000050001, 1520000050001)
sql select * from tb; sql select * from tb;
print $rows print $rows
if $rows != 19 then if $rows != 19 then
...@@ -165,32 +192,18 @@ if $rows != 23 then ...@@ -165,32 +192,18 @@ if $rows != 23 then
endi endi
print ================= step9 print ================= step9
#1520000000000 sql insert into tb values(1517408000000, 1517408000000)
#sql import into tb values(now-30d, 7003) sql insert into tb values(1518272000000, 1518272000000)
#sql import into tb values(now-20d, 34003) sql insert into tb values(1519136000000, 1519136000000)
#sql import into tb values(now-10d, 34003) sql insert into tb values(1519568000000, 1519568000000)
#sql import into tb values(now-5d, 34003) sql insert into tb values(1519654400000, 1519654400000)
#sql import into tb values(now+1d, 50001) sql insert into tb values(1519827200000, 1519827200000)
#sql import into tb values(now+2d, 50001) sql insert into tb values(1520345600000, 1520345600000)
#sql import into tb values(now+6d, 50001) sql insert into tb values(1520691200000, 1520691200000)
#sql import into tb values(now+8d, 50002) sql insert into tb values(1520864000000, 1520864000000)
#sql import into tb values(now+10d, 50003) sql insert into tb values(1521900800000, 1521900800000)
#sql import into tb values(now+12d, 50004) sql insert into tb values(1523110400000, 1523110400000)
#sql import into tb values(now+14d, 50001) sql insert into tb values(1521382400000, 1521382400000)
#sql import into tb values(now+16d, 500051)
sql import into tb values(1517408000000, 1517408000000)
sql import into tb values(1518272000000, 1518272000000)
sql import into tb values(1519136000000, 1519136000000)
sql import into tb values(1519568000000, 1519568000000)
sql import into tb values(1519654400000, 1519654400000)
sql import into tb values(1519827200000, 1519827200000)
sql import into tb values(1520345600000, 1520345600000)
sql import into tb values(1520691200000, 1520691200000)
sql import into tb values(1520864000000, 1520864000000)
sql import into tb values(1521900800000, 1521900800000)
sql import into tb values(1523110400000, 1523110400000)
sql import into tb values(1521382400000, 1521382400000)
sql select * from tb; sql select * from tb;
print $rows print $rows
if $rows != 35 then if $rows != 35 then
...@@ -198,20 +211,30 @@ if $rows != 35 then ...@@ -198,20 +211,30 @@ if $rows != 35 then
endi endi
print ================= step10 print ================= step10
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode3 -s start
$x = 0 $x = 0
step10: step10:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 40 then if $x == 60 then
return -1 print ====> db not ready!
return -1
endi endi
sql show vgroups sql show vgroups -x step10
print online vnodes $data03 print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 3 then $leaderExist = 0
goto step10 if $data(2)[4] == leader then
$leaderExist = 1
endi
if $data(2)[6] == leader then
$leaderExist = 1
endi
if $data(2)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step10
endi endi
sql select * from tb; sql select * from tb;
...@@ -221,18 +244,14 @@ if $rows != 35 then ...@@ -221,18 +244,14 @@ if $rows != 35 then
endi endi
print ================= step11 print ================= step11
sql insert into tb values(1515680000000, 1) (1515852800000, 2) (1516025600000, 3) (1516198400000, 4) (1516371200000, 5)
#sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003)
sql import into tb values(1515680000000, 1) (1515852800000, 2) (1516025600000, 3) (1516198400000, 4) (1516371200000, 5)
sql select * from tb; sql select * from tb;
if $rows != 40 then if $rows != 40 then
return -1 return -1
endi endi
print ================= step12 print ================= step12
#1520000000000 sql insert into tb values(1518358400000, 6) (1518444800000, 7) (1518531200000, 8) (1518617600000, 9) (1518704000000, 10) (1518790400000, 11) (1518876800000, 12) (1518963200000, 13) (1519049600000, 14)
#sql import into tb values(now-19d, -19) (now-18d, -18) (now-17d, -17) (now-16d, -16) (now-15d, -15) (now-14d, -14) (now-13d, -13) (now-12d, -12) (now-11d, -11)
sql import into tb values(1518358400000, 6) (1518444800000, 7) (1518531200000, 8) (1518617600000, 9) (1518704000000, 10) (1518790400000, 11) (1518876800000, 12) (1518963200000, 13) (1519049600000, 14)
sql select * from tb; sql select * from tb;
print $rows print $rows
if $rows != 49 then if $rows != 49 then
...@@ -240,22 +259,39 @@ if $rows != 49 then ...@@ -240,22 +259,39 @@ if $rows != 49 then
endi endi
print ================= step13 print ================= step13
system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep 3000 system sh/exec.sh -n dnode4 -s start
system sh/exec.sh -n dnode2 -s start $x = 0
sleep 3000 step13:
$x = $x + 1
sleep 1000
if $x == 60 then
print ====> db not ready!
return -1
endi
sql show vgroups -x step13
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
$leaderExist = 0
if $data(2)[4] == leader then
$leaderExist = 1
endi
if $data(2)[6] == leader then
$leaderExist = 1
endi
if $data(2)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step13
endi
print ================= step14 print ================= step14
#1520000000000 sql insert into tb values(1515852800001, -48)
#sql import into tb values(now-48d, -48) sql insert into tb values(1516716800000, -38)
#sql import into tb values(now-38d, -38) sql insert into tb values(1517580800000, -28)
#sql import into tb values(now-28d, -28)
sql import into tb values(1515852800001, -48)
sql import into tb values(1516716800000, -38)
sql import into tb values(1517580800000, -28)
sql select * from tb; sql select * from tb;
print $rows
if $rows != 52 then if $rows != 52 then
return -1 return -1
endi endi
...@@ -264,16 +300,27 @@ print ================= step15 ...@@ -264,16 +300,27 @@ print ================= step15
system sh/exec.sh -n dnode3 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode3 -s start
$x = 0 $x = 0
step15: step15:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 40 then if $x == 60 then
return -1 print ====> db not ready!
return -1
endi endi
sql show vgroups sql show vgroups -x step15
print online vnodes $data03 print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 3 then $leaderExist = 0
goto step15 if $data(2)[4] == leader then
$leaderExist = 1
endi
if $data(2)[6] == leader then
$leaderExist = 1
endi
if $data(2)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step15
endi endi
sql select * from tb; sql select * from tb;
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4 system sh/deploy.sh -n dnode4 -i 4
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 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.sh -n dnode1 -s start
print ========== step0
system sh/exec.sh -n dnode1 -s start
sql connect sql connect
sql create dnode $hostname2
sql create dnode $hostname3 sql create dnode $hostname port 7200
sql create dnode $hostname port 7300
sql create dnode $hostname port 7400
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start
$x = 0 $x = 0
step1: step0:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 10 then if $x == 10 then
print ====> dnode not ready!
return -1 return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 $data4_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 $data4_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
print dnode3 $data4_3 print ===> $data20 $data21 $data22 $data23 $data24 $data25
print dnode4 $data4_4 print ===> $data30 $data31 $data32 $data33 $data34 $data35
if $rows != 4 then
return -1
endi
if $data(1)[4] != ready then
goto step0
endi
if $data(2)[4] != ready then
goto step0
endi
if $data(3)[4] != ready then
goto step0
endi
if $data(4)[4] != ready then
goto step0
endi
print ========= step1
sql create database db1 replica 3 vgroups 1
sql create database db2 replica 3 vgroups 1
sql create database db3 replica 3 vgroups 1
sql create database db4 replica 3 vgroups 1
if $data4_1 != ready then print =============== step12 wait vgroup2
goto step1 $x = 0
step12:
$x = $x + 1
sleep 1000
if $x == 60 then
print ====> db not ready!
return -1
endi
sql show d1.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29
print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39
if $rows != 4 then
return -1
endi
if $data(2)[4] == leader then
$leaderExist = 1
endi endi
if $data4_2 != ready then if $data(2)[6] == leader then
goto step1 $leaderExist = 1
endi endi
if $data4_3 != ready then if $data(2)[8] == leader then
goto step1 $leaderExist = 1
endi
if $leaderExist != 1 then
goto step12
endi endi
sql show mnodes print =============== step13 wait vgroup3
print mnode1 $data2_1 $x = 0
print mnode1 $data2_2 step13:
print mnode1 $data2_3 $x = $x + 1
if $data2_1 != master then sleep 1000
goto step1 if $x == 60 then
print ====> db not ready!
return -1
endi
sql show d1.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29
print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39
if $rows != 4 then
return -1
endi
if $data(3)[4] == leader then
$leaderExist = 1
endi
if $data(3)[6] == leader then
$leaderExist = 1
endi
if $data(3)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step13
endi endi
print ========= step1 print =============== step14 wait vgroup4
sql create database db1 replica 2 $x = 0
sql create database db2 replica 2 step14:
sql create database db3 replica 2 $x = $x + 1
sql create database db4 replica 2 sleep 1000
if $x == 60 then
print ====> db not ready!
return -1
endi
sql show d1.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29
print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39
if $rows != 4 then
return -1
endi
if $data(4)[4] == leader then
$leaderExist = 1
endi
if $data(4)[6] == leader then
$leaderExist = 1
endi
if $data(4)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step14
endi
print =============== step15 wait vgroup5
$x = 0
step15:
$x = $x + 1
sleep 1000
if $x == 60 then
print ====> db not ready!
return -1
endi
sql show d1.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29
print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39
if $rows != 4 then
return -1
endi
if $data(4)[4] == leader then
$leaderExist = 1
endi
if $data(4)[6] == leader then
$leaderExist = 1
endi
if $data(4)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step15
endi
print =============== step16: create table
sql create table db1.tb1 (ts timestamp, i int) sql create table db1.tb1 (ts timestamp, i int)
sql create table db2.tb2 (ts timestamp, i int) sql create table db2.tb2 (ts timestamp, i int)
sql create table db3.tb3 (ts timestamp, i int) sql create table db3.tb3 (ts timestamp, i int)
...@@ -79,14 +190,18 @@ sql select count(*) from db4.tb4 ...@@ -79,14 +190,18 @@ sql select count(*) from db4.tb4
$lastRows4 = $rows $lastRows4 = $rows
print ======== step2 print ======== step2
run_back unique/vnode/back_insert_many.sim run_back tsim/vnode/back_insert_many.sim
sleep 3000 sleep 3000
print ======== step3
$x = 0 $x = 0
loop: loop:
print ======== step3
system sh/exec.sh -n dnode2 -s stop
sleep 3000
system sh/exec.sh -n dnode2 -s start
sleep 3000
print ======== step4 print ======== step4
system sh/exec.sh -n dnode3 -s stop system sh/exec.sh -n dnode3 -s stop
sleep 3000 sleep 3000
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4 system sh/deploy.sh -n dnode4 -i 4
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 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
print ========== step0
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sql connect sql connect
sql create dnode $hostname2
sql create dnode $hostname3 sql create dnode $hostname port 7200
sql create dnode $hostname4 sql create dnode $hostname port 7300
sql create dnode $hostname port 7400
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start system sh/exec.sh -n dnode4 -s start
$x = 0 $x = 0
step1: step0:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 10 then if $x == 10 then
print ====> dnode not ready!
return -1 return -1
endi endi
sql show dnodes sql show dnodes
print dnode1 $data4_1 print ===> $data00 $data01 $data02 $data03 $data04 $data05
print dnode2 $data4_2 print ===> $data10 $data11 $data12 $data13 $data14 $data15
print dnode3 $data4_3 print ===> $data20 $data21 $data22 $data23 $data24 $data25
print dnode4 $data4_4 print ===> $data30 $data31 $data32 $data33 $data34 $data35
if $rows != 4 then
if $data4_1 != ready then return -1
goto step1
endi endi
if $data4_2 != ready then if $data(1)[4] != ready then
goto step1 goto step0
endi endi
if $data4_3 != ready then if $data(2)[4] != ready then
goto step1 goto step0
endi endi
if $data4_4 != ready then if $data(3)[4] != ready then
goto step1 goto step0
endi
if $data(4)[4] != ready then
goto step0
endi endi
sql show mnodes print ========= step1
print mnode1 $data2_1 sql create database db replica 3 vgroups 1
print mnode1 $data2_2 $x = 0
print mnode1 $data2_3 step1:
if $data2_1 != master then $x = $x + 1
sleep 1000
if $x == 60 then
print ====> db not ready!
return -1
endi
sql show db.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $rows != 4 then
return -1
endi
if $data(2)[4] == leader then
$leaderExist = 1
endi
if $data(2)[6] == leader then
$leaderExist = 1
endi
if $data(2)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step1 goto step1
endi endi
print ========= step1
sql create database db replica 3
sql create table db.tb (ts timestamp, i int) sql create table db.tb (ts timestamp, i int)
sql insert into db.tb values(now, 1) sql insert into db.tb values(now, 1)
sql select count(*) from db.tb sql select count(*) from db.tb
$lastRows = $rows $lastRows = $rows
print ======== step2 print ======== step2
run_back unique/vnode/back_insert.sim run_back tsim/vnode/back_insert.sim
sleep 2000 sleep 2000
print ======== step3 print ======== step3
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3 system sh/deploy.sh -n dnode3 -i 3
system sh/cfg.sh -n dnode1 -c wallevel -v 2 system sh/deploy.sh -n dnode4 -i 4
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 numOfMnodes -v 3
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3
print ========== step0
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sql connect sql connect
sql create dnode $hostname2
sql create dnode $hostname3 sql create dnode $hostname port 7200
sql create dnode $hostname port 7300
sql create dnode $hostname port 7400
system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start system sh/exec.sh -n dnode3 -s start
sleep 2000 system sh/exec.sh -n dnode4 -s start
$x = 0
step0:
$x = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
print ===> $data30 $data31 $data32 $data33 $data34 $data35
if $rows != 4 then
return -1
endi
if $data(1)[4] != ready then
goto step0
endi
if $data(2)[4] != ready then
goto step0
endi
if $data(3)[4] != ready then
goto step0
endi
if $data(4)[4] != ready then
goto step0
endi
$N = 10 $N = 10
$table = table_r3 $table = table_r3
$db = db1 $db = db1
sleep 2000
print =================== step 1 print =================== step 1
sql create database $db replica 3 vgroups 2
sql create database $db replica 3
sql use $db sql use $db
sql create table st (ts timestamp, speed int) tags (t1 int)
sleep 3001
$x = 0
step1:
$x = $x + 1
sleep 1000
if $x == 60 then
print ====> db not ready!
return -1
endi
sql show vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
if $rows != 2 then
return -1
endi
$leaderExist = 0
if $data(2)[4] == leader then
$leaderExist = 1
endi
if $data(2)[6] == leader then
$leaderExist = 1
endi
if $data(2)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step1
endi
$leaderExist = 0
if $data(3)[4] == leader then
$leaderExist = 1
endi
if $data(3)[6] == leader then
$leaderExist = 1
endi
if $data(3)[8] == leader then
$leaderExist = 1
endi
if $leaderExist != 1 then
goto step1
endi
sql create table st (ts timestamp, speed int) tags (t1 int)
$tbPre = m $tbPre = m
$N = 300 $N = 300
...@@ -44,8 +107,7 @@ while $x < $y ...@@ -44,8 +107,7 @@ while $x < $y
$x = $x + 1 $x = $x + 1
endw endw
#print =================== step2
#print =================== step 2
$x = -500 $x = -500
$y = $x + $N $y = $x + $N
while $x < $y while $x < $y
...@@ -64,8 +126,4 @@ endi ...@@ -64,8 +126,4 @@ endi
system sh/exec.sh -n dnode1 -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 dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -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 dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT \ No newline at end of file
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
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/deploy.sh -n dnode4 -i 4
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 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/cfg.sh -n dnode1 -c balanceInterval -v 1
system sh/cfg.sh -n dnode2 -c balanceInterval -v 1
system sh/cfg.sh -n dnode3 -c balanceInterval -v 1
system sh/cfg.sh -n dnode4 -c balanceInterval -v 1
print ========= start dnodes
system sh/exec.sh -n dnode1 -s start
sql connect
sql create dnode $hostname2
system sh/exec.sh -n dnode2 -s start
sql create dnode $hostname3
system sh/exec.sh -n dnode3 -s start
$x = 0
step1:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
print dnode3 $data4_3
if $data4_1 != ready then
goto step1
endi
if $data4_2 != ready then
goto step1
endi
if $data4_3 != ready then
goto step1
endi
sql show mnodes
print mnode1 $data2_1
print mnode1 $data2_2
print mnode1 $data2_3
if $data2_1 != master then
goto step1
endi
if $data2_2 != null then
goto step1
endi
if $data2_3 != null then
goto step1
endi
print ======== step1
sql create database d1 replica 1
sql create database d2 replica 1
sql create database d3 replica 1
sql create database d4 replica 1
sql create table d1.t1 (ts timestamp, i int)
sql create table d2.t2 (ts timestamp, i int)
sql create table d3.t3 (ts timestamp, i int)
sql create table d4.t4 (ts timestamp, i int)
sql insert into d1.t1 values(now, 1)
sql insert into d2.t2 values(now, 1)
sql insert into d3.t3 values(now, 1)
sql insert into d4.t4 values(now, 1)
sql select * from d1.t1
if $rows != 1 then
return -1
endi
sql select * from d2.t2
if $rows != 1 then
return -1
endi
sql select * from d3.t3
if $rows != 1 then
return -1
endi
sql select * from d4.t4
if $rows != 1 then
return -1
endi
sql show dnodes
print dnode1 ==> openVnodes: $data2_1
print dnode2 ==> openVnodes: $data2_2
print dnode3 ==> openVnodes: $data2_3
if $data2_1 != 0 then
return -1
endi
if $data2_2 != 2 then
return -1
endi
if $data2_3 != 2 then
return -1
endi
print ======== step2
sql alter database d1 replica 2
sql alter database d2 replica 2
sql alter database d3 replica 2
sql alter database d4 replica 2
$x = 0
a1:
$x = $x + 1
sleep 1000
if $x == 40 then
return -1
endi
sql show d1.vgroups
print online vnodes $data03
if $data03 != 2 then
goto a1
endi
sql show d2.vgroups
print online vnodes $data03
if $data03 != 2 then
goto a1
endi
sql show d3.vgroups
print online vnodes $data03
if $data03 != 2 then
goto a1
endi
sql show d4.vgroups
print online vnodes $data03
if $data03 != 2 then
goto a1
endi
print ======== step3
sql show dnodes
print dnode1 ==> openVnodes: $data2_1
print dnode2 ==> openVnodes: $data2_2
print dnode3 ==> openVnodes: $data2_3
if $data2_1 != 0 then
return -1
endi
if $data2_2 != 4 then
return -1
endi
if $data2_3 != 4 then
return -1
endi
print ======== step4
sql insert into d1.t1 values(now, 2)
sql insert into d2.t2 values(now, 2)
sql insert into d3.t3 values(now, 2)
sql insert into d4.t4 values(now, 2)
sql select * from d1.t1
if $rows != 2 then
return -1
endi
sql select * from d2.t2
if $rows != 2 then
return -1
endi
sql select * from d3.t3
if $rows != 2 then
return -1
endi
sql select * from d4.t4
if $rows != 2 then
return -1
endi
sql reset query cache
sleep 200
print ========= step5
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sql select * from d1.t1 -x s51
s51:
#sql insert into d1.t1 values(now, 3) -x s52
s52:
print ========= step6
system sh/exec.sh -n dnode2 -s start
$x = 0
step6:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show d1.vgroups
print online vnodes $data03
if $data03 != 2 then
goto step6
endi
sql show d2.vgroups
print online vnodes $data03
if $data03 != 2 then
goto step6
endi
sql show d3.vgroups
print online vnodes $data03
if $data03 != 2 then
goto step6
endi
sql show d4.vgroups
print online vnodes $data03
if $data03 != 2 then
goto step6
endi
sql insert into d1.t1 values(now, 3) -x step6
sql insert into d2.t2 values(now, 3) -x step6
sql insert into d3.t3 values(now, 3) -x step6
sql insert into d4.t4 values(now, 3) -x step6
sql select * from d1.t1
if $rows != 3 then
return -1
endi
sql select * from d2.t2
if $rows != 3 then
return -1
endi
sql select * from d3.t3
if $rows != 3 then
return -1
endi
sql select * from d4.t4
if $rows != 3 then
return -1
endi
print ========= step61
system sh/exec.sh -n dnode3 -s stop -x SIGINT
#sql insert into d1.t1 values(now, 3) -x s61
s61:
sql select * from d2.t2 -x s62
s62:
print ========= step7
system sh/exec.sh -n dnode3 -s start
$x = 0
step7:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show d1.vgroups
print online vnodes $data03
if $data03 != 2 then
goto step7
endi
sql show d2.vgroups
print online vnodes $data03
if $data03 != 2 then
goto step7
endi
sql show d3.vgroups
print online vnodes $data03
if $data03 != 2 then
goto step7
endi
sql show d4.vgroups
print online vnodes $data03
if $data03 != 2 then
goto step7
endi
sql insert into d1.t1 values(now, 5) -x step7
sql insert into d2.t2 values(now, 5) -x step7
sql insert into d3.t3 values(now, 5) -x step7
sql insert into d4.t4 values(now, 5) -x step7
sql select * from d1.t1
if $rows != 4 then
return -1
endi
sql select * from d2.t2
if $rows != 4 then
return -1
endi
sql select * from d3.t3
if $rows != 4 then
return -1
endi
sql select * from d4.t4
if $rows != 4 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
\ No newline at end of file
此差异已折叠。
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 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 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
system sh/cfg.sh -n dnode1 -c balanceInterval -v 1
system sh/cfg.sh -n dnode2 -c balanceInterval -v 1
system sh/cfg.sh -n dnode3 -c balanceInterval -v 1
system sh/cfg.sh -n dnode4 -c balanceInterval -v 1
print ========= start dnodes
system sh/exec.sh -n dnode1 -s start
sql connect
sql create dnode $hostname2
system sh/exec.sh -n dnode2 -s start
$x = 0
step1:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
if $data4_1 != ready then
goto step1
endi
if $data4_2 != ready then
goto step1
endi
sql show mnodes
print mnode1 $data2_1
print mnode1 $data2_2
if $data2_1 != master then
goto step1
endi
print ======== step1
sql create database d1 replica 2
sql create database d2 replica 2
sql create database d3 replica 2
sql create database d4 replica 2
sql create table d1.t1 (ts timestamp, i int)
sql create table d2.t2 (ts timestamp, i int)
sql create table d3.t3 (ts timestamp, i int)
sql create table d4.t4 (ts timestamp, i int)
sql insert into d2.t2 values(now, 1)
sql insert into d1.t1 values(now, 1)
sql insert into d3.t3 values(now, 1)
sql insert into d4.t4 values(now, 1)
sleep 1000
sql select * from d1.t1
if $rows != 1 then
return -1
endi
sql select * from d2.t2
if $rows != 1 then
return -1
endi
sql select * from d3.t3
if $rows != 1 then
return -1
endi
sql select * from d4.t4
if $rows != 1 then
return -1
endi
print ======== step2 create d5
sql create database d5 replica 1
print ========= step3 alter d1
sql alter database d1 replica 1
$x = 0
a1:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show d1.vgroups
print online vnodes $data03
if $data03 != 1 then
goto a1
endi
print ========= step4 query d1
sql insert into d1.t1 values(now, 2)
sql select * from d1.t1
if $rows != 2 then
return -1
endi
print ========= step5 query d5
sql create table d5.t5 (ts timestamp, i int)
sql insert into d5.t5 values(now, 1);
sql select * from d5.t5
if $rows != 1 then
return -1
endi
return
print ========= step7 drop d1
sql drop database d1
sql reset query cache
sleep 100
print ========= step8
sql insert into d5.t5 values(now, 2)
sql insert into d2.t2 values(now, 2)
sql insert into d3.t3 values(now, 2)
sql insert into d4.t4 values(now, 2)
sql select * from d5.t5
if $rows != 2 then
return -1
endi
sql select * from d2.t2
if $rows != 2 then
return -1
endi
sql select * from d3.t3
if $rows != 2 then
return -1
endi
sql select * from d4.t4
if $rows != 2 then
return -1
endi
print ======== step9 stop dnode2
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sql insert into d5.t5 values(now, 3)
sql insert into d2.t2 values(now, 3)
sql insert into d3.t3 values(now, 3)
sql insert into d4.t4 values(now, 3)
sql select * from d5.t5
if $rows != 3 then
return -1
endi
sql select * from d2.t2
if $rows != 3 then
return -1
endi
sql select * from d3.t3
if $rows != 3 then
return -1
endi
sql select * from d4.t4
if $rows != 3 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
\ No newline at end of file
此差异已折叠。
run unique/db/commit.sim
run unique/db/delete.sim
run unique/db/replica_add12.sim
run unique/db/replica_add13.sim
run unique/db/replica_add23.sim
run unique/db/replica_reduce21.sim
run unique/db/replica_reduce32.sim
run unique/db/replica_reduce31.sim
run unique/db/replica_part.sim
run unique/db/delete_part.sim
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 2
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print =============== step1
sql drop database -x step1
step1:
sql create database db
sql use db
sql create table m1 (ts timestamp, speed int)
print =============== step 2
$x = 0
while $x < 10
$cc = $x * 60000
$ms = 1601481600000 + $cc
sql insert into m1 values ($ms , $x )
$x = $x + 1
endw
sql select * from m1
print $rows points data are retrieved
if $rows != 10 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
print =============== step 3
system sh/move_dnode.sh dnode1 dnode2
system sh/exec.sh -n dnode2 -s start
print =============== step 4
sleep 2000
sql connect
sql select * from db.m1
print $rows points data are retrieved
if $rows != 10 then
return -1
endi
system sh/exec.sh -n dnode2 -s stop -x SIGINT
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
run unique/dnode/balance1.sim
run unique/dnode/balance2.sim
run unique/dnode/balance3.sim
run unique/dnode/balancex.sim
run unique/dnode/offline1.sim
run unique/dnode/offline2.sim
run unique/dnode/remove1.sim
run unique/dnode/remove2.sim
run unique/dnode/vnode_clean.sim
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册