From fb27589c139d36859f945db0f9103cdd1d872fe4 Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Mon, 4 May 2020 04:55:27 +0000 Subject: [PATCH 01/36] first draft --- src/client/src/tscServer.c | 8 ++++---- src/common/src/tmessage.c | 12 ++++++------ src/dnode/src/dnodeRead.c | 2 +- src/dnode/src/dnodeShell.c | 6 +++--- src/inc/taosmsg.h | 22 +++++++++++----------- src/mnode/src/mgmtShell.c | 4 ++-- src/rpc/src/rpcMain.c | 4 ++-- src/vnode/src/vnodeRead.c | 8 ++++---- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index d6f1c8f42a..2bef303df5 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -512,7 +512,7 @@ void tscKillSTableQuery(SSqlObj *pSql) { tscTrace("%p metric query is cancelled", pSql); } -int tscBuildRetrieveMsg(SSqlObj *pSql, SSqlInfo *pInfo) { +int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) { char *pMsg, *pStart; pStart = pSql->cmd.payload + tsRpcHeadSize; @@ -541,7 +541,7 @@ int tscBuildRetrieveMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pRetrieveMsg->header.contLen = htonl(pSql->cmd.payloadLen); - pSql->cmd.msgType = TSDB_MSG_TYPE_RETRIEVE; + pSql->cmd.msgType = TSDB_MSG_TYPE_FETCH; return TSDB_CODE_SUCCESS; } @@ -1365,7 +1365,7 @@ int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int tscBuildRetrieveFromMgmtMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SSqlCmd *pCmd = &pSql->cmd; - pCmd->msgType = TSDB_MSG_TYPE_RETRIEVE; + pCmd->msgType = TSDB_MSG_TYPE_CM_RETRIEVE; pCmd->payloadLen = sizeof(SRetrieveTableMsg); if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) { @@ -2595,7 +2595,7 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) { void tscInitMsgsFp() { tscBuildMsg[TSDB_SQL_SELECT] = tscBuildQueryMsg; tscBuildMsg[TSDB_SQL_INSERT] = tscBuildSubmitMsg; - tscBuildMsg[TSDB_SQL_FETCH] = tscBuildRetrieveMsg; + tscBuildMsg[TSDB_SQL_FETCH] = tscBuildFetchMsg; tscBuildMsg[TSDB_SQL_CREATE_DB] = tscBuildCreateDbMsg; tscBuildMsg[TSDB_SQL_CREATE_USER] = tscBuildUserMsg; diff --git a/src/common/src/tmessage.c b/src/common/src/tmessage.c index 5a134df129..78ce17db75 100644 --- a/src/common/src/tmessage.c +++ b/src/common/src/tmessage.c @@ -23,9 +23,9 @@ char *taosMsg[] = { "query-rsp", "retrieve", "retrieve-rsp", + "create-table", "create-table-rsp", //10 - "drop-table", "drop-table-rsp", "alter-table", @@ -100,13 +100,13 @@ char *taosMsg[] = { "kill-stream-rsp", "kill-connection", "kill-connectoin-rsp", + "config-dnode", + "config-dnode-rsp", + "retrieve", + "retrieve-rsp", "heart-beat", - "heart-beat-rsp", //80 + "heart-beat-rsp", //84 - "", - "", - "", - "", "", "", "", diff --git a/src/dnode/src/dnodeRead.c b/src/dnode/src/dnodeRead.c index e52b59d20a..42c3b1faa0 100644 --- a/src/dnode/src/dnodeRead.c +++ b/src/dnode/src/dnodeRead.c @@ -95,7 +95,7 @@ void dnodeRead(SRpcMsg *pMsg) { pHead->vgId = htonl(pHead->vgId); pHead->contLen = htonl(pHead->contLen); - if (pMsg->msgType == TSDB_MSG_TYPE_RETRIEVE) { + if (pMsg->msgType == TSDB_MSG_TYPE_FETCH) { pVnode = vnodeGetVnode(pHead->vgId); } else { pVnode = vnodeAccquireVnode(pHead->vgId); diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index 544d443bc0..0c9716ca52 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -35,9 +35,9 @@ static int32_t tsDnodeQueryReqNum = 0; static int32_t tsDnodeSubmitReqNum = 0; int32_t dnodeInitShell() { - dnodeProcessShellMsgFp[TSDB_MSG_TYPE_SUBMIT] = dnodeWrite; - dnodeProcessShellMsgFp[TSDB_MSG_TYPE_QUERY] = dnodeRead; - dnodeProcessShellMsgFp[TSDB_MSG_TYPE_RETRIEVE] = dnodeRead; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_SUBMIT] = dnodeWrite; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_QUERY] = dnodeRead; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_FETCH] = dnodeRead; int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore; numOfThreads = (int32_t) ((1.0 - tsRatioOfQueryThreads) * numOfThreads / 2.0); diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index fd3105e3bb..dd9c8e1a52 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -28,14 +28,12 @@ extern "C" { #include "trpc.h" // message type -#define TSDB_MSG_TYPE_REG 1 -#define TSDB_MSG_TYPE_REG_RSP 2 #define TSDB_MSG_TYPE_SUBMIT 3 #define TSDB_MSG_TYPE_SUBMIT_RSP 4 #define TSDB_MSG_TYPE_QUERY 5 #define TSDB_MSG_TYPE_QUERY_RSP 6 -#define TSDB_MSG_TYPE_RETRIEVE 7 -#define TSDB_MSG_TYPE_RETRIEVE_RSP 8 +#define TSDB_MSG_TYPE_FETCH 7 +#define TSDB_MSG_TYPE_FETCH_RSP 8 // message from mnode to dnode #define TSDB_MSG_TYPE_MD_CREATE_TABLE 9 @@ -74,8 +72,6 @@ extern "C" { #define TSDB_MSG_TYPE_CM_CREATE_DNODE_RSP 46 #define TSDB_MSG_TYPE_CM_DROP_DNODE 47 #define TSDB_MSG_TYPE_CM_DROP_DNODE_RSP 48 -#define TSDB_MSG_TYPE_CM_CONFIG_DNODE TSDB_MSG_TYPE_MD_CONFIG_DNODE -#define TSDB_MSG_TYPE_CM_CONFIG_DNODE_RSP TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP #define TSDB_MSG_TYPE_CM_CREATE_DB 49 #define TSDB_MSG_TYPE_CM_CREATE_DB_RSP 50 #define TSDB_MSG_TYPE_CM_DROP_DB 51 @@ -103,11 +99,15 @@ extern "C" { #define TSDB_MSG_TYPE_CM_KILL_QUERY 73 #define TSDB_MSG_TYPE_CM_KILL_QUERY_RSP 74 #define TSDB_MSG_TYPE_CM_KILL_STREAM 75 -#define TSDB_MSG_TYPE_CM_KILL_STREAM_RSP 76 -#define TSDB_MSG_TYPE_CM_KILL_CONN 77 -#define TSDB_MSG_TYPE_CM_KILL_CONN_RSP 78 -#define TSDB_MSG_TYPE_CM_HEARTBEAT 79 -#define TSDB_MSG_TYPE_CM_HEARTBEAT_RSP 80 +#define TSDB_MSG_TYPE_CM_KILL_STREAM_RSP 76 +#define TSDB_MSG_TYPE_CM_KILL_CONN 77 +#define TSDB_MSG_TYPE_CM_KILL_CONN_RSP 78 +#define TSDB_MSG_TYPE_CM_CONFIG_DNODE 79 +#define TSDB_MSG_TYPE_CM_CONFIG_DNODE_RSP 80 +#define TSDB_MSG_TYPE_CM_RETRIEVE 81 +#define TSDB_MSG_TYPE_CM_RETRIEVE_RSP 82 +#define TSDB_MSG_TYPE_CM_HEARTBEAT 83 +#define TSDB_MSG_TYPE_CM_HEARTBEAT_RSP 84 // message from dnode to mnode #define TSDB_MSG_TYPE_DM_CONFIG_TABLE 91 diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index c86bf2a2dd..b09cb5aff2 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -61,7 +61,7 @@ static SShowRetrieveFp tsMgmtShowRetrieveFp[TSDB_MGMT_TABLE_MAX] = {0}; int32_t mgmtInitShell() { mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_SHOW, mgmtProcessShowMsg); - mgmtAddShellMsgHandle(TSDB_MSG_TYPE_RETRIEVE, mgmtProcessRetrieveMsg); + mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_RETRIEVE, mgmtProcessRetrieveMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_HEARTBEAT, mgmtProcessHeartBeatMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_CONNECT, mgmtProcessConnectMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_USE_DB, mgmtProcessUseMsg); @@ -490,7 +490,7 @@ static bool mgmtCheckMsgReadOnly(SQueuedMsg *pMsg) { return mgmtCheckTableMetaMsgReadOnly(pMsg); } - if (pMsg->msgType == TSDB_MSG_TYPE_CM_STABLE_VGROUP || pMsg->msgType == TSDB_MSG_TYPE_RETRIEVE || + if (pMsg->msgType == TSDB_MSG_TYPE_CM_STABLE_VGROUP || pMsg->msgType == TSDB_MSG_TYPE_CM_RETRIEVE || pMsg->msgType == TSDB_MSG_TYPE_CM_SHOW || pMsg->msgType == TSDB_MSG_TYPE_CM_TABLES_META || pMsg->msgType == TSDB_MSG_TYPE_CM_CONNECT) { return true; diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 36d74189f5..a02ee67b0a 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -363,7 +363,7 @@ void rpcSendRequest(void *shandle, const SRpcIpSet *pIpSet, const SRpcMsg *pMsg) // connection type is application specific. // for TDengine, all the query, show commands shall have TCP connection char type = pMsg->msgType; - if (type == TSDB_MSG_TYPE_QUERY || type == TSDB_MSG_TYPE_RETRIEVE || + if (type == TSDB_MSG_TYPE_QUERY || type == TSDB_MSG_TYPE_CM_RETRIEVE || type == TSDB_MSG_TYPE_FETCH || type == TSDB_MSG_TYPE_CM_STABLE_VGROUP || type == TSDB_MSG_TYPE_CM_TABLES_META || type == TSDB_MSG_TYPE_CM_SHOW ) pContext->connType = RPC_CONN_TCPC; @@ -802,7 +802,7 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) { pHead->code = htonl(pHead->code); if (terrno == 0) { - if (pHead->msgType != TSDB_MSG_TYPE_REG && pHead->encrypt) { + if (pHead->encrypt) { // decrypt here } diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c index 201214ded4..02a4e688e2 100644 --- a/src/vnode/src/vnodeRead.c +++ b/src/vnode/src/vnodeRead.c @@ -29,11 +29,11 @@ static int32_t (*vnodeProcessReadMsgFp[TSDB_MSG_TYPE_MAX])(SVnodeObj *, void *pCont, int32_t contLen, SRspRet *pRet); static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t contLen, SRspRet *pRet); -static int32_t vnodeProcessRetrieveMsg(SVnodeObj *pVnode, void *pCont, int32_t contLen, SRspRet *pRet); +static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, void *pCont, int32_t contLen, SRspRet *pRet); void vnodeInitReadFp(void) { - vnodeProcessReadMsgFp[TSDB_MSG_TYPE_QUERY] = vnodeProcessQueryMsg; - vnodeProcessReadMsgFp[TSDB_MSG_TYPE_RETRIEVE] = vnodeProcessRetrieveMsg; + vnodeProcessReadMsgFp[TSDB_MSG_TYPE_QUERY] = vnodeProcessQueryMsg; + vnodeProcessReadMsgFp[TSDB_MSG_TYPE_FETCH] = vnodeProcessFetchMsg; } int32_t vnodeProcessRead(void *param, int msgType, void *pCont, int32_t contLen, SRspRet *ret) { @@ -76,7 +76,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t cont return code; } -static int32_t vnodeProcessRetrieveMsg(SVnodeObj *pVnode, void *pCont, int32_t contLen, SRspRet *pRet) { +static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, void *pCont, int32_t contLen, SRspRet *pRet) { SRetrieveTableMsg *pRetrieve = pCont; void *pQInfo = (void*) htobe64(pRetrieve->qhandle); memset(pRet, 0, sizeof(SRspRet)); From b6225968b1888de70b623af35c2224071ec58bd8 Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Mon, 4 May 2020 07:10:05 +0000 Subject: [PATCH 02/36] second draft --- src/client/inc/tsclient.h | 5 ++--- src/client/src/tscServer.c | 27 +++++++++----------------- src/client/src/tscSql.c | 4 +--- src/client/src/tscSystem.c | 38 ++++++++----------------------------- src/client/src/tscUtil.c | 1 - src/common/src/tglobal.c | 1 - src/dnode/src/dnodeModule.c | 1 + src/dnode/src/dnodeShell.c | 12 ++++++------ src/inc/mnode.h | 2 ++ src/inc/taosdef.h | 3 +-- src/mnode/src/mgmtShell.c | 38 ++++++------------------------------- 11 files changed, 36 insertions(+), 96 deletions(-) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index d04fa9900d..e88da39d04 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -298,7 +298,6 @@ typedef struct STscObj { char sversion[TSDB_VERSION_LEN]; char writeAuth : 1; char superAuth : 1; - void* pMgmtConn; struct SSqlObj * pSql; struct SSqlObj * pHb; struct SSqlObj * sqlList; @@ -358,7 +357,7 @@ typedef struct SSqlStream { struct SSqlStream *prev, *next; } SSqlStream; -int32_t tscInitRpc(const char *user, const char *secret, void** pMgmtConn); +int32_t tscInitRpc(const char *user, const char *secret); void tscInitMsgsFp(); int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion); @@ -425,7 +424,7 @@ void tscQueueAsyncFreeResult(SSqlObj *pSql); int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo); char * tscGetResultColumnChr(SSqlRes *pRes, SQueryInfo *pQueryInfo, int32_t column); -extern void * pVnodeConn; +extern void * pDnodeConn; extern void * tscCacheHandle; extern void * tscTmr; extern void * tscQhandle; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 2bef303df5..9c57554586 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -191,7 +191,6 @@ void tscProcessActivityTimer(void *handle, void *tmrId) { } int tscSendMsgToServer(SSqlObj *pSql) { - STscObj* pObj = pSql->pTscObj; SSqlCmd* pCmd = &pSql->cmd; char *pMsg = rpcMallocCont(pCmd->payloadLen); @@ -201,30 +200,22 @@ int tscSendMsgToServer(SSqlObj *pSql) { } if (pSql->cmd.command < TSDB_SQL_MGMT) { - tscTrace("%p msg:%s is sent to server %d", pSql, taosMsg[pSql->cmd.msgType], pSql->ipList.port); memcpy(pMsg, pSql->cmd.payload + tsRpcHeadSize, pSql->cmd.payloadLen); + } else { + pSql->ipList = tscMgmtIpSet; + memcpy(pMsg, pSql->cmd.payload, pSql->cmd.payloadLen); + } - SRpcMsg rpcMsg = { + tscTrace("%p msg:%s is sent to server %d", pSql, taosMsg[pSql->cmd.msgType], pSql->ipList.port); + + SRpcMsg rpcMsg = { .msgType = pSql->cmd.msgType, .pCont = pMsg, .contLen = pSql->cmd.payloadLen, .handle = pSql, .code = 0 - }; - rpcSendRequest(pVnodeConn, &pSql->ipList, &rpcMsg); - } else { - pSql->ipList = tscMgmtIpSet; - memcpy(pMsg, pSql->cmd.payload, pSql->cmd.payloadLen); - SRpcMsg rpcMsg = { - .msgType = pSql->cmd.msgType, - .pCont = pMsg, - .contLen = pSql->cmd.payloadLen, - .handle = pSql, - .code = 0 - }; - tscTrace("%p msg:%s is sent to server", pSql, taosMsg[pSql->cmd.msgType]); - rpcSendRequest(pObj->pMgmtConn, &pSql->ipList, &rpcMsg); - } + }; + rpcSendRequest(pDnodeConn, &pSql->ipList, &rpcMsg); return TSDB_CODE_SUCCESS; } diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 1934c05014..7d6768b144 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -66,8 +66,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con return NULL; } - void* pMgmtConn = NULL; - if (tscInitRpc(user, pass, &pMgmtConn) != 0) { + if (tscInitRpc(user, pass) != 0) { terrno = TSDB_CODE_NETWORK_UNAVAIL; return NULL; } @@ -119,7 +118,6 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con strtolower(pObj->db, tmp); } - pObj->pMgmtConn = pMgmtConn; pthread_mutex_init(&pObj->mutex, NULL); SSqlObj *pSql = (SSqlObj *)calloc(1, sizeof(SSqlObj)); diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index c0ad91cd59..aa3c836ba0 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -30,7 +30,7 @@ #include "tlocale.h" // global, not configurable -void * pVnodeConn; +void * pDnodeConn; void * tscCacheHandle; void * tscTmr; void * tscQhandle; @@ -48,12 +48,12 @@ void tscCheckDiskUsage(void *UNUSED_PARAM(para), void* UNUSED_PARAM(param)) { taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr); } -int32_t tscInitRpc(const char *user, const char *secret, void** pMgmtConn) { +int32_t tscInitRpc(const char *user, const char *secret) { SRpcInit rpcInit; char secretEncrypt[32] = {0}; taosEncryptPass((uint8_t *)secret, strlen(secret), secretEncrypt); - if (pVnodeConn == NULL) { + if (pDnodeConn == NULL) { memset(&rpcInit, 0, sizeof(rpcInit)); rpcInit.localPort = 0; rpcInit.label = "TSC-vnode"; @@ -66,35 +66,13 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pMgmtConn) { rpcInit.ckey = "key"; rpcInit.secret = secretEncrypt; - pVnodeConn = rpcOpen(&rpcInit); - if (pVnodeConn == NULL) { + pDnodeConn = rpcOpen(&rpcInit); + if (pDnodeConn == NULL) { tscError("failed to init connection to vnode"); return -1; } } - if (*pMgmtConn == NULL) { - memset(&rpcInit, 0, sizeof(rpcInit)); - rpcInit.localPort = 0; - rpcInit.label = "TSC-mgmt"; - rpcInit.numOfThreads = 1; - rpcInit.cfp = tscProcessMsgFromServer; - rpcInit.ufp = tscUpdateIpSet; - rpcInit.sessions = tsMaxMgmtConnections; - rpcInit.connType = TAOS_CONN_CLIENT; - rpcInit.idleTime = 2000; - rpcInit.user = (char*)user; - rpcInit.ckey = "key"; - rpcInit.spi = 1; - rpcInit.secret = secretEncrypt; - - *pMgmtConn = rpcOpen(&rpcInit); - if (*pMgmtConn == NULL) { - tscError("failed to init connection to mgmt"); - return -1; - } - } - return 0; } @@ -190,9 +168,9 @@ void taos_cleanup() { taosCloseLog(); - if (pVnodeConn != NULL) { - rpcClose(pVnodeConn); - pVnodeConn = NULL; + if (pDnodeConn != NULL) { + rpcClose(pDnodeConn); + pDnodeConn = NULL; } taosTmrCleanUp(tscTmr); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 506fa1a605..1dbef2afde 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -760,7 +760,6 @@ void tscCloseTscObj(STscObj* pObj) { if (pSql) { sem_destroy(&pSql->rspSem); } - rpcClose(pObj->pMgmtConn); pthread_mutex_destroy(&pObj->mutex); diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 70b55b9d92..b482ca64f4 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -1244,7 +1244,6 @@ bool taosCheckGlobalCfg() { tsVersion = 10 * tsVersion; - tsMnodeShellPort = tsServerPort + TSDB_PORT_MNODESHELL; // udp[6030-6034] tcp[6030] tsDnodeShellPort = tsServerPort + TSDB_PORT_DNODESHELL; // udp[6035-6039] tcp[6035] tsMnodeDnodePort = tsServerPort + TSDB_PORT_MNODEDNODE; // udp/tcp tsDnodeMnodePort = tsServerPort + TSDB_PORT_DNODEMNODE; // udp/tcp diff --git a/src/dnode/src/dnodeModule.c b/src/dnode/src/dnodeModule.c index e1aa48d477..7d09cf2a0b 100644 --- a/src/dnode/src/dnodeModule.c +++ b/src/dnode/src/dnodeModule.c @@ -17,6 +17,7 @@ #include "os.h" #include "taosdef.h" #include "tglobal.h" +#include "trpc.h" #include "mnode.h" #include "http.h" #include "monitor.h" diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index 0c9716ca52..581273d21c 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -34,6 +34,8 @@ static void * tsDnodeShellRpc = NULL; static int32_t tsDnodeQueryReqNum = 0; static int32_t tsDnodeSubmitReqNum = 0; +void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg); + int32_t dnodeInitShell() { dnodeProcessShellMsgFp[TSDB_MSG_TYPE_SUBMIT] = dnodeWrite; dnodeProcessShellMsgFp[TSDB_MSG_TYPE_QUERY] = dnodeRead; @@ -47,8 +49,8 @@ int32_t dnodeInitShell() { SRpcInit rpcInit; memset(&rpcInit, 0, sizeof(rpcInit)); - rpcInit.localPort = tsDnodeShellPort; - rpcInit.label = "DND-shell"; + rpcInit.localPort = tsMnodeShellPort; + rpcInit.label = "SHELL"; rpcInit.numOfThreads = numOfThreads; rpcInit.cfp = dnodeProcessMsgFromShell; rpcInit.sessions = TSDB_SESSIONS_PER_DNODE; @@ -96,13 +98,11 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg) { if ( dnodeProcessShellMsgFp[pMsg->msgType] ) { (*dnodeProcessShellMsgFp[pMsg->msgType])(pMsg); } else { - dError("RPC %p, msg:%s from shell is not handled", pMsg->handle, taosMsg[pMsg->msgType]); - rpcMsg.code = TSDB_CODE_MSG_NOT_PROCESSED; - rpcSendResponse(&rpcMsg); - rpcFreeCont(pMsg->pCont); + mgmtProcessMsgFromShell(pMsg); } } + static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey) { return TSDB_CODE_SUCCESS; } diff --git a/src/inc/mnode.h b/src/inc/mnode.h index 35f7650c20..21955e29c1 100644 --- a/src/inc/mnode.h +++ b/src/inc/mnode.h @@ -26,6 +26,8 @@ void mgmtCleanUpSystem(); void mgmtStopSystem(); void sdbUpdateSync(); +void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg); + #ifdef __cplusplus } #endif diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 1142f02922..95310ae44a 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -329,8 +329,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_MAX_NORMAL_TABLES 1000 #define TSDB_MAX_CHILD_TABLES 100000 -#define TSDB_PORT_MNODESHELL 0 -#define TSDB_PORT_DNODESHELL 5 +#define TSDB_PORT_DNODESHELL 0 #define TSDB_PORT_DNODEMNODE 10 #define TSDB_PORT_MNODEDNODE 15 #define TSDB_PORT_SYNC 20 diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index b09cb5aff2..a5659fee54 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -41,9 +41,9 @@ typedef int32_t (*SShowMetaFp)(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn); typedef int32_t (*SShowRetrieveFp)(SShowObj *pShow, char *data, int32_t rows, void *pConn); -static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey); +//static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey); static bool mgmtCheckMsgReadOnly(SQueuedMsg *pMsg); -static void mgmtProcessMsgFromShell(SRpcMsg *pMsg); +//static void mgmtProcessMsgFromShell(SRpcMsg *pMsg); static void mgmtProcessUnSupportMsg(SRpcMsg *rpcMsg); static void mgmtProcessShowMsg(SQueuedMsg *queuedMsg); static void mgmtProcessRetrieveMsg(SQueuedMsg *queuedMsg); @@ -52,7 +52,7 @@ static void mgmtProcessConnectMsg(SQueuedMsg *queuedMsg); static void mgmtProcessUseMsg(SQueuedMsg *queuedMsg); void *tsMgmtTmr; -static void *tsMgmtShellRpc = NULL; +//static void *tsMgmtShellRpc = NULL; static void *tsMgmtTranQhandle = NULL; static void (*tsMgmtProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SQueuedMsg *) = {0}; static void *tsQhandleCache = NULL; @@ -70,28 +70,6 @@ int32_t mgmtInitShell() { tsMgmtTranQhandle = taosInitScheduler(tsMaxShellConns, 1, "mnodeT"); tsQhandleCache = taosCacheInit(tsMgmtTmr, 2); - int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore / 4.0; - if (numOfThreads < 1) { - numOfThreads = 1; - } - - SRpcInit rpcInit = {0}; - rpcInit.localPort = tsMnodeShellPort; - rpcInit.label = "MND-shell"; - rpcInit.numOfThreads = numOfThreads; - rpcInit.cfp = mgmtProcessMsgFromShell; - rpcInit.sessions = tsMaxShellConns; - rpcInit.connType = TAOS_CONN_SERVER; - rpcInit.idleTime = tsShellActivityTimer * 1000; - rpcInit.afp = mgmtShellRetriveAuth; - - tsMgmtShellRpc = rpcOpen(&rpcInit); - if (tsMgmtShellRpc == NULL) { - mError("failed to init server connection to shell"); - return -1; - } - - mPrint("server connection to shell is opened"); return 0; } @@ -101,12 +79,6 @@ void mgmtCleanUpShell() { tsMgmtTranQhandle = NULL; } - if (tsMgmtShellRpc) { - rpcClose(tsMgmtShellRpc); - tsMgmtShellRpc = NULL; - mPrint("server connection to shell is closed"); - } - if (tsQhandleCache) { taosCacheEmpty(tsQhandleCache); taosCacheCleanup(tsQhandleCache); @@ -148,7 +120,7 @@ void mgmtDealyedAddToShellQueue(SQueuedMsg *queuedMsg) { taosTmrReset(mgmtDoDealyedAddToShellQueue, 1000, queuedMsg, tsMgmtTmr, &unUsed); } -static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) { +void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) { assert(rpcMsg); if (rpcMsg->pCont == NULL) { @@ -370,6 +342,7 @@ static void mgmtProcessHeartBeatMsg(SQueuedMsg *pMsg) { rpcSendResponse(&rpcRsp); } +/* static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) { *spi = 1; *encrypt = 0; @@ -390,6 +363,7 @@ static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secr return TSDB_CODE_SUCCESS; } } +*/ static void mgmtProcessConnectMsg(SQueuedMsg *pMsg) { SRpcMsg rpcRsp = {.handle = pMsg->thandle, .pCont = NULL, .contLen = 0, .code = 0, .msgType = 0}; From d58c42b481a013e881b2700d9e30ef857b27ccb8 Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Mon, 4 May 2020 13:10:50 +0000 Subject: [PATCH 03/36] working version --- src/client/src/tscSql.c | 4 +- src/client/src/tscSystem.c | 2 +- src/common/inc/tglobal.h | 4 +- src/common/src/tglobal.c | 11 +- src/cq/src/cqMain.c | 8 +- .../inc/{dnodeMClient.h => dnodeDnode.h} | 11 +- src/dnode/inc/dnodeMnode.h | 30 -- src/dnode/src/dnodeClient.c | 77 +++ src/dnode/src/dnodeMClient.c | 468 ------------------ src/dnode/src/dnodeMain.c | 11 +- src/dnode/src/dnodeMgmt.c | 399 ++++++++++++++- src/dnode/src/{dnodeMnode.c => dnodeServer.c} | 44 +- src/dnode/src/dnodeShell.c | 2 +- src/inc/dnode.h | 6 + src/inc/mnode.h | 3 +- src/inc/taosdef.h | 5 +- src/kit/shell/src/shellEngine.c | 2 +- src/kit/shell/src/shellImport.c | 2 +- src/kit/shell/src/shellLinux.c | 2 +- src/mnode/inc/{mgmtDServer.h => mgmtServer.h} | 4 +- src/mnode/src/mgmtDClient.c | 87 ---- src/mnode/src/mgmtDnode.c | 6 +- src/mnode/src/mgmtMain.c | 12 +- src/mnode/src/{mgmtDServer.c => mgmtServer.c} | 70 +-- src/mnode/src/mgmtTable.c | 19 +- src/mnode/src/mgmtVgroup.c | 15 +- 26 files changed, 576 insertions(+), 728 deletions(-) rename src/dnode/inc/{dnodeMClient.h => dnodeDnode.h} (80%) delete mode 100644 src/dnode/inc/dnodeMnode.h create mode 100644 src/dnode/src/dnodeClient.c delete mode 100644 src/dnode/src/dnodeMClient.c rename src/dnode/src/{dnodeMnode.c => dnodeServer.c} (73%) rename src/mnode/inc/{mgmtDServer.h => mgmtServer.h} (93%) delete mode 100644 src/mnode/src/mgmtDClient.c rename src/mnode/src/{mgmtDServer.c => mgmtServer.c} (55%) diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 7d6768b144..d835a3c0aa 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -77,7 +77,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con tscMgmtIpSet.inUse = 0; tscMgmtIpSet.numOfIps = 1; strcpy(tscMgmtIpSet.fqdn[0], ip); - tscMgmtIpSet.port[0] = port? port: tsMnodeShellPort; + tscMgmtIpSet.port[0] = port? port: tsDnodeShellPort; } else { if (tsFirst[0] != 0) { taosGetFqdnPortFromEp(tsFirst, tscMgmtIpSet.fqdn[tscMgmtIpSet.numOfIps], &tscMgmtIpSet.port[tscMgmtIpSet.numOfIps]); @@ -100,7 +100,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con strncpy(pObj->user, user, TSDB_USER_LEN); taosEncryptPass((uint8_t *)pass, strlen(pass), pObj->pass); - pObj->mgmtPort = port ? port : tsMnodeShellPort; + pObj->mgmtPort = port ? port : tsDnodeShellPort; if (db) { int32_t len = strlen(db); diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index aa3c836ba0..7ddeed4565 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -56,7 +56,7 @@ int32_t tscInitRpc(const char *user, const char *secret) { if (pDnodeConn == NULL) { memset(&rpcInit, 0, sizeof(rpcInit)); rpcInit.localPort = 0; - rpcInit.label = "TSC-vnode"; + rpcInit.label = "TSC"; rpcInit.numOfThreads = tscNumOfThreads; rpcInit.cfp = tscProcessMsgFromServer; rpcInit.sessions = tsMaxVnodeConnections; diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index dd0dd230fd..ef12ece393 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -55,10 +55,8 @@ extern char tsFirst[]; extern char tsSecond[]; extern char tsLocalEp[]; extern uint16_t tsServerPort; -extern uint16_t tsMnodeDnodePort; -extern uint16_t tsMnodeShellPort; extern uint16_t tsDnodeShellPort; -extern uint16_t tsDnodeMnodePort; +extern uint16_t tsDnodeDnodePort; extern uint16_t tsSyncPort; extern int32_t tsStatusInterval; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index b482ca64f4..0af0710c85 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -66,11 +66,9 @@ char tsSecond[TSDB_FQDN_LEN] = {0}; char tsArbitrator[TSDB_FQDN_LEN] = {0}; char tsLocalEp[TSDB_FQDN_LEN] = {0}; // Local End Point, hostname:port uint16_t tsServerPort = 6030; -uint16_t tsMnodeShellPort = 6030; // udp[6030-6034] tcp[6030] -uint16_t tsDnodeShellPort = 6035; // udp[6035-6039] tcp[6035] -uint16_t tsMnodeDnodePort = 6040; // udp/tcp -uint16_t tsDnodeMnodePort = 6045; // udp/tcp -uint16_t tsSyncPort = 6050; +uint16_t tsDnodeShellPort = 6030; // udp[6035-6039] tcp[6035] +uint16_t tsDnodeDnodePort = 6035; // udp/tcp +uint16_t tsSyncPort = 6040; int32_t tsStatusInterval = 1; // second int32_t tsShellActivityTimer = 3; // second @@ -1245,8 +1243,7 @@ bool taosCheckGlobalCfg() { tsVersion = 10 * tsVersion; tsDnodeShellPort = tsServerPort + TSDB_PORT_DNODESHELL; // udp[6035-6039] tcp[6035] - tsMnodeDnodePort = tsServerPort + TSDB_PORT_MNODEDNODE; // udp/tcp - tsDnodeMnodePort = tsServerPort + TSDB_PORT_DNODEMNODE; // udp/tcp + tsDnodeDnodePort = tsServerPort + TSDB_PORT_DNODEDNODE; // udp/tcp tsSyncPort = tsServerPort + TSDB_PORT_SYNC; return true; diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index 62b9a41494..e4f3142b89 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -26,10 +26,10 @@ #include "tcq.h" #include "taos.h" -#define cError(...) if (cqDebugFlag & DEBUG_ERROR) {taosPrintLog("ERROR CQ ", cqDebugFlag, __VA_ARGS__);} -#define cWarn(...) if (cqDebugFlag & DEBUG_WARN) {taosPrintLog("WARN CQ ", cqDebugFlag, __VA_ARGS__);} -#define cTrace(...) if (cqDebugFlag & DEBUG_TRACE) {taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__);} -#define cPrint(...) {taosPrintLog("WAL ", 255, __VA_ARGS__);} +#define cError(...) if (cqDebugFlag & DEBUG_ERROR) {taosPrintLog("ERROR CQ ", cqDebugFlag, __VA_ARGS__);} +#define cWarn(...) if (cqDebugFlag & DEBUG_WARN) {taosPrintLog("WARN CQ ", cqDebugFlag, __VA_ARGS__);} +#define cTrace(...) if (cqDebugFlag & DEBUG_TRACE) {taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__);} +#define cPrint(...) {taosPrintLog("CQ ", 255, __VA_ARGS__);} typedef struct { int vgId; diff --git a/src/dnode/inc/dnodeMClient.h b/src/dnode/inc/dnodeDnode.h similarity index 80% rename from src/dnode/inc/dnodeMClient.h rename to src/dnode/inc/dnodeDnode.h index 6d413ada88..2ce8d80c0f 100644 --- a/src/dnode/inc/dnodeMClient.h +++ b/src/dnode/inc/dnodeDnode.h @@ -13,16 +13,17 @@ * along with this program. If not, see . */ -#ifndef TDENGINE_DNODE_MCLIENT_H -#define TDENGINE_DNODE_MCLIENT_H +#ifndef TDENGINE_DNODE_DNODE_H +#define TDENGINE_DNODE_DNODE_H #ifdef __cplusplus extern "C" { #endif -int32_t dnodeInitMClient(); -void dnodeCleanupMClient(); -void dnodeSendMsgToMnode(SRpcMsg *rpcMsg); +int32_t dnodeInitServer(); +void dnodeCleanupServer(); +int32_t dnodeInitClient(); +void dnodeCleanupClient(); #ifdef __cplusplus } diff --git a/src/dnode/inc/dnodeMnode.h b/src/dnode/inc/dnodeMnode.h deleted file mode 100644 index 76a65a06c9..0000000000 --- a/src/dnode/inc/dnodeMnode.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_DNODE_MNODE_H -#define TDENGINE_DNODE_MNODE_H - -#ifdef __cplusplus -extern "C" { -#endif - -int32_t dnodeInitMnode(); -void dnodeCleanupMnode(); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/dnode/src/dnodeClient.c b/src/dnode/src/dnodeClient.c new file mode 100644 index 0000000000..aa3ec0595f --- /dev/null +++ b/src/dnode/src/dnodeClient.c @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "os.h" +#include "taosmsg.h" +#include "trpc.h" +#include "tutil.h" +#include "tglobal.h" +#include "dnode.h" +#include "dnodeLog.h" +#include "dnodeMgmt.h" + +static void *tsDnodeClientRpc; +static void (*dnodeProcessDnodeRspFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg); +static void dnodeProcessRspFromDnode(SRpcMsg *pMsg); +extern void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet); + +int32_t dnodeInitClient() { + SRpcInit rpcInit; + memset(&rpcInit, 0, sizeof(rpcInit)); + rpcInit.label = "DND-C"; + rpcInit.numOfThreads = 1; + rpcInit.cfp = dnodeProcessRspFromDnode; + rpcInit.ufp = dnodeUpdateIpSet; + rpcInit.sessions = 100; + rpcInit.connType = TAOS_CONN_CLIENT; + rpcInit.idleTime = tsShellActivityTimer * 2000; + rpcInit.user = "t"; + rpcInit.ckey = "key"; + rpcInit.secret = "secret"; + + tsDnodeClientRpc = rpcOpen(&rpcInit); + if (tsDnodeClientRpc == NULL) { + dError("failed to init mnode rpc client"); + return -1; + } + + dPrint("inter-dndoes rpc client is opened"); + return 0; +} + +void dnodeCleanupClient() { + if (tsDnodeClientRpc) { + rpcClose(tsDnodeClientRpc); + tsDnodeClientRpc = NULL; + dPrint("inter-dnodes rpc client is closed"); + } +} + +static void dnodeProcessRspFromDnode(SRpcMsg *pMsg) { + if (dnodeProcessDnodeRspFp[pMsg->msgType]) { + (*dnodeProcessDnodeRspFp[pMsg->msgType])(pMsg); + } else { + dError("%s is not processed", taosMsg[pMsg->msgType]); + } + rpcFreeCont(pMsg->pCont); +} + +void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) { + dnodeProcessDnodeRspFp[msgType] = fp; +} + +void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg) { + rpcSendRequest(tsDnodeClientRpc, ipSet, rpcMsg); +} diff --git a/src/dnode/src/dnodeMClient.c b/src/dnode/src/dnodeMClient.c deleted file mode 100644 index 3aa863799b..0000000000 --- a/src/dnode/src/dnodeMClient.c +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#define _DEFAULT_SOURCE -#include "os.h" -#include "cJSON.h" -#include "taosmsg.h" -#include "trpc.h" -#include "tutil.h" -#include "tsync.h" -#include "ttime.h" -#include "ttimer.h" -#include "tbalance.h" -#include "tglobal.h" -#include "vnode.h" -#include "mnode.h" -#include "dnode.h" -#include "dnodeLog.h" -#include "dnodeMClient.h" -#include "dnodeModule.h" -#include "dnodeMgmt.h" - -#define MPEER_CONTENT_LEN 2000 - -static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes); -static bool dnodeReadMnodeInfos(); -static void dnodeSaveMnodeInfos(); -static void dnodeUpdateDnodeCfg(SDMDnodeCfg *pCfg); -static bool dnodeReadDnodeCfg(); -static void dnodeSaveDnodeCfg(); -static void dnodeProcessRspFromMnode(SRpcMsg *pMsg); -static void dnodeProcessStatusRsp(SRpcMsg *pMsg); -static void dnodeSendStatusMsg(void *handle, void *tmrId); -static void (*tsDnodeProcessMgmtRspFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *); - -static void *tsDnodeMClientRpc = NULL; -static void *tsDnodeTmr = NULL; -static void *tsStatusTimer = NULL; -static uint32_t tsRebootTime; - -static SRpcIpSet tsMnodeIpSet = {0}; -static SDMMnodeInfos tsMnodeInfos = {0}; -static SDMDnodeCfg tsDnodeCfg = {0}; - -void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet) { - dTrace("mgmt IP list is changed for ufp is called"); - tsMnodeIpSet = *pIpSet; -} - -void dnodeGetMnodeDnodeIpSet(void *ipSetRaw) { - SRpcIpSet *ipSet = ipSetRaw; - ipSet->numOfIps = tsMnodeInfos.nodeNum; - ipSet->inUse = tsMnodeInfos.inUse; - for (int32_t i = 0; i < tsMnodeInfos.nodeNum; ++i) { - taosGetFqdnPortFromEp(tsMnodeInfos.nodeInfos[i].nodeEp, ipSet->fqdn[i], &ipSet->port[i]); - ipSet->port[i] += TSDB_PORT_MNODEDNODE; - } -} - -int32_t dnodeInitMClient() { - dnodeReadDnodeCfg(); - tsRebootTime = taosGetTimestampSec(); - - tsDnodeTmr = taosTmrInit(100, 200, 60000, "DND-DM"); - if (tsDnodeTmr == NULL) { - dError("failed to init dnode timer"); - return -1; - } - - if (!dnodeReadMnodeInfos()) { - memset(&tsMnodeIpSet, 0, sizeof(SRpcIpSet)); - memset(&tsMnodeInfos, 0, sizeof(SDMMnodeInfos)); - tsMnodeIpSet.numOfIps = 1; - taosGetFqdnPortFromEp(tsFirst, tsMnodeIpSet.fqdn[0], &tsMnodeIpSet.port[0]); - tsMnodeIpSet.port[0] += TSDB_PORT_MNODEDNODE; - if (strcmp(tsSecond, tsFirst) != 0) { - tsMnodeIpSet.numOfIps = 2; - taosGetFqdnPortFromEp(tsSecond, tsMnodeIpSet.fqdn[1], &tsMnodeIpSet.port[1]); - tsMnodeIpSet.port[1] += TSDB_PORT_MNODEDNODE; - } - } else { - tsMnodeIpSet.inUse = tsMnodeInfos.inUse; - tsMnodeIpSet.numOfIps = tsMnodeInfos.nodeNum; - for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) { - taosGetFqdnPortFromEp(tsMnodeInfos.nodeInfos[i].nodeEp, tsMnodeIpSet.fqdn[i], &tsMnodeIpSet.port[i]); - tsMnodeIpSet.port[i] += TSDB_PORT_MNODEDNODE; - } - } - - SRpcInit rpcInit; - memset(&rpcInit, 0, sizeof(rpcInit)); - rpcInit.label = "DND-MC"; - rpcInit.numOfThreads = 1; - rpcInit.cfp = dnodeProcessRspFromMnode; - rpcInit.ufp = dnodeUpdateIpSet; - rpcInit.sessions = 100; - rpcInit.connType = TAOS_CONN_CLIENT; - rpcInit.idleTime = tsShellActivityTimer * 2000; - rpcInit.user = "t"; - rpcInit.ckey = "key"; - rpcInit.secret = "secret"; - - tsDnodeMClientRpc = rpcOpen(&rpcInit); - if (tsDnodeMClientRpc == NULL) { - dError("failed to init mnode rpc client"); - return -1; - } - - tsDnodeProcessMgmtRspFp[TSDB_MSG_TYPE_DM_STATUS_RSP] = dnodeProcessStatusRsp; - taosTmrReset(dnodeSendStatusMsg, 500, NULL, tsDnodeTmr, &tsStatusTimer); - - dPrint("mnode rpc client is opened"); - return 0; -} - -void dnodeCleanupMClient() { - if (tsStatusTimer != NULL) { - taosTmrStopA(&tsStatusTimer); - tsStatusTimer = NULL; - } - - if (tsDnodeTmr != NULL) { - taosTmrCleanUp(tsDnodeTmr); - tsDnodeTmr = NULL; - } - - if (tsDnodeMClientRpc) { - rpcClose(tsDnodeMClientRpc); - tsDnodeMClientRpc = NULL; - dPrint("mnode rpc client is closed"); - } -} - -static void dnodeProcessRspFromMnode(SRpcMsg *pMsg) { - if (tsDnodeProcessMgmtRspFp[pMsg->msgType]) { - (*tsDnodeProcessMgmtRspFp[pMsg->msgType])(pMsg); - } else { - dError("%s is not processed in dnode mclient", taosMsg[pMsg->msgType]); - SRpcMsg rpcRsp = {.pCont = 0, .contLen = 0, .code = TSDB_CODE_OPS_NOT_SUPPORT, .handle = pMsg->handle}; - rpcSendResponse(&rpcRsp); - } - - rpcFreeCont(pMsg->pCont); -} - -static void dnodeProcessStatusRsp(SRpcMsg *pMsg) { - if (pMsg->code != TSDB_CODE_SUCCESS) { - dError("status rsp is received, error:%s", tstrerror(pMsg->code)); - taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer); - return; - } - - SDMStatusRsp *pStatusRsp = pMsg->pCont; - SDMMnodeInfos *pMnodes = &pStatusRsp->mnodes; - if (pMnodes->nodeNum <= 0) { - dError("status msg is invalid, num of ips is %d", pMnodes->nodeNum); - taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer); - return; - } - - SDMDnodeCfg *pCfg = &pStatusRsp->dnodeCfg; - pCfg->numOfVnodes = htonl(pCfg->numOfVnodes); - pCfg->moduleStatus = htonl(pCfg->moduleStatus); - pCfg->dnodeId = htonl(pCfg->dnodeId); - - for (int32_t i = 0; i < pMnodes->nodeNum; ++i) { - SDMMnodeInfo *pMnodeInfo = &pMnodes->nodeInfos[i]; - pMnodeInfo->nodeId = htonl(pMnodeInfo->nodeId); - } - - SDMVgroupAccess *pVgAcccess = pStatusRsp->vgAccess; - for (int32_t i = 0; i < pCfg->numOfVnodes; ++i) { - pVgAcccess[i].vgId = htonl(pVgAcccess[i].vgId); - } - - dnodeProcessModuleStatus(pCfg->moduleStatus); - dnodeUpdateDnodeCfg(pCfg); - dnodeUpdateMnodeInfos(pMnodes); - taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer); -} - -static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes) { - bool mnodesChanged = (memcmp(&tsMnodeInfos, pMnodes, sizeof(SDMMnodeInfos)) != 0); - bool mnodesNotInit = (tsMnodeInfos.nodeNum == 0); - if (!(mnodesChanged || mnodesNotInit)) return; - - memcpy(&tsMnodeInfos, pMnodes, sizeof(SDMMnodeInfos)); - - tsMnodeIpSet.inUse = tsMnodeInfos.inUse; - tsMnodeIpSet.numOfIps = tsMnodeInfos.nodeNum; - for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) { - taosGetFqdnPortFromEp(tsMnodeInfos.nodeInfos[i].nodeEp, tsMnodeIpSet.fqdn[i], &tsMnodeIpSet.port[i]); - tsMnodeIpSet.port[i] += TSDB_PORT_MNODEDNODE; - } - - dPrint("mnodes is changed, nodeNum:%d inUse:%d", tsMnodeInfos.nodeNum, tsMnodeInfos.inUse); - for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) { - dPrint("mnode:%d, %s", tsMnodeInfos.nodeInfos[i].nodeId, tsMnodeInfos.nodeInfos[i].nodeEp); - } - - dnodeSaveMnodeInfos(); - sdbUpdateSync(); -} - -void dnodeSendMsgToMnode(SRpcMsg *rpcMsg) { - if (tsDnodeMClientRpc) { - rpcSendRequest(tsDnodeMClientRpc, &tsMnodeIpSet, rpcMsg); - } -} - -static bool dnodeReadMnodeInfos() { - char ipFile[TSDB_FILENAME_LEN] = {0}; - sprintf(ipFile, "%s/mgmtIpList.json", tsDnodeDir); - FILE *fp = fopen(ipFile, "r"); - if (!fp) { - dTrace("failed to read mnode mgmtIpList.json, file not exist"); - return false; - } - - bool ret = false; - int maxLen = 2000; - char *content = calloc(1, maxLen + 1); - int len = fread(content, 1, maxLen, fp); - if (len <= 0) { - free(content); - fclose(fp); - dError("failed to read mnode mgmtIpList.json, content is null"); - return false; - } - - cJSON* root = cJSON_Parse(content); - if (root == NULL) { - dError("failed to read mnode mgmtIpList.json, invalid json format"); - goto PARSE_OVER; - } - - cJSON* inUse = cJSON_GetObjectItem(root, "inUse"); - if (!inUse || inUse->type != cJSON_Number) { - dError("failed to read mnode mgmtIpList.json, inUse not found"); - goto PARSE_OVER; - } - tsMnodeInfos.inUse = inUse->valueint; - - cJSON* nodeNum = cJSON_GetObjectItem(root, "nodeNum"); - if (!nodeNum || nodeNum->type != cJSON_Number) { - dError("failed to read mnode mgmtIpList.json, nodeNum not found"); - goto PARSE_OVER; - } - tsMnodeInfos.nodeNum = nodeNum->valueint; - - cJSON* nodeInfos = cJSON_GetObjectItem(root, "nodeInfos"); - if (!nodeInfos || nodeInfos->type != cJSON_Array) { - dError("failed to read mnode mgmtIpList.json, nodeInfos not found"); - goto PARSE_OVER; - } - - int size = cJSON_GetArraySize(nodeInfos); - if (size != tsMnodeInfos.nodeNum) { - dError("failed to read mnode mgmtIpList.json, nodeInfos size not matched"); - goto PARSE_OVER; - } - - for (int i = 0; i < size; ++i) { - cJSON* nodeInfo = cJSON_GetArrayItem(nodeInfos, i); - if (nodeInfo == NULL) continue; - - cJSON *nodeId = cJSON_GetObjectItem(nodeInfo, "nodeId"); - if (!nodeId || nodeId->type != cJSON_Number) { - dError("failed to read mnode mgmtIpList.json, nodeId not found"); - goto PARSE_OVER; - } - tsMnodeInfos.nodeInfos[i].nodeId = nodeId->valueint; - - cJSON *nodeEp = cJSON_GetObjectItem(nodeInfo, "nodeEp"); - if (!nodeEp || nodeEp->type != cJSON_String || nodeEp->valuestring == NULL) { - dError("failed to read mnode mgmtIpList.json, nodeName not found"); - goto PARSE_OVER; - } - strncpy(tsMnodeInfos.nodeInfos[i].nodeEp, nodeEp->valuestring, TSDB_FQDN_LEN); - } - - ret = true; - - dPrint("read mnode iplist successed, numOfIps:%d inUse:%d", tsMnodeInfos.nodeNum, tsMnodeInfos.inUse); - for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) { - dPrint("mnode:%d, %s", tsMnodeInfos.nodeInfos[i].nodeId, tsMnodeInfos.nodeInfos[i].nodeEp); - } - -PARSE_OVER: - free(content); - cJSON_Delete(root); - fclose(fp); - return ret; -} - -static void dnodeSaveMnodeInfos() { - char ipFile[TSDB_FILENAME_LEN] = {0}; - sprintf(ipFile, "%s/mgmtIpList.json", tsDnodeDir); - FILE *fp = fopen(ipFile, "w"); - if (!fp) return; - - int32_t len = 0; - int32_t maxLen = 2000; - char * content = calloc(1, maxLen + 1); - - len += snprintf(content + len, maxLen - len, "{\n"); - len += snprintf(content + len, maxLen - len, " \"inUse\": %d,\n", tsMnodeInfos.inUse); - len += snprintf(content + len, maxLen - len, " \"nodeNum\": %d,\n", tsMnodeInfos.nodeNum); - len += snprintf(content + len, maxLen - len, " \"nodeInfos\": [{\n"); - for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) { - len += snprintf(content + len, maxLen - len, " \"nodeId\": %d,\n", tsMnodeInfos.nodeInfos[i].nodeId); - len += snprintf(content + len, maxLen - len, " \"nodeEp\": \"%s\"\n", tsMnodeInfos.nodeInfos[i].nodeEp); - if (i < tsMnodeInfos.nodeNum -1) { - len += snprintf(content + len, maxLen - len, " },{\n"); - } else { - len += snprintf(content + len, maxLen - len, " }]\n"); - } - } - len += snprintf(content + len, maxLen - len, "}\n"); - - fwrite(content, 1, len, fp); - fclose(fp); - free(content); - - dPrint("save mnode iplist successed"); -} - -char *dnodeGetMnodeMasterEp() { - return tsMnodeInfos.nodeInfos[tsMnodeIpSet.inUse].nodeEp; -} - -void* dnodeGetMnodeInfos() { - return &tsMnodeInfos; -} - -static void dnodeSendStatusMsg(void *handle, void *tmrId) { - if (tsDnodeTmr == NULL) { - dError("dnode timer is already released"); - return; - } - - if (tsStatusTimer == NULL) { - taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer); - dError("failed to start status timer"); - return; - } - - int32_t contLen = sizeof(SDMStatusMsg) + TSDB_MAX_VNODES * sizeof(SVnodeLoad); - SDMStatusMsg *pStatus = rpcMallocCont(contLen); - if (pStatus == NULL) { - taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer); - dError("failed to malloc status message"); - return; - } - - //strcpy(pStatus->dnodeName, tsDnodeName); - pStatus->version = htonl(tsVersion); - pStatus->dnodeId = htonl(tsDnodeCfg.dnodeId); - strcpy(pStatus->dnodeEp, tsLocalEp); - pStatus->lastReboot = htonl(tsRebootTime); - pStatus->numOfTotalVnodes = htons((uint16_t) tsNumOfTotalVnodes); - pStatus->numOfCores = htons((uint16_t) tsNumOfCores); - pStatus->diskAvailable = tsAvailDataDirGB; - pStatus->alternativeRole = (uint8_t) tsAlternativeRole; - - vnodeBuildStatusMsg(pStatus); - contLen = sizeof(SDMStatusMsg) + pStatus->openVnodes * sizeof(SVnodeLoad); - pStatus->openVnodes = htons(pStatus->openVnodes); - - SRpcMsg rpcMsg = { - .pCont = pStatus, - .contLen = contLen, - .msgType = TSDB_MSG_TYPE_DM_STATUS - }; - - dnodeSendMsgToMnode(&rpcMsg); -} - -static bool dnodeReadDnodeCfg() { - char dnodeCfgFile[TSDB_FILENAME_LEN] = {0}; - sprintf(dnodeCfgFile, "%s/dnodeCfg.json", tsDnodeDir); - - FILE *fp = fopen(dnodeCfgFile, "r"); - if (!fp) { - dTrace("failed to read dnodeCfg.json, file not exist"); - return false; - } - - bool ret = false; - int maxLen = 100; - char *content = calloc(1, maxLen + 1); - int len = fread(content, 1, maxLen, fp); - if (len <= 0) { - free(content); - fclose(fp); - dError("failed to read dnodeCfg.json, content is null"); - return false; - } - - cJSON* root = cJSON_Parse(content); - if (root == NULL) { - dError("failed to read dnodeCfg.json, invalid json format"); - goto PARSE_CFG_OVER; - } - - cJSON* dnodeId = cJSON_GetObjectItem(root, "dnodeId"); - if (!dnodeId || dnodeId->type != cJSON_Number) { - dError("failed to read dnodeCfg.json, dnodeId not found"); - goto PARSE_CFG_OVER; - } - tsDnodeCfg.dnodeId = dnodeId->valueint; - - ret = true; - - dPrint("read numOfVnodes successed, dnodeId:%d", tsDnodeCfg.dnodeId); - -PARSE_CFG_OVER: - free(content); - cJSON_Delete(root); - fclose(fp); - return ret; -} - -static void dnodeSaveDnodeCfg() { - char dnodeCfgFile[TSDB_FILENAME_LEN] = {0}; - sprintf(dnodeCfgFile, "%s/dnodeCfg.json", tsDnodeDir); - - FILE *fp = fopen(dnodeCfgFile, "w"); - if (!fp) return; - - int32_t len = 0; - int32_t maxLen = 100; - char * content = calloc(1, maxLen + 1); - - len += snprintf(content + len, maxLen - len, "{\n"); - len += snprintf(content + len, maxLen - len, " \"dnodeId\": %d\n", tsDnodeCfg.dnodeId); - len += snprintf(content + len, maxLen - len, "}\n"); - - fwrite(content, 1, len, fp); - fclose(fp); - free(content); - - dPrint("save dnodeId successed"); -} - -void dnodeUpdateDnodeCfg(SDMDnodeCfg *pCfg) { - if (tsDnodeCfg.dnodeId == 0) { - dPrint("dnodeId is set to %d", pCfg->dnodeId); - tsDnodeCfg.dnodeId = pCfg->dnodeId; - dnodeSaveDnodeCfg(); - } -} - -int32_t dnodeGetDnodeId() { - return tsDnodeCfg.dnodeId; -} diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index 940b884927..f6bd026703 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -23,9 +23,8 @@ #include "tglobal.h" #include "dnode.h" #include "dnodeLog.h" -#include "dnodeMClient.h" #include "dnodeMgmt.h" -#include "dnodeMnode.h" +#include "dnodeDnode.h" #include "dnodeModule.h" #include "dnodeRead.h" #include "dnodeShell.h" @@ -167,9 +166,9 @@ static int32_t dnodeInitSystem() { if (dnodeInitStorage() != 0) return -1; if (dnodeInitRead() != 0) return -1; if (dnodeInitWrite() != 0) return -1; - if (dnodeInitMClient() != 0) return -1; + if (dnodeInitClient() != 0) return -1; if (dnodeInitModules() != 0) return -1; - if (dnodeInitMnode() != 0) return -1; + if (dnodeInitServer() != 0) return -1; if (dnodeInitMgmt() != 0) return -1; if (dnodeInitShell() != 0) return -1; @@ -185,9 +184,9 @@ static void dnodeCleanUpSystem() { if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_STOPPED) { dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_STOPPED); dnodeCleanupShell(); - dnodeCleanupMnode(); + dnodeCleanupServer(); dnodeCleanupMgmt(); - dnodeCleanupMClient(); + dnodeCleanupClient(); dnodeCleanupWrite(); dnodeCleanupRead(); dnodeCleanUpModules(); diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index fbf1ceea71..db25cfd23b 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -15,19 +15,47 @@ #define _DEFAULT_SOURCE #include "os.h" +#include "cJSON.h" #include "ihash.h" #include "taoserror.h" #include "taosmsg.h" +#include "ttime.h" +#include "ttimer.h" #include "trpc.h" #include "tsdb.h" #include "twal.h" -#include "vnode.h" +#include "tsync.h" +#include "ttime.h" +#include "ttimer.h" +#include "tbalance.h" #include "tglobal.h" +#include "dnode.h" +#include "vnode.h" +#include "mnode.h" #include "dnodeLog.h" -#include "dnodeMClient.h" #include "dnodeMgmt.h" #include "dnodeRead.h" #include "dnodeWrite.h" +#include "dnodeModule.h" + +#define MPEER_CONTENT_LEN 2000 + +static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes); +static bool dnodeReadMnodeInfos(); +static void dnodeSaveMnodeInfos(); +static void dnodeUpdateDnodeCfg(SDMDnodeCfg *pCfg); +static bool dnodeReadDnodeCfg(); +static void dnodeSaveDnodeCfg(); +static void dnodeProcessStatusRsp(SRpcMsg *pMsg); +static void dnodeSendStatusMsg(void *handle, void *tmrId); + +static void *tsDnodeTmr = NULL; +static void *tsStatusTimer = NULL; +static uint32_t tsRebootTime; + +static SRpcIpSet tsMnodeIpSet = {0}; +static SDMMnodeInfos tsMnodeInfos = {0}; +static SDMDnodeCfg tsDnodeCfg = {0}; static int32_t dnodeOpenVnodes(); static void dnodeCloseVnodes(); @@ -43,15 +71,59 @@ int32_t dnodeInitMgmt() { dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_ALTER_STREAM] = dnodeProcessAlterStreamMsg; dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeProcessConfigDnodeMsg; + dnodeAddClientRspHandle(TSDB_MSG_TYPE_DM_STATUS_RSP, dnodeProcessStatusRsp); + dnodeReadDnodeCfg(); + tsRebootTime = taosGetTimestampSec(); + + tsDnodeTmr = taosTmrInit(100, 200, 60000, "DND-DM"); + if (tsDnodeTmr == NULL) { + dError("failed to init dnode timer"); + return -1; + } + + if (!dnodeReadMnodeInfos()) { + memset(&tsMnodeIpSet, 0, sizeof(SRpcIpSet)); + memset(&tsMnodeInfos, 0, sizeof(SDMMnodeInfos)); + tsMnodeIpSet.numOfIps = 1; + taosGetFqdnPortFromEp(tsFirst, tsMnodeIpSet.fqdn[0], &tsMnodeIpSet.port[0]); + tsMnodeIpSet.port[0] += TSDB_PORT_DNODEDNODE; + if (strcmp(tsSecond, tsFirst) != 0) { + tsMnodeIpSet.numOfIps = 2; + taosGetFqdnPortFromEp(tsSecond, tsMnodeIpSet.fqdn[1], &tsMnodeIpSet.port[1]); + tsMnodeIpSet.port[1] += TSDB_PORT_DNODEDNODE; + } + } else { + tsMnodeIpSet.inUse = tsMnodeInfos.inUse; + tsMnodeIpSet.numOfIps = tsMnodeInfos.nodeNum; + for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) { + taosGetFqdnPortFromEp(tsMnodeInfos.nodeInfos[i].nodeEp, tsMnodeIpSet.fqdn[i], &tsMnodeIpSet.port[i]); + tsMnodeIpSet.port[i] += TSDB_PORT_DNODEDNODE; + } + } + int32_t code = dnodeOpenVnodes(); if (code != TSDB_CODE_SUCCESS) { return -1; } + taosTmrReset(dnodeSendStatusMsg, 500, NULL, tsDnodeTmr, &tsStatusTimer); + + dPrint("dnode mgmt is initialized"); + return TSDB_CODE_SUCCESS; } void dnodeCleanupMgmt() { + if (tsStatusTimer != NULL) { + taosTmrStopA(&tsStatusTimer); + tsStatusTimer = NULL; + } + + if (tsDnodeTmr != NULL) { + taosTmrCleanUp(tsDnodeTmr); + tsDnodeTmr = NULL; + } + dnodeCloseVnodes(); } @@ -193,3 +265,326 @@ static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) { SMDCfgDnodeMsg *pCfg = (SMDCfgDnodeMsg *)pMsg->pCont; return taosCfgDynamicOptions(pCfg->config); } + + +void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet) { + dTrace("mgmt IP list is changed for ufp is called"); + tsMnodeIpSet = *pIpSet; +} + +void dnodeGetMnodeDnodeIpSet(void *ipSetRaw) { + SRpcIpSet *ipSet = ipSetRaw; + ipSet->numOfIps = tsMnodeInfos.nodeNum; + ipSet->inUse = tsMnodeInfos.inUse; + for (int32_t i = 0; i < tsMnodeInfos.nodeNum; ++i) { + taosGetFqdnPortFromEp(tsMnodeInfos.nodeInfos[i].nodeEp, ipSet->fqdn[i], &ipSet->port[i]); + ipSet->port[i] += TSDB_PORT_DNODEDNODE; + } +} + +static void dnodeProcessStatusRsp(SRpcMsg *pMsg) { + if (pMsg->code != TSDB_CODE_SUCCESS) { + dError("status rsp is received, error:%s", tstrerror(pMsg->code)); + taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer); + return; + } + + SDMStatusRsp *pStatusRsp = pMsg->pCont; + SDMMnodeInfos *pMnodes = &pStatusRsp->mnodes; + if (pMnodes->nodeNum <= 0) { + dError("status msg is invalid, num of ips is %d", pMnodes->nodeNum); + taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer); + return; + } + + SDMDnodeCfg *pCfg = &pStatusRsp->dnodeCfg; + pCfg->numOfVnodes = htonl(pCfg->numOfVnodes); + pCfg->moduleStatus = htonl(pCfg->moduleStatus); + pCfg->dnodeId = htonl(pCfg->dnodeId); + + for (int32_t i = 0; i < pMnodes->nodeNum; ++i) { + SDMMnodeInfo *pMnodeInfo = &pMnodes->nodeInfos[i]; + pMnodeInfo->nodeId = htonl(pMnodeInfo->nodeId); + } + + SDMVgroupAccess *pVgAcccess = pStatusRsp->vgAccess; + for (int32_t i = 0; i < pCfg->numOfVnodes; ++i) { + pVgAcccess[i].vgId = htonl(pVgAcccess[i].vgId); + } + + dnodeProcessModuleStatus(pCfg->moduleStatus); + dnodeUpdateDnodeCfg(pCfg); + dnodeUpdateMnodeInfos(pMnodes); + taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer); +} + +static void dnodeUpdateMnodeInfos(SDMMnodeInfos *pMnodes) { + bool mnodesChanged = (memcmp(&tsMnodeInfos, pMnodes, sizeof(SDMMnodeInfos)) != 0); + bool mnodesNotInit = (tsMnodeInfos.nodeNum == 0); + if (!(mnodesChanged || mnodesNotInit)) return; + + memcpy(&tsMnodeInfos, pMnodes, sizeof(SDMMnodeInfos)); + + tsMnodeIpSet.inUse = tsMnodeInfos.inUse; + tsMnodeIpSet.numOfIps = tsMnodeInfos.nodeNum; + for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) { + taosGetFqdnPortFromEp(tsMnodeInfos.nodeInfos[i].nodeEp, tsMnodeIpSet.fqdn[i], &tsMnodeIpSet.port[i]); + tsMnodeIpSet.port[i] += TSDB_PORT_DNODEDNODE; + } + + dPrint("mnodes is changed, nodeNum:%d inUse:%d", tsMnodeInfos.nodeNum, tsMnodeInfos.inUse); + for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) { + dPrint("mnode:%d, %s", tsMnodeInfos.nodeInfos[i].nodeId, tsMnodeInfos.nodeInfos[i].nodeEp); + } + + dnodeSaveMnodeInfos(); + sdbUpdateSync(); +} + +static bool dnodeReadMnodeInfos() { + char ipFile[TSDB_FILENAME_LEN] = {0}; + sprintf(ipFile, "%s/mgmtIpList.json", tsDnodeDir); + FILE *fp = fopen(ipFile, "r"); + if (!fp) { + dTrace("failed to read mnode mgmtIpList.json, file not exist"); + return false; + } + + bool ret = false; + int maxLen = 2000; + char *content = calloc(1, maxLen + 1); + int len = fread(content, 1, maxLen, fp); + if (len <= 0) { + free(content); + fclose(fp); + dError("failed to read mnode mgmtIpList.json, content is null"); + return false; + } + + cJSON* root = cJSON_Parse(content); + if (root == NULL) { + dError("failed to read mnode mgmtIpList.json, invalid json format"); + goto PARSE_OVER; + } + + cJSON* inUse = cJSON_GetObjectItem(root, "inUse"); + if (!inUse || inUse->type != cJSON_Number) { + dError("failed to read mnode mgmtIpList.json, inUse not found"); + goto PARSE_OVER; + } + tsMnodeInfos.inUse = inUse->valueint; + + cJSON* nodeNum = cJSON_GetObjectItem(root, "nodeNum"); + if (!nodeNum || nodeNum->type != cJSON_Number) { + dError("failed to read mnode mgmtIpList.json, nodeNum not found"); + goto PARSE_OVER; + } + tsMnodeInfos.nodeNum = nodeNum->valueint; + + cJSON* nodeInfos = cJSON_GetObjectItem(root, "nodeInfos"); + if (!nodeInfos || nodeInfos->type != cJSON_Array) { + dError("failed to read mnode mgmtIpList.json, nodeInfos not found"); + goto PARSE_OVER; + } + + int size = cJSON_GetArraySize(nodeInfos); + if (size != tsMnodeInfos.nodeNum) { + dError("failed to read mnode mgmtIpList.json, nodeInfos size not matched"); + goto PARSE_OVER; + } + + for (int i = 0; i < size; ++i) { + cJSON* nodeInfo = cJSON_GetArrayItem(nodeInfos, i); + if (nodeInfo == NULL) continue; + + cJSON *nodeId = cJSON_GetObjectItem(nodeInfo, "nodeId"); + if (!nodeId || nodeId->type != cJSON_Number) { + dError("failed to read mnode mgmtIpList.json, nodeId not found"); + goto PARSE_OVER; + } + tsMnodeInfos.nodeInfos[i].nodeId = nodeId->valueint; + + cJSON *nodeEp = cJSON_GetObjectItem(nodeInfo, "nodeEp"); + if (!nodeEp || nodeEp->type != cJSON_String || nodeEp->valuestring == NULL) { + dError("failed to read mnode mgmtIpList.json, nodeName not found"); + goto PARSE_OVER; + } + strncpy(tsMnodeInfos.nodeInfos[i].nodeEp, nodeEp->valuestring, TSDB_FQDN_LEN); + } + + ret = true; + + dPrint("read mnode iplist successed, numOfIps:%d inUse:%d", tsMnodeInfos.nodeNum, tsMnodeInfos.inUse); + for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) { + dPrint("mnode:%d, %s", tsMnodeInfos.nodeInfos[i].nodeId, tsMnodeInfos.nodeInfos[i].nodeEp); + } + +PARSE_OVER: + free(content); + cJSON_Delete(root); + fclose(fp); + return ret; +} + +static void dnodeSaveMnodeInfos() { + char ipFile[TSDB_FILENAME_LEN] = {0}; + sprintf(ipFile, "%s/mgmtIpList.json", tsDnodeDir); + FILE *fp = fopen(ipFile, "w"); + if (!fp) return; + + int32_t len = 0; + int32_t maxLen = 2000; + char * content = calloc(1, maxLen + 1); + + len += snprintf(content + len, maxLen - len, "{\n"); + len += snprintf(content + len, maxLen - len, " \"inUse\": %d,\n", tsMnodeInfos.inUse); + len += snprintf(content + len, maxLen - len, " \"nodeNum\": %d,\n", tsMnodeInfos.nodeNum); + len += snprintf(content + len, maxLen - len, " \"nodeInfos\": [{\n"); + for (int32_t i = 0; i < tsMnodeInfos.nodeNum; i++) { + len += snprintf(content + len, maxLen - len, " \"nodeId\": %d,\n", tsMnodeInfos.nodeInfos[i].nodeId); + len += snprintf(content + len, maxLen - len, " \"nodeEp\": \"%s\"\n", tsMnodeInfos.nodeInfos[i].nodeEp); + if (i < tsMnodeInfos.nodeNum -1) { + len += snprintf(content + len, maxLen - len, " },{\n"); + } else { + len += snprintf(content + len, maxLen - len, " }]\n"); + } + } + len += snprintf(content + len, maxLen - len, "}\n"); + + fwrite(content, 1, len, fp); + fclose(fp); + free(content); + + dPrint("save mnode iplist successed"); +} + +char *dnodeGetMnodeMasterEp() { + return tsMnodeInfos.nodeInfos[tsMnodeIpSet.inUse].nodeEp; +} + +void* dnodeGetMnodeInfos() { + return &tsMnodeInfos; +} + +static void dnodeSendStatusMsg(void *handle, void *tmrId) { + if (tsDnodeTmr == NULL) { + dError("dnode timer is already released"); + return; + } + + if (tsStatusTimer == NULL) { + taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer); + dError("failed to start status timer"); + return; + } + + int32_t contLen = sizeof(SDMStatusMsg) + TSDB_MAX_VNODES * sizeof(SVnodeLoad); + SDMStatusMsg *pStatus = rpcMallocCont(contLen); + if (pStatus == NULL) { + taosTmrReset(dnodeSendStatusMsg, tsStatusInterval * 1000, NULL, tsDnodeTmr, &tsStatusTimer); + dError("failed to malloc status message"); + return; + } + + //strcpy(pStatus->dnodeName, tsDnodeName); + pStatus->version = htonl(tsVersion); + pStatus->dnodeId = htonl(tsDnodeCfg.dnodeId); + strcpy(pStatus->dnodeEp, tsLocalEp); + pStatus->lastReboot = htonl(tsRebootTime); + pStatus->numOfTotalVnodes = htons((uint16_t) tsNumOfTotalVnodes); + pStatus->numOfCores = htons((uint16_t) tsNumOfCores); + pStatus->diskAvailable = tsAvailDataDirGB; + pStatus->alternativeRole = (uint8_t) tsAlternativeRole; + + vnodeBuildStatusMsg(pStatus); + contLen = sizeof(SDMStatusMsg) + pStatus->openVnodes * sizeof(SVnodeLoad); + pStatus->openVnodes = htons(pStatus->openVnodes); + + SRpcMsg rpcMsg = { + .pCont = pStatus, + .contLen = contLen, + .msgType = TSDB_MSG_TYPE_DM_STATUS + }; + + dnodeSendMsgToDnode(&tsMnodeIpSet, &rpcMsg); +} + +static bool dnodeReadDnodeCfg() { + char dnodeCfgFile[TSDB_FILENAME_LEN] = {0}; + sprintf(dnodeCfgFile, "%s/dnodeCfg.json", tsDnodeDir); + + FILE *fp = fopen(dnodeCfgFile, "r"); + if (!fp) { + dTrace("failed to read dnodeCfg.json, file not exist"); + return false; + } + + bool ret = false; + int maxLen = 100; + char *content = calloc(1, maxLen + 1); + int len = fread(content, 1, maxLen, fp); + if (len <= 0) { + free(content); + fclose(fp); + dError("failed to read dnodeCfg.json, content is null"); + return false; + } + + cJSON* root = cJSON_Parse(content); + if (root == NULL) { + dError("failed to read dnodeCfg.json, invalid json format"); + goto PARSE_CFG_OVER; + } + + cJSON* dnodeId = cJSON_GetObjectItem(root, "dnodeId"); + if (!dnodeId || dnodeId->type != cJSON_Number) { + dError("failed to read dnodeCfg.json, dnodeId not found"); + goto PARSE_CFG_OVER; + } + tsDnodeCfg.dnodeId = dnodeId->valueint; + + ret = true; + + dPrint("read numOfVnodes successed, dnodeId:%d", tsDnodeCfg.dnodeId); + +PARSE_CFG_OVER: + free(content); + cJSON_Delete(root); + fclose(fp); + return ret; +} + +static void dnodeSaveDnodeCfg() { + char dnodeCfgFile[TSDB_FILENAME_LEN] = {0}; + sprintf(dnodeCfgFile, "%s/dnodeCfg.json", tsDnodeDir); + + FILE *fp = fopen(dnodeCfgFile, "w"); + if (!fp) return; + + int32_t len = 0; + int32_t maxLen = 100; + char * content = calloc(1, maxLen + 1); + + len += snprintf(content + len, maxLen - len, "{\n"); + len += snprintf(content + len, maxLen - len, " \"dnodeId\": %d\n", tsDnodeCfg.dnodeId); + len += snprintf(content + len, maxLen - len, "}\n"); + + fwrite(content, 1, len, fp); + fclose(fp); + free(content); + + dPrint("save dnodeId successed"); +} + +void dnodeUpdateDnodeCfg(SDMDnodeCfg *pCfg) { + if (tsDnodeCfg.dnodeId == 0) { + dPrint("dnodeId is set to %d", pCfg->dnodeId); + tsDnodeCfg.dnodeId = pCfg->dnodeId; + dnodeSaveDnodeCfg(); + } +} + +int32_t dnodeGetDnodeId() { + return tsDnodeCfg.dnodeId; +} + diff --git a/src/dnode/src/dnodeMnode.c b/src/dnode/src/dnodeServer.c similarity index 73% rename from src/dnode/src/dnodeMnode.c rename to src/dnode/src/dnodeServer.c index 75c09d43ba..169cd6cffa 100644 --- a/src/dnode/src/dnodeMnode.c +++ b/src/dnode/src/dnodeServer.c @@ -23,10 +23,10 @@ #include "dnodeWrite.h" static void (*dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *); -static void dnodeProcessMsgFromMnode(SRpcMsg *pMsg); -static void *tsDnodeMnodeRpc = NULL; +static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg); +static void *tsDnodeServerRpc = NULL; -int32_t dnodeInitMnode() { +int32_t dnodeInitServer() { dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_CREATE_TABLE] = dnodeWrite; dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_DROP_TABLE] = dnodeWrite; dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_ALTER_TABLE] = dnodeWrite; @@ -38,33 +38,35 @@ int32_t dnodeInitMnode() { SRpcInit rpcInit; memset(&rpcInit, 0, sizeof(rpcInit)); - rpcInit.localPort = tsDnodeMnodePort; - rpcInit.label = "DND-MS"; + rpcInit.localPort = tsDnodeDnodePort; + rpcInit.label = "DND-S"; rpcInit.numOfThreads = 1; - rpcInit.cfp = dnodeProcessMsgFromMnode; + rpcInit.cfp = dnodeProcessReqMsgFromDnode; rpcInit.sessions = 100; rpcInit.connType = TAOS_CONN_SERVER; rpcInit.idleTime = tsShellActivityTimer * 2000; - tsDnodeMnodeRpc = rpcOpen(&rpcInit); - if (tsDnodeMnodeRpc == NULL) { - dError("failed to init mnode rpc server"); + tsDnodeServerRpc = rpcOpen(&rpcInit); + if (tsDnodeServerRpc == NULL) { + dError("failed to init inter-dnodes RPC server"); return -1; } - dPrint("mnode rpc server is opened"); + dPrint("inter-dnodes RPC server is opened"); return 0; } -void dnodeCleanupMnode() { - if (tsDnodeMnodeRpc) { - rpcClose(tsDnodeMnodeRpc); - tsDnodeMnodeRpc = NULL; - dPrint("mnode rpc server is closed"); +void dnodeCleanupServer() { + if (tsDnodeServerRpc) { + rpcClose(tsDnodeServerRpc); + tsDnodeServerRpc = NULL; + dPrint("inter-dnodes RPC server is closed"); } } -static void dnodeProcessMsgFromMnode(SRpcMsg *pMsg) { +void mgmtProcessReqMsgFromDnode(SRpcMsg *rpcMsg); + +static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg) { SRpcMsg rspMsg; rspMsg.handle = pMsg->handle; rspMsg.pCont = NULL; @@ -74,7 +76,7 @@ static void dnodeProcessMsgFromMnode(SRpcMsg *pMsg) { rspMsg.code = TSDB_CODE_NOT_READY; rpcSendResponse(&rspMsg); rpcFreeCont(pMsg->pCont); - dTrace("thandle:%p, query msg is ignored since dnode not running", pMsg->handle); + dTrace("thandle:%p, query msg is ignored since dnode not running", pMsg->handle); return; } @@ -83,15 +85,11 @@ static void dnodeProcessMsgFromMnode(SRpcMsg *pMsg) { rpcSendResponse(&rspMsg); return; } - + if (dnodeProcessMgmtMsgFp[pMsg->msgType]) { (*dnodeProcessMgmtMsgFp[pMsg->msgType])(pMsg); } else { - dError("%s is not processed in dnode mserver", taosMsg[pMsg->msgType]); - rspMsg.code = TSDB_CODE_MSG_NOT_PROCESSED; - rpcSendResponse(&rspMsg); - rpcFreeCont(pMsg->pCont); + mgmtProcessReqMsgFromDnode(pMsg); } } - diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index 581273d21c..e6a392a341 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -49,7 +49,7 @@ int32_t dnodeInitShell() { SRpcInit rpcInit; memset(&rpcInit, 0, sizeof(rpcInit)); - rpcInit.localPort = tsMnodeShellPort; + rpcInit.localPort = tsDnodeShellPort; rpcInit.label = "SHELL"; rpcInit.numOfThreads = numOfThreads; rpcInit.cfp = dnodeProcessMsgFromShell; diff --git a/src/inc/dnode.h b/src/inc/dnode.h index c4b893ab86..99b9046aac 100644 --- a/src/inc/dnode.h +++ b/src/inc/dnode.h @@ -20,6 +20,8 @@ extern "C" { #endif +#include "trpc.h" + typedef struct { int32_t queryReqNum; int32_t submitReqNum; @@ -47,6 +49,10 @@ void dnodeGetMnodeDnodeIpSet(void *ipSet); void * dnodeGetMnodeInfos(); int32_t dnodeGetDnodeId(); +void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); +void mgmtAddDServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); +void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg); + #ifdef __cplusplus } #endif diff --git a/src/inc/mnode.h b/src/inc/mnode.h index 21955e29c1..37fec24c20 100644 --- a/src/inc/mnode.h +++ b/src/inc/mnode.h @@ -26,7 +26,8 @@ void mgmtCleanUpSystem(); void mgmtStopSystem(); void sdbUpdateSync(); -void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg); +void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg); +void mgmtProcessReqMsgFromDnode(SRpcMsg *rpcMsg); #ifdef __cplusplus } diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 95310ae44a..ec9debaf2b 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -330,9 +330,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_MAX_CHILD_TABLES 100000 #define TSDB_PORT_DNODESHELL 0 -#define TSDB_PORT_DNODEMNODE 10 -#define TSDB_PORT_MNODEDNODE 15 -#define TSDB_PORT_SYNC 20 +#define TSDB_PORT_DNODEDNODE 5 +#define TSDB_PORT_SYNC 10 #define TAOS_QTYPE_RPC 0 #define TAOS_QTYPE_FWD 1 diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index eeaeec83f2..1bc24c6c71 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -68,7 +68,7 @@ TAOS *shellInit(struct arguments *args) { tsMeterMetaKeepTimer = 3000; // Connect to the database. - TAOS *con = taos_connect(args->host, args->user, args->password, args->database, tsMnodeShellPort); + TAOS *con = taos_connect(args->host, args->user, args->password, args->database, tsDnodeShellPort); if (con == NULL) { return con; } diff --git a/src/kit/shell/src/shellImport.c b/src/kit/shell/src/shellImport.c index e5c50bb74e..b29b96379b 100644 --- a/src/kit/shell/src/shellImport.c +++ b/src/kit/shell/src/shellImport.c @@ -229,7 +229,7 @@ static void shellRunImportThreads(struct arguments* args) ShellThreadObj *pThread = threadObj + t; pThread->threadIndex = t; pThread->totalThreads = args->threadNum; - pThread->taos = taos_connect(args->host, args->user, args->password, args->database, tsMnodeShellPort); + pThread->taos = taos_connect(args->host, args->user, args->password, args->database, tsDnodeShellPort); if (pThread->taos == NULL) { fprintf(stderr, "ERROR: thread:%d failed connect to TDengine, error:%s\n", pThread->threadIndex, taos_errstr(pThread->taos)); exit(0); diff --git a/src/kit/shell/src/shellLinux.c b/src/kit/shell/src/shellLinux.c index 22ffa78c81..f5a1145cf8 100644 --- a/src/kit/shell/src/shellLinux.c +++ b/src/kit/shell/src/shellLinux.c @@ -63,7 +63,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { break; case 'P': if (arg) { - tsMnodeShellPort = atoi(arg); + tsDnodeShellPort = atoi(arg); } else { fprintf(stderr, "Invalid port\n"); return -1; diff --git a/src/mnode/inc/mgmtDServer.h b/src/mnode/inc/mgmtServer.h similarity index 93% rename from src/mnode/inc/mgmtDServer.h rename to src/mnode/inc/mgmtServer.h index 937ae8f1ac..180e893cb0 100644 --- a/src/mnode/inc/mgmtDServer.h +++ b/src/mnode/inc/mgmtServer.h @@ -20,8 +20,8 @@ extern "C" { #endif -int32_t mgmtInitDServer(); -void mgmtCleanupDServer(); +int32_t mgmtInitServer(); +void mgmtCleanupServer(); void mgmtAddDServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); #ifdef __cplusplus diff --git a/src/mnode/src/mgmtDClient.c b/src/mnode/src/mgmtDClient.c deleted file mode 100644 index 229964e1d6..0000000000 --- a/src/mnode/src/mgmtDClient.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#define _DEFAULT_SOURCE -#include "os.h" -#include "taoserror.h" -#include "tsched.h" -#include "tsystem.h" -#include "tutil.h" -#include "tglobal.h" -#include "dnode.h" -#include "tgrant.h" -#include "mgmtDef.h" -#include "mgmtLog.h" -#include "mgmtMnode.h" -#include "mgmtDb.h" -#include "mgmtDnode.h" -#include "mgmtProfile.h" -#include "mgmtShell.h" -#include "mgmtTable.h" -#include "mgmtVgroup.h" - -static void mgmtProcessRspFromDnode(SRpcMsg *rpcMsg); -static void (*mgmtProcessDnodeRspFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg); -static void *tsMgmtDClientRpc = NULL; - -int32_t mgmtInitDClient() { - SRpcInit rpcInit = {0}; - rpcInit.localPort = 0; - rpcInit.label = "MND-DC"; - rpcInit.numOfThreads = 1; - rpcInit.cfp = mgmtProcessRspFromDnode; - rpcInit.sessions = 100; - rpcInit.connType = TAOS_CONN_CLIENT; - rpcInit.idleTime = tsShellActivityTimer * 1000; - rpcInit.user = "mgmtDClient"; - rpcInit.ckey = "key"; - rpcInit.secret = "secret"; - - tsMgmtDClientRpc = rpcOpen(&rpcInit); - if (tsMgmtDClientRpc == NULL) { - mError("failed to init client connection to dnode"); - return -1; - } - - mPrint("client connection to dnode is opened"); - return 0; -} - -void mgmtCleanupDClient() { - if (tsMgmtDClientRpc) { - rpcClose(tsMgmtDClientRpc); - tsMgmtDClientRpc = NULL; - } -} - -void mgmtAddDClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) { - mgmtProcessDnodeRspFp[msgType] = fp; -} - -void mgmtSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg) { - rpcSendRequest(tsMgmtDClientRpc, ipSet, rpcMsg); -} - -static void mgmtProcessRspFromDnode(SRpcMsg *rpcMsg) { - if (mgmtProcessDnodeRspFp[rpcMsg->msgType]) { - (*mgmtProcessDnodeRspFp[rpcMsg->msgType])(rpcMsg); - } else { - mError("%s is not processed in mgmt dclient", taosMsg[rpcMsg->msgType]); - SRpcMsg rpcRsp = {.pCont = 0, .contLen = 0, .code = TSDB_CODE_OPS_NOT_SUPPORT, .handle = rpcMsg->handle}; - rpcSendResponse(&rpcRsp); - } - - rpcFreeCont(rpcMsg->pCont); -} diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index 90ee40dc93..33c012f079 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -27,8 +27,6 @@ #include "dnode.h" #include "mgmtDef.h" #include "mgmtLog.h" -#include "mgmtDClient.h" -#include "mgmtDServer.h" #include "mgmtDnode.h" #include "mgmtMnode.h" #include "mgmtSdb.h" @@ -152,7 +150,7 @@ int32_t mgmtInitDnodes() { mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_CREATE_DNODE, mgmtProcessCreateDnodeMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_DROP_DNODE, mgmtProcessDropDnodeMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_CONFIG_DNODE, mgmtProcessCfgDnodeMsg); - mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP, mgmtProcessCfgDnodeMsgRsp); + dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP, mgmtProcessCfgDnodeMsgRsp); mgmtAddDServerMsgHandle(TSDB_MSG_TYPE_DM_STATUS, mgmtProcessDnodeStatusMsg); mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_MODULE, mgmtGetModuleMeta); mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_MODULE, mgmtRetrieveModules); @@ -241,7 +239,7 @@ void mgmtProcessCfgDnodeMsg(SQueuedMsg *pMsg) { .pCont = pMdCfgDnode, .contLen = sizeof(SMDCfgDnodeMsg) }; - mgmtSendMsgToDnode(&ipSet, &rpcMdCfgDnodeMsg); + dnodeSendMsgToDnode(&ipSet, &rpcMdCfgDnodeMsg); rpcRsp.code = TSDB_CODE_SUCCESS; } diff --git a/src/mnode/src/mgmtMain.c b/src/mnode/src/mgmtMain.c index 0f18c95539..aa95381df3 100644 --- a/src/mnode/src/mgmtMain.c +++ b/src/mnode/src/mgmtMain.c @@ -24,12 +24,11 @@ #include "dnode.h" #include "mgmtDef.h" #include "mgmtLog.h" +#include "mgmtServer.h" #include "mgmtAcct.h" #include "mgmtDnode.h" #include "mgmtMnode.h" #include "mgmtDb.h" -#include "mgmtDClient.h" -#include "mgmtDServer.h" #include "mgmtSdb.h" #include "mgmtVgroup.h" #include "mgmtUser.h" @@ -100,11 +99,7 @@ int32_t mgmtStartSystem() { mError("failed to init balance") } - if (mgmtInitDClient() < 0) { - return -1; - } - - if (mgmtInitDServer() < 0) { + if (mgmtInitServer() < 0) { return -1; } @@ -141,8 +136,7 @@ void mgmtCleanUpSystem() { mgmtCleanupMnodes(); balanceCleanUp(); mgmtCleanUpShell(); - mgmtCleanupDClient(); - mgmtCleanupDServer(); + mgmtCleanupServer(); mgmtCleanUpAccts(); mgmtCleanUpTables(); mgmtCleanUpVgroups(); diff --git a/src/mnode/src/mgmtDServer.c b/src/mnode/src/mgmtServer.c similarity index 55% rename from src/mnode/src/mgmtDServer.c rename to src/mnode/src/mgmtServer.c index 726554e490..c2b07a3f4e 100644 --- a/src/mnode/src/mgmtDServer.c +++ b/src/mnode/src/mgmtServer.c @@ -27,7 +27,6 @@ #include "mgmtDef.h" #include "mgmtLog.h" #include "mgmtDb.h" -#include "mgmtDServer.h" #include "mgmtMnode.h" #include "mgmtProfile.h" #include "mgmtShell.h" @@ -35,45 +34,21 @@ #include "mgmtTable.h" #include "mgmtVgroup.h" -static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg); -static int mgmtDServerRetrieveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey); static void (*mgmtProcessDnodeMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg); -static void *tsMgmtDServerRpc; -static void *tsMgmtDServerQhandle = NULL; +static void *tsMgmtServerQhandle = NULL; -int32_t mgmtInitDServer() { - SRpcInit rpcInit = {0}; - rpcInit.localPort = tsMnodeDnodePort; - rpcInit.label = "MND-DS"; - rpcInit.numOfThreads = 1; - rpcInit.cfp = mgmtProcessMsgFromDnode; - rpcInit.sessions = 100; - rpcInit.connType = TAOS_CONN_SERVER; - rpcInit.idleTime = tsShellActivityTimer * 1000; - rpcInit.afp = mgmtDServerRetrieveAuth; +int32_t mgmtInitServer() { - tsMgmtDServerRpc = rpcOpen(&rpcInit); - if (tsMgmtDServerRpc == NULL) { - mError("failed to init server connection to dnode"); - return -1; - } - - tsMgmtDServerQhandle = taosInitScheduler(tsMaxShellConns, 1, "MS"); + tsMgmtServerQhandle = taosInitScheduler(tsMaxShellConns, 1, "MS"); mPrint("server connection to dnode is opened"); return 0; } -void mgmtCleanupDServer() { - if (tsMgmtDServerQhandle) { - taosCleanUpScheduler(tsMgmtDServerQhandle); - tsMgmtDServerQhandle = NULL; - } - - if (tsMgmtDServerRpc) { - rpcClose(tsMgmtDServerRpc); - tsMgmtDServerRpc = NULL; - mPrint("server connection to dnode is closed"); +void mgmtCleanupServer() { + if (tsMgmtServerQhandle) { + taosCleanUpScheduler(tsMgmtServerQhandle); + tsMgmtServerQhandle = NULL; } } @@ -81,21 +56,27 @@ void mgmtAddDServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) { mgmtProcessDnodeMsgFp[msgType] = fp; } -static void mgmtProcessDServerRequest(SSchedMsg *sched) { +static void mgmtProcessRequestFromDnode(SSchedMsg *sched) { SRpcMsg *pMsg = sched->msg; (*mgmtProcessDnodeMsgFp[pMsg->msgType])(pMsg); rpcFreeCont(pMsg->pCont); free(pMsg); } -static void mgmtAddToDServerQueue(SRpcMsg *pMsg) { +static void mgmtAddToServerQueue(SRpcMsg *pMsg) { SSchedMsg schedMsg; schedMsg.msg = pMsg; - schedMsg.fp = mgmtProcessDServerRequest; - taosScheduleTask(tsMgmtDServerQhandle, &schedMsg); + schedMsg.fp = mgmtProcessRequestFromDnode; + taosScheduleTask(tsMgmtServerQhandle, &schedMsg); } -static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg) { +void mgmtProcessReqMsgFromDnode(SRpcMsg *rpcMsg) { + if (mgmtProcessDnodeMsgFp[rpcMsg->msgType] == NULL) { + mError("%s is not processed in mnode", taosMsg[rpcMsg->msgType]); + mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_MSG_NOT_PROCESSED); + rpcFreeCont(rpcMsg->pCont); + } + if (rpcMsg->pCont == NULL) { mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_INVALID_MSG_LEN); return; @@ -116,17 +97,8 @@ static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg) { return; } - if (mgmtProcessDnodeMsgFp[rpcMsg->msgType]) { - SRpcMsg *pMsg = malloc(sizeof(SRpcMsg)); - memcpy(pMsg, rpcMsg, sizeof(SRpcMsg)); - mgmtAddToDServerQueue(pMsg); - } else { - mError("%s is not processed in mgmt dserver", taosMsg[rpcMsg->msgType]); - mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_MSG_NOT_PROCESSED); - rpcFreeCont(rpcMsg->pCont); - } + SRpcMsg *pMsg = malloc(sizeof(SRpcMsg)); + memcpy(pMsg, rpcMsg, sizeof(SRpcMsg)); + mgmtAddToServerQueue(pMsg); } -static int mgmtDServerRetrieveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) { - return TSDB_CODE_SUCCESS; -} diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index 6ed19b3d11..c6d973fd81 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -24,13 +24,12 @@ #include "tname.h" #include "tidpool.h" #include "tglobal.h" +#include "dnode.h" #include "mgmtDef.h" #include "mgmtLog.h" #include "mgmtAcct.h" -#include "mgmtDClient.h" #include "mgmtDb.h" #include "mgmtDnode.h" -#include "mgmtDServer.h" #include "tgrant.h" #include "mgmtMnode.h" #include "mgmtProfile.h" @@ -538,10 +537,10 @@ int32_t mgmtInitTables() { mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_TABLE_META, mgmtProcessTableMetaMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_STABLE_VGROUP, mgmtProcessSuperTableVgroupMsg); - mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_CREATE_TABLE_RSP, mgmtProcessCreateChildTableRsp); - mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_DROP_TABLE_RSP, mgmtProcessDropChildTableRsp); - mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_DROP_STABLE_RSP, mgmtProcessDropSuperTableRsp); - mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_ALTER_TABLE_RSP, mgmtProcessAlterTableRsp); + dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_CREATE_TABLE_RSP, mgmtProcessCreateChildTableRsp); + dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_DROP_TABLE_RSP, mgmtProcessDropChildTableRsp); + dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_DROP_STABLE_RSP, mgmtProcessDropSuperTableRsp); + dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_ALTER_TABLE_RSP, mgmtProcessAlterTableRsp); mgmtAddDServerMsgHandle(TSDB_MSG_TYPE_DM_CONFIG_TABLE, mgmtProcessTableCfgMsg); @@ -810,7 +809,7 @@ static void mgmtProcessDropSuperTableMsg(SQueuedMsg *pMsg) { if (pVgroup != NULL) { SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pVgroup); SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE}; - mgmtSendMsgToDnode(&ipSet, &rpcMsg); + dnodeSendMsgToDnode(&ipSet, &rpcMsg); mgmtDecVgroupRef(pVgroup); } } @@ -1487,7 +1486,7 @@ static void mgmtProcessCreateChildTableMsg(SQueuedMsg *pMsg) { .msgType = TSDB_MSG_TYPE_MD_CREATE_TABLE }; - mgmtSendMsgToDnode(&ipSet, &rpcMsg); + dnodeSendMsgToDnode(&ipSet, &rpcMsg); } static void mgmtProcessDropChildTableMsg(SQueuedMsg *pMsg) { @@ -1525,7 +1524,7 @@ static void mgmtProcessDropChildTableMsg(SQueuedMsg *pMsg) { .msgType = TSDB_MSG_TYPE_MD_DROP_TABLE }; - mgmtSendMsgToDnode(&ipSet, &rpcMsg); + dnodeSendMsgToDnode(&ipSet, &rpcMsg); } static int32_t mgmtModifyChildTableTagValue(SChildTableObj *pTable, char *tagName, char *nContent) { @@ -1827,7 +1826,7 @@ static void mgmtProcessTableCfgMsg(SRpcMsg *rpcMsg) { .code = 0, .msgType = TSDB_MSG_TYPE_MD_CREATE_TABLE }; - mgmtSendMsgToDnode(&ipSet, &rpcRsp); + dnodeSendMsgToDnode(&ipSet, &rpcRsp); mgmtDecTableRef(pTable); mgmtDecDnodeRef(pDnode); diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index d8007d000d..4b455de41a 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -23,11 +23,10 @@ #include "ttime.h" #include "tbalance.h" #include "tglobal.h" +#include "dnode.h" #include "mgmtDef.h" #include "mgmtLog.h" #include "mgmtDb.h" -#include "mgmtDClient.h" -#include "mgmtDServer.h" #include "mgmtDnode.h" #include "mgmtMnode.h" #include "mgmtProfile.h" @@ -220,8 +219,8 @@ int32_t mgmtInitVgroups() { mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_VGROUP, mgmtGetVgroupMeta); mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_VGROUP, mgmtRetrieveVgroups); - mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_CREATE_VNODE_RSP, mgmtProcessCreateVnodeRsp); - mgmtAddDClientRspHandle(TSDB_MSG_TYPE_MD_DROP_VNODE_RSP, mgmtProcessDropVnodeRsp); + dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_CREATE_VNODE_RSP, mgmtProcessCreateVnodeRsp); + dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_DROP_VNODE_RSP, mgmtProcessDropVnodeRsp); mgmtAddDServerMsgHandle(TSDB_MSG_TYPE_DM_CONFIG_VNODE, mgmtProcessVnodeCfgMsg); mTrace("table:vgroups is created"); @@ -583,7 +582,7 @@ SRpcIpSet mgmtGetIpSetFromVgroup(SVgObj *pVgroup) { }; for (int i = 0; i < pVgroup->numOfVnodes; ++i) { strcpy(ipSet.fqdn[i], pVgroup->vnodeGid[i].pDnode->dnodeFqdn); - ipSet.port[i] = pVgroup->vnodeGid[i].pDnode->dnodePort + TSDB_PORT_DNODEMNODE; + ipSet.port[i] = pVgroup->vnodeGid[i].pDnode->dnodePort + TSDB_PORT_DNODEDNODE; } return ipSet; } @@ -594,7 +593,7 @@ SRpcIpSet mgmtGetIpSetFromIp(char *ep) { ipSet.numOfIps = 1; ipSet.inUse = 0; taosGetFqdnPortFromEp(ep, ipSet.fqdn[0], &ipSet.port[0]); - ipSet.port[0] += TSDB_PORT_DNODEMNODE; + ipSet.port[0] += TSDB_PORT_DNODEDNODE; return ipSet; } @@ -608,7 +607,7 @@ void mgmtSendCreateVnodeMsg(SVgObj *pVgroup, SRpcIpSet *ipSet, void *ahandle) { .code = 0, .msgType = TSDB_MSG_TYPE_MD_CREATE_VNODE }; - mgmtSendMsgToDnode(ipSet, &rpcMsg); + dnodeSendMsgToDnode(ipSet, &rpcMsg); } void mgmtSendCreateVgroupMsg(SVgObj *pVgroup, void *ahandle) { @@ -674,7 +673,7 @@ void mgmtSendDropVnodeMsg(int32_t vgId, SRpcIpSet *ipSet, void *ahandle) { .code = 0, .msgType = TSDB_MSG_TYPE_MD_DROP_VNODE }; - mgmtSendMsgToDnode(ipSet, &rpcMsg); + dnodeSendMsgToDnode(ipSet, &rpcMsg); } static void mgmtSendDropVgroupMsg(SVgObj *pVgroup, void *ahandle) { From fc692411e96a7e14716efd7ce7685d17af38d0ec Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Mon, 4 May 2020 23:59:30 +0000 Subject: [PATCH 04/36] messages received are handled to different modules --- src/dnode/src/dnodeClient.c | 77 ----------------- src/dnode/src/dnodeDnode.c | 165 ++++++++++++++++++++++++++++++++++++ src/dnode/src/dnodeServer.c | 95 --------------------- src/dnode/src/dnodeShell.c | 39 ++++++++- src/inc/dnode.h | 2 +- src/mnode/inc/mgmtServer.h | 1 - src/mnode/src/mgmtDnode.c | 2 +- src/mnode/src/mgmtServer.c | 2 +- src/mnode/src/mgmtShell.c | 3 - src/mnode/src/mgmtTable.c | 2 +- src/mnode/src/mgmtVgroup.c | 2 +- 11 files changed, 207 insertions(+), 183 deletions(-) delete mode 100644 src/dnode/src/dnodeClient.c create mode 100644 src/dnode/src/dnodeDnode.c delete mode 100644 src/dnode/src/dnodeServer.c diff --git a/src/dnode/src/dnodeClient.c b/src/dnode/src/dnodeClient.c deleted file mode 100644 index aa3ec0595f..0000000000 --- a/src/dnode/src/dnodeClient.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#define _DEFAULT_SOURCE -#include "os.h" -#include "taosmsg.h" -#include "trpc.h" -#include "tutil.h" -#include "tglobal.h" -#include "dnode.h" -#include "dnodeLog.h" -#include "dnodeMgmt.h" - -static void *tsDnodeClientRpc; -static void (*dnodeProcessDnodeRspFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg); -static void dnodeProcessRspFromDnode(SRpcMsg *pMsg); -extern void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet); - -int32_t dnodeInitClient() { - SRpcInit rpcInit; - memset(&rpcInit, 0, sizeof(rpcInit)); - rpcInit.label = "DND-C"; - rpcInit.numOfThreads = 1; - rpcInit.cfp = dnodeProcessRspFromDnode; - rpcInit.ufp = dnodeUpdateIpSet; - rpcInit.sessions = 100; - rpcInit.connType = TAOS_CONN_CLIENT; - rpcInit.idleTime = tsShellActivityTimer * 2000; - rpcInit.user = "t"; - rpcInit.ckey = "key"; - rpcInit.secret = "secret"; - - tsDnodeClientRpc = rpcOpen(&rpcInit); - if (tsDnodeClientRpc == NULL) { - dError("failed to init mnode rpc client"); - return -1; - } - - dPrint("inter-dndoes rpc client is opened"); - return 0; -} - -void dnodeCleanupClient() { - if (tsDnodeClientRpc) { - rpcClose(tsDnodeClientRpc); - tsDnodeClientRpc = NULL; - dPrint("inter-dnodes rpc client is closed"); - } -} - -static void dnodeProcessRspFromDnode(SRpcMsg *pMsg) { - if (dnodeProcessDnodeRspFp[pMsg->msgType]) { - (*dnodeProcessDnodeRspFp[pMsg->msgType])(pMsg); - } else { - dError("%s is not processed", taosMsg[pMsg->msgType]); - } - rpcFreeCont(pMsg->pCont); -} - -void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) { - dnodeProcessDnodeRspFp[msgType] = fp; -} - -void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg) { - rpcSendRequest(tsDnodeClientRpc, ipSet, rpcMsg); -} diff --git a/src/dnode/src/dnodeDnode.c b/src/dnode/src/dnodeDnode.c new file mode 100644 index 0000000000..dc48262009 --- /dev/null +++ b/src/dnode/src/dnodeDnode.c @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/* this file is mainly responsible for the communication between DNODEs. Each + * dnode works as both server and client. Dnode may send status, grant, config + * messages to mnode, mnode may send create/alter/drop table/vnode messages + * to dnode. All theses messages are handled from here + */ + +#include "os.h" +#include "taosmsg.h" +#include "tglobal.h" +#include "trpc.h" +#include "dnode.h" +#include "dnodeLog.h" +#include "dnodeMgmt.h" +#include "dnodeWrite.h" +#include "mnode.h" + +extern void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet); +static void (*dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *); +static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg); +static void (*dnodeProcessRspMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg); +static void dnodeProcessRspFromDnode(SRpcMsg *pMsg); +static void *tsDnodeServerRpc = NULL; +static void *tsDnodeClientRpc = NULL; + +int32_t dnodeInitServer() { + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_TABLE] = dnodeWrite; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_TABLE] = dnodeWrite; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_ALTER_TABLE] = dnodeWrite; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_STABLE] = dnodeWrite; + + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_VNODE] = dnodeMgmt; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_VNODE] = dnodeMgmt; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_ALTER_STREAM] = dnodeMgmt; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeMgmt; + + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_TABLE] = mgmtProcessReqMsgFromDnode; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = mgmtProcessReqMsgFromDnode; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_GRANT] = mgmtProcessReqMsgFromDnode; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_STATUS] = mgmtProcessReqMsgFromDnode; + + SRpcInit rpcInit; + memset(&rpcInit, 0, sizeof(rpcInit)); + rpcInit.localPort = tsDnodeDnodePort; + rpcInit.label = "DND-S"; + rpcInit.numOfThreads = 1; + rpcInit.cfp = dnodeProcessReqMsgFromDnode; + rpcInit.sessions = 100; + rpcInit.connType = TAOS_CONN_SERVER; + rpcInit.idleTime = tsShellActivityTimer * 2000; + + tsDnodeServerRpc = rpcOpen(&rpcInit); + if (tsDnodeServerRpc == NULL) { + dError("failed to init inter-dnodes RPC server"); + return -1; + } + + dPrint("inter-dnodes RPC server is opened"); + return 0; +} + +void dnodeCleanupServer() { + if (tsDnodeServerRpc) { + rpcClose(tsDnodeServerRpc); + tsDnodeServerRpc = NULL; + dPrint("inter-dnodes RPC server is closed"); + } +} + +static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg) { + SRpcMsg rspMsg; + rspMsg.handle = pMsg->handle; + rspMsg.pCont = NULL; + rspMsg.contLen = 0; + + if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_RUNING) { + rspMsg.code = TSDB_CODE_NOT_READY; + rpcSendResponse(&rspMsg); + rpcFreeCont(pMsg->pCont); + dTrace("RPC %p, msg:%s is ignored since dnode not running", pMsg->handle, taosMsg[pMsg->msgType]); + return; + } + + if (pMsg->pCont == NULL) { + rspMsg.code = TSDB_CODE_INVALID_MSG_LEN; + rpcSendResponse(&rspMsg); + return; + } + + if (dnodeProcessReqMsgFp[pMsg->msgType]) { + (*dnodeProcessReqMsgFp[pMsg->msgType])(pMsg); + } else { + rspMsg.code = TSDB_CODE_MSG_NOT_PROCESSED; + rpcSendResponse(&rspMsg); + rpcFreeCont(pMsg->pCont); + dTrace("RPC %p, message:%s not processed", pMsg->handle, taosMsg[pMsg->msgType]); + return; + + } +} + +int32_t dnodeInitClient() { + SRpcInit rpcInit; + memset(&rpcInit, 0, sizeof(rpcInit)); + rpcInit.label = "DND-C"; + rpcInit.numOfThreads = 1; + rpcInit.cfp = dnodeProcessRspFromDnode; + rpcInit.ufp = dnodeUpdateIpSet; + rpcInit.sessions = 100; + rpcInit.connType = TAOS_CONN_CLIENT; + rpcInit.idleTime = tsShellActivityTimer * 2000; + rpcInit.user = "t"; + rpcInit.ckey = "key"; + rpcInit.secret = "secret"; + + tsDnodeClientRpc = rpcOpen(&rpcInit); + if (tsDnodeClientRpc == NULL) { + dError("failed to init mnode rpc client"); + return -1; + } + + dPrint("inter-dndoes rpc client is opened"); + return 0; +} + +void dnodeCleanupClient() { + if (tsDnodeClientRpc) { + rpcClose(tsDnodeClientRpc); + tsDnodeClientRpc = NULL; + dPrint("inter-dnodes rpc client is closed"); + } +} + +static void dnodeProcessRspFromDnode(SRpcMsg *pMsg) { + + if (dnodeProcessRspMsgFp[pMsg->msgType]) { + (*dnodeProcessRspMsgFp[pMsg->msgType])(pMsg); + } else { + dError("RPC %p, msg:%s is not processed", pMsg->handle, taosMsg[pMsg->msgType]); + } + + rpcFreeCont(pMsg->pCont); +} + +void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) { + dnodeProcessRspMsgFp[msgType] = fp; +} + +void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg) { + rpcSendRequest(tsDnodeClientRpc, ipSet, rpcMsg); +} diff --git a/src/dnode/src/dnodeServer.c b/src/dnode/src/dnodeServer.c deleted file mode 100644 index 169cd6cffa..0000000000 --- a/src/dnode/src/dnodeServer.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include "os.h" -#include "taosmsg.h" -#include "tglobal.h" -#include "trpc.h" -#include "dnode.h" -#include "dnodeLog.h" -#include "dnodeMgmt.h" -#include "dnodeWrite.h" - -static void (*dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *); -static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg); -static void *tsDnodeServerRpc = NULL; - -int32_t dnodeInitServer() { - dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_CREATE_TABLE] = dnodeWrite; - dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_DROP_TABLE] = dnodeWrite; - dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_ALTER_TABLE] = dnodeWrite; - dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_DROP_STABLE] = dnodeWrite; - dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_CREATE_VNODE] = dnodeMgmt; - dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_DROP_VNODE] = dnodeMgmt; - dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_ALTER_STREAM] = dnodeMgmt; - dnodeProcessMgmtMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeMgmt; - - SRpcInit rpcInit; - memset(&rpcInit, 0, sizeof(rpcInit)); - rpcInit.localPort = tsDnodeDnodePort; - rpcInit.label = "DND-S"; - rpcInit.numOfThreads = 1; - rpcInit.cfp = dnodeProcessReqMsgFromDnode; - rpcInit.sessions = 100; - rpcInit.connType = TAOS_CONN_SERVER; - rpcInit.idleTime = tsShellActivityTimer * 2000; - - tsDnodeServerRpc = rpcOpen(&rpcInit); - if (tsDnodeServerRpc == NULL) { - dError("failed to init inter-dnodes RPC server"); - return -1; - } - - dPrint("inter-dnodes RPC server is opened"); - return 0; -} - -void dnodeCleanupServer() { - if (tsDnodeServerRpc) { - rpcClose(tsDnodeServerRpc); - tsDnodeServerRpc = NULL; - dPrint("inter-dnodes RPC server is closed"); - } -} - -void mgmtProcessReqMsgFromDnode(SRpcMsg *rpcMsg); - -static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg) { - SRpcMsg rspMsg; - rspMsg.handle = pMsg->handle; - rspMsg.pCont = NULL; - rspMsg.contLen = 0; - - if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_RUNING) { - rspMsg.code = TSDB_CODE_NOT_READY; - rpcSendResponse(&rspMsg); - rpcFreeCont(pMsg->pCont); - dTrace("thandle:%p, query msg is ignored since dnode not running", pMsg->handle); - return; - } - - if (pMsg->pCont == NULL) { - rspMsg.code = TSDB_CODE_INVALID_MSG_LEN; - rpcSendResponse(&rspMsg); - return; - } - - if (dnodeProcessMgmtMsgFp[pMsg->msgType]) { - (*dnodeProcessMgmtMsgFp[pMsg->msgType])(pMsg); - } else { - mgmtProcessReqMsgFromDnode(pMsg); - } -} - diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index e6a392a341..b16227cf39 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -41,6 +41,37 @@ int32_t dnodeInitShell() { dnodeProcessShellMsgFp[TSDB_MSG_TYPE_QUERY] = dnodeRead; dnodeProcessShellMsgFp[TSDB_MSG_TYPE_FETCH] = dnodeRead; + // the following message shall be treated as mnode write + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CONNECT] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_ACCT] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_ACCT] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_ACCT] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_USER] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_USER] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_USER] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_DNODE]= mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_DNODE] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_DB] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_DB] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_DB] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_TABLE]= mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_TABLE] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_TABLE] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_STREAM]= mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_KILL_QUERY] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_KILL_STREAM] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_KILL_CONN] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_HEARTBEAT] = mgmtProcessMsgFromShell; + + // the following message shall be treated as mnode query + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_USE_DB] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_TABLE_META] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_STABLE_VGROUP]= mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_TABLES_META] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_SHOW] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_RETRIEVE] = mgmtProcessMsgFromShell; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CONFIG_DNODE]= mgmtProcessMsgFromShell; + int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore; numOfThreads = (int32_t) ((1.0 - tsRatioOfQueryThreads) * numOfThreads / 2.0); if (numOfThreads < 1) { @@ -82,7 +113,7 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg) { rpcMsg.contLen = 0; if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_RUNING) { - dError("RPC %p, shell msg is ignored since dnode not running", pMsg->handle); + dError("RPC %p, shell msg:%s is ignored since dnode not running", pMsg->handle, taosMsg[pMsg->msgType]); rpcMsg.code = TSDB_CODE_NOT_READY; rpcSendResponse(&rpcMsg); rpcFreeCont(pMsg->pCont); @@ -98,7 +129,11 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg) { if ( dnodeProcessShellMsgFp[pMsg->msgType] ) { (*dnodeProcessShellMsgFp[pMsg->msgType])(pMsg); } else { - mgmtProcessMsgFromShell(pMsg); + dError("RPC %p, shell msg:%s is not processed", pMsg->handle, taosMsg[pMsg->msgType]); + rpcMsg.code = TSDB_CODE_MSG_NOT_PROCESSED; + rpcSendResponse(&rpcMsg); + rpcFreeCont(pMsg->pCont); + return; } } diff --git a/src/inc/dnode.h b/src/inc/dnode.h index 99b9046aac..5145a46831 100644 --- a/src/inc/dnode.h +++ b/src/inc/dnode.h @@ -50,7 +50,7 @@ void * dnodeGetMnodeInfos(); int32_t dnodeGetDnodeId(); void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); -void mgmtAddDServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); +void dnodeAddServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg); #ifdef __cplusplus diff --git a/src/mnode/inc/mgmtServer.h b/src/mnode/inc/mgmtServer.h index 180e893cb0..08e4463ad8 100644 --- a/src/mnode/inc/mgmtServer.h +++ b/src/mnode/inc/mgmtServer.h @@ -22,7 +22,6 @@ extern "C" { int32_t mgmtInitServer(); void mgmtCleanupServer(); -void mgmtAddDServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); #ifdef __cplusplus } diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index 33c012f079..30835dd201 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -151,7 +151,7 @@ int32_t mgmtInitDnodes() { mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_DROP_DNODE, mgmtProcessDropDnodeMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_CONFIG_DNODE, mgmtProcessCfgDnodeMsg); dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_CONFIG_DNODE_RSP, mgmtProcessCfgDnodeMsgRsp); - mgmtAddDServerMsgHandle(TSDB_MSG_TYPE_DM_STATUS, mgmtProcessDnodeStatusMsg); + dnodeAddServerMsgHandle(TSDB_MSG_TYPE_DM_STATUS, mgmtProcessDnodeStatusMsg); mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_MODULE, mgmtGetModuleMeta); mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_MODULE, mgmtRetrieveModules); mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_CONFIGS, mgmtGetConfigMeta); diff --git a/src/mnode/src/mgmtServer.c b/src/mnode/src/mgmtServer.c index c2b07a3f4e..2fa6e68f65 100644 --- a/src/mnode/src/mgmtServer.c +++ b/src/mnode/src/mgmtServer.c @@ -52,7 +52,7 @@ void mgmtCleanupServer() { } } -void mgmtAddDServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) { +void dnodeAddServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) { mgmtProcessDnodeMsgFp[msgType] = fp; } diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index a5659fee54..c04f9bb2d1 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -43,7 +43,6 @@ typedef int32_t (*SShowRetrieveFp)(SShowObj *pShow, char *data, int32_t rows, vo //static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey); static bool mgmtCheckMsgReadOnly(SQueuedMsg *pMsg); -//static void mgmtProcessMsgFromShell(SRpcMsg *pMsg); static void mgmtProcessUnSupportMsg(SRpcMsg *rpcMsg); static void mgmtProcessShowMsg(SQueuedMsg *queuedMsg); static void mgmtProcessRetrieveMsg(SQueuedMsg *queuedMsg); @@ -52,7 +51,6 @@ static void mgmtProcessConnectMsg(SQueuedMsg *queuedMsg); static void mgmtProcessUseMsg(SQueuedMsg *queuedMsg); void *tsMgmtTmr; -//static void *tsMgmtShellRpc = NULL; static void *tsMgmtTranQhandle = NULL; static void (*tsMgmtProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SQueuedMsg *) = {0}; static void *tsQhandleCache = NULL; @@ -121,7 +119,6 @@ void mgmtDealyedAddToShellQueue(SQueuedMsg *queuedMsg) { } void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) { - assert(rpcMsg); if (rpcMsg->pCont == NULL) { mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_INVALID_MSG_LEN); diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index c6d973fd81..a73a6abb97 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -542,7 +542,7 @@ int32_t mgmtInitTables() { dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_DROP_STABLE_RSP, mgmtProcessDropSuperTableRsp); dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_ALTER_TABLE_RSP, mgmtProcessAlterTableRsp); - mgmtAddDServerMsgHandle(TSDB_MSG_TYPE_DM_CONFIG_TABLE, mgmtProcessTableCfgMsg); + dnodeAddServerMsgHandle(TSDB_MSG_TYPE_DM_CONFIG_TABLE, mgmtProcessTableCfgMsg); mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_TABLE, mgmtGetShowTableMeta); mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_TABLE, mgmtRetrieveShowTables); diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index 4b455de41a..9efbdfeea2 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -221,7 +221,7 @@ int32_t mgmtInitVgroups() { mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_VGROUP, mgmtRetrieveVgroups); dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_CREATE_VNODE_RSP, mgmtProcessCreateVnodeRsp); dnodeAddClientRspHandle(TSDB_MSG_TYPE_MD_DROP_VNODE_RSP, mgmtProcessDropVnodeRsp); - mgmtAddDServerMsgHandle(TSDB_MSG_TYPE_DM_CONFIG_VNODE, mgmtProcessVnodeCfgMsg); + dnodeAddServerMsgHandle(TSDB_MSG_TYPE_DM_CONFIG_VNODE, mgmtProcessVnodeCfgMsg); mTrace("table:vgroups is created"); From 6fbf77eaa95bdd86d86245b26143a5f685f160cb Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Tue, 5 May 2020 00:09:59 +0000 Subject: [PATCH 05/36] add simExe --- tests/tsim/src/simExe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index 26291ba992..52d9e01963 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -584,7 +584,7 @@ bool simCreateNativeConnect(SScript *script, char *user, char *pass) { void *taos = NULL; taosMsleep(2000); for (int attempt = 0; attempt < 10; ++attempt) { - taos = taos_connect(NULL, user, pass, NULL, tsMnodeShellPort); + taos = taos_connect(NULL, user, pass, NULL, tsDnodeShellPort); if (taos == NULL) { simTrace("script:%s, user:%s connect taosd failed:%s, attempt:%d", script->fileName, user, taos_errstr(NULL), attempt); taosMsleep(1000); From ade504f9eb58d47fde1159ee570345d00b928d10 Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Tue, 5 May 2020 00:16:25 +0000 Subject: [PATCH 06/36] remove the unused message type --- src/common/src/tmessage.c | 7 +------ src/inc/taosmsg.h | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/common/src/tmessage.c b/src/common/src/tmessage.c index 78ce17db75..ebccd51e7d 100644 --- a/src/common/src/tmessage.c +++ b/src/common/src/tmessage.c @@ -122,13 +122,8 @@ char *taosMsg[] = { "status-rsp", "grant", "grant-rsp", - "", - "", //100 + "", //99 - "sdb-sync", - "sdb-sync-rsp", - "sdb-forward", - "sdb-forward-rsp", "max" }; diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index e8ac7255f0..3bae13ecab 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -119,12 +119,7 @@ extern "C" { #define TSDB_MSG_TYPE_DM_GRANT 97 #define TSDB_MSG_TYPE_DM_GRANT_RSP 98 -#define TSDB_MSG_TYPE_SDB_SYNC 101 -#define TSDB_MSG_TYPE_SDB_SYNC_RSP 102 -#define TSDB_MSG_TYPE_SDB_FORWARD 103 -#define TSDB_MSG_TYPE_SDB_FORWARD_RSP 104 - -#define TSDB_MSG_TYPE_MAX 105 +#define TSDB_MSG_TYPE_MAX 100 // IE type #define TSDB_IE_TYPE_SEC 1 From 47fa4ac4587fb602fe8f2f93bb466f3be64b56d4 Mon Sep 17 00:00:00 2001 From: liu0x54 Date: Thu, 7 May 2020 06:00:58 +0000 Subject: [PATCH 07/36] [TD-228] fix python connector to support binary interface change --- src/connector/python/linux/python2/taos/cinterface.py | 5 ++++- src/connector/python/windows/python2/taos/cinterface.py | 5 ++++- src/connector/python/windows/python3/taos/cinterface.py | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/connector/python/linux/python2/taos/cinterface.py b/src/connector/python/linux/python2/taos/cinterface.py index d9460efb21..055c4a16df 100644 --- a/src/connector/python/linux/python2/taos/cinterface.py +++ b/src/connector/python/linux/python2/taos/cinterface.py @@ -146,6 +146,7 @@ class CTaosInterface(object): libtaos.taos_errstr.restype = ctypes.c_char_p libtaos.taos_subscribe.restype = ctypes.c_void_p libtaos.taos_consume.restype = ctypes.c_void_p + libtaos.taos_fetch_lengths.restype = ctypes.c_void_p def __init__(self, config=None): ''' @@ -314,6 +315,8 @@ class CTaosInterface(object): isMicro = (CTaosInterface.libtaos.taos_result_precision(result) == FieldType.C_TIMESTAMP_MICRO) blocks = [None] * len(fields) + fieldL = CTaosInterface.libtaos.taos_fetch_lengths(result) + fieldLen = [ele for ele in ctypes.cast(fieldL, ctypes.POINTER(ctypes.c_int))[:len(fields)]] for i in range(len(fields)): data = ctypes.cast(pblock, ctypes.POINTER(ctypes.c_void_p))[i] if data == None: @@ -323,7 +326,7 @@ class CTaosInterface(object): if fields[i]['type'] not in _CONVERT_FUNC: raise DatabaseError("Invalid data type returned from database") - blocks[i] = _CONVERT_FUNC[fields[i]['type']](data, num_of_rows, fields[i]['bytes'], isMicro) + blocks[i] = _CONVERT_FUNC[fields[i]['type']](data, num_of_rows, fieldLen[i], isMicro) return blocks, abs(num_of_rows) diff --git a/src/connector/python/windows/python2/taos/cinterface.py b/src/connector/python/windows/python2/taos/cinterface.py index a18d372db2..f5d35fefd9 100644 --- a/src/connector/python/windows/python2/taos/cinterface.py +++ b/src/connector/python/windows/python2/taos/cinterface.py @@ -146,6 +146,7 @@ class CTaosInterface(object): libtaos.taos_errstr.restype = ctypes.c_char_p libtaos.taos_subscribe.restype = ctypes.c_void_p libtaos.taos_consume.restype = ctypes.c_void_p + libtaos.taos_fetch_lengths.restype = ctypes.c_void_p def __init__(self, config=None): ''' @@ -314,6 +315,8 @@ class CTaosInterface(object): isMicro = (CTaosInterface.libtaos.taos_result_precision(result) == FieldType.C_TIMESTAMP_MICRO) blocks = [None] * len(fields) + fieldL = CTaosInterface.libtaos.taos_fetch_lengths(result) + fieldLen = [ele for ele in ctypes.cast(fieldL, ctypes.POINTER(ctypes.c_int))[:len(fields)]] for i in range(len(fields)): data = ctypes.cast(pblock, ctypes.POINTER(ctypes.c_void_p))[i] if data == None: @@ -323,7 +326,7 @@ class CTaosInterface(object): if fields[i]['type'] not in _CONVERT_FUNC: raise DatabaseError("Invalid data type returned from database") - blocks[i] = _CONVERT_FUNC[fields[i]['type']](data, num_of_rows, fields[i]['bytes'], isMicro) + blocks[i] = _CONVERT_FUNC[fields[i]['type']](data, num_of_rows, fieldLen[i], isMicro) return blocks, abs(num_of_rows) diff --git a/src/connector/python/windows/python3/taos/cinterface.py b/src/connector/python/windows/python3/taos/cinterface.py index cbcf2d884e..4f9dd78755 100644 --- a/src/connector/python/windows/python3/taos/cinterface.py +++ b/src/connector/python/windows/python3/taos/cinterface.py @@ -146,6 +146,7 @@ class CTaosInterface(object): libtaos.taos_errstr.restype = ctypes.c_char_p libtaos.taos_subscribe.restype = ctypes.c_void_p libtaos.taos_consume.restype = ctypes.c_void_p + libtaos.taos_fetch_lengths.restype = ctypes.c_void_p def __init__(self, config=None): ''' @@ -314,6 +315,8 @@ class CTaosInterface(object): isMicro = (CTaosInterface.libtaos.taos_result_precision(result) == FieldType.C_TIMESTAMP_MICRO) blocks = [None] * len(fields) + fieldL = CTaosInterface.libtaos.taos_fetch_lengths(result) + fieldLen = [ele for ele in ctypes.cast(fieldL, ctypes.POINTER(ctypes.c_int))[:len(fields)]] for i in range(len(fields)): data = ctypes.cast(pblock, ctypes.POINTER(ctypes.c_void_p))[i] if data == None: @@ -323,7 +326,7 @@ class CTaosInterface(object): if fields[i]['type'] not in _CONVERT_FUNC: raise DatabaseError("Invalid data type returned from database") - blocks[i] = _CONVERT_FUNC[fields[i]['type']](data, num_of_rows, fields[i]['bytes'], isMicro) + blocks[i] = _CONVERT_FUNC[fields[i]['type']](data, num_of_rows, fieldLen[i], isMicro) return blocks, abs(num_of_rows) From 2ececaed2614775160cb1b45d3a21cb39aeffc06 Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Thu, 7 May 2020 12:47:04 +0000 Subject: [PATCH 08/36] add dummy message --- src/inc/taosmsg.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 155347ffe3..fec14bd938 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -43,6 +43,10 @@ enum { TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_SUBMIT, "submit" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_QUERY, "query" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_FETCH, "fetch" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY0, "dummy0" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY1, "dummy1" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY2, "dummy2" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY3, "dummy3" ) // message from mnode to dnode TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_CREATE_TABLE, "create-table" ) @@ -53,6 +57,10 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_DROP_VNODE, "drop-vnode" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_DROP_STABLE, "drop-stable" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_ALTER_STREAM, "alter-stream" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_MD_CONFIG_DNODE, "config-dnode" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY4, "dummy4" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY5, "dummy5" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY6, "dummy6" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY7, "dummy7" ) // message from client to mnode TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CONNECT, "connect" ) @@ -76,18 +84,25 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_STABLE_VGROUP, "stable-vgroup" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_TABLES_META, "tables-meta" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_ALTER_STREAM, "alter-stream" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_SHOW, "show" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_RETRIEVE, "retrieve" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_KILL_QUERY, "kill-query" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_KILL_STREAM, "kill-stream" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_KILL_CONN, "kill-conn" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CONFIG_DNODE, "cm-config-dnode" ) -TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_RETRIEVE, "retrieve" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_HEARTBEAT, "heartbeat" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY8, "dummy8" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY9, "dummy9" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY10, "dummy10" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY11, "dummy11" ) // message from dnode to mnode TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_TABLE, "config-table" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_VNODE, "config-vnode" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_STATUS, "status" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_GRANT, "grant" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY12, "dummy12" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY13, "dummy13" ) +TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY14, "dummy14" ) #ifndef TAOS_MESSAGE_C TSDB_MSG_TYPE_MAX // 105 From af7e3ffa29d2b8ef7e6f732edb3ad87fb9b53929 Mon Sep 17 00:00:00 2001 From: liu0x54 Date: Thu, 7 May 2020 15:03:33 +0000 Subject: [PATCH 09/36] [TD-228] fix python connector to support binary interface change --- src/plugins/http/src/gcJson.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/http/src/gcJson.c b/src/plugins/http/src/gcJson.c index 09990c123e..98069f434d 100644 --- a/src/plugins/http/src/gcJson.c +++ b/src/plugins/http/src/gcJson.c @@ -121,6 +121,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, for (int k = 0; k < numOfRows; ++k) { TAOS_ROW row = taos_fetch_row(result); + int32_t* length = taos_fetch_lengths(result); // for group by if (groupFields != -1) { @@ -150,7 +151,11 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, break; case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: - len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%s", fields[i].name, (char *)row[i]); + if (row[i]!= NULL){ + len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:", fields[i].name); + memcpy(target + len, (char *) row[i], length[i]); + len = strlen(target); + } break; default: len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%s", fields[i].name, "-"); From f55b05856bd9ed7f3ad4e75d12db1fa6f9931dc1 Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Thu, 7 May 2020 23:09:19 +0800 Subject: [PATCH 10/36] [td-225] fix bugs for tags filter --- src/client/inc/tscUtil.h | 6 ++-- src/client/src/tscSQLParser.c | 2 +- src/client/src/tscServer.c | 8 ++--- src/client/src/tscSql.c | 34 +++--------------- src/query/inc/qast.h | 8 ++--- src/query/src/qast.c | 18 +++++----- src/tsdb/src/tsdbRead.c | 65 +++++++++++++++++------------------ src/util/src/tcompare.c | 1 - 8 files changed, 58 insertions(+), 84 deletions(-) diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index 4b8a162ef7..71c24501d1 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -31,11 +31,13 @@ extern "C" { #include "tscSecondaryMerge.h" #include "tsclient.h" -#define UTIL_TABLE_IS_SUPERTABLE(metaInfo) \ +#define UTIL_TABLE_IS_SUPERTABLE(metaInfo) \ (((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_SUPER_TABLE)) -#define UTIL_TABLE_IS_NOMRAL_TABLE(metaInfo) (!(UTIL_TABLE_IS_SUPERTABLE(metaInfo))) #define UTIL_TABLE_IS_CHILD_TABLE(metaInfo) \ (((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_CHILD_TABLE)) + +#define UTIL_TABLE_IS_NOMRAL_TABLE(metaInfo)\ + (!(UTIL_TABLE_IS_SUPERTABLE(metaInfo) || UTIL_TABLE_IS_CHILD_TABLE(metaInfo))) #define TSDB_COL_IS_TAG(f) (((f)&TSDB_COL_TAG) != 0) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 947384a992..0b32dffff6 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1411,7 +1411,7 @@ int32_t addProjectionExprAndResultField(SQueryInfo* pQueryInfo, tSQLExprItem* pI STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex); STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; - if (index.columnIndex >= tscGetNumOfColumns(pTableMeta) && !UTIL_TABLE_IS_CHILD_TABLE(pTableMetaInfo)) { + if (index.columnIndex >= tscGetNumOfColumns(pTableMeta) && UTIL_TABLE_IS_NOMRAL_TABLE(pTableMetaInfo)) { return invalidSqlErrMsg(pQueryInfo->msg, msg1); } diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 5a658f6693..f6e4c66a5a 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -580,14 +580,14 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char if (UTIL_TABLE_IS_NOMRAL_TABLE(pTableMetaInfo) || pTableMetaInfo->pVgroupTables == NULL) { SCMVgroupInfo* pVgroupInfo = NULL; - if (UTIL_TABLE_IS_NOMRAL_TABLE(pTableMetaInfo)) { - pVgroupInfo = &pTableMeta->vgroupInfo; - } else { + if (UTIL_TABLE_IS_SUPERTABLE(pTableMetaInfo)) { int32_t index = pTableMetaInfo->vgroupIndex; assert(index >= 0); - + pVgroupInfo = &pTableMetaInfo->vgroupList->vgroups[index]; tscTrace("%p query on stable, vgIndex:%d, numOfVgroups:%d", pSql, index, pTableMetaInfo->vgroupList->numOfVgroups); + } else { + pVgroupInfo = &pTableMeta->vgroupInfo; } tscSetDnodeIpList(pSql, pVgroupInfo); diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 4fdd4c4323..a39b1a86bd 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -601,42 +601,18 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) { tscTrace("%p code:%d, numOfRows:%d, command:%d", pSql, pRes->code, pRes->numOfRows, pCmd->command); - void *fp = pSql->fp; - if (fp != NULL) { - pSql->freed = 1; - } - + pSql->freed = 1; tscProcessSql(pSql); /* * If release connection msg is sent to vnode, the corresponding SqlObj for async query can not be freed instantly, * since its free operation is delegated to callback function, which is tscProcessMsgFromServer. */ - if (fp == NULL) { - /* - * fp may be released here, so we cannot use the pSql->fp - * - * In case of handle sync model query, the main SqlObj cannot be freed. - * So, we only free part attributes, including allocated resources and references on metermeta/metricmeta - * data in cache. - * - * Then this object will be reused and no free operation is required. - */ - if (keepCmd) { - tscFreeSqlResult(pSql); - tscTrace("%p sql result is freed by app while sql command is kept", pSql); - } else { - tscPartiallyFreeSqlObj(pSql); - tscTrace("%p sql result is freed by app", pSql); - } - } else { // for async release, remove its link - STscObj* pObj = pSql->pTscObj; - if (pObj->pSql == pSql) { - pObj->pSql = NULL; - } + STscObj* pObj = pSql->pTscObj; + if (pObj->pSql == pSql) { + pObj->pSql = NULL; } - } else { - // if no free resource msg is sent to vnode, we free this object immediately. + } else { // if no free resource msg is sent to vnode, we free this object immediately. STscObj* pTscObj = pSql->pTscObj; if (pTscObj->pSql != pSql) { diff --git a/src/query/inc/qast.h b/src/query/inc/qast.h index 8698b3af82..9bc36413de 100644 --- a/src/query/inc/qast.h +++ b/src/query/inc/qast.h @@ -48,16 +48,16 @@ typedef struct tQueryInfo { int32_t colIndex; // index of column in schema uint8_t optr; // expression operator SSchema sch; // schema of tags -// tVariant q; // query condition value on the specific schema, filter expression char* q; __compar_fn_t compare; // filter function + void* param; // STSchema, } tQueryInfo; -typedef struct SBinaryFilterSupp { +typedef struct SExprTraverseSupp { __result_filter_fn_t fp; __do_filter_suppl_fn_t setupInfoFn; void * pExtInfo; -} SBinaryFilterSupp; +} SExprTraverseSupp; typedef struct tExprNode { uint8_t nodeType; @@ -81,7 +81,7 @@ void tSQLBinaryExprToString(tExprNode *pExpr, char *dst, int32_t *len); void tExprTreeDestroy(tExprNode **pExprs, void (*fp)(void*)); -void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, SBinaryFilterSupp *param); +void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, SExprTraverseSupp *param); void tExprTreeCalcTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput, void *param, int32_t order, char *(*cb)(void *, const char*, int32_t)); diff --git a/src/query/src/qast.c b/src/query/src/qast.c index 3336f90c83..0f5c66d429 100644 --- a/src/query/src/qast.c +++ b/src/query/src/qast.c @@ -544,13 +544,11 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr setQueryCond(pQueryInfo, &cond); if (cond.start != NULL) { - iter = tSkipListCreateIterFromVal(pSkipList, (char*) &cond.start->v, pSkipList->keyInfo.type, TSDB_ORDER_ASC); + iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->keyInfo.type, TSDB_ORDER_ASC); } else { - iter = tSkipListCreateIterFromVal(pSkipList, (char*) &cond.end->v, pSkipList->keyInfo.type, TSDB_ORDER_DESC); + iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.end->v, pSkipList->keyInfo.type, TSDB_ORDER_DESC); } - __compar_fn_t func = getKeyComparFunc(pSkipList->keyInfo.type); - if (cond.start != NULL) { int32_t optr = cond.start->optr; @@ -558,7 +556,7 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr while(tSkipListIterNext(iter)) { SSkipListNode* pNode = tSkipListIterGet(iter); - int32_t ret = func(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v); + int32_t ret = pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v); if (ret == 0) { taosArrayPush(result, SL_GET_NODE_DATA(pNode)); } else { @@ -573,7 +571,7 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr SSkipListNode* pNode = tSkipListIterGet(iter); if (comp) { - ret = func(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v); + ret = pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v); assert(ret >= 0); } @@ -708,7 +706,7 @@ static void tArrayTraverse(tExprNode *pExpr, __result_filter_fn_t fp, SArray *pR } } -static bool filterItem(tExprNode *pExpr, const void *pItem, SBinaryFilterSupp *param) { +static bool filterItem(tExprNode *pExpr, const void *pItem, SExprTraverseSupp *param) { tExprNode *pLeft = pExpr->_node.pLeft; tExprNode *pRight = pExpr->_node.pRight; @@ -747,7 +745,7 @@ static bool filterItem(tExprNode *pExpr, const void *pItem, SBinaryFilterSupp *p * @param pSchema tag schemas * @param fp filter callback function */ -static void exprTreeTraverseImpl(tExprNode *pExpr, SArray *pResult, SBinaryFilterSupp *param) { +static void exprTreeTraverseImpl(tExprNode *pExpr, SArray *pResult, SExprTraverseSupp *param) { size_t size = taosArrayGetSize(pResult); SArray* array = taosArrayInit(size, POINTER_BYTES); @@ -763,7 +761,7 @@ static void exprTreeTraverseImpl(tExprNode *pExpr, SArray *pResult, SBinaryFilte } -static void tSQLBinaryTraverseOnSkipList(tExprNode *pExpr, SArray *pResult, SSkipList *pSkipList, SBinaryFilterSupp *param ) { +static void tSQLBinaryTraverseOnSkipList(tExprNode *pExpr, SArray *pResult, SSkipList *pSkipList, SExprTraverseSupp *param ) { SSkipListIterator* iter = tSkipListCreateIter(pSkipList); while (tSkipListIterNext(iter)) { @@ -813,7 +811,7 @@ static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, // post-root order traverse syntax tree -void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, SBinaryFilterSupp *param) { +void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, SExprTraverseSupp *param) { if (pExpr == NULL) { return; } diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 6d571bd035..fc1029dff8 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -1236,12 +1236,6 @@ static int32_t getAllTableIdList(STable* pSuperTable, SArray* list) { return TSDB_CODE_SUCCESS; } -typedef struct SExprTreeSupporter { - SSchema* pTagSchema; - int32_t numOfTags; - int32_t optr; -} SExprTreeSupporter; - /** * convert the result pointer to table id instead of table object pointer * @param pRes @@ -1252,7 +1246,7 @@ static void convertQueryResult(SArray* pRes, SArray* pTableList) { } size_t size = taosArrayGetSize(pTableList); - for (int32_t i = 0; i < size; ++i) { + for (int32_t i = 0; i < size; ++i) { // todo speedup by using reserve space. STable* pTable = taosArrayGetP(pTableList, i); taosArrayPush(pRes, &pTable->tableId); } @@ -1273,16 +1267,15 @@ static void destroyHelper(void* param) { free(param); } -static int32_t getTagColumnInfo(SExprTreeSupporter* pSupporter, SSchema* pSchema) { +static int32_t getTagColumnIndex(STSchema* pTSchema, SSchema* pSchema) { // filter on table name(TBNAME) if (strcasecmp(pSchema->name, TSQL_TBNAME_L) == 0) { return TSDB_TBNAME_COLUMN_INDEX; } - - for(int32_t i = 0; i < pSupporter->numOfTags; ++i) { - if (pSupporter->pTagSchema[i].bytes == pSchema->bytes && - pSupporter->pTagSchema[i].type == pSchema->type && - pSupporter->pTagSchema[i].colId == pSchema->colId) { + + for(int32_t i = 0; i < schemaNCols(pTSchema); ++i) { + STColumn* pColumn = &pTSchema->columns[i]; + if (pColumn->bytes == pSchema->bytes && pColumn->type == pSchema->type && pColumn->colId == pSchema->colId) { return i; } } @@ -1298,21 +1291,22 @@ void filterPrepare(void* expr, void* param) { int32_t i = 0; pExpr->_node.info = calloc(1, sizeof(tQueryInfo)); - - SExprTreeSupporter* pSupporter = (SExprTreeSupporter*)param; + + STSchema* pTSSchema = (STSchema*) param; tQueryInfo* pInfo = pExpr->_node.info; tVariant* pCond = pExpr->_node.pRight->pVal; SSchema* pSchema = pExpr->_node.pLeft->pSchema; // todo : if current super table does not change schema yet, this function may failed, add test case - int32_t index = getTagColumnInfo(pSupporter, pSchema); + int32_t index = getTagColumnIndex(pTSSchema, pSchema); assert((index >= 0 && i < TSDB_MAX_TAGS) || (index == TSDB_TBNAME_COLUMN_INDEX)); pInfo->sch = *pSchema; pInfo->colIndex = index; pInfo->optr = pExpr->_node.optr; pInfo->compare = getComparFunc(pSchema->type, pInfo->optr); + pInfo->param = pTSSchema; if (pInfo->optr == TSDB_RELATION_IN) { pInfo->q = (char*) pCond->arr; @@ -1436,7 +1430,7 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC } bool tSkipListNodeFilterCallback(const void* pNode, void* param) { - tQueryInfo* pInfo = (tQueryInfo*)param; + tQueryInfo* pInfo = (tQueryInfo*) param; STable* pTable = *(STable**)(SL_GET_NODE_DATA((SSkipListNode*)pNode)); @@ -1447,7 +1441,14 @@ bool tSkipListNodeFilterCallback(const void* pNode, void* param) { val = pTable->name; type = TSDB_DATA_TYPE_BINARY; } else { - val = dataRowTuple(pTable->tagVal); // todo not only the first column + STSchema* pTSchema = (STSchema*) pInfo->param; // todo table schema is identical to stable schema?? + + int32_t offset = pTSchema->columns[pInfo->colIndex].offset; + if (pInfo->sch.type == TSDB_DATA_TYPE_BINARY || pInfo->sch.type == TSDB_DATA_TYPE_NCHAR) { + val = tdGetRowDataOfCol(pTable->tagVal, pInfo->sch.type, TD_DATA_ROW_HEAD_SIZE + offset); + } else { + val = dataRowTuple(pTable->tagVal) + offset; + } } int32_t ret = 0; @@ -1497,19 +1498,11 @@ bool tSkipListNodeFilterCallback(const void* pNode, void* param) { } static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr) { - // query according to the binary expression - STSchema* pSchema = pSTable->tagSchema; - SSchema* schema = calloc(schemaNCols(pSchema), sizeof(SSchema)); - for (int32_t i = 0; i < schemaNCols(pSchema); ++i) { - schema[i].colId = schemaColAt(pSchema, i)->colId; - schema[i].type = schemaColAt(pSchema, i)->type; - schema[i].bytes = schemaColAt(pSchema, i)->bytes; - } - - SExprTreeSupporter s = {.pTagSchema = schema, .numOfTags = schemaNCols(pSTable->tagSchema)}; - - SBinaryFilterSupp supp = { - .fp = (__result_filter_fn_t)tSkipListNodeFilterCallback, .setupInfoFn = filterPrepare, .pExtInfo = &s, + // query according to the expression tree + SExprTraverseSupp supp = { + .fp = (__result_filter_fn_t) tSkipListNodeFilterCallback, + .setupInfoFn = filterPrepare, + .pExtInfo = pSTable->tagSchema, }; SArray* pTableList = taosArrayInit(8, POINTER_BYTES); @@ -1519,7 +1512,6 @@ static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr) convertQueryResult(pRes, pTableList); taosArrayDestroy(pTableList); - free(schema); return TSDB_CODE_SUCCESS; } @@ -1527,10 +1519,17 @@ int32_t tsdbQuerySTableByTagCond(TsdbRepoT *tsdb, int64_t uid, const char *pTagC const char* tbnameCond, STableGroupInfo *pGroupInfo, SColIndex *pColIndex, int32_t numOfCols) { STable* pTable = tsdbGetTableByUid(tsdbGetMeta(tsdb), uid); if (pTable == NULL) { - uError("failed to get stable, uid:%, %p" PRIu64, uid); + uError("%p failed to get stable, uid:%" PRIu64, tsdb, uid); return TSDB_CODE_INVALID_TABLE_ID; } + if (pTable->type != TSDB_SUPER_TABLE) { + uError("%p query normal tag not allowed, uid:%, tid:%d, name:%s" PRIu64, + tsdb, uid, pTable->tableId.tid, pTable->name); + + return TSDB_CODE_OPS_NOT_SUPPORT; //basically, this error is caused by invalid sql issued by client + } + SArray* res = taosArrayInit(8, sizeof(STableId)); STSchema* pTagSchema = tsdbGetTableTagSchema(tsdbGetMeta(tsdb), pTable); diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index 13a5a8580e..2d6ae13f97 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -231,7 +231,6 @@ static UNUSED_FUNC int32_t compareWStrPatternComp(const void* pLeft, const void* return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; } -// todo promote the type definition before the comparsion __compar_fn_t getComparFunc(int32_t type, int32_t optr) { __compar_fn_t comparFn = NULL; From 3189c3ddd454cc311e9a45716a0cd0c0e3368285 Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Thu, 7 May 2020 23:15:35 +0800 Subject: [PATCH 11/36] [td-225] fix bugs for tags filter --- src/query/src/qast.c | 2 +- src/query/src/qtokenizer.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/query/src/qast.c b/src/query/src/qast.c index 0f5c66d429..98682ce778 100644 --- a/src/query/src/qast.c +++ b/src/query/src/qast.c @@ -598,7 +598,7 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr SSkipListNode* pNode = tSkipListIterGet(iter); if (comp) { - ret = func(SL_GET_NODE_KEY(pSkipList, pNode), cond.end->v); + ret = pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.end->v); assert(ret <= 0); } diff --git a/src/query/src/qtokenizer.c b/src/query/src/qtokenizer.c index d5b20e1edd..2b568cfd5a 100644 --- a/src/query/src/qtokenizer.c +++ b/src/query/src/qtokenizer.c @@ -266,8 +266,10 @@ static pthread_once_t keywordsHashTableInit = PTHREAD_ONCE_INIT; int tSQLKeywordCode(const char* z, int n) { pthread_once(&keywordsHashTableInit, doInitKeywordsTable); - - char key[128] = {0}; + + char key[512] = {0}; + assert(tListLen(key) >= n); + for (int32_t j = 0; j < n; ++j) { if (z[j] >= 'a' && z[j] <= 'z') { key[j] = (char)(z[j] & 0xDF); // touppercase and set the null-terminated From 4a54184a4504d65b4e0f332a4e4e727ae5077172 Mon Sep 17 00:00:00 2001 From: slguan Date: Thu, 7 May 2020 23:54:09 +0800 Subject: [PATCH 12/36] scripts --- tests/script/general/agg/testSuite.sim | 2 -- tests/script/general/cache/testSuite.sim | 2 -- .../general/{agg/stream.sim => stream/agg_stream.sim} | 0 .../{column/stream.sim => stream/column_stream.sim} | 0 tests/script/general/{cache => stream}/new_stream.sim | 0 .../script/general/{cache => stream}/restart_stream.sim | 0 tests/script/general/{agg => table}/fill.sim | 0 tests/script/general/table/testSuite.sim | 1 + tests/script/jenkins/basic.txt | 9 ++++++++- .../cache/cache_balance.sim => unique/cluster/cache.sim} | 0 tests/script/unique/cluster/testSuite.sim | 1 + 11 files changed, 10 insertions(+), 5 deletions(-) delete mode 100644 tests/script/general/agg/testSuite.sim rename tests/script/general/{agg/stream.sim => stream/agg_stream.sim} (100%) rename tests/script/general/{column/stream.sim => stream/column_stream.sim} (100%) rename tests/script/general/{cache => stream}/new_stream.sim (100%) rename tests/script/general/{cache => stream}/restart_stream.sim (100%) rename tests/script/general/{agg => table}/fill.sim (100%) rename tests/script/{general/cache/cache_balance.sim => unique/cluster/cache.sim} (100%) diff --git a/tests/script/general/agg/testSuite.sim b/tests/script/general/agg/testSuite.sim deleted file mode 100644 index 9aac0d7026..0000000000 --- a/tests/script/general/agg/testSuite.sim +++ /dev/null @@ -1,2 +0,0 @@ -run general/agg/fill.sim -run general/agg/stream.sim \ No newline at end of file diff --git a/tests/script/general/cache/testSuite.sim b/tests/script/general/cache/testSuite.sim index 1265a1060e..bffd4f9633 100644 --- a/tests/script/general/cache/testSuite.sim +++ b/tests/script/general/cache/testSuite.sim @@ -1,5 +1,3 @@ run general/cache/restart_table.sim run general/cache/restart_metrics.sim -run general/cache/restart_stream.sim run general/cache/new_metrics.sim -run general/cache/new_stream.sim diff --git a/tests/script/general/agg/stream.sim b/tests/script/general/stream/agg_stream.sim similarity index 100% rename from tests/script/general/agg/stream.sim rename to tests/script/general/stream/agg_stream.sim diff --git a/tests/script/general/column/stream.sim b/tests/script/general/stream/column_stream.sim similarity index 100% rename from tests/script/general/column/stream.sim rename to tests/script/general/stream/column_stream.sim diff --git a/tests/script/general/cache/new_stream.sim b/tests/script/general/stream/new_stream.sim similarity index 100% rename from tests/script/general/cache/new_stream.sim rename to tests/script/general/stream/new_stream.sim diff --git a/tests/script/general/cache/restart_stream.sim b/tests/script/general/stream/restart_stream.sim similarity index 100% rename from tests/script/general/cache/restart_stream.sim rename to tests/script/general/stream/restart_stream.sim diff --git a/tests/script/general/agg/fill.sim b/tests/script/general/table/fill.sim similarity index 100% rename from tests/script/general/agg/fill.sim rename to tests/script/general/table/fill.sim diff --git a/tests/script/general/table/testSuite.sim b/tests/script/general/table/testSuite.sim index 7d0c7b9e56..6768c75dd7 100644 --- a/tests/script/general/table/testSuite.sim +++ b/tests/script/general/table/testSuite.sim @@ -16,6 +16,7 @@ run general/table/db.table.sim #run general/table/delete_writing.sim #run general/table/describe.sim run general/table/double.sim +#run general/table/fill.sim run general/table/float.sim run general/table/int.sim run general/table/limit.sim diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 2a49398ad2..a9175dab35 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -9,9 +9,14 @@ cd ../../../debug; make ######### general ######### -#agg #alter + #cache +#./test.sh -f general/cache/restart_table.sim +#./test.sh -f general/cache/restart_metrics.sim +#./test.sh -f general/cache/new_metrics.sim + + #column #compress #compute @@ -68,6 +73,7 @@ cd ../../../debug; make #./test.sh -f general/table/delete_writing.sim #./test.sh -f general/table/describe.sim ./test.sh -f general/table/double.sim +#./test.sh -f general/table/fill.sim ./test.sh -f general/table/float.sim ./test.sh -f general/table/int.sim ./test.sh -f general/table/limit.sim @@ -108,6 +114,7 @@ cd ../../../debug; make ./test.sh -u -f unique/cluster/balance1.sim ./test.sh -u -f unique/cluster/balance2.sim ./test.sh -u -f unique/cluster/balance3.sim +#./test.sh -u -f unique/cluster/cache.sim ./test.sh -u -f unique/column/replica3.sim diff --git a/tests/script/general/cache/cache_balance.sim b/tests/script/unique/cluster/cache.sim similarity index 100% rename from tests/script/general/cache/cache_balance.sim rename to tests/script/unique/cluster/cache.sim diff --git a/tests/script/unique/cluster/testSuite.sim b/tests/script/unique/cluster/testSuite.sim index 34cdda85dd..6ef8a0dd56 100644 --- a/tests/script/unique/cluster/testSuite.sim +++ b/tests/script/unique/cluster/testSuite.sim @@ -1,3 +1,4 @@ run unique/cluster/balance1.sim run unique/cluster/balance2.sim run unique/cluster/balance3.sim +#run unique/cluster/cache.sim From d8698efc06e4deac38924beaaf1abbafdd7ea630 Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Thu, 7 May 2020 22:55:21 +0000 Subject: [PATCH 13/36] data in wal may not be written to system successfylly during initialization --- src/dnode/src/dnodeMgmt.c | 2 +- src/rpc/src/rpcTcp.c | 2 +- src/vnode/src/vnodeWrite.c | 2 +- src/wal/src/walMain.c | 11 ++++++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index fbf1ceea71..f39770a0ab 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -116,7 +116,7 @@ static int32_t dnodeOpenVnodes() { free(vnodeList); - dPrint("there are total vnodes:%d, failed to open:%d", numOfVnodes, failed); + dPrint("there are total vnodes:%d, openned:%d failed:%d", numOfVnodes, numOfVnodes-failed, failed); return TSDB_CODE_SUCCESS; } diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index 1260a34512..38458c71d2 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -188,7 +188,7 @@ static void taosAcceptTcpConnection(void *arg) { sockFd = taosOpenTcpServerSocket(pServerObj->ip, pServerObj->port); if (sockFd < 0) return; - tTrace("%s TCP server is ready, ip:%s:%hu", pServerObj->label, pServerObj->ip, pServerObj->port); + tTrace("%s TCP server is ready, ip:0x%x:%hu", pServerObj->label, pServerObj->ip, pServerObj->port); while (1) { socklen_t addrlen = sizeof(caddr); diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 3541fc15b6..0bda963620 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -51,7 +51,7 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) { if (vnodeProcessWriteMsgFp[pHead->msgType] == NULL) return TSDB_CODE_MSG_NOT_PROCESSED; - if (pVnode->status != TAOS_VN_STATUS_READY) + if (pVnode->status != TAOS_VN_STATUS_READY && qtype == TAOS_QTYPE_RPC) return TSDB_CODE_NOT_ACTIVE_VNODE; if (pHead->version == 0) { // from client diff --git a/src/wal/src/walMain.c b/src/wal/src/walMain.c index 5157d715bf..8d92fac926 100644 --- a/src/wal/src/walMain.c +++ b/src/wal/src/walMain.c @@ -79,7 +79,9 @@ void *walOpen(const char *path, const SWalCfg *pCfg) { pthread_mutex_destroy(&pWal->mutex); free(pWal); pWal = NULL; - } + } else { + wTrace("wal:%s, it is open, level:%d", path, pWal->level); + } return pWal; } @@ -177,8 +179,11 @@ void walFsync(void *handle) { SWal *pWal = handle; - if (pWal->level == TAOS_WAL_FSYNC) - fsync(pWal->fd); + if (pWal->level == TAOS_WAL_FSYNC && pWal->fd >=0) { + if (fsync(pWal->fd) < 0) { + wError("wal:%s, fsync failed(%s)", pWal->name, strerror(errno)); + } + } } int walRestore(void *handle, void *pVnode, int (*writeFp)(void *, void *, int)) { From 144e334d04604ec70fc41cdc1ddc8e4a37208a2e Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Thu, 7 May 2020 23:39:23 +0000 Subject: [PATCH 14/36] notify vnode when data file is synced, so vnode can restart TSDB --- src/inc/tsync.h | 9 ++++++--- src/vnode/src/vnodeMain.c | 9 +++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/inc/tsync.h b/src/inc/tsync.h index 797de063b9..0d6004bba5 100644 --- a/src/inc/tsync.h +++ b/src/inc/tsync.h @@ -54,8 +54,8 @@ typedef struct { int role[TAOS_SYNC_MAX_REPLICA]; } SNodesRole; -// if name is null, get the file from index or after, used by master -// if name is provided, get the named file at the specified index, used by unsynced node +// if name is empty(name[0] is zero), get the file from index or after, used by master +// if name is provided(name[0] is not zero), get the named file at the specified index, used by unsynced node // it returns the file magic number and size, if file not there, magic shall be 0. typedef uint32_t (*FGetFileInfo)(void *ahandle, char *name, uint32_t *index, int32_t *size); @@ -72,6 +72,9 @@ typedef void (*FConfirmForward)(void *ahandle, void *mhandle, int32_t code); // when role is changed, call this to notify app typedef void (*FNotifyRole)(void *ahandle, int8_t role); +// when data file is synced successfully, notity app +typedef void (*FNotifyFileSynced)(void *ahandle); + typedef struct { int32_t vgId; // vgroup ID uint64_t version; // initial version @@ -84,7 +87,7 @@ typedef struct { FWriteToCache writeToCache; FConfirmForward confirmForward; FNotifyRole notifyRole; - + FNotifyFileSynced notifyFileSynced; } SSyncInfo; typedef void* tsync_h; diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index f5d7bd45a7..d3d79efab9 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -46,6 +46,7 @@ static int vnodeWalCallback(void *arg); static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, int32_t *size); static int vnodeGetWalInfo(void *ahandle, char *name, uint32_t *index); static void vnodeNotifyRole(void *ahandle, int8_t role); +static void vnodeNotifyFileSynced(void *ahandle); static pthread_once_t vnodeModuleInit = PTHREAD_ONCE_INIT; @@ -234,6 +235,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { syncInfo.writeToCache = vnodeWriteToQueue; syncInfo.confirmForward = dnodeSendRpcWriteRsp; syncInfo.notifyRole = vnodeNotifyRole; + syncInfo.notifyFileSynced = vnodeNotifyFileSynced; pVnode->sync = syncStart(&syncInfo); // start continuous query @@ -405,6 +407,13 @@ static void vnodeNotifyRole(void *ahandle, int8_t role) { cqStop(pVnode->cq); } +static void vnodeNotifyFileSynced(void *ahandle) { + SVnodeObj *pVnode = ahandle; + dTrace("pVnode:%p vgId:%d, data file is synced", pVnode, pVnode->vgId); + + // clsoe tsdb, then open tsdb +} + static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) { char cfgFile[TSDB_FILENAME_LEN + 30] = {0}; sprintf(cfgFile, "%s/vnode%d/config.json", tsVnodeDir, pVnodeCfg->cfg.vgId); From 002b7ea5fbd1facbb8417464cd1628c49ec333d8 Mon Sep 17 00:00:00 2001 From: liu0x54 Date: Fri, 8 May 2020 01:25:01 +0000 Subject: [PATCH 15/36] [TD-228] fix python connector to support binary interface change --- src/plugins/http/src/gcJson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/http/src/gcJson.c b/src/plugins/http/src/gcJson.c index 98069f434d..544a11b5fc 100644 --- a/src/plugins/http/src/gcJson.c +++ b/src/plugins/http/src/gcJson.c @@ -125,7 +125,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, // for group by if (groupFields != -1) { - char target[HTTP_GC_TARGET_SIZE]; + char target[HTTP_GC_TARGET_SIZE] = {0}; int len; len = snprintf(target,HTTP_GC_TARGET_SIZE,"%s{",aliasBuffer); for (int i = dataFields + 1; i Date: Fri, 8 May 2020 02:03:46 +0000 Subject: [PATCH 16/36] massage the code to make the system structure more clear --- src/common/inc/tglobal.h | 3 +- src/common/src/tglobal.c | 11 +- src/cq/test/cqtest.c | 4 +- src/dnode/inc/{dnodeLog.h => dnodeInt.h} | 20 +-- src/dnode/inc/dnodeMgmt.h | 2 +- src/dnode/inc/{dnodeRead.h => dnodeVRead.h} | 2 +- src/dnode/inc/{dnodeWrite.h => dnodeVWrite.h} | 2 +- src/dnode/src/dnodeMain.c | 6 +- src/dnode/src/dnodeMgmt.c | 8 +- src/dnode/src/dnodeModule.c | 2 +- src/dnode/src/dnodePeer.c | 20 +-- src/dnode/src/dnodeShell.c | 12 +- src/dnode/src/{dnodeRead.c => dnodeVRead.c} | 6 +- src/dnode/src/{dnodeWrite.c => dnodeVWrite.c} | 6 +- src/rpc/test/rserver.c | 2 +- src/vnode/inc/vnodeInt.h | 9 ++ src/vnode/src/vnodeMain.c | 114 +++++++++--------- src/vnode/src/vnodeRead.c | 6 +- src/vnode/src/vnodeWrite.c | 16 +-- src/wal/test/waltest.c | 4 +- 20 files changed, 126 insertions(+), 129 deletions(-) rename src/dnode/inc/{dnodeLog.h => dnodeInt.h} (58%) rename src/dnode/inc/{dnodeRead.h => dnodeVRead.h} (93%) rename src/dnode/inc/{dnodeWrite.h => dnodeVWrite.h} (94%) rename src/dnode/src/{dnodeRead.c => dnodeVRead.c} (98%) rename src/dnode/src/{dnodeWrite.c => dnodeVWrite.c} (98%) diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 9b5ac0fbe7..05afbab642 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -139,7 +139,8 @@ extern int32_t tsMonitorInterval; extern int32_t tsAsyncLog; extern int32_t tsNumOfLogLines; -extern int32_t ddebugFlag; +extern int32_t dDebugFlag; +extern int32_t vDebugFlag; extern int32_t mdebugFlag; extern int32_t cdebugFlag; extern int32_t jnidebugFlag; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index e147c52463..9828906532 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -129,17 +129,18 @@ int32_t tsMaxSQLStringLen = TSDB_MAX_SQL_LEN; int32_t tsNumOfLogLines = 10000000; int32_t mdebugFlag = 135; int32_t sdbDebugFlag = 135; -int32_t ddebugFlag = 131; -int32_t cdebugFlag = 131; +int32_t dDebugFlag = 135; +int32_t vDebugFlag = 135; +int32_t cdebugFlag = 135; int32_t jnidebugFlag = 131; int32_t odbcdebugFlag = 131; int32_t httpDebugFlag = 131; int32_t monitorDebugFlag = 131; int32_t qdebugFlag = 131; -int32_t rpcDebugFlag = 131; +int32_t rpcDebugFlag = 135; int32_t uDebugFlag = 131; int32_t debugFlag = 131; -int32_t sDebugFlag = 131; +int32_t sDebugFlag = 135; // the maximum number of results for projection query on super table that are returned from // one virtual node, to order according to timestamp @@ -1002,7 +1003,7 @@ static void doInitGlobalConfig() { taosInitConfigOption(cfg); cfg.option = "dDebugFlag"; - cfg.ptr = &ddebugFlag; + cfg.ptr = &dDebugFlag; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG; cfg.minValue = 0; diff --git a/src/cq/test/cqtest.c b/src/cq/test/cqtest.c index f620f44382..7977bd85bc 100644 --- a/src/cq/test/cqtest.c +++ b/src/cq/test/cqtest.c @@ -33,13 +33,13 @@ int main(int argc, char *argv[]) { for (int i=1; imsgType]) { diff --git a/src/dnode/src/dnodeModule.c b/src/dnode/src/dnodeModule.c index 7d09cf2a0b..2e081de2a8 100644 --- a/src/dnode/src/dnodeModule.c +++ b/src/dnode/src/dnodeModule.c @@ -21,7 +21,7 @@ #include "mnode.h" #include "http.h" #include "monitor.h" -#include "dnodeLog.h" +#include "dnodeInt.h" #include "dnodeModule.h" typedef struct { diff --git a/src/dnode/src/dnodePeer.c b/src/dnode/src/dnodePeer.c index dc48262009..2d80917aca 100644 --- a/src/dnode/src/dnodePeer.c +++ b/src/dnode/src/dnodePeer.c @@ -24,9 +24,9 @@ #include "tglobal.h" #include "trpc.h" #include "dnode.h" -#include "dnodeLog.h" +#include "dnodeInt.h" #include "dnodeMgmt.h" -#include "dnodeWrite.h" +#include "dnodeVWrite.h" #include "mnode.h" extern void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet); @@ -38,15 +38,15 @@ static void *tsDnodeServerRpc = NULL; static void *tsDnodeClientRpc = NULL; int32_t dnodeInitServer() { - dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_TABLE] = dnodeWrite; - dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_TABLE] = dnodeWrite; - dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_ALTER_TABLE] = dnodeWrite; - dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_STABLE] = dnodeWrite; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_TABLE] = dnodeDispatchToVnodeWriteQueue; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_TABLE] = dnodeDispatchToVnodeWriteQueue; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_ALTER_TABLE] = dnodeDispatchToVnodeWriteQueue; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_STABLE] = dnodeDispatchToVnodeWriteQueue; - dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_VNODE] = dnodeMgmt; - dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_VNODE] = dnodeMgmt; - dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_ALTER_STREAM] = dnodeMgmt; - dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeMgmt; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_VNODE] = dnodeDispatchToDnodeMgmt; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_DROP_VNODE] = dnodeDispatchToDnodeMgmt; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_ALTER_STREAM] = dnodeDispatchToDnodeMgmt; + dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeDispatchToDnodeMgmt; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_TABLE] = mgmtProcessReqMsgFromDnode; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = mgmtProcessReqMsgFromDnode; diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index b16227cf39..8ca3aa12e1 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -22,9 +22,9 @@ #include "tglobal.h" #include "http.h" #include "dnode.h" -#include "dnodeLog.h" -#include "dnodeRead.h" -#include "dnodeWrite.h" +#include "dnodeInt.h" +#include "dnodeVRead.h" +#include "dnodeVWrite.h" #include "dnodeShell.h" static void (*dnodeProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *); @@ -37,9 +37,9 @@ static int32_t tsDnodeSubmitReqNum = 0; void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg); int32_t dnodeInitShell() { - dnodeProcessShellMsgFp[TSDB_MSG_TYPE_SUBMIT] = dnodeWrite; - dnodeProcessShellMsgFp[TSDB_MSG_TYPE_QUERY] = dnodeRead; - dnodeProcessShellMsgFp[TSDB_MSG_TYPE_FETCH] = dnodeRead; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_SUBMIT] = dnodeDispatchToVnodeWriteQueue; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_QUERY] = dnodeDispatchToVnodeReadQueue; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_FETCH] = dnodeDispatchToVnodeReadQueue; // the following message shall be treated as mnode write dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CONNECT] = mgmtProcessMsgFromShell; diff --git a/src/dnode/src/dnodeRead.c b/src/dnode/src/dnodeVRead.c similarity index 98% rename from src/dnode/src/dnodeRead.c rename to src/dnode/src/dnodeVRead.c index 1b5ee165a9..ff211bf1b2 100644 --- a/src/dnode/src/dnodeRead.c +++ b/src/dnode/src/dnodeVRead.c @@ -21,9 +21,9 @@ #include "trpc.h" #include "twal.h" #include "tglobal.h" -#include "dnodeLog.h" +#include "dnodeInt.h" #include "dnodeMgmt.h" -#include "dnodeRead.h" +#include "dnodeVRead.h" #include "vnode.h" typedef struct { @@ -84,7 +84,7 @@ void dnodeCleanupRead() { dPrint("dnode read is closed"); } -void dnodeRead(SRpcMsg *pMsg) { +void dnodeDispatchToVnodeReadQueue(SRpcMsg *pMsg) { int32_t queuedMsgNum = 0; int32_t leftLen = pMsg->contLen; char *pCont = (char *) pMsg->pCont; diff --git a/src/dnode/src/dnodeWrite.c b/src/dnode/src/dnodeVWrite.c similarity index 98% rename from src/dnode/src/dnodeWrite.c rename to src/dnode/src/dnodeVWrite.c index 4ca9b1935d..147d2bdfbb 100644 --- a/src/dnode/src/dnodeWrite.c +++ b/src/dnode/src/dnodeVWrite.c @@ -24,8 +24,8 @@ #include "tglobal.h" #include "vnode.h" #include "tdataformat.h" -#include "dnodeLog.h" -#include "dnodeWrite.h" +#include "dnodeInt.h" +#include "dnodeVWrite.h" #include "dnodeMgmt.h" typedef struct { @@ -82,7 +82,7 @@ void dnodeCleanupWrite() { dPrint("dnode write is closed"); } -void dnodeWrite(SRpcMsg *pMsg) { +void dnodeDispatchToVnodeWriteQueue(SRpcMsg *pMsg) { char *pCont = (char *)pMsg->pCont; if (pMsg->msgType == TSDB_MSG_TYPE_SUBMIT || pMsg->msgType == TSDB_MSG_TYPE_MD_DROP_STABLE) { diff --git a/src/rpc/test/rserver.c b/src/rpc/test/rserver.c index 0569a163d1..9f781ef276 100644 --- a/src/rpc/test/rserver.c +++ b/src/rpc/test/rserver.c @@ -151,7 +151,7 @@ int main(int argc, char *argv[]) { commit = atoi(argv[++i]); } else if (strcmp(argv[i], "-d")==0 && i < argc-1) { rpcDebugFlag = atoi(argv[++i]); - ddebugFlag = rpcDebugFlag; + dDebugFlag = rpcDebugFlag; uDebugFlag = rpcDebugFlag; } else { printf("\nusage: %s [options] \n", argv[0]); diff --git a/src/vnode/inc/vnodeInt.h b/src/vnode/inc/vnodeInt.h index d99cb1c96c..d4842fdf7f 100644 --- a/src/vnode/inc/vnodeInt.h +++ b/src/vnode/inc/vnodeInt.h @@ -20,8 +20,17 @@ extern "C" { #endif +#include "tlog.h" #include "tsync.h" #include "twal.h" +#include "tcq.h" + +extern int32_t vDebugFlag; + +#define vError(...) if (vDebugFlag & DEBUG_ERROR) {taosPrintLog("ERROR VND ", 255, __VA_ARGS__); } +#define vWarn(...) if (vDebugFlag & DEBUG_WARN) {taosPrintLog("WARN VND ", vDebugFlag, __VA_ARGS__); } +#define vTrace(...) if (vDebugFlag & DEBUG_TRACE) {taosPrintLog("VND ", vDebugFlag, __VA_ARGS__); } +#define vPrint(...) {taosPrintLog("VND ", 255, __VA_ARGS__); } typedef struct { int32_t vgId; // global vnode group ID diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index f5d7bd45a7..854d9f8021 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -24,14 +24,10 @@ #include "ttime.h" #include "ttimer.h" #include "cJSON.h" -#include "twal.h" #include "tglobal.h" #include "dnode.h" #include "vnode.h" #include "vnodeInt.h" -#include "vnodeLog.h" -#include "tcq.h" -//#include "tsync.h" static int32_t tsOpennedVnodes; static void *tsDnodeVnodesHash; @@ -64,7 +60,7 @@ static void vnodeInit() { tsDnodeVnodesHash = taosInitIntHash(TSDB_MAX_VNODES, sizeof(SVnodeObj *), taosHashInt); if (tsDnodeVnodesHash == NULL) { - dError("failed to init vnode list"); + vError("failed to init vnode list"); } } @@ -74,7 +70,7 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) { SVnodeObj *pTemp = (SVnodeObj *)taosGetIntHashData(tsDnodeVnodesHash, pVnodeCfg->cfg.vgId); if (pTemp != NULL) { - dPrint("vgId:%d, vnode already exist, pVnode:%p", pVnodeCfg->cfg.vgId, pTemp); + vPrint("vgId:%d, vnode already exist, pVnode:%p", pVnodeCfg->cfg.vgId, pTemp); return TSDB_CODE_SUCCESS; } @@ -93,7 +89,7 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) { code = vnodeSaveCfg(pVnodeCfg); if (code != TSDB_CODE_SUCCESS) { - dError("vgId:%d, failed to save vnode cfg, reason:%s", pVnodeCfg->cfg.vgId, tstrerror(code)); + vError("vgId:%d, failed to save vnode cfg, reason:%s", pVnodeCfg->cfg.vgId, tstrerror(code)); return code; } @@ -113,11 +109,11 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) { sprintf(tsdbDir, "%s/vnode%d/tsdb", tsVnodeDir, pVnodeCfg->cfg.vgId); code = tsdbCreateRepo(tsdbDir, &tsdbCfg, NULL); if (code != TSDB_CODE_SUCCESS) { - dError("vgId:%d, failed to create tsdb in vnode, reason:%s", pVnodeCfg->cfg.vgId, tstrerror(code)); + vError("vgId:%d, failed to create tsdb in vnode, reason:%s", pVnodeCfg->cfg.vgId, tstrerror(code)); return TSDB_CODE_VG_INIT_FAILED; } - dPrint("vgId:%d, vnode is created, clog:%d", pVnodeCfg->cfg.vgId, pVnodeCfg->cfg.walLevel); + vPrint("vgId:%d, vnode is created, clog:%d", pVnodeCfg->cfg.vgId, pVnodeCfg->cfg.walLevel); code = vnodeOpen(pVnodeCfg->cfg.vgId, rootDir); return code; @@ -126,12 +122,12 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) { int32_t vnodeDrop(int32_t vgId) { SVnodeObj **ppVnode = (SVnodeObj **)taosGetIntHashData(tsDnodeVnodesHash, vgId); if (ppVnode == NULL || *ppVnode == NULL) { - dTrace("vgId:%d, failed to drop, vgId not exist", vgId); + vTrace("vgId:%d, failed to drop, vgId not exist", vgId); return TSDB_CODE_INVALID_VGROUP_ID; } SVnodeObj *pVnode = *ppVnode; - dTrace("pVnode:%p vgId:%d, vnode will be dropped", pVnode, pVnode->vgId); + vTrace("vgId:%d, vnode will be dropped", pVnode->vgId); pVnode->status = TAOS_VN_STATUS_DELETING; vnodeCleanUp(pVnode); @@ -144,34 +140,34 @@ int32_t vnodeAlter(void *param, SMDCreateVnodeMsg *pVnodeCfg) { int32_t code = vnodeSaveCfg(pVnodeCfg); if (code != TSDB_CODE_SUCCESS) { - dError("vgId:%d, failed to save vnode cfg, reason:%s", pVnodeCfg->cfg.vgId, tstrerror(code)); + vError("vgId:%d, failed to save vnode cfg, reason:%s", pVnodeCfg->cfg.vgId, tstrerror(code)); return code; } code = vnodeReadCfg(pVnode); if (code != TSDB_CODE_SUCCESS) { - dError("pVnode:%p vgId:%d, failed to read cfg file", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read cfg file", pVnode->vgId); taosDeleteIntHash(tsDnodeVnodesHash, pVnode->vgId); return code; } code = syncReconfig(pVnode->sync, &pVnode->syncCfg); if (code != TSDB_CODE_SUCCESS) { - dTrace("pVnode:%p vgId:%d, failed to alter vnode, canot reconfig sync, result:%s", pVnode, pVnode->vgId, + vTrace("vgId:%d, failed to alter vnode, canot reconfig sync, result:%s", pVnode->vgId, tstrerror(code)); return code; } code = tsdbConfigRepo(pVnode->tsdb, &pVnode->tsdbCfg); if (code != TSDB_CODE_SUCCESS) { - dTrace("pVnode:%p vgId:%d, failed to alter vnode, canot reconfig tsdb, result:%s", pVnode, pVnode->vgId, + vTrace("vgId:%d, failed to alter vnode, canot reconfig tsdb, result:%s", pVnode->vgId, tstrerror(code)); return code; } pVnode->status = TAOS_VN_STATUS_READY; - dTrace("pVnode:%p vgId:%d, vnode is altered", pVnode, pVnode->vgId); + vTrace("vgId:%d, vnode is altered", pVnode->vgId); return TSDB_CODE_SUCCESS; } @@ -189,7 +185,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { int32_t code = vnodeReadCfg(pVnode); if (code != TSDB_CODE_SUCCESS) { - dError("pVnode:%p vgId:%d, failed to read cfg file", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read cfg file", pVnode->vgId); taosDeleteIntHash(tsDnodeVnodesHash, pVnode->vgId); return code; } @@ -214,7 +210,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { sprintf(temp, "%s/tsdb", rootDir); pVnode->tsdb = tsdbOpenRepo(temp, &appH); if (pVnode->tsdb == NULL) { - dError("pVnode:%p vgId:%d, failed to open tsdb at %s(%s)", pVnode, pVnode->vgId, temp, tstrerror(terrno)); + vError("vgId:%d, failed to open tsdb at %s(%s)", pVnode->vgId, temp, tstrerror(terrno)); taosDeleteIntHash(tsDnodeVnodesHash, pVnode->vgId); return terrno; } @@ -243,7 +239,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { pVnode->events = NULL; pVnode->status = TAOS_VN_STATUS_READY; - dTrace("pVnode:%p vgId:%d, vnode is opened in %s", pVnode, pVnode->vgId, rootDir); + vTrace("vgId:%d, vnode is opened in %s, pVnode:%p", pVnode->vgId, rootDir, pVnode); atomic_add_fetch_32(&tsOpennedVnodes, 1); return TSDB_CODE_SUCCESS; @@ -254,7 +250,7 @@ int32_t vnodeClose(int32_t vgId) { if (ppVnode == NULL || *ppVnode == NULL) return 0; SVnodeObj *pVnode = *ppVnode; - dTrace("pVnode:%p vgId:%d, vnode will be closed", pVnode, pVnode->vgId); + vTrace("vgId:%d, vnode will be closed", pVnode->vgId); pVnode->status = TAOS_VN_STATUS_CLOSING; vnodeCleanUp(pVnode); @@ -269,7 +265,7 @@ void vnodeRelease(void *pVnodeRaw) { assert(refCount >= 0); if (refCount > 0) { - dTrace("pVnode:%p vgId:%d, release vnode, refCount:%d", pVnode, vgId, refCount); + vTrace("vgId:%d, release vnode, refCount:%d", pVnode, vgId, refCount); return; } @@ -290,7 +286,7 @@ void vnodeRelease(void *pVnodeRaw) { free(pVnode); int32_t count = atomic_sub_fetch_32(&tsOpennedVnodes, 1); - dTrace("pVnode:%p vgId:%d, vnode is released, vnodes:%d", pVnode, vgId, count); + vTrace("vgId:%d, vnode is released, vnodes:%d", pVnode, vgId, count); if (count <= 0) { taosCleanUpIntHash(tsDnodeVnodesHash); @@ -303,7 +299,7 @@ void *vnodeGetVnode(int32_t vgId) { SVnodeObj **ppVnode = (SVnodeObj **)taosGetIntHashData(tsDnodeVnodesHash, vgId); if (ppVnode == NULL || *ppVnode == NULL) { terrno = TSDB_CODE_INVALID_VGROUP_ID; - dPrint("vgId:%d not exist", vgId); + vPrint("vgId:%d not exist", vgId); return NULL; } @@ -315,7 +311,7 @@ void *vnodeAccquireVnode(int32_t vgId) { if (pVnode == NULL) return pVnode; atomic_add_fetch_32(&pVnode->refCount, 1); - dTrace("pVnode:%p vgId:%d, get vnode, refCount:%d", pVnode, pVnode->vgId, pVnode->refCount); + vTrace("vgId:%d, get vnode, refCount:%d", pVnode->vgId, pVnode->refCount); return pVnode; } @@ -410,7 +406,7 @@ static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) { sprintf(cfgFile, "%s/vnode%d/config.json", tsVnodeDir, pVnodeCfg->cfg.vgId); FILE *fp = fopen(cfgFile, "w"); if (!fp) { - dError("vgId:%d, failed to open vnode cfg file for write, file:%s error:%s", pVnodeCfg->cfg.vgId, cfgFile, + vError("vgId:%d, failed to open vnode cfg file for write, file:%s error:%s", pVnodeCfg->cfg.vgId, cfgFile, strerror(errno)); return errno; } @@ -456,7 +452,7 @@ static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) { fclose(fp); free(content); - dPrint("vgId:%d, save vnode cfg successed", pVnodeCfg->cfg.vgId); + vPrint("vgId:%d, save vnode cfg successed", pVnodeCfg->cfg.vgId); return 0; } @@ -466,7 +462,7 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) { sprintf(cfgFile, "%s/vnode%d/config.json", tsVnodeDir, pVnode->vgId); FILE *fp = fopen(cfgFile, "r"); if (!fp) { - dError("pVnode:%p vgId:%d, failed to open vnode cfg file for read, file:%s, error:%s", pVnode, pVnode->vgId, + vError("vgId:%d, failed to open vnode cfg file for read, file:%s, error:%s", pVnode->vgId, cfgFile, strerror(errno)); return errno; } @@ -478,117 +474,117 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) { if (len <= 0) { free(content); fclose(fp); - dError("pVnode:%p vgId:%d, failed to read vnode cfg, content is null", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, content is null", pVnode->vgId); return false; } cJSON *root = cJSON_Parse(content); if (root == NULL) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, invalid json format", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, invalid json format", pVnode->vgId); goto PARSE_OVER; } cJSON *cfgVersion = cJSON_GetObjectItem(root, "cfgVersion"); if (!cfgVersion || cfgVersion->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, cfgVersion not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, cfgVersion not found", pVnode->vgId); goto PARSE_OVER; } pVnode->cfgVersion = cfgVersion->valueint; cJSON *cacheBlockSize = cJSON_GetObjectItem(root, "cacheBlockSize"); if (!cacheBlockSize || cacheBlockSize->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, cacheBlockSize not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, cacheBlockSize not found", pVnode->vgId); goto PARSE_OVER; } pVnode->tsdbCfg.cacheBlockSize = cacheBlockSize->valueint; cJSON *totalBlocks = cJSON_GetObjectItem(root, "totalBlocks"); if (!totalBlocks || totalBlocks->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, totalBlocks not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, totalBlocks not found", pVnode->vgId); goto PARSE_OVER; } pVnode->tsdbCfg.totalBlocks = totalBlocks->valueint; cJSON *maxTables = cJSON_GetObjectItem(root, "maxTables"); if (!maxTables || maxTables->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, maxTables not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, maxTables not found", pVnode->vgId); goto PARSE_OVER; } pVnode->tsdbCfg.maxTables = maxTables->valueint; cJSON *daysPerFile = cJSON_GetObjectItem(root, "daysPerFile"); if (!daysPerFile || daysPerFile->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, daysPerFile not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, daysPerFile not found", pVnode->vgId); goto PARSE_OVER; } pVnode->tsdbCfg.daysPerFile = daysPerFile->valueint; cJSON *daysToKeep = cJSON_GetObjectItem(root, "daysToKeep"); if (!daysToKeep || daysToKeep->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, daysToKeep not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, daysToKeep not found", pVnode->vgId); goto PARSE_OVER; } pVnode->tsdbCfg.keep = daysToKeep->valueint; cJSON *daysToKeep1 = cJSON_GetObjectItem(root, "daysToKeep1"); if (!daysToKeep1 || daysToKeep1->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, daysToKeep1 not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, daysToKeep1 not found", pVnode->vgId); goto PARSE_OVER; } pVnode->tsdbCfg.keep1 = daysToKeep1->valueint; cJSON *daysToKeep2 = cJSON_GetObjectItem(root, "daysToKeep2"); if (!daysToKeep2 || daysToKeep2->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, daysToKeep2 not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, daysToKeep2 not found", pVnode->vgId); goto PARSE_OVER; } pVnode->tsdbCfg.keep2 = daysToKeep2->valueint; cJSON *minRowsPerFileBlock = cJSON_GetObjectItem(root, "minRowsPerFileBlock"); if (!minRowsPerFileBlock || minRowsPerFileBlock->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, minRowsPerFileBlock not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, minRowsPerFileBlock not found", pVnode->vgId); goto PARSE_OVER; } pVnode->tsdbCfg.minRowsPerFileBlock = minRowsPerFileBlock->valueint; cJSON *maxRowsPerFileBlock = cJSON_GetObjectItem(root, "maxRowsPerFileBlock"); if (!maxRowsPerFileBlock || maxRowsPerFileBlock->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, maxRowsPerFileBlock not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, maxRowsPerFileBlock not found", pVnode->vgId); goto PARSE_OVER; } pVnode->tsdbCfg.maxRowsPerFileBlock = maxRowsPerFileBlock->valueint; cJSON *commitTime = cJSON_GetObjectItem(root, "commitTime"); if (!commitTime || commitTime->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, commitTime not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, commitTime not found", pVnode->vgId); goto PARSE_OVER; } pVnode->tsdbCfg.commitTime = (int8_t)commitTime->valueint; cJSON *precision = cJSON_GetObjectItem(root, "precision"); if (!precision || precision->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, precision not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, precision not found", pVnode->vgId); goto PARSE_OVER; } pVnode->tsdbCfg.precision = (int8_t)precision->valueint; cJSON *compression = cJSON_GetObjectItem(root, "compression"); if (!compression || compression->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, compression not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, compression not found", pVnode->vgId); goto PARSE_OVER; } pVnode->tsdbCfg.compression = (int8_t)compression->valueint; cJSON *walLevel = cJSON_GetObjectItem(root, "walLevel"); if (!walLevel || walLevel->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, walLevel not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, walLevel not found", pVnode->vgId); goto PARSE_OVER; } pVnode->walCfg.walLevel = (int8_t) walLevel->valueint; cJSON *wals = cJSON_GetObjectItem(root, "wals"); if (!wals || wals->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, wals not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, wals not found", pVnode->vgId); goto PARSE_OVER; } pVnode->walCfg.wals = (int8_t)wals->valueint; @@ -596,27 +592,27 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) { cJSON *replica = cJSON_GetObjectItem(root, "replica"); if (!replica || replica->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, replica not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, replica not found", pVnode->vgId); goto PARSE_OVER; } pVnode->syncCfg.replica = (int8_t)replica->valueint; cJSON *quorum = cJSON_GetObjectItem(root, "quorum"); if (!quorum || quorum->type != cJSON_Number) { - dError("failed to read vnode cfg, quorum not found", pVnode, pVnode->vgId); + vError("failed to read vnode cfg, quorum not found", pVnode->vgId); goto PARSE_OVER; } pVnode->syncCfg.quorum = (int8_t)quorum->valueint; cJSON *nodeInfos = cJSON_GetObjectItem(root, "nodeInfos"); if (!nodeInfos || nodeInfos->type != cJSON_Array) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, nodeInfos not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, nodeInfos not found", pVnode->vgId); goto PARSE_OVER; } int size = cJSON_GetArraySize(nodeInfos); if (size != pVnode->syncCfg.replica) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, nodeInfos size not matched", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, nodeInfos size not matched", pVnode->vgId); goto PARSE_OVER; } @@ -626,14 +622,14 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) { cJSON *nodeId = cJSON_GetObjectItem(nodeInfo, "nodeId"); if (!nodeId || nodeId->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, nodeId not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, nodeId not found", pVnode->vgId); goto PARSE_OVER; } pVnode->syncCfg.nodeInfo[i].nodeId = nodeId->valueint; cJSON *nodeEp = cJSON_GetObjectItem(nodeInfo, "nodeEp"); if (!nodeEp || nodeEp->type != cJSON_String || nodeEp->valuestring == NULL) { - dError("pVnode:%p vgId:%d, failed to read vnode cfg, nodeFqdn not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode cfg, nodeFqdn not found", pVnode->vgId); goto PARSE_OVER; } @@ -643,9 +639,9 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) { ret = 0; - dPrint("pVnode:%p vgId:%d, read vnode cfg successed, replcia:%d", pVnode, pVnode->vgId, pVnode->syncCfg.replica); + vPrint("vgId:%d, read vnode cfg successed, replcia:%d", pVnode->vgId, pVnode->syncCfg.replica); for (int32_t i = 0; i < pVnode->syncCfg.replica; i++) { - dPrint("pVnode:%p vgId:%d, dnode:%d, %s:%d", pVnode, pVnode->vgId, pVnode->syncCfg.nodeInfo[i].nodeId, + vPrint("vgId:%d, dnode:%d, %s:%d", pVnode->vgId, pVnode->syncCfg.nodeInfo[i].nodeId, pVnode->syncCfg.nodeInfo[i].nodeFqdn, pVnode->syncCfg.nodeInfo[i].nodePort); } @@ -661,7 +657,7 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) { sprintf(versionFile, "%s/vnode%d/version.json", tsVnodeDir, pVnode->vgId); FILE *fp = fopen(versionFile, "w"); if (!fp) { - dError("pVnode:%p vgId:%d, failed to open vnode version file for write, file:%s error:%s", pVnode, pVnode->vgId, + vError("vgId:%d, failed to open vnode version file for write, file:%s error:%s", pVnode->vgId, versionFile, strerror(errno)); return errno; } @@ -678,7 +674,7 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) { fclose(fp); free(content); - dPrint("pVnode:%p vgId:%d, save vnode version:%" PRId64 " successed", pVnode, pVnode->vgId, pVnode->version); + vPrint("vgId:%d, save vnode version:%" PRId64 " successed", pVnode->vgId, pVnode->version); return 0; } @@ -688,7 +684,7 @@ static bool vnodeReadVersion(SVnodeObj *pVnode) { sprintf(versionFile, "%s/vnode%d/version.json", tsVnodeDir, pVnode->vgId); FILE *fp = fopen(versionFile, "r"); if (!fp) { - dTrace("pVnode:%p vgId:%d, failed to open version file:%s error:%s", pVnode, pVnode->vgId, + vTrace("vgId:%d, failed to open version file:%s error:%s", pVnode->vgId, versionFile, strerror(errno)); return false; } @@ -700,26 +696,26 @@ static bool vnodeReadVersion(SVnodeObj *pVnode) { if (len <= 0) { free(content); fclose(fp); - dPrint("pVnode:%p vgId:%d, failed to read vnode version, content is null", pVnode, pVnode->vgId); + vPrint("vgId:%d, failed to read vnode version, content is null", pVnode->vgId); return false; } cJSON *root = cJSON_Parse(content); if (root == NULL) { - dError("pVnode:%p vgId:%d, failed to read vnode version, invalid json format", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode version, invalid json format", pVnode->vgId); goto PARSE_OVER; } cJSON *version = cJSON_GetObjectItem(root, "version"); if (!version || version->type != cJSON_Number) { - dError("pVnode:%p vgId:%d, failed to read vnode version, version not found", pVnode, pVnode->vgId); + vError("vgId:%d, failed to read vnode version, version not found", pVnode->vgId); goto PARSE_OVER; } pVnode->version = version->valueint; ret = true; - dPrint("pVnode:%p vgId:%d, read vnode version successed, version:%%" PRId64, pVnode, pVnode->vgId, pVnode->version); + vPrint("vgId:%d, read vnode version successed, version:%%" PRId64, pVnode->vgId, pVnode->version); PARSE_OVER: free(content); diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c index f13efddde0..d2dd1811cf 100644 --- a/src/vnode/src/vnodeRead.c +++ b/src/vnode/src/vnodeRead.c @@ -65,7 +65,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t cont pRet->len = sizeof(SQueryTableRsp); pRet->rsp = pRsp; - dTrace("pVnode:%p vgId:%d QInfo:%p, dnode query msg disposed", pVnode, pVnode->vgId, pQInfo); + vTrace("vgId:%d QInfo:%p, dnode query msg disposed", pVnode->vgId, pQInfo); } else { pQInfo = pCont; code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -83,7 +83,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, void *pCont, int32_t cont int32_t code = TSDB_CODE_SUCCESS; - dTrace("pVnode:%p vgId:%d QInfo:%p, retrieve msg is received", pVnode, pVnode->vgId, pQInfo); + vTrace("vgId:%d QInfo:%p, retrieve msg is received", pVnode->vgId, pQInfo); pRet->code = qRetrieveQueryResultInfo(pQInfo); if (pRet->code != TSDB_CODE_SUCCESS) { @@ -104,6 +104,6 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, void *pCont, int32_t cont } } - dTrace("pVnode:%p vgId:%d QInfo:%p, retrieve msg is disposed", pVnode, pVnode->vgId, pQInfo); + vTrace("vgId:%d QInfo:%p, retrieve msg is disposed", pVnode->vgId, pQInfo); return code; } diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 3541fc15b6..c81e758d65 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -91,7 +91,7 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR // save insert result into item - dTrace("pVnode:%p vgId:%d, submit msg is processed", pVnode, pVnode->vgId); + vTrace("vgId:%d, submit msg is processed", pVnode->vgId); code = tsdbInsertData(pVnode->tsdb, pCont); pRet->len = sizeof(SShellSubmitRspMsg); @@ -110,7 +110,7 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe SMDCreateTableMsg *pTable = pCont; int32_t code = 0; - dTrace("pVnode:%p vgId:%d, table:%s, start to create", pVnode, pVnode->vgId, pTable->tableId); + vTrace("vgId:%d, table:%s, start to create", pVnode->vgId, pTable->tableId); int16_t numOfColumns = htons(pTable->numOfColumns); int16_t numOfTags = htons(pTable->numOfTags); int32_t sid = htonl(pTable->sid); @@ -157,7 +157,7 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe tfree(pDestTagSchema); tfree(pDestSchema); - dTrace("pVnode:%p vgId:%d, table:%s is created, result:%x", pVnode, pVnode->vgId, pTable->tableId, code); + vTrace("vgId:%d, table:%s is created, result:%x", pVnode->vgId, pTable->tableId, code); return code; } @@ -165,7 +165,7 @@ static int32_t vnodeProcessDropTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet SMDDropTableMsg *pTable = pCont; int32_t code = 0; - dTrace("pVnode:%p vgId:%d, table:%s, start to drop", pVnode, pVnode->vgId, pTable->tableId); + vTrace("vgId:%d, table:%s, start to drop", pVnode->vgId, pTable->tableId); STableId tableId = { .uid = htobe64(pTable->uid), .tid = htonl(pTable->sid) @@ -180,7 +180,7 @@ static int32_t vnodeProcessAlterTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet SMDCreateTableMsg *pTable = pCont; int32_t code = 0; - dTrace("pVnode:%p vgId:%d, table:%s, start to alter", pVnode, pVnode->vgId, pTable->tableId); + vTrace("vgId:%d, table:%s, start to alter", pVnode->vgId, pTable->tableId); int16_t numOfColumns = htons(pTable->numOfColumns); int16_t numOfTags = htons(pTable->numOfTags); int32_t sid = htonl(pTable->sid); @@ -221,7 +221,7 @@ static int32_t vnodeProcessAlterTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet tfree(pDestSchema); - dTrace("pVnode:%p vgId:%d, table:%s, alter table result:%d", pVnode, pVnode->vgId, pTable->tableId, code); + vTrace("vgId:%d, table:%s, alter table result:%d", pVnode->vgId, pTable->tableId, code); return code; } @@ -230,14 +230,14 @@ static int32_t vnodeProcessDropStableMsg(SVnodeObj *pVnode, void *pCont, SRspRet SMDDropSTableMsg *pTable = pCont; int32_t code = 0; - dTrace("pVnode:%p vgId:%d, stable:%s, start to drop", pVnode, pVnode->vgId, pTable->tableId); + vTrace("vgId:%d, stable:%s, start to drop", pVnode->vgId, pTable->tableId); // TODO: drop stable in vvnode //int64_t uid = htobe64(pTable->uid); //void *pTsdb = dnodeGetVnodeTsdb(pMsg->pVnode); //rpcRsp.code = tsdbDropTable(pTsdb, pTable->uid); code = TSDB_CODE_SUCCESS; - dTrace("pVnode:%p vgId:%d, stable:%s, drop stable result:%x", pVnode, pTable->tableId, code); + vTrace("vgId:%d, stable:%s, drop stable result:%x", pVnode, pTable->tableId, code); return code; } diff --git a/src/wal/test/waltest.c b/src/wal/test/waltest.c index 5293c85443..cf9bf9542e 100644 --- a/src/wal/test/waltest.c +++ b/src/wal/test/waltest.c @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) { } else if (strcmp(argv[i], "-v")==0 && i < argc-1) { ver = atoll(argv[++i]); } else if (strcmp(argv[i], "-d")==0 && i < argc-1) { - ddebugFlag = atoi(argv[++i]); + dDebugFlag = atoi(argv[++i]); } else { printf("\nusage: %s [options] \n", argv[0]); printf(" [-p path]: wal file path default is:%s\n", path); @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) { printf(" [-r rows]: rows of records per wal file, default is:%d\n", rows); printf(" [-k keep]: keep the wal after closing, default is:%d\n", keep); printf(" [-v version]: initial version, default is:%ld\n", ver); - printf(" [-d debugFlag]: debug flag, default:%d\n", ddebugFlag); + printf(" [-d debugFlag]: debug flag, default:%d\n", dDebugFlag); printf(" [-h help]: print out this help\n\n"); exit(0); } From 59cf3b3f8d642e8eb53ad09f3aa10700ab272d8b Mon Sep 17 00:00:00 2001 From: hzcheng Date: Fri, 8 May 2020 10:10:28 +0800 Subject: [PATCH 17/36] add part of tsdb log --- src/tsdb/src/tsdbMain.c | 57 +++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 3f41a3c5fe..8d570911a9 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -90,6 +90,7 @@ void tsdbFreeCfg(STsdbCfg *pCfg) { int32_t tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg, void *limiter /* TODO */) { if (mkdir(rootDir, 0755) != 0) { + tsdbError("id %d: failed to create rootDir! rootDir %s, reason %s", pCfg->tsdbId, rootDir, strerror(errno)); if (errno == EACCES) { return TSDB_CODE_NO_DISK_PERMISSIONS; } else if (errno == ENOSPC) { @@ -611,14 +612,20 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) { if (pCfg->precision == -1) { pCfg->precision = TSDB_DEFAULT_PRECISION; } else { - if (!IS_VALID_PRECISION(pCfg->precision)) return -1; + if (!IS_VALID_PRECISION(pCfg->precision)) { + tsdbError("id %d: invalid precision configuration! precision %d", pCfg->tsdbId, pCfg->precision); + return -1; + } } // Check compression if (pCfg->compression == -1) { pCfg->compression = TSDB_DEFAULT_COMPRESSION; } else { - if (!IS_VALID_COMPRESSION(pCfg->compression)) return -1; + if (!IS_VALID_COMPRESSION(pCfg->compression)) { + tsdbError("id %d: invalid compression configuration! compression %d", pCfg->tsdbId, pCfg->precision); + return -1; + } } // Check tsdbId @@ -628,29 +635,49 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) { if (pCfg->maxTables == -1) { pCfg->maxTables = TSDB_DEFAULT_TABLES; } else { - if (pCfg->maxTables < TSDB_MIN_TABLES || pCfg->maxTables > TSDB_MAX_TABLES) return -1; + if (pCfg->maxTables < TSDB_MIN_TABLES || pCfg->maxTables > TSDB_MAX_TABLES) { + tsdbError("id %d: invalid maxTables configuration! maxTables %d TSDB_MIN_TABLES %d TSDB_MAX_TABLES %d", + pCfg->tsdbId, pCfg->maxTables, TSDB_MIN_TABLES, TSDB_MAX_TABLES); + return -1; + } } // Check daysPerFile if (pCfg->daysPerFile == -1) { pCfg->daysPerFile = TSDB_DEFAULT_DAYS_PER_FILE; } else { - if (pCfg->daysPerFile < TSDB_MIN_DAYS_PER_FILE || pCfg->daysPerFile > TSDB_MAX_DAYS_PER_FILE) return -1; + if (pCfg->daysPerFile < TSDB_MIN_DAYS_PER_FILE || pCfg->daysPerFile > TSDB_MAX_DAYS_PER_FILE) { + tsdbError( + "id %d: invalid daysPerFile configuration! daysPerFile %d TSDB_MIN_DAYS_PER_FILE %d TSDB_MAX_DAYS_PER_FILE " + "%d", + pCfg->tsdbId, pCfg->daysPerFile, TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE); + return -1; + } } // Check minRowsPerFileBlock and maxRowsPerFileBlock if (pCfg->minRowsPerFileBlock == -1) { pCfg->minRowsPerFileBlock = TSDB_DEFAULT_MIN_ROW_FBLOCK; } else { - if (pCfg->minRowsPerFileBlock < TSDB_MIN_MIN_ROW_FBLOCK || pCfg->minRowsPerFileBlock > TSDB_MAX_MIN_ROW_FBLOCK) + if (pCfg->minRowsPerFileBlock < TSDB_MIN_MIN_ROW_FBLOCK || pCfg->minRowsPerFileBlock > TSDB_MAX_MIN_ROW_FBLOCK) { + tsdbError( + "id %d: invalid minRowsPerFileBlock configuration! minRowsPerFileBlock %d TSDB_MIN_MIN_ROW_FBLOCK %d " + "TSDB_MAX_MIN_ROW_FBLOCK %d", + pCfg->tsdbId, pCfg->minRowsPerFileBlock, TSDB_MIN_MIN_ROW_FBLOCK, TSDB_MAX_MIN_ROW_FBLOCK); return -1; + } } if (pCfg->maxRowsPerFileBlock == -1) { pCfg->maxRowsPerFileBlock = TSDB_DEFAULT_MAX_ROW_FBLOCK; } else { - if (pCfg->maxRowsPerFileBlock < TSDB_MIN_MAX_ROW_FBLOCK || pCfg->maxRowsPerFileBlock > TSDB_MAX_MAX_ROW_FBLOCK) + if (pCfg->maxRowsPerFileBlock < TSDB_MIN_MAX_ROW_FBLOCK || pCfg->maxRowsPerFileBlock > TSDB_MAX_MAX_ROW_FBLOCK) { + tsdbError( + "id %d: invalid maxRowsPerFileBlock configuration! maxRowsPerFileBlock %d TSDB_MIN_MAX_ROW_FBLOCK %d " + "TSDB_MAX_MAX_ROW_FBLOCK %d", + pCfg->tsdbId, pCfg->maxRowsPerFileBlock, TSDB_MIN_MIN_ROW_FBLOCK, TSDB_MAX_MIN_ROW_FBLOCK); return -1; + } } if (pCfg->minRowsPerFileBlock > pCfg->maxRowsPerFileBlock) return -1; @@ -659,7 +686,13 @@ static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg) { if (pCfg->keep == -1) { pCfg->keep = TSDB_DEFAULT_KEEP; } else { - if (pCfg->keep < TSDB_MIN_KEEP || pCfg->keep > TSDB_MAX_KEEP) return -1; + if (pCfg->keep < TSDB_MIN_KEEP || pCfg->keep > TSDB_MAX_KEEP) { + tsdbError( + "id %d: invalid keep configuration! keep %d TSDB_MIN_KEEP %d " + "TSDB_MAX_KEEP %d", + pCfg->tsdbId, pCfg->keep, TSDB_MIN_KEEP, TSDB_MAX_KEEP); + return -1; + } } return 0; @@ -716,15 +749,22 @@ static int32_t tsdbGetDataDirName(STsdbRepo *pRepo, char *fname) { } static int32_t tsdbSetRepoEnv(STsdbRepo *pRepo) { + STsdbCfg *pCfg = &pRepo->config; if (tsdbSaveConfig(pRepo) < 0) return -1; char dirName[128] = "\0"; if (tsdbGetDataDirName(pRepo, dirName) < 0) return -1; if (mkdir(dirName, 0755) < 0) { + tsdbError("id %d: failed to create repository directory! reason %s", pRepo->config.tsdbId, strerror(errno)); return -1; } + tsdbError( + "id %d: set up tsdb environment succeed! cacheBlockSize %d, totalBlocks %d, maxTables %d, daysPerFile %d, keep " + "%d, minRowsPerFileBlock %d, maxRowsPerFileBlock %d, precision %d, compression%d", + pRepo->config.tsdbId, pCfg->cacheBlockSize, pCfg->totalBlocks, pCfg->maxTables, pCfg->daysPerFile, pCfg->keep, + pCfg->minRowsPerFileBlock, pCfg->maxRowsPerFileBlock, pCfg->precision, pCfg->compression); return 0; } @@ -811,7 +851,8 @@ static int32_t tsdbInsertDataToTable(TsdbRepoT *repo, SSubmitBlk *pBlock, TSKEY STableId tableId = {.uid = pBlock->uid, .tid = pBlock->tid}; STable *pTable = tsdbIsValidTableToInsert(pRepo->tsdbMeta, tableId); if (pTable == NULL) { - tsdbError("failed to get table for insert, uid:%" PRIu64 ", tid:%d", tableId.uid, tableId.tid); + tsdbError("id %d: failed to get table for insert, uid:%" PRIu64 ", tid:%d", pRepo->config.tsdbId, pBlock->uid, + pBlock->tid); return TSDB_CODE_INVALID_TABLE_ID; } From 4281e3a5e718196ecdf180d34e0c26044a25ea32 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 8 May 2020 10:34:29 +0800 Subject: [PATCH 18/36] change null to NULL according to Dr. Liao --- tests/script/general/alter/insert1.sim | 382 +++++++++--------- tests/script/general/alter/insert2.sim | 196 ++++----- tests/script/general/alter/metrics.sim | 2 +- tests/script/general/alter/table.sim | 2 +- tests/script/general/compute/null.sim | 16 +- tests/script/general/http/telegraf.sim | 14 +- tests/script/general/parser/alter.sim | 14 +- tests/script/general/parser/alter1.sim | 20 +- .../general/parser/columnValue_bool.sim | 24 +- tests/script/general/parser/create_mt.sim | 2 +- tests/script/general/parser/create_tb.sim | 2 +- tests/script/general/parser/fill.sim | 50 +-- tests/script/general/parser/fill_stb.sim | 38 +- .../general/parser/first_last_query.sim | 12 +- tests/script/general/parser/insert_tb.sim | 8 +- tests/script/general/parser/interp_test.sim | 116 +++--- tests/script/general/parser/lastrow_query.sim | 2 +- tests/script/general/parser/limit1_stb.sim | 16 +- tests/script/general/parser/limit1_tb.sim | 12 +- tests/script/general/parser/limit2_query.sim | 12 +- tests/script/general/parser/limit_stb.sim | 24 +- tests/script/general/parser/limit_tb.sim | 20 +- tests/script/general/parser/null_char.sim | 86 ++-- .../parser/projection_limit_offset.sim | 4 +- tests/script/general/parser/set_tag_vals.sim | 20 +- tests/script/general/parser/slimit.sim | 4 +- tests/script/general/parser/slimit_query.sim | 8 +- tests/script/general/parser/timestamp.sim | 2 +- tests/script/general/parser/where.sim | 30 +- tests/script/general/stream/metrics_del.sim | 6 +- tests/script/general/stream/stream_2.sim | 4 +- tests/script/general/stream/table_del.sim | 6 +- tests/script/general/table/int.sim | 16 +- tests/script/general/tag/add.sim | 2 +- tests/script/general/tag/change.sim | 10 +- tests/script/general/tag/commit.sim | 4 +- tests/script/general/tag/delete.sim | 50 +-- tests/script/general/tag/set.sim | 10 +- tests/script/unique/big/balance.sim | 4 +- tests/script/unique/cluster/balance1.sim | 8 +- tests/script/unique/cluster/balance2.sim | 12 +- tests/script/unique/cluster/balance3.sim | 8 +- tests/script/unique/dnode/balance1.sim | 14 +- tests/script/unique/dnode/balance2.sim | 12 +- tests/script/unique/dnode/balance3.sim | 8 +- tests/script/unique/dnode/balancex.sim | 2 +- tests/script/unique/dnode/offline1.sim | 2 +- tests/script/unique/dnode/offline2.sim | 2 +- tests/script/unique/dnode/remove1.sim | 4 +- tests/script/unique/dnode/remove2.sim | 2 +- tests/script/unique/dnode/vnode_clean.sim | 4 +- tests/script/unique/http/opentsdb.sim | 8 +- .../unique/metrics/balance_replica1.sim | 2 +- tests/script/unique/mnode/mgmt22.sim | 2 +- tests/script/unique/mnode/mgmt23.sim | 6 +- tests/script/unique/mnode/mgmt25.sim | 4 +- tests/script/unique/mnode/mgmt26.sim | 6 +- tests/script/unique/mnode/mgmt33.sim | 10 +- tests/script/unique/mnode/mgmt34.sim | 18 +- tests/script/unique/mnode/mgmtr2.sim | 6 +- .../script/unique/stream/metrics_balance.sim | 2 +- tests/script/unique/stream/table_balance.sim | 2 +- tests/script/unique/stream/table_move.sim | 4 +- tests/script/windows/alter/metrics.sim | 2 +- tests/script/windows/alter/table.sim | 2 +- tests/script/windows/tag/add.sim | 2 +- tests/script/windows/tag/change.sim | 10 +- tests/script/windows/tag/delete.sim | 50 +-- tests/script/windows/tag/set.sim | 10 +- 69 files changed, 737 insertions(+), 737 deletions(-) diff --git a/tests/script/general/alter/insert1.sim b/tests/script/general/alter/insert1.sim index 7095313a0d..031cba09e0 100644 --- a/tests/script/general/alter/insert1.sim +++ b/tests/script/general/alter/insert1.sim @@ -20,25 +20,25 @@ endi if $data01 != -28 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi -if $data08 != null then +if $data08 != NULL then return -1 endi @@ -61,25 +61,25 @@ endi if $data02 != 0 then return -1 endi -if $data12 != null then +if $data12 != NULL then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi -if $data14 != null then +if $data14 != NULL then return -1 endi -if $data15 != null then +if $data15 != NULL then return -1 endi -if $data16 != null then +if $data16 != NULL then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi @@ -95,25 +95,25 @@ endi if $data01 != -28 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi -if $data08 != null then +if $data08 != NULL then return -1 endi if $data11 != -25 then @@ -122,22 +122,22 @@ endi if $data12 != 0 then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi -if $data14 != null then +if $data14 != NULL then return -1 endi -if $data15 != null then +if $data15 != NULL then return -1 endi -if $data16 != null then +if $data16 != NULL then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi if $data21 != -22 then @@ -149,19 +149,19 @@ endi if $data23 != 0 then return -1 endi -if $data24 != null then +if $data24 != NULL then return -1 endi -if $data25 != null then +if $data25 != NULL then return -1 endi -if $data26 != null then +if $data26 != NULL then return -1 endi -if $data27 != null then +if $data27 != NULL then return -1 endi -if $data28 != null then +if $data28 != NULL then return -1 endi @@ -177,25 +177,25 @@ endi if $data01 != -28 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi -if $data08 != null then +if $data08 != NULL then return -1 endi if $data11 != -25 then @@ -204,22 +204,22 @@ endi if $data12 != 0 then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi -if $data14 != null then +if $data14 != NULL then return -1 endi -if $data15 != null then +if $data15 != NULL then return -1 endi -if $data16 != null then +if $data16 != NULL then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi if $data21 != -22 then @@ -231,19 +231,19 @@ endi if $data23 != 0 then return -1 endi -if $data24 != null then +if $data24 != NULL then return -1 endi -if $data25 != null then +if $data25 != NULL then return -1 endi -if $data26 != null then +if $data26 != NULL then return -1 endi -if $data27 != null then +if $data27 != NULL then return -1 endi -if $data28 != null then +if $data28 != NULL then return -1 endi if $data31 != -19 then @@ -258,16 +258,16 @@ endi if $data34 != 0 then return -1 endi -if $data35 != null then +if $data35 != NULL then return -1 endi -if $data36 != null then +if $data36 != NULL then return -1 endi -if $data37 != null then +if $data37 != NULL then return -1 endi -if $data38 != null then +if $data38 != NULL then return -1 endi @@ -291,25 +291,25 @@ endi if $data01 != -28 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi -if $data08 != null then +if $data08 != NULL then return -1 endi if $data11 != -25 then @@ -318,22 +318,22 @@ endi if $data12 != 0 then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi -if $data14 != null then +if $data14 != NULL then return -1 endi -if $data15 != null then +if $data15 != NULL then return -1 endi -if $data16 != null then +if $data16 != NULL then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi if $data21 != -22 then @@ -345,19 +345,19 @@ endi if $data23 != 0 then return -1 endi -if $data24 != null then +if $data24 != NULL then return -1 endi -if $data25 != null then +if $data25 != NULL then return -1 endi -if $data26 != null then +if $data26 != NULL then return -1 endi -if $data27 != null then +if $data27 != NULL then return -1 endi -if $data28 != null then +if $data28 != NULL then return -1 endi if $data31 != -19 then @@ -372,16 +372,16 @@ endi if $data34 != 0 then return -1 endi -if $data35 != null then +if $data35 != NULL then return -1 endi -if $data36 != null then +if $data36 != NULL then return -1 endi -if $data37 != null then +if $data37 != NULL then return -1 endi -if $data38 != null then +if $data38 != NULL then return -1 endi if $data41 != -16 then @@ -399,13 +399,13 @@ endi if $data45 != 3 then return -1 endi -if $data46 != null then +if $data46 != NULL then return -1 endi -if $data47 != null then +if $data47 != NULL then return -1 endi -if $data48 != null then +if $data48 != NULL then return -1 endi @@ -421,25 +421,25 @@ endi if $data01 != -28 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi -if $data08 != null then +if $data08 != NULL then return -1 endi if $data11 != -25 then @@ -448,22 +448,22 @@ endi if $data12 != 0 then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi -if $data14 != null then +if $data14 != NULL then return -1 endi -if $data15 != null then +if $data15 != NULL then return -1 endi -if $data16 != null then +if $data16 != NULL then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi if $data21 != -22 then @@ -475,19 +475,19 @@ endi if $data23 != 0 then return -1 endi -if $data24 != null then +if $data24 != NULL then return -1 endi -if $data25 != null then +if $data25 != NULL then return -1 endi -if $data26 != null then +if $data26 != NULL then return -1 endi -if $data27 != null then +if $data27 != NULL then return -1 endi -if $data28 != null then +if $data28 != NULL then return -1 endi if $data31 != -19 then @@ -502,16 +502,16 @@ endi if $data34 != 0 then return -1 endi -if $data35 != null then +if $data35 != NULL then return -1 endi -if $data36 != null then +if $data36 != NULL then return -1 endi -if $data37 != null then +if $data37 != NULL then return -1 endi -if $data38 != null then +if $data38 != NULL then return -1 endi if $data41 != -16 then @@ -529,13 +529,13 @@ endi if $data45 != 3 then return -1 endi -if $data46 != null then +if $data46 != NULL then return -1 endi -if $data47 != null then +if $data47 != NULL then return -1 endi -if $data48 != null then +if $data48 != NULL then return -1 endi if $data51 != -13 then @@ -556,10 +556,10 @@ endi if $data56 != 8.00000 then return -1 endi -if $data57 != null then +if $data57 != NULL then return -1 endi -if $data58 != null then +if $data58 != NULL then return -1 endi @@ -575,25 +575,25 @@ endi if $data01 != -28 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi -if $data08 != null then +if $data08 != NULL then return -1 endi if $data11 != -25 then @@ -602,22 +602,22 @@ endi if $data12 != 0 then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi -if $data14 != null then +if $data14 != NULL then return -1 endi -if $data15 != null then +if $data15 != NULL then return -1 endi -if $data16 != null then +if $data16 != NULL then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi if $data21 != -22 then @@ -629,19 +629,19 @@ endi if $data23 != 0 then return -1 endi -if $data24 != null then +if $data24 != NULL then return -1 endi -if $data25 != null then +if $data25 != NULL then return -1 endi -if $data26 != null then +if $data26 != NULL then return -1 endi -if $data27 != null then +if $data27 != NULL then return -1 endi -if $data28 != null then +if $data28 != NULL then return -1 endi if $data31 != -19 then @@ -656,16 +656,16 @@ endi if $data34 != 0 then return -1 endi -if $data35 != null then +if $data35 != NULL then return -1 endi -if $data36 != null then +if $data36 != NULL then return -1 endi -if $data37 != null then +if $data37 != NULL then return -1 endi -if $data38 != null then +if $data38 != NULL then return -1 endi if $data41 != -16 then @@ -683,13 +683,13 @@ endi if $data45 != 3 then return -1 endi -if $data46 != null then +if $data46 != NULL then return -1 endi -if $data47 != null then +if $data47 != NULL then return -1 endi -if $data48 != null then +if $data48 != NULL then return -1 endi if $data51 != -13 then @@ -710,10 +710,10 @@ endi if $data56 != 8.00000 then return -1 endi -if $data57 != null then +if $data57 != NULL then return -1 endi -if $data58 != null then +if $data58 != NULL then return -1 endi if $data61 != -10 then @@ -737,7 +737,7 @@ endi if $data67 != 10.000000000 then return -1 endi -if $data68 != null then +if $data68 != NULL then return -1 endi @@ -753,25 +753,25 @@ endi if $data01 != -28 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi -if $data08 != null then +if $data08 != NULL then return -1 endi if $data11 != -25 then @@ -780,22 +780,22 @@ endi if $data12 != 0 then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi -if $data14 != null then +if $data14 != NULL then return -1 endi -if $data15 != null then +if $data15 != NULL then return -1 endi -if $data16 != null then +if $data16 != NULL then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi if $data21 != -22 then @@ -807,19 +807,19 @@ endi if $data23 != 0 then return -1 endi -if $data24 != null then +if $data24 != NULL then return -1 endi -if $data25 != null then +if $data25 != NULL then return -1 endi -if $data26 != null then +if $data26 != NULL then return -1 endi -if $data27 != null then +if $data27 != NULL then return -1 endi -if $data28 != null then +if $data28 != NULL then return -1 endi if $data31 != -19 then @@ -834,16 +834,16 @@ endi if $data34 != 0 then return -1 endi -if $data35 != null then +if $data35 != NULL then return -1 endi -if $data36 != null then +if $data36 != NULL then return -1 endi -if $data37 != null then +if $data37 != NULL then return -1 endi -if $data38 != null then +if $data38 != NULL then return -1 endi if $data41 != -16 then @@ -861,13 +861,13 @@ endi if $data45 != 3 then return -1 endi -if $data46 != null then +if $data46 != NULL then return -1 endi -if $data47 != null then +if $data47 != NULL then return -1 endi -if $data48 != null then +if $data48 != NULL then return -1 endi if $data51 != -13 then @@ -888,10 +888,10 @@ endi if $data56 != 8.00000 then return -1 endi -if $data57 != null then +if $data57 != NULL then return -1 endi -if $data58 != null then +if $data58 != NULL then return -1 endi if $data61 != -10 then @@ -915,7 +915,7 @@ endi if $data67 != 10.000000000 then return -1 endi -if $data68 != null then +if $data68 != NULL then return -1 endi if $data71 != -7 then @@ -942,7 +942,7 @@ endi if $data78 != 11 then return -1 endi -if $data79 != null then +if $data79 != NULL then return -1 endi @@ -959,25 +959,25 @@ endi if $data01 != -28 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi -if $data08 != null then +if $data08 != NULL then return -1 endi if $data11 != -25 then @@ -986,22 +986,22 @@ endi if $data12 != 0 then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi -if $data14 != null then +if $data14 != NULL then return -1 endi -if $data15 != null then +if $data15 != NULL then return -1 endi -if $data16 != null then +if $data16 != NULL then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi if $data21 != -22 then @@ -1013,19 +1013,19 @@ endi if $data23 != 0 then return -1 endi -if $data24 != null then +if $data24 != NULL then return -1 endi -if $data25 != null then +if $data25 != NULL then return -1 endi -if $data26 != null then +if $data26 != NULL then return -1 endi -if $data27 != null then +if $data27 != NULL then return -1 endi -if $data28 != null then +if $data28 != NULL then return -1 endi if $data31 != -19 then @@ -1040,16 +1040,16 @@ endi if $data34 != 0 then return -1 endi -if $data35 != null then +if $data35 != NULL then return -1 endi -if $data36 != null then +if $data36 != NULL then return -1 endi -if $data37 != null then +if $data37 != NULL then return -1 endi -if $data38 != null then +if $data38 != NULL then return -1 endi if $data41 != -16 then @@ -1067,13 +1067,13 @@ endi if $data45 != 3 then return -1 endi -if $data46 != null then +if $data46 != NULL then return -1 endi -if $data47 != null then +if $data47 != NULL then return -1 endi -if $data48 != null then +if $data48 != NULL then return -1 endi if $data51 != -13 then @@ -1094,10 +1094,10 @@ endi if $data56 != 8.00000 then return -1 endi -if $data57 != null then +if $data57 != NULL then return -1 endi -if $data58 != null then +if $data58 != NULL then return -1 endi if $data61 != -10 then @@ -1121,7 +1121,7 @@ endi if $data67 != 10.000000000 then return -1 endi -if $data68 != null then +if $data68 != NULL then return -1 endi if $data71 != -7 then diff --git a/tests/script/general/alter/insert2.sim b/tests/script/general/alter/insert2.sim index a248c7cd2b..1123fdb790 100644 --- a/tests/script/general/alter/insert2.sim +++ b/tests/script/general/alter/insert2.sim @@ -74,7 +74,7 @@ endi if $data07 != 8 then return -1 endi -if $data08 != null then +if $data08 != NULL then return -1 endi if $data11 != 1 then @@ -98,7 +98,7 @@ endi if $data17 != 8 then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi @@ -129,10 +129,10 @@ endi if $data06 != 8 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi -if $data08 != null then +if $data08 != NULL then return -1 endi if $data11 != 2 then @@ -153,10 +153,10 @@ endi if $data16 != 8 then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi if $data21 != 1 then @@ -177,10 +177,10 @@ endi if $data26 != 8 then return -1 endi -if $data27 != null then +if $data27 != NULL then return -1 endi -if $data28 != null then +if $data28 != NULL then return -1 endi @@ -206,16 +206,16 @@ endi if $data04 != 0 then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi -if $data08 != null then +if $data08 != NULL then return -1 endi if $data11 != 3 then @@ -230,16 +230,16 @@ endi if $data14 != 8 then return -1 endi -if $data15 != null then +if $data15 != NULL then return -1 endi -if $data16 != null then +if $data16 != NULL then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi if $data21 != 2 then @@ -254,16 +254,16 @@ endi if $data24 != 8 then return -1 endi -if $data25 != null then +if $data25 != NULL then return -1 endi -if $data26 != null then +if $data26 != NULL then return -1 endi -if $data27 != null then +if $data27 != NULL then return -1 endi -if $data28 != null then +if $data28 != NULL then return -1 endi if $data31 != 1 then @@ -278,16 +278,16 @@ endi if $data34 != 8 then return -1 endi -if $data35 != null then +if $data35 != NULL then return -1 endi -if $data36 != null then +if $data36 != NULL then return -1 endi -if $data37 != null then +if $data37 != NULL then return -1 endi -if $data38 != null then +if $data38 != NULL then return -1 endi @@ -313,19 +313,19 @@ endi if $data03 != 5 then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi -if $data08 != null then +if $data08 != NULL then return -1 endi if $data11 != -19 then @@ -337,19 +337,19 @@ endi if $data13 != 0 then return -1 endi -if $data14 != null then +if $data14 != NULL then return -1 endi -if $data15 != null then +if $data15 != NULL then return -1 endi -if $data16 != null then +if $data16 != NULL then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi if $data21 != 3 then @@ -361,19 +361,19 @@ endi if $data23 != 8 then return -1 endi -if $data24 != null then +if $data24 != NULL then return -1 endi -if $data25 != null then +if $data25 != NULL then return -1 endi -if $data26 != null then +if $data26 != NULL then return -1 endi -if $data27 != null then +if $data27 != NULL then return -1 endi -if $data28 != null then +if $data28 != NULL then return -1 endi if $data31 != 2 then @@ -385,19 +385,19 @@ endi if $data33 != 8 then return -1 endi -if $data34 != null then +if $data34 != NULL then return -1 endi -if $data35 != null then +if $data35 != NULL then return -1 endi -if $data36 != null then +if $data36 != NULL then return -1 endi -if $data37 != null then +if $data37 != NULL then return -1 endi -if $data38 != null then +if $data38 != NULL then return -1 endi if $data41 != 1 then @@ -409,19 +409,19 @@ endi if $data43 != 8 then return -1 endi -if $data44 != null then +if $data44 != NULL then return -1 endi -if $data45 != null then +if $data45 != NULL then return -1 endi -if $data46 != null then +if $data46 != NULL then return -1 endi -if $data47 != null then +if $data47 != NULL then return -1 endi -if $data48 != null then +if $data48 != NULL then return -1 endi @@ -443,22 +443,22 @@ endi if $data12 != 5 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi -if $data08 != null then +if $data08 != NULL then return -1 endi if $data21 != -19 then @@ -467,22 +467,22 @@ endi if $data22 != 0 then return -1 endi -if $data23 != null then +if $data23 != NULL then return -1 endi -if $data24 != null then +if $data24 != NULL then return -1 endi -if $data25 != null then +if $data25 != NULL then return -1 endi -if $data26 != null then +if $data26 != NULL then return -1 endi -if $data27 != null then +if $data27 != NULL then return -1 endi -if $data28 != null then +if $data28 != NULL then return -1 endi if $data31 != 3 then @@ -491,22 +491,22 @@ endi if $data32 != 8 then return -1 endi -if $data33 != null then +if $data33 != NULL then return -1 endi -if $data34 != null then +if $data34 != NULL then return -1 endi -if $data35 != null then +if $data35 != NULL then return -1 endi -if $data36 != null then +if $data36 != NULL then return -1 endi -if $data37 != null then +if $data37 != NULL then return -1 endi -if $data38 != null then +if $data38 != NULL then return -1 endi if $data41 != 2 then @@ -515,22 +515,22 @@ endi if $data42 != 8 then return -1 endi -if $data43 != null then +if $data43 != NULL then return -1 endi -if $data44 != null then +if $data44 != NULL then return -1 endi -if $data45 != null then +if $data45 != NULL then return -1 endi -if $data46 != null then +if $data46 != NULL then return -1 endi -if $data47 != null then +if $data47 != NULL then return -1 endi -if $data48 != null then +if $data48 != NULL then return -1 endi if $data51 != 1 then @@ -539,19 +539,19 @@ endi if $data52 != 8 then return -1 endi -if $data53 != null then +if $data53 != NULL then return -1 endi -if $data54 != null then +if $data54 != NULL then return -1 endi -if $data55 != null then +if $data55 != NULL then return -1 endi -if $data57 != null then +if $data57 != NULL then return -1 endi -if $data58 != null then +if $data58 != NULL then return -1 endi @@ -568,52 +568,52 @@ print data01 = $data01 if $data01 != -10 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi if $data11 != -13 then return -1 endi -if $data12 != null then +if $data12 != NULL then return -1 endi if $data21 != -16 then return -1 endi -if $data22 != null then +if $data22 != NULL then return -1 endi if $data31 != -19 then return -1 endi -if $data32 != null then +if $data32 != NULL then return -1 endi -if $data33 != null then +if $data33 != NULL then return -1 endi if $data41 != 3 then return -1 endi -if $data42 != null then +if $data42 != NULL then return -1 endi if $data51 != 2 then return -1 endi -if $data52 != null then +if $data52 != NULL then return -1 endi -if $data53 != null then +if $data53 != NULL then return -1 endi if $data61 != 1 then return -1 endi -if $data62 != null then +if $data62 != NULL then return -1 endi @@ -632,52 +632,52 @@ endi if $data01 != -10 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi if $data11 != -13 then return -1 endi -if $data12 != null then +if $data12 != NULL then return -1 endi if $data21 != -16 then return -1 endi -if $data22 != null then +if $data22 != NULL then return -1 endi if $data31 != -19 then return -1 endi -if $data32 != null then +if $data32 != NULL then return -1 endi -if $data33 != null then +if $data33 != NULL then return -1 endi if $data41 != 3 then return -1 endi -if $data42 != null then +if $data42 != NULL then return -1 endi if $data51 != 2 then return -1 endi -if $data52 != null then +if $data52 != NULL then return -1 endi -if $data53 != null then +if $data53 != NULL then return -1 endi if $data61 != 1 then return -1 endi -if $data62 != null then +if $data62 != NULL then return -1 endi diff --git a/tests/script/general/alter/metrics.sim b/tests/script/general/alter/metrics.sim index be11ddc7f5..55763cf2d4 100644 --- a/tests/script/general/alter/metrics.sim +++ b/tests/script/general/alter/metrics.sim @@ -770,7 +770,7 @@ endi if $data21 != INT then return -1 endi -if $data30 != null then +if $data30 != NULL then return -1 endi diff --git a/tests/script/general/alter/table.sim b/tests/script/general/alter/table.sim index 8660d0d312..9438bed8ab 100644 --- a/tests/script/general/alter/table.sim +++ b/tests/script/general/alter/table.sim @@ -673,7 +673,7 @@ endi if $data11 != INT then return -1 endi -if $data20 != null then +if $data20 != NULL then return -1 endi diff --git a/tests/script/general/compute/null.sim b/tests/script/general/compute/null.sim index 9f2e9ecf40..df9d009f34 100644 --- a/tests/script/general/compute/null.sim +++ b/tests/script/general/compute/null.sim @@ -51,7 +51,7 @@ $tb = $tbPrefix . $i sql select * from $tb print $data00 $data01 $data02 -if $data01 != null then +if $data01 != NULL then return -1 endi if $data02 != 0 then @@ -165,7 +165,7 @@ sql select * from t2 if $rows != 1 then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi @@ -173,7 +173,7 @@ sql select * from t3 if $rows != 1 then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi @@ -181,7 +181,7 @@ sql select * from t4 if $rows != 1 then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi @@ -189,7 +189,7 @@ sql select * from t5 if $rows != 1 then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi @@ -197,7 +197,7 @@ sql select * from t6 if $rows != 1 then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi @@ -205,7 +205,7 @@ sql select * from t7 if $rows != 1 then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi @@ -213,7 +213,7 @@ endi #if $rows != 1 then # return -1 #endi -#if $data01 != null then +#if $data01 != NULL then # return -1 #endi diff --git a/tests/script/general/http/telegraf.sim b/tests/script/general/http/telegraf.sim index d9f3340f06..60eeec652e 100644 --- a/tests/script/general/http/telegraf.sim +++ b/tests/script/general/http/telegraf.sim @@ -16,14 +16,14 @@ print =============== step1 - parse system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/ print $system_content -if $system_content != @{"status":"error","code":1022,"desc":"database name can not be null"}@ then +if $system_content != @{"status":"error","code":1022,"desc":"database name can not be NULL"}@ then return -1 endi system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'select * from d1.table_admin' -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/ print $system_content -if $system_content != @{"status":"error","code":1022,"desc":"database name can not be null"}@ then +if $system_content != @{"status":"error","code":1022,"desc":"database name can not be NULL"}@ then return -1 endi @@ -170,7 +170,7 @@ endi system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"":"windows"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 print $system_content -if $system_content != @{"status":"error","code":1038,"desc":"tag name is null"}@ then +if $system_content != @{"status":"error","code":1038,"desc":"tag name is NULL"}@ then return -1 endi @@ -191,14 +191,14 @@ endi system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":""},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 print $system_content -if $system_content != @{"status":"error","code":1041,"desc":"tag value is null"}@ then +if $system_content != @{"status":"error","code":1041,"desc":"tag value is NULL"}@ then return -1 endi system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"1022":"111"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 print $system_content -if $system_content != @{"status":"error","code":1042,"desc":"table is null"}@ then +if $system_content != @{"status":"error","code":1042,"desc":"table is NULL"}@ then return -1 endi @@ -219,14 +219,14 @@ endi system_content curl -u root:taosdata -d '{"fields":{"":0,"Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 print $system_content -if $system_content != @{"status":"error","code":1048,"desc":"field name is null"}@ then +if $system_content != @{"status":"error","code":1048,"desc":"field name is NULL"}@ then return -1 endi system_content curl -u root:taosdata -d '{"fields":{"Percent_DPC_Time":"","Percent_Idle_Time":95.59830474853516,"Percent_Interrupt_Time":0,"Percent_Privileged_Time":0,"Percent_Processor_Time":0,"Percent_User_Time":0},"name":"win_cpu","tags":{"host":"windows","instance":"1","objectname":"Processor"},"timestamp":1535784122}' 127.0.0.1:6020/telegraf/db/root/taosdata1 print $system_content -if $system_content != @{"status":"error","code":1051,"desc":"field value is null"}@ then +if $system_content != @{"status":"error","code":1051,"desc":"field value is NULL"}@ then return -1 endi diff --git a/tests/script/general/parser/alter.sim b/tests/script/general/parser/alter.sim index 1b19101bc0..f97581c5f5 100644 --- a/tests/script/general/parser/alter.sim +++ b/tests/script/general/parser/alter.sim @@ -38,7 +38,7 @@ endi if $data02 != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi sql alter table tb add column c3 nchar(4) @@ -46,7 +46,7 @@ sql select * from tb order by ts desc if $rows != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi sql insert into tb values (now, 2, 2, 'taos') @@ -72,13 +72,13 @@ endi if $data02 != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi sql alter table mt add column c3 nchar(4) sql select * from tb order by ts desc -if $data03 != null then +if $data03 != NULL then return -1 endi sql insert into tb values (now, 2, 2, 'taos') @@ -89,7 +89,7 @@ endi if $data03 != taos then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi sql drop table tb @@ -169,7 +169,7 @@ endi if $data01 != 2 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi sql alter table mt add column c2 int @@ -200,7 +200,7 @@ if $data02 != insert then endi sql alter table mt add column c3 nchar(4) sql select * from tb order by ts desc -if $data03 != null then +if $data03 != NULL then return -1 endi # the query below should be deleted after bug fix diff --git a/tests/script/general/parser/alter1.sim b/tests/script/general/parser/alter1.sim index c0221e1033..7c4609a87d 100644 --- a/tests/script/general/parser/alter1.sim +++ b/tests/script/general/parser/alter1.sim @@ -36,16 +36,16 @@ print rows = $rows if $rows != 4 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi -if $data23 != null then +if $data23 != NULL then return -1 endi -if $data33 != null then +if $data33 != NULL then return -1 endi @@ -53,10 +53,10 @@ sql select c1 from stb if $rows != 4 then return -1 endi -if $data00 != null then +if $data00 != NULL then return -1 endi -if $data30 != null then +if $data30 != NULL then return -1 endi @@ -69,10 +69,10 @@ sql select c1+speed from car1 if $rows != 2 then return -1 endi -if $data00 != null then +if $data00 != NULL then return -1 endi -if $data10 != null then +if $data10 != NULL then return -1 endi @@ -80,10 +80,10 @@ sql select * from car1 if $rows != 2 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi diff --git a/tests/script/general/parser/columnValue_bool.sim b/tests/script/general/parser/columnValue_bool.sim index 84ee53670e..7f3a6c3d6a 100644 --- a/tests/script/general/parser/columnValue_bool.sim +++ b/tests/script/general/parser/columnValue_bool.sim @@ -10,7 +10,7 @@ print ========== bool sql create table mt_bool (ts timestamp, c bool) tags (tagname bool) ## case 00: static create table for test tag values -sql create table st_bool_0 using mt_bool tags (null) +sql create table st_bool_0 using mt_bool tags (NULL) sql select tagname from st_bool_0 if $data00 != NULL then print ==1== expect: NULL, actually: $data00 @@ -22,7 +22,7 @@ if $data00 != NULL then print ==2== expect: NULL, actually: $data00 return -1 endi -sql create table st_bool_2 using mt_bool tags ('null') +sql create table st_bool_2 using mt_bool tags ('NULL') sql select tagname from st_bool_2 if $data00 != NULL then print ==3== expect: NULL, actually: $data00 @@ -34,7 +34,7 @@ if $data00 != NULL then print ==4== expect: NULL, actually: $data00 return -1 endi -sql create table st_bool_4 using mt_bool tags ("null") +sql create table st_bool_4 using mt_bool tags ("NULL") sql select tagname from st_bool_4 if $data00 != NULL then print ==5== expect: NULL, actually: $data00 @@ -120,7 +120,7 @@ if $data00 != 1 then endi ## case 01: insert values for test column values -sql insert into st_bool_0 values (now, null) +sql insert into st_bool_0 values (now, NULL) sql select * from st_bool_0 if $rows != 1 then return -1 @@ -138,7 +138,7 @@ if $data01 != NULL then print ==18== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_2 values (now, 'null') +sql insert into st_bool_2 values (now, 'NULL') sql select * from st_bool_2 if $rows != 1 then return -1 @@ -156,7 +156,7 @@ if $data01 != NULL then print ==20== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_4 values (now, "null") +sql insert into st_bool_4 values (now, "NULL") sql select * from st_bool_4 if $rows != 1 then return -1 @@ -284,7 +284,7 @@ if $data01 != 1 then endi ## case 02: dynamic create table for test tag values -sql insert into st_bool_16 using mt_bool tags (null) values (now, null) +sql insert into st_bool_16 using mt_bool tags (NULL) values (now, NULL) sql select tagname from st_bool_16 if $data00 != NULL then print ==33== expect: NULL, actually: $data00 @@ -307,7 +307,7 @@ if $data01 != NULL then print ==36== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_18 using mt_bool tags ('null') values (now, 'null') +sql insert into st_bool_18 using mt_bool tags ('NULL') values (now, 'NULL') sql select tagname from st_bool_18 if $data00 != NULL then print ==37== expect: NULL, actually: $data00 @@ -329,7 +329,7 @@ if $data01 != NULL then print ==40== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_20 using mt_bool tags ("null") values (now, "null") +sql insert into st_bool_20 using mt_bool tags ("NULL") values (now, "NULL") sql select tagname from st_bool_20 if $data00 != NULL then print ==41== expect: NULL, actually: $data00 @@ -505,7 +505,7 @@ endi #if $data00 != false then # return -1 #endi -#sql alter table st_bool_0 set tag tagname=null +#sql alter table st_bool_0 set tag tagname=NULL #sql select tagname from st_bool_0 #if $data00 != NULL then # return -1 @@ -515,7 +515,7 @@ endi #if $data00 != true then # return -1 #endi -#sql alter table st_bool_0 set tag tagname='null' +#sql alter table st_bool_0 set tag tagname='NULL' #sql select tagname from st_bool_0 #if $data00 != NULL then # return -1 @@ -535,7 +535,7 @@ endi #if $data00 != true then # return -1 #endi -#sql alter table st_bool_0 set tag tagname="null" +#sql alter table st_bool_0 set tag tagname="NULL" #sql select tagname from st_bool_0 #if $data00 != NULL then # return -1 diff --git a/tests/script/general/parser/create_mt.sim b/tests/script/general/parser/create_mt.sim index 275393f4ac..43fc216ab0 100644 --- a/tests/script/general/parser/create_mt.sim +++ b/tests/script/general/parser/create_mt.sim @@ -46,7 +46,7 @@ if $rows != 0 then return -1 endi print data00 = $data00 -if $data00 != null then +if $data00 != NULL then return -1 endi print case_insensitivity test passed diff --git a/tests/script/general/parser/create_tb.sim b/tests/script/general/parser/create_tb.sim index a3a18697a2..33b7be1194 100644 --- a/tests/script/general/parser/create_tb.sim +++ b/tests/script/general/parser/create_tb.sim @@ -45,7 +45,7 @@ if $rows != 0 then return -1 endi print data00 = $data00 -if $data00 != null then +if $data00 != NULL then return -1 endi print case_insensitivity test passed diff --git a/tests/script/general/parser/fill.sim b/tests/script/general/parser/fill.sim index c3966c47c1..459bc7611e 100644 --- a/tests/script/general/parser/fill.sim +++ b/tests/script/general/parser/fill.sim @@ -390,7 +390,7 @@ sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $ sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1, 1e1, 1e1) sql select first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1') # fill quoted values into bool column will throw error unless the value is 'true' or 'false' Note:2018-10-24 -# fill values into binary or nchar columns will be set to null automatically Note:2018-10-24 +# fill values into binary or nchar columns will be set to NULL automatically Note:2018-10-24 sql_error select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1','1e1') sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, true, true, true) sql select first(c6), first(c7), first(c8) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true', 'true','true') @@ -649,25 +649,25 @@ endi if $data01 != 1 then return -1 endi -if $data11 != null then +if $data11 != NULL then return -1 endi if $data21 != 1 then return -1 endi -if $data31 != null then +if $data31 != NULL then return -1 endi if $data41 != 1 then return -1 endi -if $data51 != null then +if $data51 != NULL then return -1 endi if $data61 != 1 then return -1 endi -if $data71 != null then +if $data71 != NULL then return -1 endi if $data81 != 1 then @@ -686,25 +686,25 @@ endi if $data01 != 0.000000000 then return -1 endi -if $data11 != null then +if $data11 != NULL then return -1 endi if $data21 != 1.000000000 then return -1 endi -if $data31 != null then +if $data31 != NULL then return -1 endi if $data41 != 2.000000000 then return -1 endi -if $data51 != null then +if $data51 != NULL then return -1 endi if $data61 != 3.000000000 then return -1 endi -if $data71 != null then +if $data71 != NULL then return -1 endi if $data81 != 4.000000000 then @@ -719,25 +719,25 @@ endi if $data01 != 0 then return -1 endi -if $data11 != null then +if $data11 != NULL then return -1 endi if $data21 != 1 then return -1 endi -if $data31 != null then +if $data31 != NULL then return -1 endi if $data41 != 2 then return -1 endi -if $data51 != null then +if $data51 != NULL then return -1 endi if $data61 != 3 then return -1 endi -if $data71 != null then +if $data71 != NULL then return -1 endi if $data81 != 4 then @@ -752,25 +752,25 @@ endi if $data01 != 0 then return -1 endi -if $data11 != null then +if $data11 != NULL then return -1 endi if $data21 != 1 then return -1 endi -if $data31 != null then +if $data31 != NULL then return -1 endi if $data41 != 2 then return -1 endi -if $data51 != null then +if $data51 != NULL then return -1 endi if $data61 != 3 then return -1 endi -if $data71 != null then +if $data71 != NULL then return -1 endi if $data81 != 4 then @@ -785,25 +785,25 @@ endi if $data01 != 0 then return -1 endi -if $data11 != null then +if $data11 != NULL then return -1 endi if $data21 != 1 then return -1 endi -if $data31 != null then +if $data31 != NULL then return -1 endi if $data41 != 2 then return -1 endi -if $data51 != null then +if $data51 != NULL then return -1 endi if $data61 != 3 then return -1 endi -if $data71 != null then +if $data71 != NULL then return -1 endi if $data81 != 4 then @@ -818,25 +818,25 @@ endi if $data01 != 0 then return -1 endi -if $data11 != null then +if $data11 != NULL then return -1 endi if $data21 != 1 then return -1 endi -if $data31 != null then +if $data31 != NULL then return -1 endi if $data41 != 2 then return -1 endi -if $data51 != null then +if $data51 != NULL then return -1 endi if $data61 != 3 then return -1 endi -if $data71 != null then +if $data71 != NULL then return -1 endi if $data81 != 4 then diff --git a/tests/script/general/parser/fill_stb.sim b/tests/script/general/parser/fill_stb.sim index a40e5d15a4..113f4b68a4 100644 --- a/tests/script/general/parser/fill_stb.sim +++ b/tests/script/general/parser/fill_stb.sim @@ -68,7 +68,7 @@ $tsu = $tsu + $ts0 #### fill test cases for stables -# null values in each group +# NULL values in each group #sql select count(*) from $stb where ts >= '2018-09-16 00:00:00.000' and ts <= $tsu interval(1d) fill(prev) group by t1 #$val = $tbNum * 2 #if rows != $val then @@ -227,7 +227,7 @@ sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 1e1, 1e1, 1e1) sql select first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1') # fill quoted values into bool column will throw error unless the value is 'true' or 'false' Note:2018-10-24 -# fill values into binary or nchar columns will be set to null automatically Note:2018-10-24 +# fill values into binary or nchar columns will be set to NULL automatically Note:2018-10-24 sql_error select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, '1e', '1e1','1e1') sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, true, true, true) sql select first(c7), first(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, 'true', 'true','true') @@ -283,13 +283,13 @@ endi if $data08 != 0 then return -1 endi -if $data15 != null then +if $data15 != NULL then return -1 endi -if $data16 != null then +if $data16 != NULL then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi if $data18 != 0 then @@ -313,16 +313,16 @@ endi if $data07 != nchar0 then return -1 endi -if $data12 != null then +if $data12 != NULL then return -1 endi -if $data14 != null then +if $data14 != NULL then return -1 endi -if $data16 != null then +if $data16 != NULL then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi if $data08 != 5 then @@ -341,7 +341,7 @@ endi if $data07 != nchar0 then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi @@ -359,16 +359,16 @@ endi if $data01 != 0 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi if $data09 != 5 then return -1 endi -if $data12 != null then +if $data12 != NULL then return -1 endi if $data19 != 5 then @@ -386,17 +386,17 @@ endi ## NULL fill print fill(NULL) -sql select max(c1), min(c2), avg(c3), sum(c4), count(c5), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 4 interval(5m) fill(value, null) group by t1 limit 5 +sql select max(c1), min(c2), avg(c3), sum(c4), count(c5), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 4 interval(5m) fill(value, NULL) group by t1 limit 5 if $rows != 25 then return -1 endi if $data01 != 0 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi if $data06 != 1 then @@ -405,16 +405,16 @@ endi if $data09 != 5 then return -1 endi -if $data11 != null then +if $data11 != NULL then return -1 endi -if $data12 != null then +if $data12 != NULL then return -1 endi if $data19 != 5 then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi if $data59 != 6 then diff --git a/tests/script/general/parser/first_last_query.sim b/tests/script/general/parser/first_last_query.sim index 2a10e09db4..17e9d3502d 100644 --- a/tests/script/general/parser/first_last_query.sim +++ b/tests/script/general/parser/first_last_query.sim @@ -40,27 +40,27 @@ print data03 = $data03 if $data03 != 0.00000 then return -1 endi -#if $data04 != null then +#if $data04 != NULL then if $data04 != 0.000000000 then return -1 endi -#if $data05 != null then +#if $data05 != NULL then if $data05 != 0 then return -1 endi -#if $data06 != null then +#if $data06 != NULL then if $data06 != 0 then return -1 endi -#if $data07 != null then +#if $data07 != NULL then if $data07 != 1 then return -1 endi -#if $data08 != null then +#if $data08 != NULL then if $data08 != BINARY then return -1 endi -#if $data09 != null then +#if $data09 != NULL then if $data09 != NCHAR then return -1 endi diff --git a/tests/script/general/parser/insert_tb.sim b/tests/script/general/parser/insert_tb.sim index 201bb28786..4f2c5fcc78 100644 --- a/tests/script/general/parser/insert_tb.sim +++ b/tests/script/general/parser/insert_tb.sim @@ -218,10 +218,10 @@ if $data46 != @quoted double@ then return -1 endi -# case: support null char of the binary field [TBASE-660] -sql create table nullb (ts timestamp, c1 binary(20), c2 binary(20), c3 float) -sql insert into nullb values ('2018-09-17 09:00:00.000', '', '', 3.746) -sql select * from nullb +# case: support NULL char of the binary field [TBASE-660] +sql create table NULLb (ts timestamp, c1 binary(20), c2 binary(20), c3 float) +sql insert into NULLb values ('2018-09-17 09:00:00.000', '', '', 3.746) +sql select * from NULLb if $rows != 1 then return -1 endi diff --git a/tests/script/general/parser/interp_test.sim b/tests/script/general/parser/interp_test.sim index 03e6997321..3e6d5de85b 100644 --- a/tests/script/general/parser/interp_test.sim +++ b/tests/script/general/parser/interp_test.sim @@ -87,7 +87,7 @@ $tb = $tbPrefix . 0 ### illegal queries on a table sql_error select interp(ts), c1 from $tb where ts = $ts0 sql_error select interp(ts) from $tb where ts >= $ts0 - sql_error select interp(ts), max(c1), min(c2), count(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(null) + sql_error select interp(ts), max(c1), min(c2), count(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(NULL) ### interp from tb + fill $t = $ts0 + 1000 @@ -107,7 +107,7 @@ $tb = $tbPrefix . 0 return -1 endi - ## fill(null) + ## fill(NULL) $t = $tsu - 1000 sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from $tb where ts = $t fill(value, NULL) order by ts asc if $rows != 1 then @@ -116,31 +116,31 @@ $tb = $tbPrefix . 0 if $data00 != @18-11-25 19:29:59.000@ then return -1 endi - if $data01 != null then + if $data01 != NULL then return -1 endi - if $data02 != null then + if $data02 != NULL then return -1 endi - if $data03 != null then + if $data03 != NULL then return -1 endi - if $data04 != null then + if $data04 != NULL then return -1 endi - if $data05 != null then + if $data05 != NULL then return -1 endi - if $data06 != null then + if $data06 != NULL then return -1 endi - if $data07 != null then + if $data07 != NULL then return -1 endi - if $data08 != null then + if $data08 != NULL then return -1 endi - if $data09 != null then + if $data09 != NULL then return -1 endi @@ -209,7 +209,7 @@ $tb = $tbPrefix . 0 if $data01 != 0 then return -1 endi - if $data02 != null then + if $data02 != NULL then return -1 endi if $data03 != 0.00000 then @@ -254,13 +254,13 @@ $tb = $tbPrefix . 0 if $data06 != 0 then return -1 endi - if $data07 != null then + if $data07 != NULL then return -1 endi - if $data08 != null then + if $data08 != NULL then return -1 endi - if $data09 != null then + if $data09 != NULL then return -1 endi # columns contain NULL values @@ -276,13 +276,13 @@ $tb = $tbPrefix . 0 if $data01 != 0 then return -1 endi - if $data02 != null then + if $data02 != NULL then return -1 endi if $data03 != 0.00167 then return -1 endi - if $data04 != null then + if $data04 != NULL then return -1 endi if $data05 != 0 then @@ -291,13 +291,13 @@ $tb = $tbPrefix . 0 if $data06 != 0 then return -1 endi - if $data07 != null then + if $data07 != NULL then return -1 endi - if $data08 != null then + if $data08 != NULL then return -1 endi - if $data09 != null then + if $data09 != NULL then return -1 endi @@ -346,13 +346,13 @@ $tb = $tbPrefix . 0 if $data01 != 0 then return -1 endi - if $data02 != null then + if $data02 != NULL then return -1 endi if $data03 != 0.00000 then return -1 endi - if $data04 != null then + if $data04 != NULL then return -1 endi if $data05 != 0 then @@ -413,10 +413,10 @@ $tb = $tbPrefix . 0 if $data07 != 1 then return -1 endi - if $data08 != null then + if $data08 != NULL then return -1 endi - if $data09 != null then + if $data09 != NULL then return -1 endi @@ -454,7 +454,7 @@ $tb = $tbPrefix . 0 if $data09 != nchar0 then return -1 endi - # table has null columns + # table has NULL columns sql select interp(ts), interp(c1), interp(c2), interp(c3), interp(c4), interp(c5), interp(c6), interp(c7), interp(c8), interp(c9) from intp_tb3 where ts = $ts0 fill(value, -1, -2, -3) if $rows != 1 then return -1 @@ -465,13 +465,13 @@ $tb = $tbPrefix . 0 if $data01 != 0 then return -1 endi - if $data02 != null then + if $data02 != NULL then return -1 endi if $data03 != 0.00000 then return -1 endi - if $data04 != null then + if $data04 != NULL then return -1 endi @@ -521,10 +521,10 @@ $tb = $tbPrefix . 0 if $data08 != intp_tb0 then return -1 endi - if $data22 != null then + if $data22 != NULL then return -1 endi - if $data24 != null then + if $data24 != NULL then return -1 endi if $data28 != intp_tb2 then @@ -558,51 +558,51 @@ $tb = $tbPrefix . 0 if $data21 != 0 then return -1 endi - if $data22 != null then + if $data22 != NULL then return -1 endi - if $data24 != null then + if $data24 != NULL then return -1 endi ## interp(*) from stb + group by + fill(none) $t = $ts0 + 1000 - sql select interp(*) from $stb where ts = $t fill(null) group by tbname + sql select interp(*) from $stb where ts = $t fill(NULL) group by tbname if $rows != $tbNum then return -1 endi if $data00 != @18-09-17 09:00:01.000@ then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi -if $data12 != null then +if $data12 != NULL then return -1 endi -if $data23 != null then +if $data23 != NULL then return -1 endi -if $data34 != null then +if $data34 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data16 != null then +if $data16 != NULL then return -1 endi -if $data27 != null then +if $data27 != NULL then return -1 endi -if $data38 != null then +if $data38 != NULL then return -1 endi -if $data09 != null then +if $data09 != NULL then return -1 endi -sql select interp(*) from $stb where ts = $ts0 fill(null) group by tbname +sql select interp(*) from $stb where ts = $ts0 fill(NULL) group by tbname print $rows if $rows != 4 then @@ -619,10 +619,10 @@ endi if $data21 != 0 then return -1 endi -if $data22 != null then +if $data22 != NULL then return -1 endi -if $data24 != null then +if $data24 != NULL then return -1 endi @@ -670,13 +670,13 @@ endi if $data21 != 0 then return -1 endi - if $data22 != null then + if $data22 != NULL then return -1 endi if $data23 != 0.00000 then return -1 endi - if $data24 != null then + if $data24 != NULL then return -1 endi if $data25 != 0 then @@ -724,13 +724,13 @@ endi if $data06 != 0 then return -1 endi - if $data07 != null then + if $data07 != NULL then return -1 endi - if $data08 != null then + if $data08 != NULL then return -1 endi - if $data09 != null then + if $data09 != NULL then return -1 endi if $data20 != @18-09-17 09:00:01.000@ then @@ -739,13 +739,13 @@ endi if $data21 != 0 then return -1 endi - if $data22 != null then + if $data22 != NULL then return -1 endi if $data23 != 0.00167 then return -1 endi - if $data24 != null then + if $data24 != NULL then return -1 endi if $data25 != 0 then @@ -754,13 +754,13 @@ endi if $data26 != 0 then return -1 endi - if $data27 != null then + if $data27 != NULL then return -1 endi - if $data28 != null then + if $data28 != NULL then return -1 endi - if $data29 != null then + if $data29 != NULL then return -1 endi @@ -796,10 +796,10 @@ endi if $data07 != 1 then return -1 endi - if $data08 != null then + if $data08 != NULL then return -1 endi - if $data09 != null then + if $data09 != NULL then return -1 endi if $data20 != @18-09-17 09:00:01.000@ then @@ -826,9 +826,9 @@ endi if $data27 != 1 then return -1 endi - if $data28 != null then + if $data28 != NULL then return -1 endi - if $data29 != null then + if $data29 != NULL then return -1 endi diff --git a/tests/script/general/parser/lastrow_query.sim b/tests/script/general/parser/lastrow_query.sim index 3ff0426dcd..a5e003fb65 100644 --- a/tests/script/general/parser/lastrow_query.sim +++ b/tests/script/general/parser/lastrow_query.sim @@ -27,7 +27,7 @@ endi if $data01 != 1439 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi if $data03 != 1439.00000 then diff --git a/tests/script/general/parser/limit1_stb.sim b/tests/script/general/parser/limit1_stb.sim index b9ba90ef50..e69d6ab14f 100644 --- a/tests/script/general/parser/limit1_stb.sim +++ b/tests/script/general/parser/limit1_stb.sim @@ -62,13 +62,13 @@ endi if $data01 != 9 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi if $data03 != 9.00000 then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi if $data05 != 9 then @@ -130,13 +130,13 @@ endi if $data11 != 0 then return -1 endi -if $data12 != null then +if $data12 != NULL then return -1 endi if $data13 != 0.00000 then return -1 endi -if $data14 != null then +if $data14 != NULL then return -1 endi if $data15 != 0 then @@ -261,13 +261,13 @@ endi if $data01 != 0 then return -1 endi -if $data12 != null then +if $data12 != NULL then return -1 endi if $data23 != 2.00000 then return -1 endi -if $data34 != null then +if $data34 != NULL then return -1 endi if $data45 != 4 then @@ -428,7 +428,7 @@ endi if $data26 != 1 then return -1 endi -if $data31 != null then +if $data31 != NULL then return -1 endi if $data42 != 4.500000000 then @@ -458,7 +458,7 @@ endi if $data00 != 9 then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi if $data12 != 4.500000000 then diff --git a/tests/script/general/parser/limit1_tb.sim b/tests/script/general/parser/limit1_tb.sim index a9484d10db..8ed21a47e6 100644 --- a/tests/script/general/parser/limit1_tb.sim +++ b/tests/script/general/parser/limit1_tb.sim @@ -111,16 +111,16 @@ endi if $data09 != nchar0 then return -1 endi -if $data11 != null then +if $data11 != NULL then return -1 endi -if $data12 != null then +if $data12 != NULL then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi -if $data14 != null then +if $data14 != NULL then return -1 endi @@ -543,7 +543,7 @@ endi if $data14 != 8.000000000 then return -1 endi -if $data21 != null then +if $data21 != NULL then return -1 endi @@ -613,7 +613,7 @@ endi if $data21 != 7.000000000 then return -1 endi -if $data31 != null then +if $data31 != NULL then return -1 endi sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 diff --git a/tests/script/general/parser/limit2_query.sim b/tests/script/general/parser/limit2_query.sim index d5b4d3e5ff..57cd13abee 100644 --- a/tests/script/general/parser/limit2_query.sim +++ b/tests/script/general/parser/limit2_query.sim @@ -166,13 +166,13 @@ endi if $data47 != 1 then return -1 endi -if $data57 != null then +if $data57 != NULL then return -1 endi if $data68 != binary3 then return -1 endi -if $data79 != null then +if $data79 != NULL then return -1 endi @@ -216,10 +216,10 @@ endi if $data09 != nchar5 then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi -if $data19 != null then +if $data19 != NULL then return -1 endi if $data16 != -2.000000000 then @@ -269,10 +269,10 @@ endi if $data27 != 1 then return -1 endi -if $data38 != null then +if $data38 != NULL then return -1 endi -if $data49 != null then +if $data49 != NULL then return -1 endi diff --git a/tests/script/general/parser/limit_stb.sim b/tests/script/general/parser/limit_stb.sim index 3e3c75ddac..c6a3766b7d 100644 --- a/tests/script/general/parser/limit_stb.sim +++ b/tests/script/general/parser/limit_stb.sim @@ -117,13 +117,13 @@ endi if $data01 != 9 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi if $data03 != 9.00000 then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi if $data05 != 9 then @@ -185,13 +185,13 @@ endi if $data11 != 0 then return -1 endi -if $data12 != null then +if $data12 != NULL then return -1 endi if $data13 != 0.00000 then return -1 endi -if $data14 != null then +if $data14 != NULL then return -1 endi if $data15 != 0 then @@ -405,7 +405,7 @@ endi if $data28 != 4 then return -1 endi -if $data31 != null then +if $data31 != NULL then return -1 endi if $data47 != nchar0 then @@ -427,7 +427,7 @@ endi if $data00 != 9 then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi if $data02 != 4.500000000 then @@ -726,16 +726,16 @@ endi if $data00 != @18-09-17 09:10:00.000@ then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi if $data09 != 5 then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi if $data19 != 5 then @@ -747,13 +747,13 @@ endi if $data24 != 0 then return -1 endi -if $data25 != null then +if $data25 != NULL then return -1 endi -if $data26 != null then +if $data26 != NULL then return -1 endi -if $data27 != null then +if $data27 != NULL then return -1 endi if $data28 != 1 then diff --git a/tests/script/general/parser/limit_tb.sim b/tests/script/general/parser/limit_tb.sim index 8fee85cece..00d49b556f 100644 --- a/tests/script/general/parser/limit_tb.sim +++ b/tests/script/general/parser/limit_tb.sim @@ -111,16 +111,16 @@ endi if $data09 != nchar0 then return -1 endi -if $data11 != null then +if $data11 != NULL then return -1 endi -if $data12 != null then +if $data12 != NULL then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi -if $data14 != null then +if $data14 != NULL then return -1 endi @@ -537,7 +537,7 @@ endi if $data14 != 8.000000000 then return -1 endi -if $data21 != null then +if $data21 != NULL then return -1 endi @@ -554,7 +554,7 @@ endi if $data21 != 9 then return -1 endi -if $data31 != null then +if $data31 != NULL then return -1 endi @@ -574,7 +574,7 @@ endi if $data31 != 9 then return -1 endi -if $data41 != null then +if $data41 != NULL then return -1 endi sql select sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1 @@ -590,7 +590,7 @@ endi if $data21 != 9 then return -1 endi -if $data31 != null then +if $data31 != NULL then return -1 endi @@ -607,7 +607,7 @@ endi if $data21 != 7.000000000 then return -1 endi -if $data31 != null then +if $data31 != NULL then return -1 endi sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1 @@ -623,7 +623,7 @@ endi if $data21 != 9.000000000 then return -1 endi -if $data31 != null then +if $data31 != NULL then return -1 endi diff --git a/tests/script/general/parser/null_char.sim b/tests/script/general/parser/null_char.sim index ae402a477d..e4f6c5f849 100644 --- a/tests/script/general/parser/null_char.sim +++ b/tests/script/general/parser/null_char.sim @@ -9,57 +9,57 @@ system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect -print ========== null_char.sim +print ========== NULL_char.sim $db = db sql drop database if exists $db sql create database $db sql use $db -#### case 0: field null, or 'null' +#### case 0: field NULL, or 'NULL' sql create table mt1 (ts timestamp, col1 int, col2 bigint, col3 float, col4 double, col5 binary(8), col6 bool, col7 smallint, col8 tinyint, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag4 bigint, tag5 bool, tag6 float) -sql create table st1 using mt1 tags (null, 'null', 100, 1000, 'false', 9.123) +sql create table st1 using mt1 tags (NULL, 'NULL', 100, 1000, 'false', 9.123) sql insert into st1 values ('2019-01-01 09:00:00.000', 123, -123, 3.0, 4.0, 'binary', true, 1000, 121, 'nchar') sql insert into st1 values ('2019-01-01 09:00:01.000', '456', '456', '3.33', '4.444', 'binary', 'true', '1001', '122', 'nchar') -sql insert into st1 values ('2019-01-01 09:00:02.000', null, null, null, null, null, null, null, null, null) -sql insert into st1 values ('2019-01-01 09:00:03.000', null, null, null, null, 'null', 'null', 2002, 127, 'null') +sql insert into st1 values ('2019-01-01 09:00:02.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) +sql insert into st1 values ('2019-01-01 09:00:03.000', NULL, NULL, NULL, NULL, 'NULL', 'NULL', 2002, 127, 'NULL') sql select * from mt1 if $rows != 4 then return -1 endi -if $data21 != null then +if $data21 != NULL then return -1 endi -if $data22 != null then +if $data22 != NULL then return -1 endi -if $data23 != null then +if $data23 != NULL then return -1 endi -if $data24 != null then +if $data24 != NULL then return -1 endi -if $data25 != null then +if $data25 != NULL then return -1 endi -if $data26 != null then +if $data26 != NULL then return -1 endi -if $data27 != null then +if $data27 != NULL then return -1 endi -if $data28 != null then +if $data28 != NULL then return -1 endi -if $data29 != null then +if $data29 != NULL then return -1 endi -if $data31 != null then +if $data31 != NULL then return -1 endi -if $data32 != null then +if $data32 != NULL then return -1 endi #if $data33 != 0.00000 then @@ -70,20 +70,20 @@ endi # print === expect 0.00000, actually $data34 # return -1 #endi -if $data35 != null then +if $data35 != NULL then return -1 endi -if $data36 != null then +if $data36 != NULL then return -1 endi -if $data39 != null then +if $data39 != NULL then return -1 endi -#### case 1: tag null, or 'null' +#### case 1: tag NULL, or 'NULL' sql create table mt2 (ts timestamp, col1 int, col3 float, col5 binary(8), col6 bool, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag5 bool) -sql create table st2 using mt2 tags (null, 'null', 102, 'true') +sql create table st2 using mt2 tags (NULL, 'NULL', 102, 'true') sql describe st2 if $rows != 10 then return -1 @@ -92,7 +92,7 @@ if $data63 != NULL then print ==1== expect: NULL, actually: $data63 return -1 endi -if $data73 != null then +if $data73 != NULL then print ==2== expect: NULL, actually: $data73 return -1 endi @@ -127,7 +127,7 @@ endi ### bool: sql_error create table stx using mt2 tags ('NULL', '123aBc', 104, '123') sql_error create table sty using mt2 tags ('NULL', '123aBc', 104, 'xtz') -sql create table st4 using mt2 tags ('NULL', '123aBc', 104, 'null') +sql create table st4 using mt2 tags ('NULL', '123aBc', 104, 'NULL') sql describe st4 if $rows != 10 then return -1 @@ -168,9 +168,9 @@ endi #### case 2: dynamic create table using super table when insert into sql create table mt3 (ts timestamp, col1 int, col3 float, col5 binary(8), col6 bool, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag5 bool) -sql_error insert into st31 using mt3 tags (null, 'null', 102, 'true') values (now+1s, 31, 31, 'bin_31', '123', 'nchar_31') +sql_error insert into st31 using mt3 tags (NULL, 'NULL', 102, 'true') values (now+1s, 31, 31, 'bin_31', '123', 'nchar_31') sql_error insert into st32 using mt3 tags (NULL, 'ABC', 103, 'FALSE') values (now+2s, 32, 32.12345, 'bin_32', 'abc', 'nchar_32') -sql_error insert into st33 using mt3 tags ('NULL', '123aBc', 104, 'null') values (now+3s, 33, 33, 'bin_33', 'false123', 'nchar_33') +sql_error insert into st33 using mt3 tags ('NULL', '123aBc', 104, 'NULL') values (now+3s, 33, 33, 'bin_33', 'false123', 'nchar_33') sql_error insert into st34 using mt3 tags ('NULL', '123aBc', 105, NULL) values (now+4s, 34, 34.12345, 'bin_34', 'true123', 'nchar_34') @@ -214,9 +214,9 @@ sql alter table st41 set tag tag_binary = "" #if $data23 != $tagvalue then # return -1 #endi -sql alter table st41 set tag tag_binary = "null" +sql alter table st41 set tag tag_binary = "NULL" sql describe st41 -if $data23 != null then +if $data23 != NULL then return -1 endi sql alter table st41 set tag tag_binary = NULL @@ -242,9 +242,9 @@ sql alter table st41 set tag tag_nchar = '' #if $data33 != $tagvalue then # return -1 #endi -sql alter table st41 set tag tag_nchar = "null" +sql alter table st41 set tag tag_nchar = "NULL" sql describe st41 -if $data33 != null then +if $data33 != NULL then return -1 endi sql alter table st41 set tag tag_nchar = NULL @@ -279,13 +279,13 @@ sql describe st41 if $data43 != -2000 then return -1 endi -sql alter table st41 set tag tag_int = null +sql alter table st41 set tag tag_int = NULL sql describe st41 if $data43 != NULL then print ==10== expect: NULL, actually: $data43 return -1 endi -sql alter table st41 set tag tag_int = 'null' +sql alter table st41 set tag tag_int = 'NULL' sql_error alter table st41 set tag tag_int = '' sql_error alter table st41 set tag tag_int = abc379 @@ -310,13 +310,13 @@ sql describe st41 if $data53 != true then return -1 endi -sql alter table st41 set tag tag_bool = 'null' +sql alter table st41 set tag tag_bool = 'NULL' sql describe st41 if $data53 != NULL then print ==14== expect: NULL, actually: $data53 return -1 endi -sql alter table st41 set tag tag_bool = null +sql alter table st41 set tag tag_bool = NULL sql describe st41 if $data53 != NULL then return -1 @@ -350,13 +350,13 @@ if $data63 != 54.123455 then print ==11== expect: 54.123455, actually : $data63 return -1 endi -sql alter table st41 set tag tag_float = null +sql alter table st41 set tag tag_float = NULL sql describe st41 if $data63 != NULL then print ==12== expect: NULL, actually : $data63 return -1 endi -sql alter table st41 set tag tag_float = 'null' +sql alter table st41 set tag tag_float = 'NULL' sql describe st41 if $data63 != NULL then print ==17== expect: NULL, actually : $data63 @@ -396,13 +396,13 @@ sql describe st41 if $data73 != -2456.000000 then return -1 endi -sql alter table st41 set tag tag_double = null +sql alter table st41 set tag tag_double = NULL sql describe st41 if $data73 != NULL then print ==13== expect: NULL, actually : $data73 return -1 endi -sql alter table st41 set tag tag_double = 'null' +sql alter table st41 set tag tag_double = 'NULL' sql describe st41 if $data73 != NULL then print ==20== expect: NULL, actually : $data73 @@ -420,7 +420,7 @@ sql create table mt5 (ts timestamp, c1 int) tags (tag_bigint bigint, tag_smallin sql create table st51 using mt5 tags (1, 2, 3) sql alter table st51 set tag tag_bigint = '-379' sql alter table st51 set tag tag_bigint = -2000 -sql alter table st51 set tag tag_bigint = null +sql alter table st51 set tag tag_bigint = NULL sql alter table st51 set tag tag_bigint = 9223372036854775807 sql describe st51 if $data23 != 9223372036854775807 then @@ -439,13 +439,13 @@ endi sql_error alter table st51 set tag tag_bigint = -9223372036854775808 -sql alter table st51 set tag tag_bigint = 'null' +sql alter table st51 set tag tag_bigint = 'NULL' sql_error alter table st51 set tag tag_bigint = '' sql_error alter table st51 set tag tag_bigint = abc379 #### sql alter table st51 set tag tag_smallint = -2000 -sql alter table st51 set tag tag_smallint = null +sql alter table st51 set tag tag_smallint = NULL sql alter table st51 set tag tag_smallint = 32767 sql describe st51 if $data33 != 32767 then @@ -460,13 +460,13 @@ if $data33 != -32767 then endi sql_error alter table st51 set tag tag_smallint = -32768 -sql alter table st51 set tag tag_smallint = 'null' +sql alter table st51 set tag tag_smallint = 'NULL' sql_error alter table st51 set tag tag_smallint = '' sql_error alter table st51 set tag tag_smallint = abc379 #### sql alter table st51 set tag tag_tinyint = -127 -sql alter table st51 set tag tag_tinyint = null +sql alter table st51 set tag tag_tinyint = NULL sql alter table st51 set tag tag_tinyint = 127 sql describe st51 if $data43 != 127 then @@ -479,7 +479,7 @@ if $data43 != -127 then endi sql_error alter table st51 set tag tag_tinyint = '-128' sql_error alter table st51 set tag tag_tinyint = 128 -sql alter table st51 set tag tag_tinyint = 'null' +sql alter table st51 set tag tag_tinyint = 'NULL' sql_error alter table st51 set tag tag_tinyint = '' sql_error alter table st51 set tag tag_tinyint = abc379 diff --git a/tests/script/general/parser/projection_limit_offset.sim b/tests/script/general/parser/projection_limit_offset.sim index d990a79628..4b10694190 100644 --- a/tests/script/general/parser/projection_limit_offset.sim +++ b/tests/script/general/parser/projection_limit_offset.sim @@ -344,11 +344,11 @@ if $data11 != 1 then return -1 endi -if $data12 != null then +if $data12 != NULL then return -1 endi -if $data13 != null then +if $data13 != NULL then return -1 endi diff --git a/tests/script/general/parser/set_tag_vals.sim b/tests/script/general/parser/set_tag_vals.sim index 270b6ed065..de29c28ba3 100644 --- a/tests/script/general/parser/set_tag_vals.sim +++ b/tests/script/general/parser/set_tag_vals.sim @@ -87,7 +87,7 @@ if $rows != 0 then return -1 endi -print ================== set tag to null +print ================== set tag to NULL sql create table stb1_tg (ts timestamp, c1 int) tags(t1 int,t2 bigint,t3 double,t4 float,t5 smallint,t6 tinyint) sql create table stb2_tg (ts timestamp, c1 int) tags(t1 bool,t2 binary(10), t3 nchar(10)) sql create table tb1_tg1 using stb1_tg tags(1,2,3,4,5,6) @@ -195,33 +195,33 @@ sql select * from stb1_tg if $rows != 1 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi sql select * from stb2_tg -if $data02 != null then +if $data02 != NULL then return -1 endi print $data03 -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi diff --git a/tests/script/general/parser/slimit.sim b/tests/script/general/parser/slimit.sim index 7d2d3fc60b..234e31d261 100644 --- a/tests/script/general/parser/slimit.sim +++ b/tests/script/general/parser/slimit.sim @@ -57,7 +57,7 @@ while $i < $tbNum $x = $x + 1 endw $ts = $ts + $delta - sql insert into $tb values ( $ts , null, null, null, null, null, null, null, null, null ) + sql insert into $tb values ( $ts , NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) $i = $i + 1 endw print ====== $db tables created @@ -87,7 +87,7 @@ while $i < $tbNum while $x < $rowNum $xs = $x * $delta $ts = $ts0 + $xs - sql insert into $tb values ( $ts , null , null , null , null , null , null , null , null , null ) + sql insert into $tb values ( $ts , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL ) $x = $x + 1 endw $i = $i + 1 diff --git a/tests/script/general/parser/slimit_query.sim b/tests/script/general/parser/slimit_query.sim index 7735b1b84b..655bc5f8be 100644 --- a/tests/script/general/parser/slimit_query.sim +++ b/tests/script/general/parser/slimit_query.sim @@ -219,10 +219,10 @@ endi if $data13 != -2.000000000 then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi if $data19 != slm_tb6 then @@ -293,10 +293,10 @@ endi if $data13 != -2.000000000 then return -1 endi -if $data17 != null then +if $data17 != NULL then return -1 endi -if $data18 != null then +if $data18 != NULL then return -1 endi if $data19 != slm_tb5 then diff --git a/tests/script/general/parser/timestamp.sim b/tests/script/general/parser/timestamp.sim index ce2b62fcc9..9a1c793909 100644 --- a/tests/script/general/parser/timestamp.sim +++ b/tests/script/general/parser/timestamp.sim @@ -49,7 +49,7 @@ while $i < $tbNum $x = $x + 1 endw $ts = $ts + $delta - sql insert into $tb values ( $ts , null, null ) + sql insert into $tb values ( $ts , NULL, NULL ) $i = $i + 1 endw print ====== $db tables created diff --git a/tests/script/general/parser/where.sim b/tests/script/general/parser/where.sim index c840bcf22e..fb3a0a69e7 100644 --- a/tests/script/general/parser/where.sim +++ b/tests/script/general/parser/where.sim @@ -228,47 +228,47 @@ if $data11 != @19-01-01 09:10:00.000@ then return -1 endi -sql create table tb_where_null (ts timestamp, c1 float, c2 binary(10)) -sql insert into tb_where_null values ('2019-01-01 09:00:00.000', 1, 'val1') -sql insert into tb_where_null values ('2019-01-01 09:00:01.000', NULL, NULL) -sql insert into tb_where_null values ('2019-01-01 09:00:02.000', 2, 'val2') -sql_error select * from tb_where_null where c1 = NULL -sql_error select * from tb_where_null where c1 <> NULL -sql_error select * from tb_where_null where c1 < NULL -sql select * from tb_where_null where c1 = "NULL" +sql create table tb_where_NULL (ts timestamp, c1 float, c2 binary(10)) +sql insert into tb_where_NULL values ('2019-01-01 09:00:00.000', 1, 'val1') +sql insert into tb_where_NULL values ('2019-01-01 09:00:01.000', NULL, NULL) +sql insert into tb_where_NULL values ('2019-01-01 09:00:02.000', 2, 'val2') +sql_error select * from tb_where_NULL where c1 = NULL +sql_error select * from tb_where_NULL where c1 <> NULL +sql_error select * from tb_where_NULL where c1 < NULL +sql select * from tb_where_NULL where c1 = "NULL" if $rows != 0 then return -1 endi -sql select * from tb_where_null where c1 <> "NULL" +sql select * from tb_where_NULL where c1 <> "NULL" if $rows != 2 then return -1 endi -sql select * from tb_where_null where c1 <> "nulL" +sql select * from tb_where_NULL where c1 <> "nulL" if $rows != 2 then return -1 endi -sql select * from tb_where_null where c1 > "NULL" +sql select * from tb_where_NULL where c1 > "NULL" if $rows != 0 then return -1 endi -sql select * from tb_where_null where c1 >= "NULL" +sql select * from tb_where_NULL where c1 >= "NULL" if $rows != 0 then return -1 endi -sql select * from tb_where_null where c2 = "NULL" +sql select * from tb_where_NULL where c2 = "NULL" if $rows != 0 then return -1 endi -sql select * from tb_where_null where c2 <> "NULL" +sql select * from tb_where_NULL where c2 <> "NULL" if $rows != 2 then return -1 endi -sql select * from tb_where_null where c2 <> "nUll" +sql select * from tb_where_NULL where c2 <> "nUll" if $rows != 2 then return -1 endi diff --git a/tests/script/general/stream/metrics_del.sim b/tests/script/general/stream/metrics_del.sim index 025f4cbdc0..c856871e93 100644 --- a/tests/script/general/stream/metrics_del.sim +++ b/tests/script/general/stream/metrics_del.sim @@ -84,12 +84,12 @@ $st = $stPrefix . c3 sql select * from $st print ===> select * from $st print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data01 != null then +if $data01 != NULL then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi diff --git a/tests/script/general/stream/stream_2.sim b/tests/script/general/stream/stream_2.sim index ed45784584..13aac98337 100644 --- a/tests/script/general/stream/stream_2.sim +++ b/tests/script/general/stream/stream_2.sim @@ -185,10 +185,10 @@ print select * from $st => $data01 $data02, $data03 if $data01 != 200 then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi diff --git a/tests/script/general/stream/table_del.sim b/tests/script/general/stream/table_del.sim index 16dc8c2bb1..66fd58308f 100644 --- a/tests/script/general/stream/table_del.sim +++ b/tests/script/general/stream/table_del.sim @@ -79,12 +79,12 @@ $st = $stPrefix . c3 sql select * from $st print ===> select * from $st print ===> $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 -if $data01 != null then +if $data01 != NULL then return -1 endi -if $data02 != null then +if $data02 != NULL then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi diff --git a/tests/script/general/table/int.sim b/tests/script/general/table/int.sim index 5c5b542e0a..81bdcda47d 100644 --- a/tests/script/general/table/int.sim +++ b/tests/script/general/table/int.sim @@ -22,7 +22,7 @@ sql select * from $tb order by ts desc if $rows != 1 then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi @@ -35,7 +35,7 @@ sql select * from $tb order by ts desc if $rows != 2 then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi @@ -58,7 +58,7 @@ sql select * from $tb order by ts desc if $rows != 4 then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi @@ -96,22 +96,22 @@ if $data01 != 2 then endi print =============== step8 -sql insert into $tb values (now+8m, "null") +sql insert into $tb values (now+8m, "NULL") sql select * from $tb order by ts desc if $rows != 8 then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi print =============== step9 -sql insert into $tb values (now+9m, 'null') +sql insert into $tb values (now+9m, 'NULL') sql select * from $tb order by ts desc if $rows != 9 then return -1 endi -if $data01 != null then +if $data01 != NULL then return -1 endi @@ -131,4 +131,4 @@ if $rows != 0 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/tag/add.sim b/tests/script/general/tag/add.sim index 92fa800450..3d4323c401 100644 --- a/tests/script/general/tag/add.sim +++ b/tests/script/general/tag/add.sim @@ -545,7 +545,7 @@ endi if $data04 != 0 then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi diff --git a/tests/script/general/tag/change.sim b/tests/script/general/tag/change.sim index 74431458f9..1b7e643a21 100644 --- a/tests/script/general/tag/change.sim +++ b/tests/script/general/tag/change.sim @@ -394,7 +394,7 @@ endi if $data06 != 6 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -421,7 +421,7 @@ endi if $data06 != 6 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -448,7 +448,7 @@ endi if $data06 != 6 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -475,7 +475,7 @@ endi if $data06 != 6 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -502,7 +502,7 @@ endi if $data06 != 6 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi diff --git a/tests/script/general/tag/commit.sim b/tests/script/general/tag/commit.sim index 1e78628b28..021f49a998 100644 --- a/tests/script/general/tag/commit.sim +++ b/tests/script/general/tag/commit.sim @@ -544,7 +544,7 @@ endi if $data04 != 0 then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi @@ -1054,7 +1054,7 @@ endi if $data04 != 0 then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi diff --git a/tests/script/general/tag/delete.sim b/tests/script/general/tag/delete.sim index ef886d7644..6dd6254d32 100644 --- a/tests/script/general/tag/delete.sim +++ b/tests/script/general/tag/delete.sim @@ -428,7 +428,7 @@ endi if $data02 != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi @@ -452,7 +452,7 @@ endi if $data02 != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi @@ -476,7 +476,7 @@ endi if $data02 != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi @@ -500,7 +500,7 @@ endi if $data02 != 1.000000000 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi @@ -524,10 +524,10 @@ endi if $data02 != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi @@ -554,10 +554,10 @@ endi if $data02 != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi @@ -584,10 +584,10 @@ endi if $data02 != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi @@ -614,10 +614,10 @@ endi if $data02 != 1.000000000 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi @@ -644,13 +644,13 @@ endi if $data02 != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi @@ -683,13 +683,13 @@ endi if $data03 != 4.00000 then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi @@ -722,16 +722,16 @@ endi if $data03 != 4.000000000 then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -771,13 +771,13 @@ endi if $data04 != 5.000000000 then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi diff --git a/tests/script/general/tag/set.sim b/tests/script/general/tag/set.sim index e48db5a7a8..bc7b8ac534 100644 --- a/tests/script/general/tag/set.sim +++ b/tests/script/general/tag/set.sim @@ -338,7 +338,7 @@ endi if $data06 != 11 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -365,7 +365,7 @@ endi if $data06 != 11 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -392,7 +392,7 @@ endi if $data06 != 11 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -419,7 +419,7 @@ endi if $data06 != 11 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -446,7 +446,7 @@ endi if $data06 != 11 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi diff --git a/tests/script/unique/big/balance.sim b/tests/script/unique/big/balance.sim index 3d4d39af53..4eb5772811 100644 --- a/tests/script/unique/big/balance.sim +++ b/tests/script/unique/big/balance.sim @@ -160,7 +160,7 @@ print dnode3 freeVnodes $data3_192.168.0.3 if $data3_192.168.0.1 != 2 then goto show3 endi -if $data3_192.168.0.2 != null then +if $data3_192.168.0.2 != NULL then goto show3 endi if $data3_192.168.0.3 != 2 then @@ -216,7 +216,7 @@ print dnode3 freeVnodes $data3_192.168.0.3 if $data3_192.168.0.1 != 0 then goto show4 endi -if $data3_192.168.0.3 != null then +if $data3_192.168.0.3 != NULL then goto show4 endi diff --git a/tests/script/unique/cluster/balance1.sim b/tests/script/unique/cluster/balance1.sim index 424a80d25a..10e05971d7 100644 --- a/tests/script/unique/cluster/balance1.sim +++ b/tests/script/unique/cluster/balance1.sim @@ -77,7 +77,7 @@ print dnode2 $dnode2Vnodes if $dnode1Vnodes != 2 then return -1 endi -if $dnode2Vnodes != null then +if $dnode2Vnodes != NULL then return -1 endi @@ -146,7 +146,7 @@ print dnode2 $dnode2Vnodes if $dnode1Vnodes != 3 then goto show4 endi -if $dnode2Vnodes != null then +if $dnode2Vnodes != NULL then goto show4 endi @@ -229,7 +229,7 @@ print dnode3 $dnode3Vnodes if $dnode1Vnodes != 3 then goto show8 endi -if $dnode3Vnodes != null then +if $dnode3Vnodes != NULL then goto show8 endi @@ -245,7 +245,7 @@ if $dnode1Role != master then return -1 endi -if $dnode3Role != null then +if $dnode3Role != NULL then return -1 endi diff --git a/tests/script/unique/cluster/balance2.sim b/tests/script/unique/cluster/balance2.sim index 08fdd233e0..d741e03eec 100644 --- a/tests/script/unique/cluster/balance2.sim +++ b/tests/script/unique/cluster/balance2.sim @@ -131,7 +131,7 @@ print dnode3 $dnode3Vnodes if $dnode1Vnodes != 3 then goto show2 endi -if $dnode2Vnodes != null then +if $dnode2Vnodes != NULL then goto show2 endi if $dnode3Vnodes != 3 then @@ -194,7 +194,7 @@ print dnode4 ==> $dnode4Role if $dnode1Role != master then return -1 endi -if $dnode2Role != null then +if $dnode2Role != NULL then return -1 endi if $dnode3Role != slave then @@ -231,7 +231,7 @@ endi if $dnode4Vnodes != 3 then goto show4 endi -if $dnode3Vnodes != null then +if $dnode3Vnodes != NULL then goto show4 endi @@ -248,10 +248,10 @@ print dnode4 ==> $dnode4Role if $dnode1Role != master then return -1 endi -if $dnode2Role != null then +if $dnode2Role != NULL then return -1 endi -if $dnode3Role != null then +if $dnode3Role != NULL then return -1 endi @@ -339,7 +339,7 @@ print dnode4 $dnode4Vnodes $dnode5Vnodes = $data2_5 print dnode5 $dnode5Vnodes -if $dnode1Vnodes != null then +if $dnode1Vnodes != NULL then goto show6 endi if $dnode4Vnodes != 3 then diff --git a/tests/script/unique/cluster/balance3.sim b/tests/script/unique/cluster/balance3.sim index 407adc7f3b..e9847e21da 100644 --- a/tests/script/unique/cluster/balance3.sim +++ b/tests/script/unique/cluster/balance3.sim @@ -110,7 +110,7 @@ endi if $dnode3Vnodes != 3 then goto show1 endi -if $dnode4Vnodes != null then +if $dnode4Vnodes != NULL then goto show1 endi @@ -166,7 +166,7 @@ print dnode4 $dnode4Vnodes if $dnode1Vnodes != 3 then goto show3 endi -if $dnode2Vnodes != null then +if $dnode2Vnodes != NULL then goto show3 endi if $dnode3Vnodes != 3 then @@ -232,7 +232,7 @@ endi if $dnode5Vnodes != 3 then goto show5 endi -if $dnode3Vnodes != null then +if $dnode3Vnodes != NULL then goto show5 endi if $dnode4Vnodes != 3 then @@ -298,7 +298,7 @@ endi if $dnode6Vnodes != 3 then goto show7 endi -if $dnode4Vnodes != null then +if $dnode4Vnodes != NULL then goto show7 endi diff --git a/tests/script/unique/dnode/balance1.sim b/tests/script/unique/dnode/balance1.sim index 79f22c42ff..34d3310394 100644 --- a/tests/script/unique/dnode/balance1.sim +++ b/tests/script/unique/dnode/balance1.sim @@ -103,7 +103,7 @@ print dnode2 openVnodes $data2_2 if $data2_1 != 2 then goto show4 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show4 endi if $rows != 1 then @@ -131,7 +131,7 @@ print dnode3 openVnodes $data2_3 if $data2_1 != 0 then goto show5 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show5 endi if $data2_3 != 2 then @@ -155,7 +155,7 @@ print dnode3 openVnodes $data2_3 if $data2_1 != 0 then return -1 endi -if $data2_2 != null then +if $data2_2 != NULL then return -1 endi if $data2_3 != 3 then @@ -182,7 +182,7 @@ print dnode4 openVnodes $data2_4 if $data2_1 != 0 then goto show7 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show7 endi if $data2_3 != 2 then @@ -210,7 +210,7 @@ print dnode4 openVnodes $data2_4 if $data2_1 != 0 then return -1 endi -if $data2_2 != null then +if $data2_2 != NULL then return -1 endi if $data2_3 != 2 then @@ -240,10 +240,10 @@ print dnode4 openVnodes $data2_4 if $data2_1 != 0 then goto show9 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show9 endi -if $data2_3 != null then +if $data2_3 != NULL then goto show9 endi if $data2_4 != 4 then diff --git a/tests/script/unique/dnode/balance2.sim b/tests/script/unique/dnode/balance2.sim index 4518c42622..9786a854a5 100644 --- a/tests/script/unique/dnode/balance2.sim +++ b/tests/script/unique/dnode/balance2.sim @@ -76,7 +76,7 @@ print dnode3 openVnodes $data2_3 if $data2_1 != 2 then goto show2 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show2 endi if $data2_3 != 2 then @@ -105,7 +105,7 @@ print dnode4 openVnodes $data2_4 if $data2_1 != 0 then goto show3 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show3 endi if $data2_3 != 2 then @@ -132,7 +132,7 @@ print dnode4 openVnodes $data2_4 if $data2_1 != 0 then return -1 endi -if $data2_2 != null then +if $data2_2 != NULL then return -1 endi if $data2_3 != 3 then @@ -163,7 +163,7 @@ print dnode5 openVnodes $data2_5 if $data2_1 != 0 then goto show5 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show5 endi if $data2_3 != 2 then @@ -196,10 +196,10 @@ print dnode5 openVnodes $data2_5 if $data2_1 != 0 then goto show6 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show6 endi -if $data2_3 != null then +if $data2_3 != NULL then goto show6 endi if $data2_4 != 3 then diff --git a/tests/script/unique/dnode/balance3.sim b/tests/script/unique/dnode/balance3.sim index acb0d033d4..6d5bbc77a5 100644 --- a/tests/script/unique/dnode/balance3.sim +++ b/tests/script/unique/dnode/balance3.sim @@ -88,7 +88,7 @@ print dnode4 openVnodes $data2_4 if $data2_1 != 2 then goto show2 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show2 endi if $data2_3 != 2 then @@ -122,7 +122,7 @@ print dnode5 openVnodes $data2_5 if $data2_1 != 0 then goto show3 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show3 endi if $data2_3 != 2 then @@ -162,7 +162,7 @@ print dnode5 openVnodes $data2_5 if $data2_1 != 0 then goto show4 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show4 endi if $data2_3 != 3 then @@ -228,7 +228,7 @@ endi if $data2_6 != 3 then goto show6 endi -if $data2_3 != null then +if $data2_3 != NULL then goto show6 endi if $data2_4 != 3 then diff --git a/tests/script/unique/dnode/balancex.sim b/tests/script/unique/dnode/balancex.sim index d717250a79..4b46db4b49 100644 --- a/tests/script/unique/dnode/balancex.sim +++ b/tests/script/unique/dnode/balancex.sim @@ -132,7 +132,7 @@ print dnode3 openVnodes $data2_3 if $data2_1 != 1 then goto show5 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show5 endi if $data2_3 != 3 then diff --git a/tests/script/unique/dnode/offline1.sim b/tests/script/unique/dnode/offline1.sim index 5e4ab65be3..4d67b5f55c 100644 --- a/tests/script/unique/dnode/offline1.sim +++ b/tests/script/unique/dnode/offline1.sim @@ -63,7 +63,7 @@ print dnode1 $data4_2 if $data4_1 != ready then return -1 endi -if $data4_2 != null then +if $data4_2 != NULL then return -1 endi diff --git a/tests/script/unique/dnode/offline2.sim b/tests/script/unique/dnode/offline2.sim index 2615746e05..6aa85465dd 100644 --- a/tests/script/unique/dnode/offline2.sim +++ b/tests/script/unique/dnode/offline2.sim @@ -90,7 +90,7 @@ sql show dnodes if $data4_1 != ready then goto show4 endi -if $data4_2 != null then +if $data4_2 != NULL then goto show4 endi if $data4_3 != ready then diff --git a/tests/script/unique/dnode/remove1.sim b/tests/script/unique/dnode/remove1.sim index c69c51fa96..d6837d7dfe 100644 --- a/tests/script/unique/dnode/remove1.sim +++ b/tests/script/unique/dnode/remove1.sim @@ -105,7 +105,7 @@ sql show dnodes print dnode1 openVnodes $data2_1 print dnode2 openVnodes $data2_2 print dnode3 openVnodes $data2_3 -if $data2_2 != null then +if $data2_2 != NULL then goto show4 endi @@ -130,7 +130,7 @@ print dnode4 openVnodes $data2_4 if $data2_1 != 4 then goto show5 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show5 endi if $data2_3 != 2 then diff --git a/tests/script/unique/dnode/remove2.sim b/tests/script/unique/dnode/remove2.sim index c9e48d9283..66ebd97722 100644 --- a/tests/script/unique/dnode/remove2.sim +++ b/tests/script/unique/dnode/remove2.sim @@ -106,7 +106,7 @@ sql show dnodes print dnode1 openVnodes $data2_1 print dnode2 openVnodes $data2_2 print dnode3 openVnodes $data2_3 -if $data2_2 != null then +if $data2_2 != NULL then goto show4 endi if $data2_1 != 3 then diff --git a/tests/script/unique/dnode/vnode_clean.sim b/tests/script/unique/dnode/vnode_clean.sim index 6b3c8ebeb2..55abdab2b0 100644 --- a/tests/script/unique/dnode/vnode_clean.sim +++ b/tests/script/unique/dnode/vnode_clean.sim @@ -91,7 +91,7 @@ print dnode2 openVnodes $data2_2 if $data2_1 != 2 then goto show4 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show4 endi if $rows != 1 then @@ -220,7 +220,7 @@ print dnode3 openVnodes $data2_3 if $data2_1 != 4 then goto show9 endi -if $data2_2 != null then +if $data2_2 != NULL then goto show9 endi if $data2_3 != 0 then diff --git a/tests/script/unique/http/opentsdb.sim b/tests/script/unique/http/opentsdb.sim index d1b193173e..1c09dac5b6 100644 --- a/tests/script/unique/http/opentsdb.sim +++ b/tests/script/unique/http/opentsdb.sim @@ -12,7 +12,7 @@ print ============================ dnode1 start print =============== step1 - parse system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/ print $system_content -if $system_content != @{"status":"error","code":1057,"desc":"database name can not be null"}@ then +if $system_content != @{"status":"error","code":1057,"desc":"database name can not be NULL"}@ then return -1 endi @@ -24,7 +24,7 @@ endi system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/ print $system_content -if $system_content != @{"status":"error","code":1057,"desc":"database name can not be null"}@ then +if $system_content != @{"status":"error","code":1057,"desc":"database name can not be NULL"}@ then return -1 endi @@ -129,7 +129,7 @@ endi system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"": "web01"}}]' 127.0.0.1:6020/opentsdb/db/put print $system_content -if $system_content != @{"status":"error","code":1073,"desc":"tag name is null"}@ then +if $system_content != @{"status":"error","code":1073,"desc":"tag name is NULL"}@ then return -1 endi @@ -147,7 +147,7 @@ endi system_content curl -u root:taosdata -d '[{"metric": "sys_cpu","timestamp": 1346846400,"value": 18,"tags": {"host": ""}}]' 127.0.0.1:6020/opentsdb/db/put print $system_content -if $system_content != @{"status":"error","code":1076,"desc":"tag value is null"}@ then +if $system_content != @{"status":"error","code":1076,"desc":"tag value is NULL"}@ then return -1 endi diff --git a/tests/script/unique/metrics/balance_replica1.sim b/tests/script/unique/metrics/balance_replica1.sim index eb50276260..3c4e8b0664 100644 --- a/tests/script/unique/metrics/balance_replica1.sim +++ b/tests/script/unique/metrics/balance_replica1.sim @@ -76,7 +76,7 @@ print dnode2 $dnode2Vnodes if $dnode1Vnodes != 0 then goto show1 endi -if $dnode2Vnodes != null then +if $dnode2Vnodes != NULL then goto show1 endi print =============== step3 start dnode2 diff --git a/tests/script/unique/mnode/mgmt22.sim b/tests/script/unique/mnode/mgmt22.sim index 3275a233ad..ae3c386122 100644 --- a/tests/script/unique/mnode/mgmt22.sim +++ b/tests/script/unique/mnode/mgmt22.sim @@ -100,7 +100,7 @@ endi if $data2_2 != slave then goto show7 endi -if $data3_3 != null then +if $data3_3 != NULL then goto show7 endi diff --git a/tests/script/unique/mnode/mgmt23.sim b/tests/script/unique/mnode/mgmt23.sim index 8c144dd0c4..99d9159573 100644 --- a/tests/script/unique/mnode/mgmt23.sim +++ b/tests/script/unique/mnode/mgmt23.sim @@ -59,7 +59,7 @@ endi if $dnode2Role != slave then return -1 endi -if $dnode3Role != null then +if $dnode3Role != NULL then return -1 endi @@ -78,7 +78,7 @@ print dnode3 ==> $dnode3Role if $dnode1Role != master then return -1 endi -if $dnode2Role != null then +if $dnode2Role != NULL then return -1 endi if $dnode3Role != slave then @@ -106,7 +106,7 @@ print dnode3 ==> $dnode3Role if $dnode1Role != master then return -1 endi -if $dnode2Role != null then +if $dnode2Role != NULL then return -1 endi if $dnode3Role != slave then diff --git a/tests/script/unique/mnode/mgmt25.sim b/tests/script/unique/mnode/mgmt25.sim index 8c8eeba466..ba545f9479 100644 --- a/tests/script/unique/mnode/mgmt25.sim +++ b/tests/script/unique/mnode/mgmt25.sim @@ -59,7 +59,7 @@ endi if $dnode2Role != slave then return -1 endi -if $dnode3Role != null then +if $dnode3Role != NULL then return -1 endi @@ -78,7 +78,7 @@ print dnode3 ==> $dnode3Role if $dnode1Role != master then return -1 endi -if $dnode2Role != null then +if $dnode2Role != NULL then return -1 endi if $dnode3Role != slave then diff --git a/tests/script/unique/mnode/mgmt26.sim b/tests/script/unique/mnode/mgmt26.sim index 373a0abaed..e5ead5bb39 100644 --- a/tests/script/unique/mnode/mgmt26.sim +++ b/tests/script/unique/mnode/mgmt26.sim @@ -59,7 +59,7 @@ endi if $dnode2Role != slave then return -1 endi -if $dnode3Role != null then +if $dnode3Role != NULL then return -1 endi @@ -79,7 +79,7 @@ print dnode3 ==> $dnode3Role if $dnode1Role != master then return -1 endi -if $dnode2Role != null then +if $dnode2Role != NULL then return -1 endi if $dnode3Role != slave then @@ -106,7 +106,7 @@ print dnode3 ==> $dnode3Role if $dnode1Role != master then return -1 endi -if $dnode2Role != null then +if $dnode2Role != NULL then return -1 endi if $dnode3Role != slave then diff --git a/tests/script/unique/mnode/mgmt33.sim b/tests/script/unique/mnode/mgmt33.sim index e3a62a2d22..36b7ba8139 100644 --- a/tests/script/unique/mnode/mgmt33.sim +++ b/tests/script/unique/mnode/mgmt33.sim @@ -18,10 +18,10 @@ print dnode3 ==> $data3_3 if $data2_1 != master then return -1 endi -if $data3_2 != null then +if $data3_2 != NULL then return -1 endi -if $data3_3 != null then +if $data3_3 != NULL then return -1 endi @@ -44,7 +44,7 @@ endi if $dnode2Role != slave then return -1 endi -if $dnode3Role != null then +if $dnode3Role != NULL then return -1 endi @@ -86,7 +86,7 @@ print dnode3 ==> $dnode3Role if $dnode1Role != master then return -1 endi -if $dnode2Role != null then +if $dnode2Role != NULL then return -1 endi if $dnode3Role != slave then @@ -156,7 +156,7 @@ print dnode1 ==> $dnode1Role print dnode2 ==> $dnode2Role print dnode3 ==> $dnode3Role -if $dnode1Role != null then +if $dnode1Role != NULL then return -1 endi #if $dnode2Role != master then diff --git a/tests/script/unique/mnode/mgmt34.sim b/tests/script/unique/mnode/mgmt34.sim index 4409c825c8..1139daea1c 100644 --- a/tests/script/unique/mnode/mgmt34.sim +++ b/tests/script/unique/mnode/mgmt34.sim @@ -22,10 +22,10 @@ print dnode3 ==> $data3_3 if $data2_1 != master then return -1 endi -if $data3_2 != null then +if $data3_2 != NULL then return -1 endi -if $data3_3 != null then +if $data3_3 != NULL then return -1 endi @@ -50,10 +50,10 @@ endi if $dnode2Role != slave then return -1 endi -if $dnode3Role != null then +if $dnode3Role != NULL then return -1 endi -if $dnode4Role != null then +if $dnode4Role != NULL then return -1 endi @@ -81,7 +81,7 @@ endi if $dnode3Role != slave then return -1 endi -if $dnode4Role != null then +if $dnode4Role != NULL then return -1 endi @@ -110,7 +110,7 @@ endi if $dnode3Role != slave then return -1 endi -if $dnode4Role != null then +if $dnode4Role != NULL then return -1 endi @@ -131,7 +131,7 @@ print dnode4 ==> $dnode4Role if $dnode1Role != master then return -1 endi -if $dnode2Role != null then +if $dnode2Role != NULL then return -1 endi if $dnode3Role != slave then @@ -165,7 +165,7 @@ print dnode4 ==> $dnode4Role if $dnode1Role != master then return -1 endi -if $dnode2Role != null then +if $dnode2Role != NULL then return -1 endi if $dnode3Role != slave then @@ -207,7 +207,7 @@ print dnode2 ==> $dnode2Role print dnode3 ==> $dnode3Role print dnode4 ==> $dnode4Role -if $dnode1Role != null then +if $dnode1Role != NULL then return -1 endi if $dnode2Role != slave then diff --git a/tests/script/unique/mnode/mgmtr2.sim b/tests/script/unique/mnode/mgmtr2.sim index 097d510929..aa0f4877fb 100644 --- a/tests/script/unique/mnode/mgmtr2.sim +++ b/tests/script/unique/mnode/mgmtr2.sim @@ -23,10 +23,10 @@ print dnode3 ==> $dnode3Role if $dnode1Role != master then return -1 endi -if $dnode2Role != null then +if $dnode2Role != NULL then return -1 endi -if $dnode3Role != null then +if $dnode3Role != NULL then return -1 endi @@ -71,7 +71,7 @@ endi if $rows != 2 then return -1 endi -if $dnode3Role != null then +if $dnode3Role != NULL then return -1 endi diff --git a/tests/script/unique/stream/metrics_balance.sim b/tests/script/unique/stream/metrics_balance.sim index ff6ca9d1f0..e711baf206 100644 --- a/tests/script/unique/stream/metrics_balance.sim +++ b/tests/script/unique/stream/metrics_balance.sim @@ -192,7 +192,7 @@ print dnode2 $dnode2Vnodes if $dnode1Vnodes != 0 then goto show1 endi -if $dnode2Vnodes != null then +if $dnode2Vnodes != NULL then goto show1 endi diff --git a/tests/script/unique/stream/table_balance.sim b/tests/script/unique/stream/table_balance.sim index 015f9f1f17..7e33005b9b 100644 --- a/tests/script/unique/stream/table_balance.sim +++ b/tests/script/unique/stream/table_balance.sim @@ -129,7 +129,7 @@ print dnode2 $dnode2Vnodes if $dnode1Vnodes != 0 then goto show1 endi -if $dnode2Vnodes != null then +if $dnode2Vnodes != NULL then goto show1 endi diff --git a/tests/script/unique/stream/table_move.sim b/tests/script/unique/stream/table_move.sim index 6589ed941e..54cd3195db 100644 --- a/tests/script/unique/stream/table_move.sim +++ b/tests/script/unique/stream/table_move.sim @@ -163,7 +163,7 @@ print dnode2 $dnode2Vnodes if $dnode1Vnodes != 6 then goto show1 endi -if $dnode2Vnodes != null then +if $dnode2Vnodes != NULL then goto show1 endi @@ -214,7 +214,7 @@ print dnode1 $dnode1Vnodes $dnode2Vnodes = $data3_192.168.0.2 print dnode2 $dnode2Vnodes -if $dnode1Vnodes != null then +if $dnode1Vnodes != NULL then goto show6 endi if $dnode2Vnodes != 6 then diff --git a/tests/script/windows/alter/metrics.sim b/tests/script/windows/alter/metrics.sim index 7cfee695d0..ce003a9836 100644 --- a/tests/script/windows/alter/metrics.sim +++ b/tests/script/windows/alter/metrics.sim @@ -763,7 +763,7 @@ endi if $data21 != INT then return -1 endi -if $data30 != null then +if $data30 != NULL then return -1 endi diff --git a/tests/script/windows/alter/table.sim b/tests/script/windows/alter/table.sim index a05b6559dd..155debda0d 100644 --- a/tests/script/windows/alter/table.sim +++ b/tests/script/windows/alter/table.sim @@ -666,7 +666,7 @@ endi if $data11 != INT then return -1 endi -if $data20 != null then +if $data20 != NULL then return -1 endi diff --git a/tests/script/windows/tag/add.sim b/tests/script/windows/tag/add.sim index b734846686..adcff4f62d 100644 --- a/tests/script/windows/tag/add.sim +++ b/tests/script/windows/tag/add.sim @@ -537,7 +537,7 @@ endi if $data04 != false then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi diff --git a/tests/script/windows/tag/change.sim b/tests/script/windows/tag/change.sim index 201c74c0bf..95a767da49 100644 --- a/tests/script/windows/tag/change.sim +++ b/tests/script/windows/tag/change.sim @@ -386,7 +386,7 @@ endi if $data06 != 6 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -413,7 +413,7 @@ endi if $data06 != 6 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -440,7 +440,7 @@ endi if $data06 != 6 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -467,7 +467,7 @@ endi if $data06 != 6 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -494,7 +494,7 @@ endi if $data06 != 6 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi diff --git a/tests/script/windows/tag/delete.sim b/tests/script/windows/tag/delete.sim index d671b61abe..75702fe9ee 100644 --- a/tests/script/windows/tag/delete.sim +++ b/tests/script/windows/tag/delete.sim @@ -420,7 +420,7 @@ endi if $data02 != true then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi @@ -444,7 +444,7 @@ endi if $data02 != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi @@ -468,7 +468,7 @@ endi if $data02 != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi @@ -492,7 +492,7 @@ endi if $data02 != 1.000000000 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi @@ -516,10 +516,10 @@ endi if $data02 != true then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi @@ -546,10 +546,10 @@ endi if $data02 != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi @@ -576,10 +576,10 @@ endi if $data02 != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi @@ -606,10 +606,10 @@ endi if $data02 != 1.000000000 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi @@ -636,13 +636,13 @@ endi if $data02 != 1 then return -1 endi -if $data03 != null then +if $data03 != NULL then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi @@ -675,13 +675,13 @@ endi if $data03 != 4.0000 then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi @@ -714,16 +714,16 @@ endi if $data03 != 4.000000000 then return -1 endi -if $data04 != null then +if $data04 != NULL then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -763,13 +763,13 @@ endi if $data04 != 5.000000000 then return -1 endi -if $data05 != null then +if $data05 != NULL then return -1 endi -if $data06 != null then +if $data06 != NULL then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi diff --git a/tests/script/windows/tag/set.sim b/tests/script/windows/tag/set.sim index 7f8cf3b0a7..b264164604 100644 --- a/tests/script/windows/tag/set.sim +++ b/tests/script/windows/tag/set.sim @@ -330,7 +330,7 @@ endi if $data06 != 11 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -357,7 +357,7 @@ endi if $data06 != 11 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -384,7 +384,7 @@ endi if $data06 != 11 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -411,7 +411,7 @@ endi if $data06 != 11 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi @@ -438,7 +438,7 @@ endi if $data06 != 11 then return -1 endi -if $data07 != null then +if $data07 != NULL then return -1 endi From fb54c651049af29bddf616dd46e0f458fa6a7210 Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Fri, 8 May 2020 02:43:26 +0000 Subject: [PATCH 19/36] debug change --- src/vnode/src/vnodeMain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 08a68022ea..6ffac08b4e 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -405,7 +405,7 @@ static void vnodeNotifyRole(void *ahandle, int8_t role) { static void vnodeNotifyFileSynced(void *ahandle) { SVnodeObj *pVnode = ahandle; - dTrace("pVnode:%p vgId:%d, data file is synced", pVnode, pVnode->vgId); + vTrace("pVnode:%p vgId:%d, data file is synced", pVnode, pVnode->vgId); // clsoe tsdb, then open tsdb } From eb30aa35c3de03620aea8d635ae17f21c47bce53 Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 8 May 2020 11:51:34 +0800 Subject: [PATCH 20/36] scripts --- src/dnode/src/dnodePeer.c | 2 +- src/vnode/inc/vnodeLog.h | 12 ++++++------ tests/script/general/insert/basic.sim | 15 ++++++++------- tests/script/general/insert/insert_drop.sim | 2 ++ tests/script/general/insert/query_block1_file.sim | 2 ++ .../script/general/insert/query_block1_memory.sim | 1 + tests/script/general/insert/query_block2_file.sim | 1 + .../script/general/insert/query_block2_memory.sim | 2 ++ tests/script/general/insert/query_file_memory.sim | 2 +- tests/script/general/insert/query_multi_file.sim | 1 + tests/script/general/insert/tcp.sim | 7 ++----- tests/script/general/insert/testSuite.sim | 15 ++++++++------- tests/script/jenkins/basic.txt | 13 ++++++++++++- 13 files changed, 47 insertions(+), 28 deletions(-) diff --git a/src/dnode/src/dnodePeer.c b/src/dnode/src/dnodePeer.c index 2d80917aca..b1e5d9fd38 100644 --- a/src/dnode/src/dnodePeer.c +++ b/src/dnode/src/dnodePeer.c @@ -133,7 +133,7 @@ int32_t dnodeInitClient() { return -1; } - dPrint("inter-dndoes rpc client is opened"); + dPrint("inter-dnodes rpc client is opened"); return 0; } diff --git a/src/vnode/inc/vnodeLog.h b/src/vnode/inc/vnodeLog.h index 450220e17f..bd8daae0b6 100644 --- a/src/vnode/inc/vnodeLog.h +++ b/src/vnode/inc/vnodeLog.h @@ -22,19 +22,19 @@ extern "C" { #include "tlog.h" -extern int32_t ddebugFlag; +extern int32_t dDebugFlag; #define dError(...) \ - if (ddebugFlag & DEBUG_ERROR) { \ + if (dDebugFlag & DEBUG_ERROR) { \ taosPrintLog("ERROR DND ", 255, __VA_ARGS__); \ } #define dWarn(...) \ - if (ddebugFlag & DEBUG_WARN) { \ - taosPrintLog("WARN DND ", ddebugFlag, __VA_ARGS__); \ + if (dDebugFlag & DEBUG_WARN) { \ + taosPrintLog("WARN DND ", dDebugFlag, __VA_ARGS__); \ } #define dTrace(...) \ - if (ddebugFlag & DEBUG_TRACE) { \ - taosPrintLog("DND ", ddebugFlag, __VA_ARGS__); \ + if (dDebugFlag & DEBUG_TRACE) { \ + taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); \ } #define dPrint(...) \ { taosPrintLog("DND ", 255, __VA_ARGS__); } diff --git a/tests/script/general/insert/basic.sim b/tests/script/general/insert/basic.sim index ef8d71fd25..ba8cff83fa 100644 --- a/tests/script/general/insert/basic.sim +++ b/tests/script/general/insert/basic.sim @@ -1,6 +1,5 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -29,21 +28,23 @@ while $x < 10 endw print =============== step 2 -sql insert into $tb values (now - 5m , 10) -x error_insert -sql insert into $tb values (now - 6m , 10) -x error_insert -sql insert into $tb values (now - 7m , 10) -x error_insert -sql insert into $tb values (now - 8m , 10) -x error_insert -error_insert: +sql insert into $tb values (now - 5m , 10) +sql insert into $tb values (now - 6m , 10) +sql insert into $tb values (now - 7m , 10) +sql insert into $tb values (now - 8m , 10) sql select * from $tb print $rows points data are retrieved -if $rows != 10 then +if $rows != 14 then return -1 endi sql drop database $db +sleep 1000 sql show databases if $rows != 0 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/insert_drop.sim b/tests/script/general/insert/insert_drop.sim index 04f9415e2f..087b9f6aa9 100644 --- a/tests/script/general/insert/insert_drop.sim +++ b/tests/script/general/insert/insert_drop.sim @@ -75,9 +75,11 @@ sql connect sleep 3000 sql use $db + sql create table tb5 using $stb tags(5) sql select * from tb5 if $rows != 0 then return -1 endi +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/query_block1_file.sim b/tests/script/general/insert/query_block1_file.sim index 5a1298bfdf..6d6daca7b5 100644 --- a/tests/script/general/insert/query_block1_file.sim +++ b/tests/script/general/insert/query_block1_file.sim @@ -193,3 +193,5 @@ sql show databases if $rows != 0 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/query_block1_memory.sim b/tests/script/general/insert/query_block1_memory.sim index 30af2579bc..83509ad5b0 100644 --- a/tests/script/general/insert/query_block1_memory.sim +++ b/tests/script/general/insert/query_block1_memory.sim @@ -175,3 +175,4 @@ if $rows != 0 then return -1 endi +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/query_block2_file.sim b/tests/script/general/insert/query_block2_file.sim index 773602ceb6..34da170a9e 100644 --- a/tests/script/general/insert/query_block2_file.sim +++ b/tests/script/general/insert/query_block2_file.sim @@ -208,3 +208,4 @@ if $rows != 0 then return -1 endi +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/query_block2_memory.sim b/tests/script/general/insert/query_block2_memory.sim index 2c90fe5d12..3f2c97a098 100644 --- a/tests/script/general/insert/query_block2_memory.sim +++ b/tests/script/general/insert/query_block2_memory.sim @@ -170,3 +170,5 @@ sql show databases if $rows != 0 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/query_file_memory.sim b/tests/script/general/insert/query_file_memory.sim index f8de8f5fd6..f923ebed13 100644 --- a/tests/script/general/insert/query_file_memory.sim +++ b/tests/script/general/insert/query_file_memory.sim @@ -206,4 +206,4 @@ if $rows != 0 then return -1 endi - +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/query_multi_file.sim b/tests/script/general/insert/query_multi_file.sim index 81809b51b8..8622fa6f9b 100644 --- a/tests/script/general/insert/query_multi_file.sim +++ b/tests/script/general/insert/query_multi_file.sim @@ -53,3 +53,4 @@ if $rows != 0 then return -1 endi +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/tcp.sim b/tests/script/general/insert/tcp.sim index 9cea0d6866..0bc4c123b8 100644 --- a/tests/script/general/insert/tcp.sim +++ b/tests/script/general/insert/tcp.sim @@ -1,6 +1,5 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -20,7 +19,6 @@ sql create database db sql use db sql create table tb (ts timestamp, test binary(1000)) - $x = 0 while $x < 10000 $ms = $x . s @@ -30,11 +28,10 @@ endw sql select * from tb - -return - sql drop database $db sql show databases if $rows != 0 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/testSuite.sim b/tests/script/general/insert/testSuite.sim index 582351a218..72e4c057c1 100644 --- a/tests/script/general/insert/testSuite.sim +++ b/tests/script/general/insert/testSuite.sim @@ -1,8 +1,9 @@ -#run general/insert/basic.sim +run general/insert/basic.sim #run general/insert/insert_drop.sim -#run general/insert/query_block1_memory.sim -#run general/insert/query_block2_memory.sim -#run general/insert/query_block1_file.sim -#run general/insert/query_block2_file.sim -#run general/insert/query_file_memory.sim -#run general/insert/query_multi_file.sim +run general/insert/query_block1_memory.sim +run general/insert/query_block2_memory.sim +run general/insert/query_block1_file.sim +run general/insert/query_block2_file.sim +run general/insert/query_file_memory.sim +run general/insert/query_multi_file.sim +run general/insert/tcp.sim diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index a9175dab35..c5f8cdcd06 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -50,7 +50,18 @@ cd ../../../debug; make #import -#insert + +./test.sh -f general/insert/basic.sim +#./test.sh -f general/insert/insert_drop.sim +./test.sh -f general/insert/query_block1_memory.sim +./test.sh -f general/insert/query_block2_memory.sim +./test.sh -f general/insert/query_block1_file.sim +./test.sh -f general/insert/query_block2_file.sim +./test.sh -f general/insert/query_file_memory.sim +./test.sh -f general/insert/query_multi_file.sim +./test.sh -f general/insert/tcp.sim + + #metrics #parser #stream From e71466fd638d49424d6f24990ec599dd4536acf1 Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Fri, 8 May 2020 12:10:33 +0800 Subject: [PATCH 21/36] [td-225] fix bugs for data bind insert --- src/client/src/tscParseInsert.c | 35 ++++++++++++----------- src/client/src/tscServer.c | 2 +- src/client/src/tscSubquery.c | 1 - src/client/src/tscUtil.c | 1 + src/common/inc/tdataformat.h | 8 +++--- src/inc/taosdef.h | 3 +- src/query/src/qtokenizer.c | 6 ++-- tests/script/general/parser/create_mt.sim | 22 +++++++------- tests/script/general/parser/create_tb.sim | 2 +- 9 files changed, 43 insertions(+), 37 deletions(-) diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 5401e500bd..65555dba13 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -305,10 +305,8 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload, case TSDB_DATA_TYPE_BINARY: // binary data cannot be null-terminated char string, otherwise the last char of the string is lost if (pToken->type == TK_NULL) { - *(int16_t*) payload = sizeof(int8_t); - payload += VARSTR_HEADER_SIZE; - - *payload = TSDB_DATA_BINARY_NULL; + varDataSetLen(payload, sizeof(int8_t)); + *(uint8_t*) varDataVal(payload) = TSDB_DATA_BINARY_NULL; } else { // too long values will return invalid sql, not be truncated automatically if (pToken->n + VARSTR_HEADER_SIZE > pSchema->bytes) { //todo refactor return tscInvalidSQLErrMsg(msg, "string data overflow", pToken->z); @@ -321,22 +319,18 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SSQLToken *pToken, char *payload, case TSDB_DATA_TYPE_NCHAR: if (pToken->type == TK_NULL) { - *(int16_t*) payload = sizeof(int32_t); - payload += VARSTR_HEADER_SIZE; - - *(uint32_t*) payload = TSDB_DATA_NCHAR_NULL; + varDataSetLen(payload, sizeof(int32_t)); + *(uint32_t*) varDataVal(payload) = TSDB_DATA_NCHAR_NULL; } else { // if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long' - size_t wcharLength = 0; - if (!taosMbsToUcs4(pToken->z, pToken->n, payload + VARSTR_HEADER_SIZE, pSchema->bytes - VARSTR_HEADER_SIZE, - &wcharLength)) { - + size_t output = 0; + if (!taosMbsToUcs4(pToken->z, pToken->n, varDataVal(payload), pSchema->bytes - VARSTR_HEADER_SIZE, &output)) { char buf[512] = {0}; snprintf(buf, tListLen(buf), "%s", strerror(errno)); return tscInvalidSQLErrMsg(msg, buf, pToken->z); } - *(uint16_t*) payload = (uint16_t) (wcharLength); + varDataSetLen(payload, output); } break; @@ -480,10 +474,19 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[ char *ptr = payload; for (int32_t i = 0; i < spd->numOfCols; ++i) { + if (!spd->hasVal[i]) { // current column do not have any value to insert, set it to null - setNull(ptr, schema[i].type, schema[i].bytes); + if (schema[i].type == TSDB_DATA_TYPE_BINARY) { + varDataSetLen(ptr, sizeof(int8_t)); + *(uint8_t*) varDataVal(ptr) = TSDB_DATA_BINARY_NULL; + } else if (schema[i].type == TSDB_DATA_TYPE_NCHAR) { + varDataSetLen(ptr, sizeof(int32_t)); + *(uint32_t*) varDataVal(ptr) = TSDB_DATA_NCHAR_NULL; + } else { + setNull(ptr, schema[i].type, schema[i].bytes); + } } - + ptr += schema[i].bytes; } @@ -1288,6 +1291,7 @@ int tsParseInsertSql(SSqlObj *pSql) { pCmd->count = 0; pCmd->command = TSDB_SQL_INSERT; + pSql->res.numOfRows = 0; SQueryInfo *pQueryInfo = NULL; tscGetQueryInfoDetailSafely(pCmd, pCmd->clauseIndex, &pQueryInfo); @@ -1300,7 +1304,6 @@ int tsParseInsertSql(SSqlObj *pSql) { return tscInvalidSQLErrMsg(pCmd->payload, "keyword INTO is expected", sToken.z); } - pSql->res.numOfRows = 0; return doParseInsertSql(pSql, pSql->sqlstr + index); } diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index f6e4c66a5a..79916c4991 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2419,7 +2419,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf strncpy(pNewMeterMetaInfo->name, pTableMetaInfo->name, tListLen(pNewMeterMetaInfo->name)); memcpy(pNew->cmd.payload, pSql->cmd.payload, TSDB_DEFAULT_PAYLOAD_SIZE); // tag information if table does not exists. - tscTrace("%p new pSqlObj:%p to get tableMeta", pSql, pNew); + tscTrace("%p new pSqlObj:%p to get tableMeta, auto create:%d", pSql, pNew, pNew->cmd.autoCreated); pNew->fp = tscTableMetaCallBack; pNew->param = pSql; diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 7682287f94..be4d13bd97 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -2024,7 +2024,6 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) { tExprTreeCalcTraverse(pRes->pArithSup->pArithExpr->pExpr, 1, pRes->buffer[i], pRes->pArithSup, TSDB_ORDER_ASC, getArithemicInputSrc); pRes->tsrow[i] = pRes->buffer[i]; -// free(sas); //todo optimization } } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 727c7741f3..0b11305082 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -357,6 +357,7 @@ void tscResetSqlCmdObj(SSqlCmd* pCmd) { pCmd->curSql = NULL; pCmd->msgType = 0; pCmd->parseFinished = 0; + pCmd->autoCreated = 0; taosHashCleanup(pCmd->pTableList); pCmd->pTableList = NULL; diff --git a/src/common/inc/tdataformat.h b/src/common/inc/tdataformat.h index 794d45da6f..ec52bcd2ae 100644 --- a/src/common/inc/tdataformat.h +++ b/src/common/inc/tdataformat.h @@ -28,16 +28,16 @@ extern "C" { #define STR_TO_VARSTR(x, str) do {VarDataLenT __len = strlen(str); \ *(VarDataLenT*)(x) = __len; \ - strncpy((char*)(x) + VARSTR_HEADER_SIZE, (str), __len);} while(0); + strncpy(varDataVal(x), (str), __len);} while(0); #define STR_WITH_MAXSIZE_TO_VARSTR(x, str, _maxs) do {\ - char* _e = stpncpy((char*)(x) + VARSTR_HEADER_SIZE, (str), (_maxs));\ - *(VarDataLenT*)(x) = (_e - (x) - VARSTR_HEADER_SIZE);\ + char* _e = stpncpy(varDataVal(x), (str), (_maxs));\ + varDataSetLen(x, (_e - (x) - VARSTR_HEADER_SIZE));\ } while(0) #define STR_WITH_SIZE_TO_VARSTR(x, str, _size) do {\ *(VarDataLenT*)(x) = (_size); \ - strncpy((char*)(x) + VARSTR_HEADER_SIZE, (str), (_size));\ + strncpy(varDataVal(x), (str), (_size));\ } while(0); // ----------------- TSDB COLUMN DEFINITION diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 5523f2e0f9..09136fa6ce 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -40,9 +40,10 @@ typedef int16_t VarDataLenT; #define varDataLen(v) ((VarDataLenT *)(v))[0] #define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v)) -#define varDataVal(v) ((void *)((char *)v + sizeof(VarDataLenT))) +#define varDataVal(v) ((void *)((char *)v + VARSTR_HEADER_SIZE)) #define varDataCopy(dst, v) memcpy((dst), (void*) (v), varDataTLen(v)) #define varDataLenByData(v) (*(VarDataLenT *)(((char*)(v)) - VARSTR_HEADER_SIZE)) +#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT) (_len)) // this data type is internally used only in 'in' query to hold the values #define TSDB_DATA_TYPE_ARRAY (TSDB_DATA_TYPE_NCHAR + 1) diff --git a/src/query/src/qtokenizer.c b/src/query/src/qtokenizer.c index 2b568cfd5a..22cffafdaa 100644 --- a/src/query/src/qtokenizer.c +++ b/src/query/src/qtokenizer.c @@ -268,11 +268,13 @@ int tSQLKeywordCode(const char* z, int n) { pthread_once(&keywordsHashTableInit, doInitKeywordsTable); char key[512] = {0}; - assert(tListLen(key) >= n); + if (n > tListLen(key)) { // too long token, can not be any other token type + return TK_ID; + } for (int32_t j = 0; j < n; ++j) { if (z[j] >= 'a' && z[j] <= 'z') { - key[j] = (char)(z[j] & 0xDF); // touppercase and set the null-terminated + key[j] = (char)(z[j] & 0xDF); // to uppercase and set the null-terminated } else { key[j] = z[j]; } diff --git a/tests/script/general/parser/create_mt.sim b/tests/script/general/parser/create_mt.sim index 275393f4ac..f87033b71e 100644 --- a/tests/script/general/parser/create_mt.sim +++ b/tests/script/general/parser/create_mt.sim @@ -172,8 +172,8 @@ sql create table $tb using $mt tags (-1) # -x ng_tag_v # return -1 #ng_tag_v: -sql describe $tb -if $data23 != -1 then +sql select tg from $tb +if $data00 != -1 then return -1 endi sql drop table $tb @@ -182,9 +182,9 @@ sql drop table $tb print create_mt.sim unmatched_tag_types sql reset query cache sql create table $tb using $mt tags ('123') -sql describe $tb -#print data23 = $data23 -if $data23 != 123 then +sql select tg from $tb +print data00 = $data00 +if $data00 != 123 then return -1 endi sql drop table $tb @@ -194,14 +194,14 @@ sql_error create table $tb using $mt tags ('abc') sql drop table if exists $tb sql reset query cache sql create table $tb using $mt tags (1e1) -sql describe $tb -if $data23 != 10 then +sql select tg from $tb +if $data00 != 10 then return -1 endi sql drop table $tb sql create table $tb using $mt tags ('1e1') -sql describe $tb -if $data23 != 10 then +sql select tg from $tb +if $data00 != 10 then return -1 endi sql_error create table $tb using $mt tags (2147483649) @@ -234,13 +234,13 @@ $mt2 = mt2 #if $data20 != $mt2 then # return -1 #endi -#sql describe $mt1 +#sql select tg from $mt1 ##print expected $CN_char ##print returned $data10 #if $data10 != $CN_char then # return -1 #endi -#sql describe $mt2 +#sql select tg from $mt2 ##print expected: $CN_char ##print returned: $data20 #if $data20 != $CN_char then diff --git a/tests/script/general/parser/create_tb.sim b/tests/script/general/parser/create_tb.sim index a3a18697a2..c098da226d 100644 --- a/tests/script/general/parser/create_tb.sim +++ b/tests/script/general/parser/create_tb.sim @@ -172,7 +172,7 @@ print ========== create_tb.sim case7: table_name_length_exceeds_limit $tbname32 = _32_aaaabbbbccccddddaaaabbbbcccc $tbname64 = _64_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbcccc $tbname63 = _63_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbccc -$tbname65 = _65_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbcccca +$tbname65 = _65_aaaabbbbccccddddaaaabbbbccccddddaaaabbbbccccddddaaaabbbbcccca1111111111111111111111111111111111aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa sql create table $tbname32 (ts timestamp, col int) sql insert into $tbname32 values (now, 1) sql create table $tbname64 (ts timestamp, col int) From 557064d1f3aae9a05844c1de911170e40a58bbfa Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Fri, 8 May 2020 15:02:55 +0800 Subject: [PATCH 22/36] [td-225] fix bugs for last(*) query --- src/common/src/ttypes.c | 4 ++-- src/inc/taosdef.h | 2 +- src/tsdb/src/tsdbRead.c | 11 ++++------- tests/script/general/parser/first_last.sim | 2 +- tests/script/general/parser/first_last_query.sim | 2 +- tests/script/general/parser/import_commit1.sim | 2 +- tests/script/general/parser/import_commit2.sim | 2 +- tests/script/general/parser/import_commit3.sim | 2 +- 8 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/common/src/ttypes.c b/src/common/src/ttypes.c index 533f992151..626fde3293 100644 --- a/src/common/src/ttypes.c +++ b/src/common/src/ttypes.c @@ -92,9 +92,9 @@ bool isNull(const char *val, int32_t type) { case TSDB_DATA_TYPE_DOUBLE: return *(uint64_t *)val == TSDB_DATA_DOUBLE_NULL; case TSDB_DATA_TYPE_NCHAR: - return *(uint32_t *)val == TSDB_DATA_NCHAR_NULL; + return *(uint32_t*) varDataVal(val) == TSDB_DATA_NCHAR_NULL; case TSDB_DATA_TYPE_BINARY: - return *(uint8_t *)val == TSDB_DATA_BINARY_NULL; + return *(uint8_t *) varDataVal(val) == TSDB_DATA_BINARY_NULL; default: return false; }; diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 09136fa6ce..499f19b76d 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -241,7 +241,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_MULTI_METERMETA_MAX_NUM 100000 // maximum batch size allowed to load metermeta #define TSDB_MIN_CACHE_BLOCK_SIZE 1 -#define TSDB_MAX_CACHE_BLOCK_SIZE 1000000 +#define TSDB_MAX_CACHE_BLOCK_SIZE 10240 // 10GB for each vnode #define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16 #define TSDB_MIN_TOTAL_BLOCKS 2 diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index fc1029dff8..008ad223ed 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -335,11 +335,7 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo pCheckInfo->compSize = compIndex->len; } - // tsdbLoadCompBlocks(fileGroup, compIndex, pCheckInfo->pCompInfo); - STable* pTable = tsdbGetTableByUid(tsdbGetMeta(pQueryHandle->pTsdb), pCheckInfo->tableId.uid); - assert(pTable != NULL); - - tsdbSetHelperTable(&pQueryHandle->rhelper, pTable, pQueryHandle->pTsdb); + tsdbSetHelperTable(&pQueryHandle->rhelper, pCheckInfo->pTableObj, pQueryHandle->pTsdb); tsdbLoadCompInfo(&(pQueryHandle->rhelper), (void *)(pCheckInfo->pCompInfo)); SCompInfo* pCompInfo = pCheckInfo->pCompInfo; @@ -472,6 +468,7 @@ static bool loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock filterDataInDataBlock(pQueryHandle, pCheckInfo, pBlock, sa); } else { // the whole block is loaded in to buffer pQueryHandle->realNumOfRows = pBlock->numOfPoints; + cur->pos = 0; } } else { // query ended in current block @@ -491,6 +488,7 @@ static bool loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock filterDataInDataBlock(pQueryHandle, pCheckInfo, pBlock, sa); } else { pQueryHandle->realNumOfRows = pBlock->numOfPoints; + cur->pos = pBlock->numOfPoints - 1; } } @@ -568,7 +566,7 @@ static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInf SDataBlockInfo blockInfo = getTrueDataBlockInfo(pCheckInfo, pBlock); SDataCols* pCols = pQueryHandle->rhelper.pDataCols[0]; - + int32_t endPos = cur->pos; if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order) && pQueryHandle->window.ekey > blockInfo.window.ekey) { endPos = blockInfo.rows - 1; @@ -612,7 +610,6 @@ static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInf int32_t reqCols = taosArrayGetSize(pQueryHandle->pColumns); for (int32_t i = 0; i < reqCols; ++i) { -// int16_t colId = *(int16_t*)taosArrayGet(sa, i); SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i); int32_t bytes = pCol->info.bytes; diff --git a/tests/script/general/parser/first_last.sim b/tests/script/general/parser/first_last.sim index 8bede7573a..ca709af2fd 100644 --- a/tests/script/general/parser/first_last.sim +++ b/tests/script/general/parser/first_last.sim @@ -21,7 +21,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db rows 400 cache 4096 maxTables 4 +sql create database $db maxrows 400 cache 1 maxTables 4 sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) diff --git a/tests/script/general/parser/first_last_query.sim b/tests/script/general/parser/first_last_query.sim index 2a10e09db4..3cad823dbf 100644 --- a/tests/script/general/parser/first_last_query.sim +++ b/tests/script/general/parser/first_last_query.sim @@ -56,8 +56,8 @@ endi if $data07 != 1 then return -1 endi -#if $data08 != null then if $data08 != BINARY then + print expect BINARY, actual: $data08 return -1 endi #if $data09 != null then diff --git a/tests/script/general/parser/import_commit1.sim b/tests/script/general/parser/import_commit1.sim index 743642f208..fde0698c33 100644 --- a/tests/script/general/parser/import_commit1.sim +++ b/tests/script/general/parser/import_commit1.sim @@ -23,7 +23,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db cache 2048 +sql create database $db cache 16 print ====== create tables sql use $db diff --git a/tests/script/general/parser/import_commit2.sim b/tests/script/general/parser/import_commit2.sim index 9d5cfff672..2c49aa7eca 100644 --- a/tests/script/general/parser/import_commit2.sim +++ b/tests/script/general/parser/import_commit2.sim @@ -22,7 +22,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db cache 2048 +sql create database $db cache 16 print ====== create tables sql use $db diff --git a/tests/script/general/parser/import_commit3.sim b/tests/script/general/parser/import_commit3.sim index 7a1f1e902c..7ed5045b9a 100644 --- a/tests/script/general/parser/import_commit3.sim +++ b/tests/script/general/parser/import_commit3.sim @@ -22,7 +22,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db cache 16384 +sql create database $db cache 16 print ====== create tables sql use $db From 093ccc11a5cf99b06c25add4eef540d507629033 Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 8 May 2020 15:15:23 +0800 Subject: [PATCH 23/36] scripts --- .../alter/cached_schema_after_alter.sim | 2 + tests/script/general/alter/count.sim | 1 + tests/script/general/alter/import.sim | 2 + tests/script/general/alter/insert1.sim | 2 + tests/script/general/alter/insert2.sim | 1 + tests/script/general/alter/metrics.sim | 1 + tests/script/general/alter/table.sim | 1 + tests/script/general/alter/testSuite.sim | 2 +- tests/script/general/cache/new_metrics.sim | 4 +- .../script/general/cache/restart_metrics.sim | 1 + tests/script/general/cache/restart_table.sim | 2 +- tests/script/general/cache/testSuite.sim | 2 +- tests/script/general/column/commit.sim | 4 +- tests/script/general/column/metrics.sim | 2 + tests/script/general/column/table.sim | 2 + tests/script/general/column/testSuite.sim | 5 +- tests/script/general/compress/commitlog.sim | 9 +- tests/script/general/compress/compress.sim | 9 +- tests/script/general/compress/compress2.sim | 9 +- tests/script/general/compress/testSuite.sim | 4 +- tests/script/general/compress/uncompress.sim | 10 +- tests/script/general/compute/avg.sim | 4 +- tests/script/general/compute/bottom.sim | 4 +- tests/script/general/compute/count.sim | 4 +- tests/script/general/compute/diff.sim | 4 +- tests/script/general/compute/diff2.sim | 2 + tests/script/general/compute/first.sim | 4 +- tests/script/general/compute/interval.sim | 4 +- tests/script/general/compute/last.sim | 4 +- tests/script/general/compute/leastsquare.sim | 2 + tests/script/general/compute/max.sim | 4 +- tests/script/general/compute/min.sim | 4 +- tests/script/general/compute/null.sim | 4 +- tests/script/general/compute/percentile.sim | 2 + tests/script/general/compute/stddev.sim | 4 +- tests/script/general/compute/sum.sim | 4 +- tests/script/general/compute/testSuite.sim | 24 +-- tests/script/general/compute/top.sim | 4 +- tests/script/general/db/testSuite.sim | 2 +- tests/script/general/field/2.sim | 14 +- tests/script/general/field/3.sim | 12 +- tests/script/general/field/4.sim | 12 +- tests/script/general/field/5.sim | 12 +- tests/script/general/field/6.sim | 12 +- tests/script/general/field/bigint.sim | 12 +- tests/script/general/field/binary.sim | 12 +- tests/script/general/field/bool.sim | 12 +- tests/script/general/field/double.sim | 12 +- tests/script/general/field/float.sim | 12 +- tests/script/general/field/int.sim | 12 +- tests/script/general/field/single.sim | 12 +- tests/script/general/field/smallint.sim | 12 +- tests/script/general/field/testSuite.sim | 17 +- tests/script/general/field/tinyint.sim | 12 +- tests/script/general/http/testSuite.sim | 4 +- tests/script/general/import/basic.sim | 37 ++-- tests/script/general/import/commit.sim | 18 +- tests/script/general/import/large.sim | 18 +- tests/script/general/import/replica1.sim | 169 +++++++++++------- tests/script/general/import/testSuite.sim | 2 +- tests/script/general/insert/tcp.sim | 6 - tests/script/general/insert/testSuite.sim | 2 +- tests/script/general/metrics/disk.sim | 4 +- tests/script/general/metrics/metrics.sim | 4 +- tests/script/general/metrics/values.sim | 23 +-- tests/script/general/metrics/vnode3.sim | 4 +- tests/script/general/table/testSuite.sim | 12 +- tests/script/general/tag/3.sim | 5 +- tests/script/general/tag/4.sim | 2 + tests/script/general/tag/5.sim | 2 + tests/script/general/tag/6.sim | 2 + tests/script/general/tag/add.sim | 4 +- tests/script/general/tag/bigint.sim | 4 +- tests/script/general/tag/binary.sim | 4 +- tests/script/general/tag/binary_binary.sim | 4 +- tests/script/general/tag/bool.sim | 4 +- tests/script/general/tag/bool_binary.sim | 4 +- tests/script/general/tag/bool_int.sim | 4 +- tests/script/general/tag/change.sim | 4 +- tests/script/general/tag/column.sim | 4 +- tests/script/general/tag/commit.sim | 4 +- tests/script/general/tag/create.sim | 2 + tests/script/general/tag/delete.sim | 4 +- tests/script/general/tag/double.sim | 4 +- tests/script/general/tag/filter.sim | 4 +- tests/script/general/tag/float.sim | 4 +- tests/script/general/tag/int.sim | 4 +- tests/script/general/tag/int_binary.sim | 4 +- tests/script/general/tag/int_float.sim | 4 +- tests/script/general/tag/set.sim | 4 +- tests/script/general/tag/smallint.sim | 4 +- tests/script/general/tag/testSuite.sim | 36 ++-- tests/script/general/tag/tinyint.sim | 4 +- tests/script/general/user/testSuite.sim | 2 +- tests/script/general/vector/metrics_field.sim | 4 +- tests/script/general/vector/metrics_mix.sim | 4 +- tests/script/general/vector/metrics_query.sim | 4 +- tests/script/general/vector/metrics_tag.sim | 4 +- tests/script/general/vector/metrics_time.sim | 4 +- tests/script/general/vector/multi.sim | 5 +- tests/script/general/vector/single.sim | 4 +- tests/script/general/vector/table_field.sim | 4 +- tests/script/general/vector/table_mix.sim | 4 +- tests/script/general/vector/table_query.sim | 4 +- tests/script/general/vector/table_time.sim | 4 +- tests/script/general/vector/testSuite.sim | 17 +- tests/script/jenkins/basic.txt | 147 ++++++++++++--- tests/script/unique/big/balance.sim | 9 + tests/script/unique/big/maxvnodes.sim | 9 + tests/script/unique/big/tcp.sim | 11 +- tests/script/unique/big/testSuite.sim | 6 +- tests/script/unique/cluster/testSuite.sim | 2 +- tests/script/unique/db/commit.sim | 11 +- tests/script/unique/db/delete.sim | 9 + tests/script/unique/db/delete_part.sim | 13 +- tests/script/unique/db/testSuite.sim | 6 +- tests/script/unique/dnode/remove1.sim | 9 + tests/script/unique/dnode/remove2.sim | 9 + tests/script/unique/dnode/testSuite.sim | 6 +- tests/script/unique/dnode/vnode_clean.sim | 8 + tests/script/unique/http/opentsdb.sim | 11 +- tests/script/unique/http/testSuite.sim | 2 +- tests/script/unique/import/replica2.sim | 47 +++-- tests/script/unique/import/replica3.sim | 166 ++++++++++------- tests/script/unique/import/testSuite.sim | 4 +- .../unique/metrics/balance_replica1.sim | 11 +- tests/script/unique/metrics/dnode2.sim | 11 +- tests/script/unique/metrics/dnode2_stop.sim | 11 +- tests/script/unique/metrics/dnode3.sim | 11 +- .../script/unique/metrics/replica2_dnode4.sim | 11 +- .../script/unique/metrics/replica2_vnode3.sim | 11 +- .../script/unique/metrics/replica3_dnode6.sim | 11 +- .../script/unique/metrics/replica3_vnode3.sim | 11 +- tests/script/unique/metrics/testSuite.sim | 12 +- tests/script/unique/mnode/mgmtr2.sim | 11 +- tests/script/unique/mnode/secondIp.sim | 11 +- tests/script/unique/table/delete_part.sim | 15 +- tests/script/unique/table/testSuite.sim | 2 +- tests/script/unique/vnode/commit.sim | 9 +- tests/script/unique/vnode/many.sim | 9 +- tests/script/unique/vnode/replica2_basic.sim | 11 +- tests/script/unique/vnode/replica2_repeat.sim | 9 +- tests/script/unique/vnode/replica3_repeat.sim | 9 +- tests/script/unique/vnode/replica3_vgroup.sim | 10 +- tests/script/unique/vnode/testSuite.sim | 11 +- 145 files changed, 1004 insertions(+), 530 deletions(-) diff --git a/tests/script/general/alter/cached_schema_after_alter.sim b/tests/script/general/alter/cached_schema_after_alter.sim index d81720a1da..921cfee3d1 100644 --- a/tests/script/general/alter/cached_schema_after_alter.sim +++ b/tests/script/general/alter/cached_schema_after_alter.sim @@ -117,3 +117,5 @@ endi if $data12 != 2 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/count.sim b/tests/script/general/alter/count.sim index a6a2a13ef7..a42fde74b7 100644 --- a/tests/script/general/alter/count.sim +++ b/tests/script/general/alter/count.sim @@ -264,3 +264,4 @@ if $data00 != 31 then return -1 endi +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/import.sim b/tests/script/general/alter/import.sim index 1771d47298..6129765513 100644 --- a/tests/script/general/alter/import.sim +++ b/tests/script/general/alter/import.sim @@ -47,3 +47,5 @@ sql select count(b) from tb if $data00 != 5 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/insert1.sim b/tests/script/general/alter/insert1.sim index 031cba09e0..4246bdc18e 100644 --- a/tests/script/general/alter/insert1.sim +++ b/tests/script/general/alter/insert1.sim @@ -1148,3 +1148,5 @@ endi if $data78 != 11 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/insert2.sim b/tests/script/general/alter/insert2.sim index 1123fdb790..007060b7f0 100644 --- a/tests/script/general/alter/insert2.sim +++ b/tests/script/general/alter/insert2.sim @@ -681,3 +681,4 @@ if $data62 != NULL then return -1 endi +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/metrics.sim b/tests/script/general/alter/metrics.sim index 55763cf2d4..b346b3b2c0 100644 --- a/tests/script/general/alter/metrics.sim +++ b/tests/script/general/alter/metrics.sim @@ -781,3 +781,4 @@ if $rows != 0 then return -1 endi +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/table.sim b/tests/script/general/alter/table.sim index 9438bed8ab..c6402b45f7 100644 --- a/tests/script/general/alter/table.sim +++ b/tests/script/general/alter/table.sim @@ -684,3 +684,4 @@ if $rows != 0 then return -1 endi +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/testSuite.sim b/tests/script/general/alter/testSuite.sim index 33a926f7b2..cfac68144c 100644 --- a/tests/script/general/alter/testSuite.sim +++ b/tests/script/general/alter/testSuite.sim @@ -1,5 +1,5 @@ -run general/alter/count.sim run general/alter/cached_schema_after_alter.sim +run general/alter/count.sim run general/alter/import.sim run general/alter/insert1.sim run general/alter/insert2.sim diff --git a/tests/script/general/cache/new_metrics.sim b/tests/script/general/cache/new_metrics.sim index 2f7de7f1eb..64170ec67e 100644 --- a/tests/script/general/cache/new_metrics.sim +++ b/tests/script/general/cache/new_metrics.sim @@ -140,6 +140,4 @@ if $data04 != 10 then return -1 endi - - - +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/cache/restart_metrics.sim b/tests/script/general/cache/restart_metrics.sim index 70f53ac69e..dbd15b945f 100644 --- a/tests/script/general/cache/restart_metrics.sim +++ b/tests/script/general/cache/restart_metrics.sim @@ -83,3 +83,4 @@ if $data02 != 3 then return -1 endi +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/cache/restart_table.sim b/tests/script/general/cache/restart_table.sim index 7ea4c24b4d..4e8bc92c10 100644 --- a/tests/script/general/cache/restart_table.sim +++ b/tests/script/general/cache/restart_table.sim @@ -56,4 +56,4 @@ if $data01 != 1 then return -1 endi - +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/cache/testSuite.sim b/tests/script/general/cache/testSuite.sim index bffd4f9633..f09ece89b6 100644 --- a/tests/script/general/cache/testSuite.sim +++ b/tests/script/general/cache/testSuite.sim @@ -1,3 +1,3 @@ +run general/cache/new_metrics.sim run general/cache/restart_table.sim run general/cache/restart_metrics.sim -run general/cache/new_metrics.sim diff --git a/tests/script/general/column/commit.sim b/tests/script/general/column/commit.sim index f8fc85a109..7bc62619f3 100644 --- a/tests/script/general/column/commit.sim +++ b/tests/script/general/column/commit.sim @@ -151,4 +151,6 @@ if $data08 != 10 then endi if $data09 != 10 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/column/metrics.sim b/tests/script/general/column/metrics.sim index 23fbbfdbf5..401a4ae54e 100644 --- a/tests/script/general/column/metrics.sim +++ b/tests/script/general/column/metrics.sim @@ -215,3 +215,5 @@ endi if $data09 != 20 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/column/table.sim b/tests/script/general/column/table.sim index af357eea86..8e9c44fc46 100644 --- a/tests/script/general/column/table.sim +++ b/tests/script/general/column/table.sim @@ -211,3 +211,5 @@ endi if $data07 != 2.872281323 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/column/testSuite.sim b/tests/script/general/column/testSuite.sim index 2a0b9efd45..f60d197e95 100644 --- a/tests/script/general/column/testSuite.sim +++ b/tests/script/general/column/testSuite.sim @@ -1,4 +1,3 @@ -run general/column/table.sim -run general/column/metrics.sim -run general/column/stream.sim run general/column/commit.sim +run general/column/metrics.sim +run general/column/table.sim diff --git a/tests/script/general/compress/commitlog.sim b/tests/script/general/compress/commitlog.sim index e2c3964e1b..2c69b809d1 100644 --- a/tests/script/general/compress/commitlog.sim +++ b/tests/script/general/compress/commitlog.sim @@ -1,9 +1,8 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 1 -system sh/cfg.sh -n dnode1 -c compression -v 1 +system sh/cfg.sh -n dnode1 -c comp -v 1 system sh/exec.sh -n dnode1 -s start sleep 3000 @@ -88,9 +87,9 @@ endi print =============== step4 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 20000 +sleep 5000 system sh/exec.sh -n dnode1 -s start -sleep 10000 +sleep 3000 print =============== step5 @@ -124,4 +123,4 @@ if $rows != $N then return -1 endi - +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compress/compress.sim b/tests/script/general/compress/compress.sim index 276fba9f8c..bc56227c74 100644 --- a/tests/script/general/compress/compress.sim +++ b/tests/script/general/compress/compress.sim @@ -1,9 +1,8 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c compression -v 1 +system sh/cfg.sh -n dnode1 -c comp -v 1 system sh/exec.sh -n dnode1 -s start sleep 3000 @@ -83,9 +82,9 @@ endi print =============== step4 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 10000 +sleep 5000 system sh/exec.sh -n dnode1 -s start -sleep 10000 +sleep 3000 print =============== step5 @@ -119,4 +118,4 @@ if $rows != $N then return -1 endi - +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compress/compress2.sim b/tests/script/general/compress/compress2.sim index 29d14c2c75..c3b445c04c 100644 --- a/tests/script/general/compress/compress2.sim +++ b/tests/script/general/compress/compress2.sim @@ -1,9 +1,8 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c compression -v 2 +system sh/cfg.sh -n dnode1 -c comp -v 2 system sh/exec.sh -n dnode1 -s start sleep 3000 @@ -83,9 +82,9 @@ endi print =============== step4 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 10000 +sleep 5000 system sh/exec.sh -n dnode1 -s start -sleep 10000 +sleep 3000 print =============== step5 @@ -119,4 +118,4 @@ if $rows != $N then return -1 endi - +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compress/testSuite.sim b/tests/script/general/compress/testSuite.sim index 97c76aec15..3573985c8a 100644 --- a/tests/script/general/compress/testSuite.sim +++ b/tests/script/general/compress/testSuite.sim @@ -1,4 +1,4 @@ -run general/compress/compress.sim -run general/compress/uncompress.sim run general/compress/commitlog.sim run general/compress/compress2.sim +run general/compress/compress.sim +run general/compress/uncompress.sim diff --git a/tests/script/general/compress/uncompress.sim b/tests/script/general/compress/uncompress.sim index a7b8a95d52..8dde7fae34 100644 --- a/tests/script/general/compress/uncompress.sim +++ b/tests/script/general/compress/uncompress.sim @@ -1,9 +1,7 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 -system sh/cfg.sh -n dnode1 -c compression -v 1 +system sh/cfg.sh -n dnode1 -c comp -v 1 system sh/exec.sh -n dnode1 -s start sleep 3000 @@ -83,9 +81,9 @@ endi print =============== step4 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 10000 +sleep 5000 system sh/exec.sh -n dnode1 -s start -sleep 10000 +sleep 3000 print =============== step5 @@ -119,4 +117,4 @@ if $rows != $N then return -1 endi - +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/avg.sim b/tests/script/general/compute/avg.sim index 21dea70071..9a37363a60 100644 --- a/tests/script/general/compute/avg.sim +++ b/tests/script/general/compute/avg.sim @@ -153,4 +153,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/bottom.sim b/tests/script/general/compute/bottom.sim index 241f775f34..592f87651e 100644 --- a/tests/script/general/compute/bottom.sim +++ b/tests/script/general/compute/bottom.sim @@ -94,4 +94,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/count.sim b/tests/script/general/compute/count.sim index bb087c0ffb..aef30c8b6c 100644 --- a/tests/script/general/compute/count.sim +++ b/tests/script/general/compute/count.sim @@ -169,4 +169,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/diff.sim b/tests/script/general/compute/diff.sim index 00f1396319..8a60cd00bc 100644 --- a/tests/script/general/compute/diff.sim +++ b/tests/script/general/compute/diff.sim @@ -86,4 +86,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/diff2.sim b/tests/script/general/compute/diff2.sim index ec23b2481b..53b508ca6f 100644 --- a/tests/script/general/compute/diff2.sim +++ b/tests/script/general/compute/diff2.sim @@ -153,3 +153,5 @@ print =============== clear #if $rows != 0 then # return -1 #endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/first.sim b/tests/script/general/compute/first.sim index 39acb444ab..80f4f53cdb 100644 --- a/tests/script/general/compute/first.sim +++ b/tests/script/general/compute/first.sim @@ -155,4 +155,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/interval.sim b/tests/script/general/compute/interval.sim index f00d39bcef..26f40eda5a 100644 --- a/tests/script/general/compute/interval.sim +++ b/tests/script/general/compute/interval.sim @@ -171,4 +171,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/last.sim b/tests/script/general/compute/last.sim index 779d1f3691..0e92bb6d45 100644 --- a/tests/script/general/compute/last.sim +++ b/tests/script/general/compute/last.sim @@ -154,4 +154,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/leastsquare.sim b/tests/script/general/compute/leastsquare.sim index ebafa2baf5..bbadd849cb 100644 --- a/tests/script/general/compute/leastsquare.sim +++ b/tests/script/general/compute/leastsquare.sim @@ -96,3 +96,5 @@ sql show databases if $rows != 0 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/max.sim b/tests/script/general/compute/max.sim index 5a90739838..4fc760d66d 100644 --- a/tests/script/general/compute/max.sim +++ b/tests/script/general/compute/max.sim @@ -154,4 +154,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/min.sim b/tests/script/general/compute/min.sim index d87ca1ae9b..82a22b642e 100644 --- a/tests/script/general/compute/min.sim +++ b/tests/script/general/compute/min.sim @@ -155,4 +155,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/null.sim b/tests/script/general/compute/null.sim index df9d009f34..cde95ca77f 100644 --- a/tests/script/general/compute/null.sim +++ b/tests/script/general/compute/null.sim @@ -222,4 +222,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/percentile.sim b/tests/script/general/compute/percentile.sim index 5d3f40a6de..dd309c3789 100644 --- a/tests/script/general/compute/percentile.sim +++ b/tests/script/general/compute/percentile.sim @@ -112,3 +112,5 @@ sql show databases if $rows != 0 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/stddev.sim b/tests/script/general/compute/stddev.sim index 4eaba14605..7cea8726a9 100644 --- a/tests/script/general/compute/stddev.sim +++ b/tests/script/general/compute/stddev.sim @@ -93,4 +93,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/sum.sim b/tests/script/general/compute/sum.sim index 79c7bc0762..d05fe8930e 100644 --- a/tests/script/general/compute/sum.sim +++ b/tests/script/general/compute/sum.sim @@ -154,4 +154,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/compute/testSuite.sim b/tests/script/general/compute/testSuite.sim index 5539e08a9d..6cd6badaee 100644 --- a/tests/script/general/compute/testSuite.sim +++ b/tests/script/general/compute/testSuite.sim @@ -1,16 +1,16 @@ -run general/compute/count.sim run general/compute/avg.sim -run general/compute/sum.sim -run general/compute/min.sim -run general/compute/max.sim -run general/compute/first.sim -run general/compute/last.sim -run general/compute/stddev.sim -run general/compute/leastsquare.sim -run general/compute/top.sim run general/compute/bottom.sim -run general/compute/percentile.sim +run general/compute/count.sim run general/compute/diff.sim -run general/compute/interval.sim -run general/compute/null.sim run general/compute/diff2.sim +run general/compute/first.sim +run general/compute/interval.sim +run general/compute/last.sim +run general/compute/leastsquare.sim +run general/compute/max.sim +run general/compute/min.sim +run general/compute/null.sim +run general/compute/percentile.sim +run general/compute/stddev.sim +run general/compute/sum.sim +run general/compute/top.sim diff --git a/tests/script/general/compute/top.sim b/tests/script/general/compute/top.sim index 8f3797b678..14b3b328a0 100644 --- a/tests/script/general/compute/top.sim +++ b/tests/script/general/compute/top.sim @@ -94,4 +94,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/db/testSuite.sim b/tests/script/general/db/testSuite.sim index 893d2040a9..2cac8b8fa8 100644 --- a/tests/script/general/db/testSuite.sim +++ b/tests/script/general/db/testSuite.sim @@ -7,7 +7,7 @@ run general/db/basic5.sim run general/db/delete_reuse1.sim run general/db/delete_reuse2.sim run general/db/delete_reusevnode.sim -#run general/db/delete_reusevnode2.sim +run general/db/delete_reusevnode2.sim run general/db/delete_writing1.sim run general/db/delete_writing2.sim run general/db/len.sim diff --git a/tests/script/general/field/2.sim b/tests/script/general/field/2.sim index dff0e6250c..28506b7cb8 100644 --- a/tests/script/general/field/2.sim +++ b/tests/script/general/field/2.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -9,9 +7,9 @@ sleep 3000 sql connect print ======================== dnode1 start -$dbPrefix = fi_bt_db -$tbPrefix = fi_bt_tb -$mtPrefix = fi_bt_mt +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st $tbNum = 10 $rowNum = 20 $totalNum = 200 @@ -233,6 +231,8 @@ if $data00 != 100 then return -1 endi +print sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 + sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol2 = 1 print $data00 $data01 $data02 $data03 $data04 $data05 $data06 if $data00 != 100 then @@ -292,4 +292,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/3.sim b/tests/script/general/field/3.sim index 05fed07428..453f4968bf 100644 --- a/tests/script/general/field/3.sim +++ b/tests/script/general/field/3.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -9,9 +7,9 @@ sleep 3000 sql connect print ======================== dnode1 start -$dbPrefix = fi_3_db -$tbPrefix = fi_3_tb -$mtPrefix = fi_3_mt +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = mt $tbNum = 10 $rowNum = 20 $totalNum = 200 @@ -518,4 +516,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/4.sim b/tests/script/general/field/4.sim index ad84124b7d..243424724f 100644 --- a/tests/script/general/field/4.sim +++ b/tests/script/general/field/4.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -9,9 +7,9 @@ sleep 3000 sql connect print ======================== dnode1 start -$dbPrefix = fi_4_db -$tbPrefix = fi_4_tb -$mtPrefix = fi_4_mt +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st $tbNum = 10 $rowNum = 20 $totalNum = 200 @@ -708,4 +706,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/5.sim b/tests/script/general/field/5.sim index 63fec1f169..ca1543b54b 100644 --- a/tests/script/general/field/5.sim +++ b/tests/script/general/field/5.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -9,9 +7,9 @@ sleep 3000 sql connect print ======================== dnode1 start -$dbPrefix = fi_5_db -$tbPrefix = fi_5_tb -$mtPrefix = fi_5_mt +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st $tbNum = 10 $rowNum = 20 $totalNum = 200 @@ -831,4 +829,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/6.sim b/tests/script/general/field/6.sim index 409c2e53c3..23223e5c15 100644 --- a/tests/script/general/field/6.sim +++ b/tests/script/general/field/6.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -9,9 +7,9 @@ sleep 3000 sql connect print ======================== dnode1 start -$dbPrefix = fi_6_db -$tbPrefix = fi_6_tb -$mtPrefix = fi_6_mt +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st $tbNum = 10 $rowNum = 20 $totalNum = 200 @@ -986,4 +984,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/bigint.sim b/tests/script/general/field/bigint.sim index e355cb3161..5cca73595c 100644 --- a/tests/script/general/field/bigint.sim +++ b/tests/script/general/field/bigint.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -9,9 +7,9 @@ sleep 3000 sql connect print ======================== dnode1 start -$dbPrefix = fi_bi_db -$tbPrefix = fi_bi_tb -$mtPrefix = fi_bi_mt +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st $tbNum = 10 $rowNum = 20 $totalNum = 200 @@ -157,4 +155,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/binary.sim b/tests/script/general/field/binary.sim index 3ac4376097..8bf1c84b93 100644 --- a/tests/script/general/field/binary.sim +++ b/tests/script/general/field/binary.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -9,9 +7,9 @@ sleep 3000 sql connect print ======================== dnode1 start -$dbPrefix = fi_by_db -$tbPrefix = fi_by_tb -$mtPrefix = fi_by_mt +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st $tbNum = 10 $rowNum = 20 $totalNum = 200 @@ -81,4 +79,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/bool.sim b/tests/script/general/field/bool.sim index 8a1a717225..4528f79bc7 100644 --- a/tests/script/general/field/bool.sim +++ b/tests/script/general/field/bool.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -9,9 +7,9 @@ sleep 3000 sql connect print ======================== dnode1 start -$dbPrefix = fi_bo_db -$tbPrefix = fi_bo_tb -$mtPrefix = fi_bo_mt +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st $tbNum = 10 $rowNum = 20 $totalNum = 200 @@ -158,4 +156,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/double.sim b/tests/script/general/field/double.sim index 2de34ad5b6..40650cb9bd 100644 --- a/tests/script/general/field/double.sim +++ b/tests/script/general/field/double.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -9,9 +7,9 @@ sleep 3000 sql connect print ======================== dnode1 start -$dbPrefix = fi_do_db -$tbPrefix = fi_do_tb -$mtPrefix = fi_do_mt +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st $tbNum = 10 $rowNum = 20 $totalNum = 200 @@ -157,4 +155,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/float.sim b/tests/script/general/field/float.sim index 443a721340..0ead9fb48a 100644 --- a/tests/script/general/field/float.sim +++ b/tests/script/general/field/float.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -9,9 +7,9 @@ sleep 3000 sql connect print ======================== dnode1 start -$dbPrefix = fi_fl_db -$tbPrefix = fi_fl_tb -$mtPrefix = fi_fl_mt +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st $tbNum = 10 $rowNum = 20 $totalNum = 200 @@ -157,4 +155,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/int.sim b/tests/script/general/field/int.sim index 4ab1005671..a095dc2176 100644 --- a/tests/script/general/field/int.sim +++ b/tests/script/general/field/int.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -9,9 +7,9 @@ sleep 3000 sql connect print ======================== dnode1 start -$dbPrefix = fi_in_db -$tbPrefix = fi_in_tb -$mtPrefix = fi_in_mt +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st $tbNum = 10 $rowNum = 20 $totalNum = 200 @@ -157,4 +155,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/single.sim b/tests/script/general/field/single.sim index 6d710614f2..8540608e96 100644 --- a/tests/script/general/field/single.sim +++ b/tests/script/general/field/single.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -9,9 +7,9 @@ sleep 3000 sql connect print ======================== dnode1 start -$dbPrefix = fi_si_db -$tbPrefix = fi_si_tb -$mtPrefix = fi_si_mt +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st $rowNum = 20 print =============== step1 @@ -215,4 +213,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/smallint.sim b/tests/script/general/field/smallint.sim index 37ddadb271..578de4ea44 100644 --- a/tests/script/general/field/smallint.sim +++ b/tests/script/general/field/smallint.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -9,9 +7,9 @@ sleep 3000 sql connect print ======================== dnode1 start -$dbPrefix = fi_sm_db -$tbPrefix = fi_sm_tb -$mtPrefix = fi_sm_mt +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st $tbNum = 10 $rowNum = 20 $totalNum = 200 @@ -157,4 +155,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/field/testSuite.sim b/tests/script/general/field/testSuite.sim index 9b58c77e92..807ee8e315 100644 --- a/tests/script/general/field/testSuite.sim +++ b/tests/script/general/field/testSuite.sim @@ -1,14 +1,11 @@ -run general/field/single.sim -run general/field/bool.sim -run general/field/smallint.sim -run general/field/tinyint.sim -run general/field/int.sim -run general/field/bigint.sim -run general/field/float.sim -run general/field/double.sim -run general/field/binary.sim run general/field/2.sim run general/field/3.sim run general/field/4.sim run general/field/5.sim -run general/field/6.sim \ No newline at end of file +run general/field/6.sim +run general/field/bigint.sim +run general/field/binary.sim +run general/field/bool.sim +run general/field/single.sim +run general/field/smallint.sim +run general/field/tinyint.sim diff --git a/tests/script/general/field/tinyint.sim b/tests/script/general/field/tinyint.sim index 65775c1145..f132b42702 100644 --- a/tests/script/general/field/tinyint.sim +++ b/tests/script/general/field/tinyint.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start @@ -10,9 +8,9 @@ sql connect print ======================== dnode1 start -$dbPrefix = fi_ti_db -$tbPrefix = fi_ti_tb -$mtPrefix = fi_ti_mt +$dbPrefix = db +$tbPrefix = tb +$mtPrefix = st $tbNum = 10 $rowNum = 20 $totalNum = 200 @@ -158,4 +156,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/http/testSuite.sim b/tests/script/general/http/testSuite.sim index 3337f4fc97..d91e9f452d 100644 --- a/tests/script/general/http/testSuite.sim +++ b/tests/script/general/http/testSuite.sim @@ -4,5 +4,5 @@ run general/http/restful_limit.sim run general/http/restful_full.sim run general/http/prepare.sim run general/http/telegraf.sim -#run general/http/grafana_bug.sim -#run general/http/grafana.sim +run general/http/grafana_bug.sim +run general/http/grafana.sim diff --git a/tests/script/general/import/basic.sim b/tests/script/general/import/basic.sim index 0623405c2f..2b72d55cda 100644 --- a/tests/script/general/import/basic.sim +++ b/tests/script/general/import/basic.sim @@ -1,10 +1,4 @@ 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 @@ -25,10 +19,10 @@ system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000 -system sh/cfg.sh -n dnode1 -c commitlog -v 0 -system sh/cfg.sh -n dnode2 -c commitlog -v 0 -system sh/cfg.sh -n dnode3 -c commitlog -v 0 -system sh/cfg.sh -n dnode4 -c commitlog -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 0 +system sh/cfg.sh -n dnode2 -c walLevel -v 0 +system sh/cfg.sh -n dnode3 -c walLevel -v 0 +system sh/cfg.sh -n dnode4 -c walLevel -v 0 print ========= start dnode1 system sh/exec.sh -n dnode1 -s start @@ -50,14 +44,14 @@ endi print ================= step2 sql insert into tb values(1564641708000, 8000) sql select * from tb; -if $rows != 1 then +if $rows != 2 then return -1 endi print ================= step3 sql insert into tb values(1564641720000, 20000) sql select * from tb; -if $rows != 2 then +if $rows != 3 then return -1 endi @@ -76,7 +70,7 @@ sql insert into tb values(1564641714000, 14000) sql insert into tb values(1564641725000, 25000) sql insert into tb values(1564641740000, 40000) sql select * from tb; -if $rows != 6 then +if $rows != 8 then return -1 endi @@ -87,7 +81,7 @@ sql import into tb values(1564641723000, 23000) sql import into tb values(1564641734000, 34000) sql import into tb values(1564641750000, 50000) sql select * from tb; -if $rows != 11 then +if $rows != 13 then return -1 endi @@ -98,7 +92,7 @@ sql import into tb values(1564641723001, 23001) sql import into tb values(1564641734001, 34001) sql import into tb values(1564641750001, 50001) sql select * from tb; -if $rows != 16 then +if $rows != 18 then return -1 endi @@ -108,28 +102,28 @@ sql insert into tb values(1564641714002, 14002) sql insert into tb values(1564641725002, 25002) sql insert into tb values(1564641900000, 200000) sql select * from tb; -if $rows != 17 then +if $rows != 22 then return -1 endi print ================= step9 only insert last one sql import into tb values(1564641705000, 5000)(1564641718000, 18000)(1564642400000, 700000) sql select * from tb; -if $rows != 20 then +if $rows != 25 then return -1 endi print ================= step10 sql import into tb values(1564641705000, 5000)(1564641718000, 18000)(1564642400000, 70000) sql select * from tb; -if $rows != 20 then +if $rows != 25 then return -1 endi print ================= step11 sql import into tb values(1564642400000, 700000) sql select * from tb; -if $rows != 20 then +if $rows != 25 then return -1 endi @@ -137,7 +131,7 @@ print ================= step12 sql import into tb values(1564641709527, 9527)(1564641709527, 9528) sql select * from tb; print rows=> $rows -if $rows != 21 then +if $rows != 26 then return -1 endi @@ -145,7 +139,8 @@ print ================= step13 sql import into tb values(1564641709898, 9898)(1564641709897, 9897) sql select * from tb; print rows=> $rows -if $rows != 23 then +if $rows != 28 then return -1 endi +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/import/commit.sim b/tests/script/general/import/commit.sim index ce52b9496f..64833fcd61 100644 --- a/tests/script/general/import/commit.sim +++ b/tests/script/general/import/commit.sim @@ -1,10 +1,4 @@ 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 @@ -25,10 +19,10 @@ system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000 -system sh/cfg.sh -n dnode1 -c commitlog -v 0 -system sh/cfg.sh -n dnode2 -c commitlog -v 0 -system sh/cfg.sh -n dnode3 -c commitlog -v 0 -system sh/cfg.sh -n dnode4 -c commitlog -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 0 +system sh/cfg.sh -n dnode2 -c walLevel -v 0 +system sh/cfg.sh -n dnode3 -c walLevel -v 0 +system sh/cfg.sh -n dnode4 -c walLevel -v 0 print ========= start dnode1 system sh/exec.sh -n dnode1 -s start @@ -93,6 +87,4 @@ if $rows != 12 then return -1 endi - - - +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/import/large.sim b/tests/script/general/import/large.sim index 6a0bbf28d2..6f6889a226 100644 --- a/tests/script/general/import/large.sim +++ b/tests/script/general/import/large.sim @@ -1,10 +1,4 @@ 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 @@ -25,10 +19,10 @@ system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000 -system sh/cfg.sh -n dnode1 -c commitlog -v 0 -system sh/cfg.sh -n dnode2 -c commitlog -v 0 -system sh/cfg.sh -n dnode3 -c commitlog -v 0 -system sh/cfg.sh -n dnode4 -c commitlog -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 0 +system sh/cfg.sh -n dnode2 -c walLevel -v 0 +system sh/cfg.sh -n dnode3 -c walLevel -v 0 +system sh/cfg.sh -n dnode4 -c walLevel -v 0 print ========= start dnode1 system sh/exec.sh -n dnode1 -s start @@ -99,4 +93,6 @@ while $i < 1000 $i = $i + 1 endw -print ================= step2 \ No newline at end of file +print ================= step2 + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/import/replica1.sim b/tests/script/general/import/replica1.sim index 14e27ffa50..b2b7291623 100644 --- a/tests/script/general/import/replica1.sim +++ b/tests/script/general/import/replica1.sim @@ -1,10 +1,5 @@ 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 @@ -25,10 +20,10 @@ system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000 -system sh/cfg.sh -n dnode1 -c commitlog -v 0 -system sh/cfg.sh -n dnode2 -c commitlog -v 0 -system sh/cfg.sh -n dnode3 -c commitlog -v 0 -system sh/cfg.sh -n dnode4 -c commitlog -v 0 +system sh/cfg.sh -n dnode1 -c walLevel -v 2 +system sh/cfg.sh -n dnode2 -c walLevel -v 2 +system sh/cfg.sh -n dnode3 -c walLevel -v 2 +system sh/cfg.sh -n dnode4 -c walLevel -v 2 print ========= start dnode1 system sh/exec.sh -n dnode1 -s start @@ -40,53 +35,59 @@ sql use ir1db sql create table tb(ts timestamp, i int) print ================= step1 -sql import into tb values(now+10000a, 10000) +sql import into tb values(1520000010000, 10000) sql select * from tb; +print $rows if $rows != 1 then return -1 endi print ================= step2 -sql insert into tb values(now+8000a, 8000) -sql select * from tb; -if $rows != 1 then - return -1 -endi - -print ================= step3 -sql insert into tb values(now+20000a, 20000) +sql insert into tb values(1520000008000, 8000) +print $rows sql select * from tb; if $rows != 2 then return -1 endi -print ================= step4 -sql import into tb values(now+8000a, 9000) -sql import into tb values(now+15000a, 15000) -sql import into tb values(now+30000a, 30000) +print ================= step3 +sql insert into tb values(1520000020000, 20000) sql select * from tb; -if $rows != 5 then +print $rows +if $rows != 3 then return -1 endi -print ================= step5 -sql insert into tb values(now+8000a, 8000) -sql insert into tb values(now+14000a, 14000) -sql insert into tb values(now+25000a, 25000) -sql insert into tb values(now+40000a, 40000) +print ================= step4 +sql import into tb values(1520000009000, 9000) +sql import into tb values(1520000015000, 15000) +sql import into tb values(1520000030000, 30000) sql select * from tb; +print $rows if $rows != 6 then return -1 endi -print ================= step6 -sql import into tb values(now+7000a, 7000) -sql import into tb values(now+12000a, 12000) -sql import into tb values(now+23000a, 23000) -sql import into tb values(now+34000a, 34000) -sql import into tb values(now+50000a, 50000) +print ================= step5 +sql insert into tb values(1520000008000, 8000) +sql insert into tb values(1520000014000, 14000) +sql insert into tb values(1520000025000, 25000) +sql insert into tb values(1520000040000, 40000) sql select * from tb; -if $rows != 11 then +print $rows +if $rows != 9 then + return -1 +endi + +print ================= step6 +sql import into tb values(1520000007000, 7000) +sql import into tb values(1520000012000, 12000) +sql import into tb values(1520000023000, 23000) +sql import into tb values(1520000034000, 34000) +sql import into tb values(1520000050000, 50000) +sql select * from tb; +print $rows +if $rows != 14 then return -1 endi @@ -98,46 +99,63 @@ sleep 5000 sql use ir1db sql select * from tb; -if $rows != 11 then +if $rows != 14 then return -1 endi print ================= step7 -sql import into tb values(now+7001a, 7001) -sql import into tb values(now+12001a, 12001) -sql import into tb values(now+23001a, 23001) -sql import into tb values(now+34001a, 34001) -sql import into tb values(now+50001a, 50001) +sql import into tb values(1520000007001, 7001) +sql import into tb values(1520000012001, 12001) +sql import into tb values(1520000023001, 23001) +sql import into tb values(1520000034001, 34001) +sql import into tb values(1520000050001, 50001) sql select * from tb; -if $rows != 16 then +print $rows +if $rows != 19 then return -1 endi print ================= step8 -sql insert into tb values(now+8002a, 8002) -sql insert into tb values(now+14002a, 14002) -sql insert into tb values(now+25002a, 25002) -sql insert into tb values(now+200000a, 60000) +sql insert into tb values(1520000008002, 8002) +sql insert into tb values(1520000014002, 14002) +sql insert into tb values(1520000025002, 25002) +sql insert into tb values(1520000060000, 60000) sql select * from tb; -if $rows != 17 then +print $rows +if $rows != 24 then return -1 endi print ================= step9 -sql import into tb values(now-30d, 7003) -sql import into tb values(now-20d, 34003) -sql import into tb values(now-10d, 34003) -sql import into tb values(now-5d, 34003) -sql import into tb values(now+1m, 50001) -sql import into tb values(now+2m, 50001) -sql import into tb values(now+3m, 50001) -sql import into tb values(now+4m, 50002) -sql import into tb values(now+5m, 50003) -sql import into tb values(now+6m, 50004) -sql import into tb values(now+7m, 50001) -sql import into tb values(now+8m, 500051) +#1520000000000 +#sql import into tb values(now-30d, 7003) +#sql import into tb values(now-20d, 34003) +#sql import into tb values(now-10d, 34003) +#sql import into tb values(now-5d, 34003) +#sql import into tb values(now+1d, 50001) +#sql import into tb values(now+2d, 50001) +#sql import into tb values(now+6d, 50001) +#sql import into tb values(now+8d, 50002) +#sql import into tb values(now+10d, 50003) +#sql import into tb values(now+12d, 50004) +#sql import into tb values(now+14d, 50001) +#sql import into tb values(now+16d, 500051) + +sql import into tb values(1517408000000, 7003) +sql import into tb values(1518272000000, 34003) +sql import into tb values(1519136000000, 34003) +sql import into tb values(1519568000000, 34003) +sql import into tb values(1519654400000, 50001) +sql import into tb values(1519827200000, 50001) +sql import into tb values(1520345600000, 50001) +sql import into tb values(1520691200000, 50002) +sql import into tb values(1520864000000, 50003) +sql import into tb values(1521900800000, 50004) +sql import into tb values(1523110400000, 50001) +sql import into tb values(1521382400000, 500051) sql select * from tb; -if $rows != 29 then +print $rows +if $rows != 36 then return -1 endi @@ -149,23 +167,44 @@ sleep 5000 sql use ir1db sql select * from tb; -if $rows != 29 then +print $rows +if $rows != 36 then return -1 endi print ================= step11 -sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) + +#sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) +sql import into tb values(1515680000000, 7003) (1515852800000, 7003) (1516025600000, 7003) (1516198400000, 7003) (1516371200000, 7003) sql select * from tb; -if $rows != 34 then +if $rows != 41 then return -1 endi -sql import into tb values(now-19d, 7003) (now-18d, 7003) (now-17d, 7003) (now-16d, 7003) (now-15d, 7003) (now-14d, 7003) (now-13d, 7003) (now-12d, 7003) (now-11d, 7003) +print ================= step12 +#1520000000000 +#sql import into tb values(now-19d, 7003) (now-18d, 7003) (now-17d, 7003) (now-16d, 7003) (now-15d, 7003) (now-14d, 7003) (now-13d, 7003) (now-12d, 7003) (now-11d, 7003) +sql import into tb values(1518358400000, 7003) (1518444800000, 7003) (1518531200000, 7003) (1518617600000, 7003) (1518704000000, 7003) (1518790400000, 7003) (1518876800000, 7003) (1518963200000, 7003) (1519049600000, 7003) sql select * from tb; -if $rows != 43 then +print $rows +if $rows != 50 then return -1 endi +print ================= step14 +#1520000000000 +#sql import into tb values(now-48d, 34003) +#sql import into tb values(now-38d, 50001) +#sql import into tb values(now-28d, 50001) +sql import into tb values(1515852800001, 34003) +sql import into tb values(1516716800000, 50001) +sql import into tb values(1517580800000, 50001) +sql select * from tb; +if $rows != 50 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/import/testSuite.sim b/tests/script/general/import/testSuite.sim index d340d90d66..9157410ea5 100644 --- a/tests/script/general/import/testSuite.sim +++ b/tests/script/general/import/testSuite.sim @@ -1,4 +1,4 @@ run general/import/basic.sim -#run general/import/commit.sim +run general/import/commit.sim run general/import/large.sim run general/import/replica1.sim diff --git a/tests/script/general/insert/tcp.sim b/tests/script/general/insert/tcp.sim index 0bc4c123b8..6f9752087d 100644 --- a/tests/script/general/insert/tcp.sim +++ b/tests/script/general/insert/tcp.sim @@ -28,10 +28,4 @@ endw sql select * from tb -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi - system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/insert/testSuite.sim b/tests/script/general/insert/testSuite.sim index 72e4c057c1..da44167be5 100644 --- a/tests/script/general/insert/testSuite.sim +++ b/tests/script/general/insert/testSuite.sim @@ -1,5 +1,5 @@ run general/insert/basic.sim -#run general/insert/insert_drop.sim +run general/insert/insert_drop.sim run general/insert/query_block1_memory.sim run general/insert/query_block2_memory.sim run general/insert/query_block1_file.sim diff --git a/tests/script/general/metrics/disk.sim b/tests/script/general/metrics/disk.sim index a23a117ac2..0865719a14 100644 --- a/tests/script/general/metrics/disk.sim +++ b/tests/script/general/metrics/disk.sim @@ -194,4 +194,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/metrics/metrics.sim b/tests/script/general/metrics/metrics.sim index 52448a4002..b9367469b3 100644 --- a/tests/script/general/metrics/metrics.sim +++ b/tests/script/general/metrics/metrics.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 @@ -135,3 +133,5 @@ sql show databases if $rows != 0 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/metrics/values.sim b/tests/script/general/metrics/values.sim index efabc67722..f524eee411 100644 --- a/tests/script/general/metrics/values.sim +++ b/tests/script/general/metrics/values.sim @@ -102,25 +102,4 @@ if $rows != 100 then return -1 endi - - - - - - - - - - - - - - - - - - - - - - +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/metrics/vnode3.sim b/tests/script/general/metrics/vnode3.sim index 5d4a9f7f5b..73be7a1195 100644 --- a/tests/script/general/metrics/vnode3.sim +++ b/tests/script/general/metrics/vnode3.sim @@ -175,4 +175,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/table/testSuite.sim b/tests/script/general/table/testSuite.sim index 6768c75dd7..d6cc88b36a 100644 --- a/tests/script/general/table/testSuite.sim +++ b/tests/script/general/table/testSuite.sim @@ -11,17 +11,17 @@ run general/table/column_value.sim run general/table/column2.sim run general/table/date.sim run general/table/db.table.sim -#run general/table/delete_reuse1.sim -#run general/table/delete_reuse2.sim -#run general/table/delete_writing.sim -#run general/table/describe.sim +run general/table/delete_reuse1.sim +run general/table/delete_reuse2.sim +run general/table/delete_writing.sim +run general/table/describe.sim run general/table/double.sim -#run general/table/fill.sim +run general/table/fill.sim run general/table/float.sim run general/table/int.sim run general/table/limit.sim run general/table/smallint.sim -#run general/table/table_len.sim +run general/table/table_len.sim run general/table/table.sim run general/table/tinyint.sim run general/table/vgroup.sim diff --git a/tests/script/general/tag/3.sim b/tests/script/general/tag/3.sim index e2a503ce8b..4b3104fe1b 100644 --- a/tests/script/general/tag/3.sim +++ b/tests/script/general/tag/3.sim @@ -1,13 +1,10 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect -sql reset query cache print ======================== dnode1 start @@ -521,3 +518,5 @@ sql show databases if $rows != 0 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/4.sim b/tests/script/general/tag/4.sim index 93c422bb31..120ef4e4e3 100644 --- a/tests/script/general/tag/4.sim +++ b/tests/script/general/tag/4.sim @@ -711,3 +711,5 @@ sql show databases if $rows != 0 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/5.sim b/tests/script/general/tag/5.sim index 949c9c257b..efe88b3650 100644 --- a/tests/script/general/tag/5.sim +++ b/tests/script/general/tag/5.sim @@ -834,3 +834,5 @@ sql show databases if $rows != 0 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/6.sim b/tests/script/general/tag/6.sim index de5542c635..d5f0a6c4af 100644 --- a/tests/script/general/tag/6.sim +++ b/tests/script/general/tag/6.sim @@ -989,3 +989,5 @@ sql show databases if $rows != 0 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/add.sim b/tests/script/general/tag/add.sim index 3d4323c401..69fd909dcf 100644 --- a/tests/script/general/tag/add.sim +++ b/tests/script/general/tag/add.sim @@ -851,4 +851,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/bigint.sim b/tests/script/general/tag/bigint.sim index 736c30607f..4fa22d3995 100644 --- a/tests/script/general/tag/bigint.sim +++ b/tests/script/general/tag/bigint.sim @@ -239,4 +239,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/binary.sim b/tests/script/general/tag/binary.sim index f57f5cc996..7c6f95b1ef 100644 --- a/tests/script/general/tag/binary.sim +++ b/tests/script/general/tag/binary.sim @@ -239,4 +239,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/binary_binary.sim b/tests/script/general/tag/binary_binary.sim index 5f001e028e..077ec85b52 100644 --- a/tests/script/general/tag/binary_binary.sim +++ b/tests/script/general/tag/binary_binary.sim @@ -306,4 +306,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/bool.sim b/tests/script/general/tag/bool.sim index 82d6cd14bf..540eaf1238 100644 --- a/tests/script/general/tag/bool.sim +++ b/tests/script/general/tag/bool.sim @@ -236,4 +236,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/bool_binary.sim b/tests/script/general/tag/bool_binary.sim index c836dd227b..a3f99e25ad 100644 --- a/tests/script/general/tag/bool_binary.sim +++ b/tests/script/general/tag/bool_binary.sim @@ -306,4 +306,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/bool_int.sim b/tests/script/general/tag/bool_int.sim index 86a16fde9b..1a2726dbaa 100644 --- a/tests/script/general/tag/bool_int.sim +++ b/tests/script/general/tag/bool_int.sim @@ -322,4 +322,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/change.sim b/tests/script/general/tag/change.sim index 1b7e643a21..1577514765 100644 --- a/tests/script/general/tag/change.sim +++ b/tests/script/general/tag/change.sim @@ -511,4 +511,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/column.sim b/tests/script/general/tag/column.sim index e9b89b7b46..4a36e832f1 100644 --- a/tests/script/general/tag/column.sim +++ b/tests/script/general/tag/column.sim @@ -91,4 +91,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/commit.sim b/tests/script/general/tag/commit.sim index 021f49a998..94dc13f0cf 100644 --- a/tests/script/general/tag/commit.sim +++ b/tests/script/general/tag/commit.sim @@ -1180,4 +1180,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/create.sim b/tests/script/general/tag/create.sim index 3d4ecf8bc3..c0cdbe87dc 100644 --- a/tests/script/general/tag/create.sim +++ b/tests/script/general/tag/create.sim @@ -598,3 +598,5 @@ print $data00 $data01 $data02 if $data02 != 12345 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/delete.sim b/tests/script/general/tag/delete.sim index 6dd6254d32..3454ce9d82 100644 --- a/tests/script/general/tag/delete.sim +++ b/tests/script/general/tag/delete.sim @@ -823,4 +823,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/double.sim b/tests/script/general/tag/double.sim index 47c94d8ae6..13dcb1fc72 100644 --- a/tests/script/general/tag/double.sim +++ b/tests/script/general/tag/double.sim @@ -239,4 +239,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/filter.sim b/tests/script/general/tag/filter.sim index b10e8a0372..4388f029f9 100644 --- a/tests/script/general/tag/filter.sim +++ b/tests/script/general/tag/filter.sim @@ -1,6 +1,4 @@ system sh/stop_dnodes.sh - - system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start @@ -146,3 +144,5 @@ sql show databases if $rows != 0 then return -1 endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/float.sim b/tests/script/general/tag/float.sim index 4f86eec338..2352bbaf2e 100644 --- a/tests/script/general/tag/float.sim +++ b/tests/script/general/tag/float.sim @@ -239,4 +239,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/int.sim b/tests/script/general/tag/int.sim index d0dea47cb1..a93df9a57a 100644 --- a/tests/script/general/tag/int.sim +++ b/tests/script/general/tag/int.sim @@ -239,4 +239,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/int_binary.sim b/tests/script/general/tag/int_binary.sim index 234780d6d5..d379500668 100644 --- a/tests/script/general/tag/int_binary.sim +++ b/tests/script/general/tag/int_binary.sim @@ -306,4 +306,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/int_float.sim b/tests/script/general/tag/int_float.sim index bfa3ed7f72..510c4f92d0 100644 --- a/tests/script/general/tag/int_float.sim +++ b/tests/script/general/tag/int_float.sim @@ -322,4 +322,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/set.sim b/tests/script/general/tag/set.sim index bc7b8ac534..917844c3e3 100644 --- a/tests/script/general/tag/set.sim +++ b/tests/script/general/tag/set.sim @@ -455,4 +455,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/smallint.sim b/tests/script/general/tag/smallint.sim index 4ca9459477..18b0957b15 100644 --- a/tests/script/general/tag/smallint.sim +++ b/tests/script/general/tag/smallint.sim @@ -239,4 +239,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/tag/testSuite.sim b/tests/script/general/tag/testSuite.sim index 10874262d6..45356efac1 100644 --- a/tests/script/general/tag/testSuite.sim +++ b/tests/script/general/tag/testSuite.sim @@ -1,25 +1,25 @@ -run general/tag/filter.sim -run general/tag/column.sim -run general/tag/bool.sim -run general/tag/smallint.sim -run general/tag/tinyint.sim -run general/tag/int.sim -run general/tag/bigint.sim -run general/tag/float.sim -run general/tag/double.sim -run general/tag/binary.sim -run general/tag/bool_int.sim -run general/tag/bool_binary.sim -run general/tag/int_float.sim -run general/tag/int_binary.sim -run general/tag/binary_binary.sim run general/tag/3.sim run general/tag/4.sim run general/tag/5.sim run general/tag/6.sim +run general/tag/add.sim +run general/tag/bigint.sim +run general/tag/binary_binary.sim +run general/tag/binary.sim +run general/tag/bool_binary.sim +run general/tag/bool_int.sim +run general/tag/bool.sim +run general/tag/change.sim +run general/tag/column.sim +run general/tag/commit.sim run general/tag/create.sim run general/tag/delete.sim -run general/tag/change.sim +run general/tag/double.sim +run general/tag/filter.sim +run general/tag/float.sim +run general/tag/int_binary.sim +run general/tag/int_float.sim +run general/tag/int.sim run general/tag/set.sim -run general/tag/add.sim -run general/tag/commit.sim \ No newline at end of file +run general/tag/smallint.sim +run general/tag/tinyint.sim diff --git a/tests/script/general/tag/tinyint.sim b/tests/script/general/tag/tinyint.sim index 9e339a352c..f104f8df04 100644 --- a/tests/script/general/tag/tinyint.sim +++ b/tests/script/general/tag/tinyint.sim @@ -239,4 +239,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/user/testSuite.sim b/tests/script/general/user/testSuite.sim index 16bc96f4dc..b4bf52cfd1 100644 --- a/tests/script/general/user/testSuite.sim +++ b/tests/script/general/user/testSuite.sim @@ -1,5 +1,5 @@ run general/user/basic1.sim -#run general/user/monitor.sim +run general/user/monitor.sim run general/user/pass_alter.sim run general/user/pass_len.sim run general/user/user_create.sim diff --git a/tests/script/general/vector/metrics_field.sim b/tests/script/general/vector/metrics_field.sim index 1b96b8c36d..2a03ccea19 100644 --- a/tests/script/general/vector/metrics_field.sim +++ b/tests/script/general/vector/metrics_field.sim @@ -618,4 +618,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/metrics_mix.sim b/tests/script/general/vector/metrics_mix.sim index 992ce6e189..96b2f6a7a0 100644 --- a/tests/script/general/vector/metrics_mix.sim +++ b/tests/script/general/vector/metrics_mix.sim @@ -618,4 +618,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/metrics_query.sim b/tests/script/general/vector/metrics_query.sim index 8e3833f7a4..824aa6f22e 100644 --- a/tests/script/general/vector/metrics_query.sim +++ b/tests/script/general/vector/metrics_query.sim @@ -614,4 +614,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/metrics_tag.sim b/tests/script/general/vector/metrics_tag.sim index 81f15a194f..e7575cc9df 100644 --- a/tests/script/general/vector/metrics_tag.sim +++ b/tests/script/general/vector/metrics_tag.sim @@ -614,4 +614,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/metrics_time.sim b/tests/script/general/vector/metrics_time.sim index f7e78ae521..bbcabfd1b7 100644 --- a/tests/script/general/vector/metrics_time.sim +++ b/tests/script/general/vector/metrics_time.sim @@ -614,4 +614,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/multi.sim b/tests/script/general/vector/multi.sim index 3a607b2410..105f210950 100644 --- a/tests/script/general/vector/multi.sim +++ b/tests/script/general/vector/multi.sim @@ -206,10 +206,11 @@ sql select a + f from $tb where g = 2 and ts > now + 4m order by ts asc -x step return -1 step74: - print =============== clear sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/single.sim b/tests/script/general/vector/single.sim index 8eff3e1fb1..2292d6f44a 100644 --- a/tests/script/general/vector/single.sim +++ b/tests/script/general/vector/single.sim @@ -298,4 +298,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/table_field.sim b/tests/script/general/vector/table_field.sim index 96adf54f1d..a9d6910f4d 100644 --- a/tests/script/general/vector/table_field.sim +++ b/tests/script/general/vector/table_field.sim @@ -614,4 +614,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/table_mix.sim b/tests/script/general/vector/table_mix.sim index c994697ff2..a6c4dc92da 100644 --- a/tests/script/general/vector/table_mix.sim +++ b/tests/script/general/vector/table_mix.sim @@ -614,4 +614,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/table_query.sim b/tests/script/general/vector/table_query.sim index ce3acc1d66..812229afc4 100644 --- a/tests/script/general/vector/table_query.sim +++ b/tests/script/general/vector/table_query.sim @@ -614,4 +614,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/table_time.sim b/tests/script/general/vector/table_time.sim index 3c2ff183ed..a83195beba 100644 --- a/tests/script/general/vector/table_time.sim +++ b/tests/script/general/vector/table_time.sim @@ -614,4 +614,6 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/vector/testSuite.sim b/tests/script/general/vector/testSuite.sim index e660fd90a9..f0b9fef991 100644 --- a/tests/script/general/vector/testSuite.sim +++ b/tests/script/general/vector/testSuite.sim @@ -1,12 +1,11 @@ -run general/vector/single.sim -run general/vector/multi.sim -run general/vector/table_query.sim -run general/vector/table_time.sim -run general/vector/table_field.sim -run general/vector/table_mix.sim +run general/vector/metrics_field.sim +run general/vector/metrics_mix.sim run general/vector/metrics_query.sim run general/vector/metrics_tag.sim run general/vector/metrics_time.sim -run general/vector/metrics_field.sim -run general/vector/metrics_mix.sim - +run general/vector/multi.sim +run general/vector/single.sim +run general/vector/table_field.sim +run general/vector/table_mix.sim +run general/vector/table_query.sim +run general/vector/table_time.sim diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index c5f8cdcd06..1a9862e4ed 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -6,20 +6,43 @@ cd ../../../debug; cmake .. #cd ../../../debug; make clean cd ../../../debug; make +#./test.sh -f general/alter/cached_schema_after_alter.sim +#./test.sh -f general/alter/count.sim +#./test.sh -f general/alter/import.sim +#./test.sh -f general/alter/insert1.sim +#./test.sh -f general/alter/insert2.sim +#./test.sh -f general/alter/metrics.sim +#./test.sh -f general/alter/table.sim -######### general ######### - -#alter - -#cache -#./test.sh -f general/cache/restart_table.sim +./test.sh -f general/cache/new_metrics.sim #./test.sh -f general/cache/restart_metrics.sim -#./test.sh -f general/cache/new_metrics.sim +./test.sh -f general/cache/restart_table.sim +#./test.sh -f general/column/commit.sim +#./test.sh -f general/column/metrics.sim +#./test.sh -f general/column/table.sim -#column -#compress -#compute +./test.sh -f general/compress/commitlog.sim +./test.sh -f general/compress/compress.sim +./test.sh -f general/compress/compress2.sim +./test.sh -f general/compress/uncompress.sim + +#./test.sh -f general/compute/avg.sim +./test.sh -f general/compute/bottom.sim +#./test.sh -f general/compute/count.sim +./test.sh -f general/compute/diff.sim +#./test.sh -f general/compute/diff2.sim +#./test.sh -f general/compute/first.sim +#./test.sh -f general/compute/interval.sim +#./test.sh -f general/compute/last.sim +#./test.sh -f general/compute/leastsquare.sim +#./test.sh -f general/compute/max.sim +#./test.sh -f general/compute/min.sim +./test.sh -f general/compute/null.sim +./test.sh -f general/compute/percentile.sim +./test.sh -f general/compute/stddev.sim +#./test.sh -f general/compute/sum.sim +./test.sh -f general/compute/top.sim ./test.sh -f general/db/basic.sim ./test.sh -f general/db/basic1.sim @@ -37,7 +60,17 @@ cd ../../../debug; make ./test.sh -f general/db/repeat.sim ./test.sh -f general/db/tables.sim -#field +#./test.sh -f general/field/2.sim +#./test.sh -f general/field/3.sim +#./test.sh -f general/field/4.sim +#./test.sh -f general/field/5.sim +#./test.sh -f general/field/6.sim +./test.sh -f general/field/bigint.sim +#./test.sh -f general/field/binary.sim +./test.sh -f general/field/bool.sim +#./test.sh -f general/field/single.sim +./test.sh -f general/field/smallint.sim +./test.sh -f general/field/tinyint.sim ./test.sh -f general/http/restful.sim ./test.sh -f general/http/restful_insert.sim @@ -48,8 +81,10 @@ cd ../../../debug; make #./test.sh -f general/http/grafana_bug.sim #./test.sh -f general/http/grafana.sim - -#import +./test.sh -f general/import/basic.sim +./test.sh -f general/import/commit.sim +./test.sh -f general/import/large.sim +#./test.sh -f general/import/replica1.sim ./test.sh -f general/insert/basic.sim #./test.sh -f general/insert/insert_drop.sim @@ -61,8 +96,11 @@ cd ../../../debug; make ./test.sh -f general/insert/query_multi_file.sim ./test.sh -f general/insert/tcp.sim +#./test.sh -f general/metrics/disk.sim +#./test.sh -f general/metrics/metrics.sim +#./test.sh -f general/metrics/values.sim +#./test.sh -f general/metrics/vnode3.sim -#metrics #parser #stream @@ -94,19 +132,52 @@ cd ../../../debug; make ./test.sh -f general/table/tinyint.sim ./test.sh -f general/table/vgroup.sim - -#tag +#./test.sh -f general/tag/3.sim +#./test.sh -f general/tag/4.sim +#./test.sh -f general/tag/5.sim +#./test.sh -f general/tag/6.sim +#./test.sh -f general/tag/add.sim +#./test.sh -f general/tag/bigint.sim +#./test.sh -f general/tag/binary_binary.sim +#./test.sh -f general/tag/binary.sim +#./test.sh -f general/tag/bool_binary.sim +#./test.sh -f general/tag/bool_int.sim +#./test.sh -f general/tag/bool.sim +#./test.sh -f general/tag/change.sim +#./test.sh -f general/tag/column.sim +#./test.sh -f general/tag/commit.sim +#./test.sh -f general/tag/create.sim +#./test.sh -f general/tag/delete.sim +#./test.sh -f general/tag/double.sim +#./test.sh -f general/tag/filter.sim +#./test.sh -f general/tag/float.sim +#./test.sh -f general/tag/int_binary.sim +#./test.sh -f general/tag/int_float.sim +#./test.sh -f general/tag/int.sim +#./test.sh -f general/tag/set.sim +#./test.sh -f general/tag/smallint.sim +#./test.sh -f general/tag/tinyint.sim ./test.sh -f general/user/basic1.sim -./test.sh -f general/user/monitor.sim +#./test.sh -f general/user/monitor.sim ./test.sh -f general/user/pass_alter.sim ./test.sh -f general/user/pass_len.sim ./test.sh -f general/user/user_create.sim ./test.sh -f general/user/user_len.sim -#vector +#./test.sh -f general/vector/metrics_field.sim +#./test.sh -f general/vector/metrics_mix.sim +#./test.sh -f general/vector/metrics_query.sim +#./test.sh -f general/vector/metrics_tag.sim +#./test.sh -f general/vector/metrics_time.sim +#./test.sh -f general/vector/multi.sim +./test.sh -f general/vector/single.sim +#./test.sh -f general/vector/table_field.sim +#./test.sh -f general/vector/table_mix.sim +#./test.sh -f general/vector/table_query.sim +#./test.sh -f general/vector/table_time.sim -######### unique ######### +################################# ./test.sh -u -f unique/account/account_create.sim ./test.sh -u -f unique/account/account_delete.sim @@ -120,7 +191,9 @@ cd ../../../debug; make ./test.sh -u -f unique/account/user_create.sim ./test.sh -u -f unique/account/user_len.sim -#big +#./test.sh -u -f unique/big/balance.sim +#./test.sh -u -f unique/big/maxvnodes.sim +#./test.sh -u -f unique/big/tcp.sim ./test.sh -u -f unique/cluster/balance1.sim ./test.sh -u -f unique/cluster/balance2.sim @@ -129,6 +202,9 @@ cd ../../../debug; make ./test.sh -u -f unique/column/replica3.sim +#./test.sh -u -f unique/db/commit.sim +#./test.sh -u -f unique/db/delete.sim +#./test.sh -u -f unique/db/delete_part.sim ./test.sh -u -f unique/db/replica_add12.sim ./test.sh -u -f unique/db/replica_add13.sim ./test.sh -u -f unique/db/replica_add23.sim @@ -143,12 +219,24 @@ cd ../../../debug; make ./test.sh -u -f unique/dnode/balancex.sim ./test.sh -u -f unique/dnode/offline1.sim ./test.sh -u -f unique/dnode/offline2.sim +#./test.sh -u -f unique/dnode/remove1.sim +#./test.sh -u -f unique/dnode/remove2.sim +#./test.sh -u -f unique/dnode/vnode_clean.sim ./test.sh -u -f unique/http/admin.sim +./test.sh -u -f unique/http/opentsdb.sim -#import +#./test.sh -u -f unique/import/replica2.sim +#./test.sh -u -f unique/import/replica3.sim -#metrics +#./test.sh -u -f unique/metrics/balance_replica1.sim +#./test.sh -u -f unique/metrics/dnode2_stop.sim +#./test.sh -u -f unique/metrics/dnode2.sim +#./test.sh -u -f unique/metrics/dnode3.sim +#./test.sh -u -f unique/metrics/replica2_dnode4.sim +#./test.sh -u -f unique/metrics/replica2_vnode3.sim +#./test.sh -u -f unique/metrics/replica3_dnode6.sim +#./test.sh -u -f unique/metrics/replica3_vnode3.sim ./test.sh -u -f unique/mnode/mgmt22.sim ./test.sh -u -f unique/mnode/mgmt23.sim @@ -157,10 +245,21 @@ cd ../../../debug; make ./test.sh -u -f unique/mnode/mgmt26.sim ./test.sh -u -f unique/mnode/mgmt33.sim ./test.sh -u -f unique/mnode/mgmt34.sim +#./test.sh -u -f unique/mnode/mgmtr2.sim +#./test.sh -u -f unique/mnode/secondIp.sim #stream -#table +./test.sh -u -f unique/table/delete_part.sim ./test.sh -u -f unique/vnode/replica2_basic2.sim -./test.sh -u -f unique/vnode/replica3_basic.sim \ No newline at end of file +./test.sh -u -f unique/vnode/replica3_basic.sim + +#./test.sh -u -f unique/vnode/commit.sim +#./test.sh -u -f unique/vnode/many.sim +#./test.sh -u -f unique/vnode/replica2_basic.sim +./test.sh -u -f unique/vnode/replica2_basic2.sim +#./test.sh -u -f unique/vnode/replica2_repeat.sim +./test.sh -u -f unique/vnode/replica3_basic.sim +#./test.sh -u -f unique/vnode/replica3_repeat.sim +#./test.sh -u -f unique/vnode/replica3_vgroup.sim diff --git a/tests/script/unique/big/balance.sim b/tests/script/unique/big/balance.sim index 4eb5772811..52199f046e 100644 --- a/tests/script/unique/big/balance.sim +++ b/tests/script/unique/big/balance.sim @@ -304,3 +304,12 @@ print select count(*) from mt $data00 expect $rowNum if $data00 != $totalNum then goto show5 endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/big/maxvnodes.sim b/tests/script/unique/big/maxvnodes.sim index 738fd0704d..00995ba32c 100644 --- a/tests/script/unique/big/maxvnodes.sim +++ b/tests/script/unique/big/maxvnodes.sim @@ -79,3 +79,12 @@ sql select count(*) from mt if $data00 != 25600 then return -1 endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/big/tcp.sim b/tests/script/unique/big/tcp.sim index 7957449617..1fb414ec74 100644 --- a/tests/script/unique/big/tcp.sim +++ b/tests/script/unique/big/tcp.sim @@ -103,5 +103,12 @@ while $i < 100 $i = $i + 1 endw -system sh/stop_dnodes.sh -sleep 10000 + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/big/testSuite.sim b/tests/script/unique/big/testSuite.sim index 5881d1fb67..2cead5626a 100644 --- a/tests/script/unique/big/testSuite.sim +++ b/tests/script/unique/big/testSuite.sim @@ -1,3 +1,3 @@ -#run unique/big/balance.sim -#run unique/big/maxvnodes.sim -#run unique/big/tcp.sim +run unique/big/balance.sim +run unique/big/maxvnodes.sim +run unique/big/tcp.sim diff --git a/tests/script/unique/cluster/testSuite.sim b/tests/script/unique/cluster/testSuite.sim index 6ef8a0dd56..9657558c12 100644 --- a/tests/script/unique/cluster/testSuite.sim +++ b/tests/script/unique/cluster/testSuite.sim @@ -1,4 +1,4 @@ run unique/cluster/balance1.sim run unique/cluster/balance2.sim run unique/cluster/balance3.sim -#run unique/cluster/cache.sim +run unique/cluster/cache.sim diff --git a/tests/script/unique/db/commit.sim b/tests/script/unique/db/commit.sim index 0e58c6ed76..648cd8db2f 100644 --- a/tests/script/unique/db/commit.sim +++ b/tests/script/unique/db/commit.sim @@ -1,7 +1,4 @@ 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 @@ -118,3 +115,11 @@ if $data01 != 40 then return -1 endi +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/delete.sim b/tests/script/unique/db/delete.sim index 5100b93dcd..e222db8d70 100644 --- a/tests/script/unique/db/delete.sim +++ b/tests/script/unique/db/delete.sim @@ -44,3 +44,12 @@ sql show databases if $rows != 0 then return -1 endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/delete_part.sim b/tests/script/unique/db/delete_part.sim index 3ed4f5d753..3d1cc5dc63 100644 --- a/tests/script/unique/db/delete_part.sim +++ b/tests/script/unique/db/delete_part.sim @@ -1,9 +1,4 @@ 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 @@ -77,3 +72,11 @@ begin: goto begin +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/db/testSuite.sim b/tests/script/unique/db/testSuite.sim index 4918850426..adc1883a71 100644 --- a/tests/script/unique/db/testSuite.sim +++ b/tests/script/unique/db/testSuite.sim @@ -1,5 +1,5 @@ -#run unique/db/commit.sim -#run unique/db/delete.sim +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 @@ -7,4 +7,4 @@ 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 +run unique/db/delete_part.sim diff --git a/tests/script/unique/dnode/remove1.sim b/tests/script/unique/dnode/remove1.sim index d6837d7dfe..545c28a4ea 100644 --- a/tests/script/unique/dnode/remove1.sim +++ b/tests/script/unique/dnode/remove1.sim @@ -194,3 +194,12 @@ endi if $data41 != 35 then return -1 endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/remove2.sim b/tests/script/unique/dnode/remove2.sim index 66ebd97722..972b77a35d 100644 --- a/tests/script/unique/dnode/remove2.sim +++ b/tests/script/unique/dnode/remove2.sim @@ -140,3 +140,12 @@ endi if $data41 != 35 then return -1 endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/dnode/testSuite.sim b/tests/script/unique/dnode/testSuite.sim index 9921cbf378..ecd43cc224 100644 --- a/tests/script/unique/dnode/testSuite.sim +++ b/tests/script/unique/dnode/testSuite.sim @@ -4,6 +4,6 @@ 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 +run unique/dnode/remove1.sim +run unique/dnode/remove2.sim +run unique/dnode/vnode_clean.sim diff --git a/tests/script/unique/dnode/vnode_clean.sim b/tests/script/unique/dnode/vnode_clean.sim index 55abdab2b0..da34c7bc9b 100644 --- a/tests/script/unique/dnode/vnode_clean.sim +++ b/tests/script/unique/dnode/vnode_clean.sim @@ -302,3 +302,11 @@ if $data41 != 45 then return -1 endi +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/http/opentsdb.sim b/tests/script/unique/http/opentsdb.sim index 1c09dac5b6..914838361a 100644 --- a/tests/script/unique/http/opentsdb.sim +++ b/tests/script/unique/http/opentsdb.sim @@ -234,4 +234,13 @@ system_content curl -u root:taosdata -d 'select count(*) from db.sys_cpu_d_bbb' print $system_content if $system_content != @{"status":"succ","head":["count(*)"],"data":[[8]],"rows":1}@ then return -1 -endi \ No newline at end of file +endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/http/testSuite.sim b/tests/script/unique/http/testSuite.sim index d4a6b1f5f5..3a9753e744 100644 --- a/tests/script/unique/http/testSuite.sim +++ b/tests/script/unique/http/testSuite.sim @@ -1,2 +1,2 @@ run unique/http/admin.sim -#run general/http/opentsdb.sim \ No newline at end of file +run general/http/opentsdb.sim \ No newline at end of file diff --git a/tests/script/unique/import/replica2.sim b/tests/script/unique/import/replica2.sim index bab04bd211..bcb4179c12 100644 --- a/tests/script/unique/import/replica2.sim +++ b/tests/script/unique/import/replica2.sim @@ -40,14 +40,16 @@ sql create table tb(ts timestamp, i int) print ================= step1 sql import into tb values(1520000010000, 10000) sql select * from tb; +print $rows if $rows != 1 then return -1 endi print ================= step2 sql insert into tb values(1520000008000, 8000) +print $rows sql select * from tb; -if $rows != 1 then +if $rows != 2 then return -1 endi @@ -55,7 +57,7 @@ print ================= step3 sql insert into tb values(1520000020000, 20000) sql select * from tb; print $rows -if $rows != 2 then +if $rows != 3 then return -1 endi @@ -64,7 +66,8 @@ sql import into tb values(1520000009000, 9000) sql import into tb values(1520000015000, 15000) sql import into tb values(1520000030000, 30000) sql select * from tb; -if $rows != 5 then +print $rows +if $rows != 6 then return -1 endi @@ -74,7 +77,8 @@ sql insert into tb values(1520000014000, 14000) sql insert into tb values(1520000025000, 25000) sql insert into tb values(1520000040000, 40000) sql select * from tb; -if $rows != 6 then +print $rows +if $rows != 9 then return -1 endi @@ -85,7 +89,8 @@ sql import into tb values(1520000023000, 23000) sql import into tb values(1520000034000, 34000) sql import into tb values(1520000050000, 50000) sql select * from tb; -if $rows != 11 then +print $rows +if $rows != 14 then return -1 endi @@ -95,7 +100,7 @@ sleep 5000 system sh/exec_up.sh -n dnode1 -s start sleep 5000 sql select * from tb; -if $rows != 11 then +if $rows != 14 then return -1 endi @@ -106,7 +111,8 @@ sql import into tb values(1520000023001, 23001) sql import into tb values(1520000034001, 34001) sql import into tb values(1520000050001, 50001) sql select * from tb; -if $rows != 16 then +print $rows +if $rows != 19 then return -1 endi @@ -116,7 +122,8 @@ sql insert into tb values(1520000014002, 14002) sql insert into tb values(1520000025002, 25002) sql insert into tb values(1520000060000, 60000) sql select * from tb; -if $rows != 17 then +print $rows +if $rows != 24 then return -1 endi @@ -148,7 +155,8 @@ sql import into tb values(1521900800000, 50004) sql import into tb values(1523110400000, 50001) sql import into tb values(1521382400000, 500051) sql select * from tb; -if $rows != 29 then +print $rows +if $rows != 36 then return -1 endi @@ -158,7 +166,8 @@ sleep 5000 system sh/exec_up.sh -n dnode1 -s start sleep 5000 sql select * from tb; -if $rows != 29 then +print $rows +if $rows != 36 then return -1 endi @@ -167,7 +176,7 @@ print ================= step11 #sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) sql import into tb values(1515680000000, 7003) (1515852800000, 7003) (1516025600000, 7003) (1516198400000, 7003) (1516371200000, 7003) sql select * from tb; -if $rows != 34 then +if $rows != 41 then return -1 endi @@ -176,7 +185,8 @@ print ================= step12 #sql import into tb values(now-19d, 7003) (now-18d, 7003) (now-17d, 7003) (now-16d, 7003) (now-15d, 7003) (now-14d, 7003) (now-13d, 7003) (now-12d, 7003) (now-11d, 7003) sql import into tb values(1518358400000, 7003) (1518444800000, 7003) (1518531200000, 7003) (1518617600000, 7003) (1518704000000, 7003) (1518790400000, 7003) (1518876800000, 7003) (1518963200000, 7003) (1519049600000, 7003) sql select * from tb; -if $rows != 43 then +print $rows +if $rows != 50 then return -1 endi @@ -195,7 +205,7 @@ sql import into tb values(1516716800000, 50001) sql import into tb values(1517580800000, 50001) sql select * from tb; -if $rows != 46 then +if $rows != 50 then return -1 endi @@ -205,6 +215,15 @@ sleep 8000 system sh/exec_up.sh -n dnode1 -s stop sleep 10000 -if $rows != 46 then +if $rows != 50 then return -1 endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/import/replica3.sim b/tests/script/unique/import/replica3.sim index c10f2da2f1..8d70d227a5 100644 --- a/tests/script/unique/import/replica3.sim +++ b/tests/script/unique/import/replica3.sim @@ -41,53 +41,59 @@ sql use ir3db sql create table tb(ts timestamp, i int) print ================= step1 -sql import into tb values(now+10000a, 10000) +sql import into tb values(1520000010000, 10000) sql select * from tb; +print $rows if $rows != 1 then return -1 endi print ================= step2 -sql insert into tb values(now+8000a, 8000) -sql select * from tb; -if $rows != 1 then - return -1 -endi - -print ================= step3 -sql insert into tb values(now+20000a, 20000) +sql insert into tb values(1520000008000, 8000) +print $rows sql select * from tb; if $rows != 2 then return -1 endi -print ================= step4 -sql import into tb values(now+8000a, 9000) -sql import into tb values(now+15000a, 15000) -sql import into tb values(now+30000a, 30000) +print ================= step3 +sql insert into tb values(1520000020000, 20000) sql select * from tb; -if $rows != 5 then +print $rows +if $rows != 3 then return -1 endi -print ================= step5 -sql insert into tb values(now+8000a, 8000) -sql insert into tb values(now+14000a, 14000) -sql insert into tb values(now+25000a, 25000) -sql insert into tb values(now+40000a, 40000) +print ================= step4 +sql import into tb values(1520000009000, 9000) +sql import into tb values(1520000015000, 15000) +sql import into tb values(1520000030000, 30000) sql select * from tb; +print $rows if $rows != 6 then return -1 endi -print ================= step6 -sql import into tb values(now+7000a, 7000) -sql import into tb values(now+12000a, 12000) -sql import into tb values(now+23000a, 23000) -sql import into tb values(now+34000a, 34000) -sql import into tb values(now+50000a, 50000) +print ================= step5 +sql insert into tb values(1520000008000, 8000) +sql insert into tb values(1520000014000, 14000) +sql insert into tb values(1520000025000, 25000) +sql insert into tb values(1520000040000, 40000) sql select * from tb; -if $rows != 11 then +print $rows +if $rows != 9 then + return -1 +endi + +print ================= step6 +sql import into tb values(1520000007000, 7000) +sql import into tb values(1520000012000, 12000) +sql import into tb values(1520000023000, 23000) +sql import into tb values(1520000034000, 34000) +sql import into tb values(1520000050000, 50000) +sql select * from tb; +print $rows +if $rows != 14 then return -1 endi @@ -97,46 +103,63 @@ endi #system sh/exec_up.sh -n dnode1 -s start #sleep 5000 #sql select * from tb; -#if $rows != 11 then +#if $rows != 14 then # return -1 #endi print ================= step7 -sql import into tb values(now+7001a, 7001) -sql import into tb values(now+12001a, 12001) -sql import into tb values(now+23001a, 23001) -sql import into tb values(now+34001a, 34001) -sql import into tb values(now+50001a, 50001) +sql import into tb values(1520000007001, 7001) +sql import into tb values(1520000012001, 12001) +sql import into tb values(1520000023001, 23001) +sql import into tb values(1520000034001, 34001) +sql import into tb values(1520000050001, 50001) sql select * from tb; -if $rows != 16 then +print $rows +if $rows != 19 then return -1 endi print ================= step8 -sql insert into tb values(now+8002a, 8002) -sql insert into tb values(now+14002a, 14002) -sql insert into tb values(now+25002a, 25002) -sql insert into tb values(now+200000a, 60000) +sql insert into tb values(1520000008002, 8002) +sql insert into tb values(1520000014002, 14002) +sql insert into tb values(1520000025002, 25002) +sql insert into tb values(1520000060000, 60000) sql select * from tb; -if $rows != 17 then +print $rows +if $rows != 24 then return -1 endi print ================= step9 -sql import into tb values(now-30d, 7003) -sql import into tb values(now-20d, 34003) -sql import into tb values(now-10d, 34003) -sql import into tb values(now-5d, 34003) -sql import into tb values(now+1m, 50001) -sql import into tb values(now+2m, 50001) -sql import into tb values(now+6m, 50001) -sql import into tb values(now+8m, 50002) -sql import into tb values(now+10m, 50003) -sql import into tb values(now+12m, 50004) -sql import into tb values(now+14m, 50001) -sql import into tb values(now+16m, 500051) +#1520000000000 +#sql import into tb values(now-30d, 7003) +#sql import into tb values(now-20d, 34003) +#sql import into tb values(now-10d, 34003) +#sql import into tb values(now-5d, 34003) +#sql import into tb values(now+1d, 50001) +#sql import into tb values(now+2d, 50001) +#sql import into tb values(now+6d, 50001) +#sql import into tb values(now+8d, 50002) +#sql import into tb values(now+10d, 50003) +#sql import into tb values(now+12d, 50004) +#sql import into tb values(now+14d, 50001) +#sql import into tb values(now+16d, 500051) + +sql import into tb values(1517408000000, 7003) +sql import into tb values(1518272000000, 34003) +sql import into tb values(1519136000000, 34003) +sql import into tb values(1519568000000, 34003) +sql import into tb values(1519654400000, 50001) +sql import into tb values(1519827200000, 50001) +sql import into tb values(1520345600000, 50001) +sql import into tb values(1520691200000, 50002) +sql import into tb values(1520864000000, 50003) +sql import into tb values(1521900800000, 50004) +sql import into tb values(1523110400000, 50001) +sql import into tb values(1521382400000, 500051) sql select * from tb; -if $rows != 29 then +print $rows +if $rows != 36 then return -1 endi @@ -146,21 +169,27 @@ sleep 5000 system sh/exec_up.sh -n dnode1 -s start sleep 5000 sql select * from tb; -if $rows != 29 then +print $rows +if $rows != 36 then return -1 endi print ================= step11 -sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) + +#sql import into tb values(now-50d, 7003) (now-48d, 7003) (now-46d, 7003) (now-44d, 7003) (now-42d, 7003) +sql import into tb values(1515680000000, 7003) (1515852800000, 7003) (1516025600000, 7003) (1516198400000, 7003) (1516371200000, 7003) sql select * from tb; -if $rows != 34 then +if $rows != 41 then return -1 endi print ================= step12 -sql import into tb values(now-19d, 7003) (now-18d, 7003) (now-17d, 7003) (now-16d, 7003) (now-15d, 7003) (now-14d, 7003) (now-13d, 7003) (now-12d, 7003) (now-11d, 7003) +#1520000000000 +#sql import into tb values(now-19d, 7003) (now-18d, 7003) (now-17d, 7003) (now-16d, 7003) (now-15d, 7003) (now-14d, 7003) (now-13d, 7003) (now-12d, 7003) (now-11d, 7003) +sql import into tb values(1518358400000, 7003) (1518444800000, 7003) (1518531200000, 7003) (1518617600000, 7003) (1518704000000, 7003) (1518790400000, 7003) (1518876800000, 7003) (1518963200000, 7003) (1519049600000, 7003) sql select * from tb; -if $rows != 43 then +print $rows +if $rows != 50 then return -1 endi @@ -169,11 +198,17 @@ system sh/exec_up.sh -n dnode2 -s stop sleep 5000 print ================= step14 -sql import into tb values(now-48d, 34003) -sql import into tb values(now-38d, 50001) -sql import into tb values(now-28d, 50001) +#1520000000000 +#sql import into tb values(now-48d, 34003) +#sql import into tb values(now-38d, 50001) +#sql import into tb values(now-28d, 50001) + +sql import into tb values(1515852800001, 34003) +sql import into tb values(1516716800000, 50001) +sql import into tb values(1517580800000, 50001) + sql select * from tb; -if $rows != 46 then +if $rows != 50 then return -1 endi @@ -183,6 +218,15 @@ sleep 8000 system sh/exec_up.sh -n dnode3 -s stop sleep 3000 -if $rows != 46 then +if $rows != 50 then return -1 endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/import/testSuite.sim b/tests/script/unique/import/testSuite.sim index df87ebf1be..8be358ce17 100644 --- a/tests/script/unique/import/testSuite.sim +++ b/tests/script/unique/import/testSuite.sim @@ -1,2 +1,2 @@ -#run unique/import/replica2.sim -#run unique/import/replica3.sim \ No newline at end of file +run unique/import/replica2.sim +run unique/import/replica3.sim \ No newline at end of file diff --git a/tests/script/unique/metrics/balance_replica1.sim b/tests/script/unique/metrics/balance_replica1.sim index 3c4e8b0664..52bf558faa 100644 --- a/tests/script/unique/metrics/balance_replica1.sim +++ b/tests/script/unique/metrics/balance_replica1.sim @@ -136,4 +136,13 @@ sql select * from $mt print select * from $mt ==> $rows if $rows != 2600 then return -1 -endi \ No newline at end of file +endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/metrics/dnode2.sim b/tests/script/unique/metrics/dnode2.sim index 03a881ea49..cd76b39ba0 100644 --- a/tests/script/unique/metrics/dnode2.sim +++ b/tests/script/unique/metrics/dnode2.sim @@ -195,4 +195,13 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/metrics/dnode2_stop.sim b/tests/script/unique/metrics/dnode2_stop.sim index 58a46f9be9..996482d11e 100644 --- a/tests/script/unique/metrics/dnode2_stop.sim +++ b/tests/script/unique/metrics/dnode2_stop.sim @@ -148,4 +148,13 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/metrics/dnode3.sim b/tests/script/unique/metrics/dnode3.sim index 503ce6c47a..3a5419dff4 100644 --- a/tests/script/unique/metrics/dnode3.sim +++ b/tests/script/unique/metrics/dnode3.sim @@ -224,4 +224,13 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/metrics/replica2_dnode4.sim b/tests/script/unique/metrics/replica2_dnode4.sim index 7672b19ad9..bedc895dd1 100644 --- a/tests/script/unique/metrics/replica2_dnode4.sim +++ b/tests/script/unique/metrics/replica2_dnode4.sim @@ -215,4 +215,13 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/metrics/replica2_vnode3.sim b/tests/script/unique/metrics/replica2_vnode3.sim index e7163e826d..9a1d3477be 100644 --- a/tests/script/unique/metrics/replica2_vnode3.sim +++ b/tests/script/unique/metrics/replica2_vnode3.sim @@ -192,4 +192,13 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/metrics/replica3_dnode6.sim b/tests/script/unique/metrics/replica3_dnode6.sim index ef70bf5cc3..135e594cdc 100644 --- a/tests/script/unique/metrics/replica3_dnode6.sim +++ b/tests/script/unique/metrics/replica3_dnode6.sim @@ -245,4 +245,13 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/metrics/replica3_vnode3.sim b/tests/script/unique/metrics/replica3_vnode3.sim index 50ad6d7584..ca147c1ef5 100644 --- a/tests/script/unique/metrics/replica3_vnode3.sim +++ b/tests/script/unique/metrics/replica3_vnode3.sim @@ -214,4 +214,13 @@ sql drop database $db sql show databases if $rows != 0 then return -1 -endi \ No newline at end of file +endi + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/metrics/testSuite.sim b/tests/script/unique/metrics/testSuite.sim index dd8ab53aa1..2e3ab31a44 100644 --- a/tests/script/unique/metrics/testSuite.sim +++ b/tests/script/unique/metrics/testSuite.sim @@ -1,4 +1,8 @@ -#run unique/metrics/disk.sim -#run unique/metrics/metrics.sim -#run unique/metrics/values.sim -#run unique/metrics/vnode3.sim \ No newline at end of file +run unique/metrics/balance_replica1.sim +run unique/metrics/dnode2_stop.sim +run unique/metrics/dnode2.sim +run unique/metrics/dnode3.sim +run unique/metrics/replica2_dnode4.sim +run unique/metrics/replica2_vnode3.sim +run unique/metrics/replica3_dnode6.sim +run unique/metrics/replica3_vnode3.sim \ No newline at end of file diff --git a/tests/script/unique/mnode/mgmtr2.sim b/tests/script/unique/mnode/mgmtr2.sim index aa0f4877fb..56a4b30573 100644 --- a/tests/script/unique/mnode/mgmtr2.sim +++ b/tests/script/unique/mnode/mgmtr2.sim @@ -75,6 +75,11 @@ if $dnode3Role != NULL then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -system sh/exec_up.sh -n dnode2 -s stop -system sh/exec_up.sh -n dnode3 -s stop \ No newline at end of file +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/mnode/secondIp.sim b/tests/script/unique/mnode/secondIp.sim index 71c2cdfb76..cfe75ffc84 100644 --- a/tests/script/unique/mnode/secondIp.sim +++ b/tests/script/unique/mnode/secondIp.sim @@ -34,6 +34,11 @@ if $data4_2 != 4 then return -1 endi -system sh/exec_up.sh -n dnode1 -s stop -system sh/exec_up.sh -n dnode2 -s stop -system sh/exec_up.sh -n dnode3 -s stop \ No newline at end of file +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/table/delete_part.sim b/tests/script/unique/table/delete_part.sim index f4a7b6fce4..04cb03598c 100644 --- a/tests/script/unique/table/delete_part.sim +++ b/tests/script/unique/table/delete_part.sim @@ -1,9 +1,4 @@ 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 @@ -79,4 +74,12 @@ begin: $loop = $loop + 1 goto begin - \ No newline at end of file + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/table/testSuite.sim b/tests/script/unique/table/testSuite.sim index 373f358ac8..e0c0a1f2fa 100644 --- a/tests/script/unique/table/testSuite.sim +++ b/tests/script/unique/table/testSuite.sim @@ -1 +1 @@ -#run unique/table/delete_part.sim +run unique/table/delete_part.sim diff --git a/tests/script/unique/vnode/commit.sim b/tests/script/unique/vnode/commit.sim index dae6571667..29c9f72335 100644 --- a/tests/script/unique/vnode/commit.sim +++ b/tests/script/unique/vnode/commit.sim @@ -148,4 +148,11 @@ if $rows != $remainRows then return -1 endi -system sh/exec_up.sh -n dnode1 -s start +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT diff --git a/tests/script/unique/vnode/many.sim b/tests/script/unique/vnode/many.sim index 544f7d5b55..0504207c2e 100644 --- a/tests/script/unique/vnode/many.sim +++ b/tests/script/unique/vnode/many.sim @@ -113,4 +113,11 @@ if $x < 5 then goto loop endi - +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica2_basic.sim b/tests/script/unique/vnode/replica2_basic.sim index 8e18c3b9e7..a0ea7085cb 100644 --- a/tests/script/unique/vnode/replica2_basic.sim +++ b/tests/script/unique/vnode/replica2_basic.sim @@ -188,5 +188,12 @@ if $rows != $expect then endi print =================== step 12 -system sh/exec_up.sh -n dnode1 -s stop -system sh/exec_up.sh -n dnode2 -s stop + +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica2_repeat.sim b/tests/script/unique/vnode/replica2_repeat.sim index cc1feecb07..f7da1babb7 100644 --- a/tests/script/unique/vnode/replica2_repeat.sim +++ b/tests/script/unique/vnode/replica2_repeat.sim @@ -71,4 +71,11 @@ if $x < 5 then goto loop endi - +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica3_repeat.sim b/tests/script/unique/vnode/replica3_repeat.sim index 0ed16e0729..8c3ed902fb 100644 --- a/tests/script/unique/vnode/replica3_repeat.sim +++ b/tests/script/unique/vnode/replica3_repeat.sim @@ -80,4 +80,11 @@ if $x < 5 then goto loop endi - +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/replica3_vgroup.sim b/tests/script/unique/vnode/replica3_vgroup.sim index 2763ed7c67..f63bf1783d 100644 --- a/tests/script/unique/vnode/replica3_vgroup.sim +++ b/tests/script/unique/vnode/replica3_vgroup.sim @@ -61,5 +61,11 @@ endw # return -1 #endi - - +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/unique/vnode/testSuite.sim b/tests/script/unique/vnode/testSuite.sim index 9cf8ed0fc1..46b01aaa45 100644 --- a/tests/script/unique/vnode/testSuite.sim +++ b/tests/script/unique/vnode/testSuite.sim @@ -1,7 +1,8 @@ +run unique/vnode/commit.sim +run unique/vnode/many.sim +run unique/vnode/replica2_basic.sim run unique/vnode/replica2_basic2.sim -#run unique/vnode/replica2_basic.sim -#run unique/vnode/replica2_repeat.sim +run unique/vnode/replica2_repeat.sim run unique/vnode/replica3_basic.sim -#run unique/vnode/replica3_repeat.sim -#run unique/vnode/commit.sim -#run unique/vnode/many.sim +run unique/vnode/replica3_repeat.sim +run unique/vnode/replica3_vgroup.sim From dd1bb6e0369c3cd3eed49b798454c182571b0b68 Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 8 May 2020 15:36:39 +0800 Subject: [PATCH 24/36] fix alter db bug --- src/mnode/src/mgmtDb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mnode/src/mgmtDb.c b/src/mnode/src/mgmtDb.c index d8dfcbe213..5cee1f30cd 100644 --- a/src/mnode/src/mgmtDb.c +++ b/src/mnode/src/mgmtDb.c @@ -803,7 +803,7 @@ static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) { newCfg.daysToKeep2 = daysToKeep2; } - if (compression > 0 && compression != pDb->cfg.compression) { + if (compression >= 0 && compression != pDb->cfg.compression) { mTrace("db:%s, compression:%d change to %d", pDb->name, pDb->cfg.compression, compression); newCfg.compression = compression; } @@ -823,7 +823,7 @@ static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) { } } - if (walLevel > 0 && (walLevel < TSDB_MIN_WAL_LEVEL || walLevel > TSDB_MAX_WAL_LEVEL)) { + if (walLevel >= 0 && (walLevel < TSDB_MIN_WAL_LEVEL || walLevel > TSDB_MAX_WAL_LEVEL)) { mError("db:%s, wal level %d should be between 0-2, origin:%d", pDb->name, walLevel, pDb->cfg.walLevel); terrno = TSDB_CODE_INVALID_OPTION; } From 6a70b5d19a2dbad18279284e672ea12648c10940 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 8 May 2020 15:55:28 +0800 Subject: [PATCH 25/36] add general/parser test case to 2.0 [TD-253] --- tests/script/basicSuite.sim | 1 + .../general/parser/auto_create_tb_drop_tb.sim | 2 +- tests/script/general/parser/create_db.sim | 14 +- tests/script/general/parser/first_last.sim | 2 +- tests/script/general/parser/mixed_blocks.sim | 2 +- tests/script/general/parser/slimit.sim | 4 +- tests/script/general/parser/slimit1.sim | 2 +- .../general/parser/slimit_alter_tags.sim | 2 +- tests/script/general/parser/testSuite.sim | 178 ++++++++++-------- tests/script/general/parser/timestamp.sim | 2 +- 10 files changed, 115 insertions(+), 94 deletions(-) diff --git a/tests/script/basicSuite.sim b/tests/script/basicSuite.sim index df15c7ebbb..973a88f553 100644 --- a/tests/script/basicSuite.sim +++ b/tests/script/basicSuite.sim @@ -42,4 +42,5 @@ run general/compute/diff.sim run general/compute/null.sim # run general/compute/diff2.sim +run general/parse/testSuite.sim ################################## diff --git a/tests/script/general/parser/auto_create_tb_drop_tb.sim b/tests/script/general/parser/auto_create_tb_drop_tb.sim index 23cad7137e..aa14d2fdfb 100644 --- a/tests/script/general/parser/auto_create_tb_drop_tb.sim +++ b/tests/script/general/parser/auto_create_tb_drop_tb.sim @@ -22,7 +22,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db rows 200 cache 2048 maxTables 4 +sql create database $db maxrows 200 cache 2048 maxTables 4 print ====== create tables sql use $db diff --git a/tests/script/general/parser/create_db.sim b/tests/script/general/parser/create_db.sim index 6e11f9d25b..8048770198 100644 --- a/tests/script/general/parser/create_db.sim +++ b/tests/script/general/parser/create_db.sim @@ -108,10 +108,10 @@ $cache = 4096 # 4 kb $ablocks = 100 $tblocks = 32 # max=512, automatically trimmed when exceeding $ctime = 36000 # 10 hours -$clog = 0 # max=32, automatically trimmed when exceeding +$wal = 0 # valid value is 0, 1, 2 $comp = 1 # max=32, automatically trimmed when exceeding -sql create database $db replica $replica days $days keep $keep rows $rows_db cache $cache ablocks $ablocks tblocks $tblocks ctime $ctime clog $clog comp $comp +sql create database $db replica $replica days $days keep $keep maxrows $rows_db cache $cache ablocks $ablocks tblocks $tblocks ctime $ctime wal $wal comp $comp sql show databases if $rows != 1 then return -1 @@ -156,8 +156,8 @@ sql_error create database $db keep 0 #sql_error create database $db keep 3651 # rows [200, 10000] -sql_error create database $db rows 199 -#sql_error create database $db rows 10001 +sql_error create database $db maxrows 199 +#sql_error create database $db maxrows 10001 # cache [100, 10485760] sql_error create database $db cache 99 @@ -175,9 +175,9 @@ sql_error create database $db ablocks -1 sql_error create database $db ctime 29 sql_error create database $db ctime 40961 -# clog {0, 1} -sql_error create database $db clog -1 -#sql_error create database $db clog 2 +# wal {0, 1} +sql_error create database $db wal -1 +#sql_error create database $db wal 2 # comp {0, 1, 2} sql_error create database $db comp -1 diff --git a/tests/script/general/parser/first_last.sim b/tests/script/general/parser/first_last.sim index 8bede7573a..b67764dc9b 100644 --- a/tests/script/general/parser/first_last.sim +++ b/tests/script/general/parser/first_last.sim @@ -21,7 +21,7 @@ $stb = $stbPrefix . $i sql drop database $db -x step1 step1: -sql create database $db rows 400 cache 4096 maxTables 4 +sql create database $db maxrows 400 cache 4096 maxTables 4 sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int) diff --git a/tests/script/general/parser/mixed_blocks.sim b/tests/script/general/parser/mixed_blocks.sim index 37ba1a8900..77838774df 100644 --- a/tests/script/general/parser/mixed_blocks.sim +++ b/tests/script/general/parser/mixed_blocks.sim @@ -22,7 +22,7 @@ sql drop database if exists $db $paramRows = 200 $rowNum = $paramRows * 4 $rowNum = $rowNum / 5 -sql create database $db rows $paramRows maxTables 4 +sql create database $db maxrows $paramRows maxTables 4 print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 bool, c6 binary(10), c7 nchar(10)) tags(t1 int) diff --git a/tests/script/general/parser/slimit.sim b/tests/script/general/parser/slimit.sim index 234e31d261..017e8d4d2e 100644 --- a/tests/script/general/parser/slimit.sim +++ b/tests/script/general/parser/slimit.sim @@ -22,7 +22,7 @@ $db = $dbPrefix . $i $stb = $stbPrefix . $i sql drop database if exists $db -sql create database $db rows 200 cache 1024 tblocks 200 maxTables 4 +sql create database $db maxrows 200 cache 1024 tblocks 200 maxTables 4 print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 binary(15), t2 int, t3 bigint, t4 nchar(10), t5 double, t6 bool) @@ -64,7 +64,7 @@ print ====== $db tables created $db = $dbPrefix . 1 sql drop database if exists $db -sql create database $db rows 200 cache 1024 +sql create database $db maxrows 200 cache 1024 sql use $db sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 binary(15), t2 int, t3 bigint, t4 nchar(10), t5 double, t6 bool) diff --git a/tests/script/general/parser/slimit1.sim b/tests/script/general/parser/slimit1.sim index 7020cc8bb7..3dbe9f0a06 100644 --- a/tests/script/general/parser/slimit1.sim +++ b/tests/script/general/parser/slimit1.sim @@ -18,7 +18,7 @@ $delta = 600000 $db = $dbPrefix sql drop database if exists $db -sql create database $db rows 200 +sql create database $db maxrows 200 sql use $db sql create table stb (ts timestamp, c1 int, c2 bigint, c3 double) tags(t1 int, t2 int) diff --git a/tests/script/general/parser/slimit_alter_tags.sim b/tests/script/general/parser/slimit_alter_tags.sim index 630855260c..5c62482802 100644 --- a/tests/script/general/parser/slimit_alter_tags.sim +++ b/tests/script/general/parser/slimit_alter_tags.sim @@ -18,7 +18,7 @@ $delta = 600000 $db = $dbPrefix sql drop database if exists $db -sql create database $db rows 200 +sql create database $db maxrows 200 sql use $db sql create table stb (ts timestamp, c1 int, c2 bigint, c3 double) tags(t1 int, t2 int) diff --git a/tests/script/general/parser/testSuite.sim b/tests/script/general/parser/testSuite.sim index d1228f5820..aaf8979337 100644 --- a/tests/script/general/parser/testSuite.sim +++ b/tests/script/general/parser/testSuite.sim @@ -1,93 +1,113 @@ -#run general/parser/alter.sim -#sleep 2000 -#run general/parser/alter1.sim -#sleep 2000 -#run general/parser/alter_stable.sim -#sleep 2000 -#run general/parser/auto_create_tb.sim -#sleep 2000 -#run general/parser/auto_create_tb_drop_tb.sim +# run general/parser/alter.sim +# sleep 2000 +# run general/parser/alter1.sim +# sleep 2000 +# run general/parser/alter_stable.sim +# sleep 2000 +# run general/parser/auto_create_tb.sim +# sleep 2000 +# run general/parser/auto_create_tb_drop_tb.sim +# sleep 2000 +run general/parser/binary_escapeCharacter.sim +sleep 2000 +run general/parser/bug.sim sleep 2000 run general/parser/col_arithmetic_operation.sim sleep 2000 -run general/parser/columnValue.sim +run general/parser/columnValue_bigint.sim sleep 2000 -run general/parser/commit.sim -run general/parser/create_db.sim +run general/parser/columnValue_bool.sim sleep 2000 -run general/parser/create_mt.sim +run general/parser/columnValue_double.sim sleep 2000 -run general/parser/create_tb.sim +run general/parser/columnValue_float.sim sleep 2000 -run general/parser/dbtbnameValidate.sim -sleep 2000 -run general/parser/fill.sim -sleep 2000 -run general/parser/fill_stb.sim -sleep 2000 -run general/parser/first_last.sim -sleep 2000 -run general/parser/import_commit1.sim -sleep 2000 -run general/parser/import_commit2.sim -sleep 2000 -run general/parser/import_commit3.sim -sleep 2000 -run general/parser/import_file.sim -sleep 2000 -run general/parser/insert_tb.sim -sleep 2000 -run general/parser/tags_dynamically_specifiy.sim -sleep 2000 -run general/parser/interp.sim -run general/parser/lastrow.sim -sleep 2000 -run general/parser/limit.sim -sleep 2000 -run general/parser/limit1.sim -sleep 2000 -run general/parser/limit1_tblocks100.sim -sleep 2000 -run general/parser/limit2.sim -sleep 2000 -run general/parser/mixed_blocks.sim -sleep 2000 -run general/parser/nchar.sim -sleep 2000 -run general/parser/null_char.sim -sleep 2000 -run general/parser/selectResNum.sim -sleep 2000 -run general/parser/select_across_vnodes.sim +run general/parser/columnValue_int.sim sleep 2000 + +# sleep 2000 +# run general/parser/col_arithmetic_operation.sim +# sleep 2000 +# run general/parser/columnValue.sim +# sleep 2000 +# run general/parser/commit.sim +# run general/parser/create_db.sim +# sleep 2000 +# run general/parser/create_mt.sim +# sleep 2000 +# run general/parser/create_tb.sim +# sleep 2000 +# run general/parser/dbtbnameValidate.sim +# sleep 2000 +# run general/parser/fill.sim +# sleep 2000 +# run general/parser/fill_stb.sim +# sleep 2000 +# run general/parser/first_last.sim +# sleep 2000 +# run general/parser/import_commit1.sim +# sleep 2000 +# run general/parser/import_commit2.sim +# sleep 2000 +# run general/parser/import_commit3.sim +# sleep 2000 +# run general/parser/import_file.sim +# sleep 2000 +# run general/parser/insert_tb.sim +# sleep 2000 +# run general/parser/tags_dynamically_specifiy.sim +# sleep 2000 +# run general/parser/interp.sim +# run general/parser/lastrow.sim +# sleep 2000 +# run general/parser/limit.sim +# sleep 2000 +# run general/parser/limit1.sim +# sleep 2000 +# run general/parser/limit1_tblocks100.sim +# sleep 2000 +# run general/parser/limit2.sim +# sleep 2000 +# run general/parser/mixed_blocks.sim +# sleep 2000 +# run general/parser/nchar.sim +# sleep 2000 +# run general/parser/null_char.sim +# sleep 2000 +# run general/parser/selectResNum.sim +# sleep 2000 +# run general/parser/select_across_vnodes.sim +# sleep 2000 run general/parser/select_from_cache_disk.sim sleep 2000 -run general/parser/set_tag_vals.sim -sleep 2000 -run general/parser/single_row_in_tb.sim -sleep 2000 -run general/parser/slimit.sim -sleep 2000 +# run general/parser/set_tag_vals.sim +# sleep 2000 +# run general/parser/single_row_in_tb.sim +# sleep 2000 +# run general/parser/slimit.sim +# sleep 2000 run general/parser/slimit1.sim sleep 2000 -run general/parser/slimit_alter_tags.sim +run general/parser/slimit1_query.sim sleep 2000 -run general/parser/stream_on_sys.sim -sleep 2000 -run general/parser/stream.sim -sleep 2000 -run general/parser/tbnameIn.sim -sleep 2000 -run general/parser/where.sim -sleep 2000 -#run general/parser/repeatAlter.sim -sleep 2000 -#run general/parser/repeatStream.sim -sleep 2000 -run general/parser/join.sim -run general/parser/join_multivnode.sim -run general/parser/projection_limit_offset.sim -sleep 2000 -run general/parser/select_with_tags.sim -run general/parser/groupby.sim +# run general/parser/slimit_alter_tags.sim +# sleep 2000 +# run general/parser/stream_on_sys.sim +# sleep 2000 +# run general/parser/stream.sim +# sleep 2000 +# run general/parser/tbnameIn.sim +# sleep 2000 +# run general/parser/where.sim +# sleep 2000 +# #run general/parser/repeatAlter.sim +# sleep 2000 +# #run general/parser/repeatStream.sim +# sleep 2000 +# run general/parser/join.sim +# run general/parser/join_multivnode.sim +# run general/parser/projection_limit_offset.sim +# sleep 2000 +# run general/parser/select_with_tags.sim +# run general/parser/groupby.sim diff --git a/tests/script/general/parser/timestamp.sim b/tests/script/general/parser/timestamp.sim index 9a1c793909..fbe0f24a47 100644 --- a/tests/script/general/parser/timestamp.sim +++ b/tests/script/general/parser/timestamp.sim @@ -21,7 +21,7 @@ $db = $dbPrefix . $i $stb = $stbPrefix . $i sql drop database if exists $db -sql create database $db rows 200 cache 1024 tblocks 200 maxTables 4 +sql create database $db maxrows 200 cache 1024 tblocks 200 maxTables 4 print ====== create tables sql use $db sql create table $stb (ts timestamp, c1 timestamp, c2 int) tags(t1 binary(20)) From c4e7acc3c01f42e51252ed896d0dc036952052c7 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 8 May 2020 13:17:10 +0800 Subject: [PATCH 26/36] add general/field/*.sim to 2.0 [TD-252] --- tests/script/basicSuite.sim | 2 ++ tests/script/general/field/testSuite.sim | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/script/basicSuite.sim b/tests/script/basicSuite.sim index df15c7ebbb..7ab8803ae8 100644 --- a/tests/script/basicSuite.sim +++ b/tests/script/basicSuite.sim @@ -42,4 +42,6 @@ run general/compute/diff.sim run general/compute/null.sim # run general/compute/diff2.sim +run general/field/testSuite.sim + ################################## diff --git a/tests/script/general/field/testSuite.sim b/tests/script/general/field/testSuite.sim index 9b58c77e92..d12f0ebbd4 100644 --- a/tests/script/general/field/testSuite.sim +++ b/tests/script/general/field/testSuite.sim @@ -1,4 +1,4 @@ -run general/field/single.sim +# run general/field/single.sim run general/field/bool.sim run general/field/smallint.sim run general/field/tinyint.sim @@ -6,9 +6,9 @@ run general/field/int.sim run general/field/bigint.sim run general/field/float.sim run general/field/double.sim -run general/field/binary.sim -run general/field/2.sim -run general/field/3.sim -run general/field/4.sim -run general/field/5.sim -run general/field/6.sim \ No newline at end of file +# run general/field/binary.sim +# run general/field/2.sim +# run general/field/3.sim +# run general/field/4.sim +# run general/field/5.sim +# run general/field/6.sim From 4b86e0a39c54d86891c8a53a46c11aa345611d71 Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Fri, 8 May 2020 16:23:07 +0800 Subject: [PATCH 27/36] [td-225] add remove support for skiplist and super table index. --- src/tsdb/src/tsdbMeta.c | 12 +- src/util/inc/tskiplist.h | 5 +- src/util/src/tskiplist.c | 496 ++++++++++++++++++++------------------- 3 files changed, 267 insertions(+), 246 deletions(-) diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 63ccb538ed..7b849135e0 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -502,13 +502,19 @@ static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable) { memcpy(SL_GET_NODE_DATA(pNode), &pTable, POINTER_BYTES); tSkipListPut(list, pNode); - return 0; } static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) { - assert(pTable->type == TSDB_CHILD_TABLE); - // TODO + assert(pTable->type == TSDB_CHILD_TABLE && pTable != NULL); + + STable* pSTable = tsdbGetTableByUid(pMeta, pTable->superUid); + assert(pSTable != NULL); + + char* key = dataRowTuple(pTable->tagVal); // key + bool ret = tSkipListRemove(pSTable->pIndex, key); + + assert(ret); return 0; } diff --git a/src/util/inc/tskiplist.h b/src/util/inc/tskiplist.h index 4634c14881..759ecbb7ed 100644 --- a/src/util/inc/tskiplist.h +++ b/src/util/inc/tskiplist.h @@ -178,10 +178,9 @@ SSkipListNode *tSkipListPut(SSkipList *pSkipList, SSkipListNode *pNode); * * @param pSkipList * @param pKey - * @param keyType * @return */ -SArray *tSkipListGet(SSkipList *pSkipList, SSkipListKey pKey, int16_t keyType); +SArray *tSkipListGet(SSkipList *pSkipList, SSkipListKey pKey); /** * get the size of skip list @@ -242,7 +241,7 @@ void *tSkipListDestroyIter(SSkipListIterator *iter); * true: one node has been removed * false: no node has been removed */ -bool tSkipListRemove(SSkipList *pSkipList, SSkipListKey *pKey); +bool tSkipListRemove(SSkipList *pSkipList, SSkipListKey key); /* * remove the specified node in parameters diff --git a/src/util/src/tskiplist.c b/src/util/src/tskiplist.c index 4149449e6c..25ea49b60d 100644 --- a/src/util/src/tskiplist.c +++ b/src/util/src/tskiplist.c @@ -74,6 +74,7 @@ static void tSkipListDoInsert(SSkipList *pSkipList, SSkipListNode **forward, SSk static SSkipListNode* tSkipListPushBack(SSkipList *pSkipList, SSkipListNode *pNode); static SSkipListNode* tSkipListPushFront(SSkipList* pSkipList, SSkipListNode *pNode); static SSkipListIterator* doCreateSkipListIterator(SSkipList *pSkipList, int32_t order); +static SSkipListNode* tSkipListDoGet(SSkipList *pSkipList, SSkipListKey key); static bool initForwardBackwardPtr(SSkipList* pSkipList) { uint32_t maxLevel = pSkipList->maxLevel; @@ -97,6 +98,7 @@ static bool initForwardBackwardPtr(SSkipList* pSkipList) { return true; } + SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint8_t keyLen, uint8_t dupKey, uint8_t lock, uint8_t freeNode, __sl_key_fn_t fn) { SSkipList *pSkipList = (SSkipList *)calloc(1, sizeof(SSkipList)); @@ -139,25 +141,6 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint8_t keyLen, ui return pSkipList; } -// static void doRemove(SSkipList *pSkipList, SSkipListNode *pNode, SSkipListNode *forward[]) { -// int32_t level = pNode->level; -// for (int32_t j = level - 1; j >= 0; --j) { -// if ((forward[j]->pForward[j] != NULL) && (forward[j]->pForward[j]->pForward[j])) { -// forward[j]->pForward[j]->pForward[j]->pBackward[j] = forward[j]; -// } -// -// if (forward[j]->pForward[j] != NULL) { -// forward[j]->pForward[j] = forward[j]->pForward[j]->pForward[j]; -// } -// } -// -// pSkipList->state.nTotalMemSize -= (sizeof(SSkipListNode) + POINTER_BYTES * pNode->level * 2); -// removeNodeEachLevel(pSkipList, pNode->level); -// -// tfree(pNode); -// --pSkipList->size; -//} - void *tSkipListDestroy(SSkipList *pSkipList) { if (pSkipList == NULL) { return NULL; @@ -257,105 +240,10 @@ SSkipListNode *tSkipListPut(SSkipList *pSkipList, SSkipListNode *pNode) { return pNode; } -void tSkipListDoInsert(SSkipList *pSkipList, SSkipListNode **forward, SSkipListNode *pNode) { - DO_MEMSET_PTR_AREA(pNode); - - for (int32_t i = 0; i < pNode->level; ++i) { - SSkipListNode *x = forward[i]; - SL_GET_BACKWARD_POINTER(pNode, i) = x; - - SSkipListNode *next = SL_GET_FORWARD_POINTER(x, i); - SL_GET_BACKWARD_POINTER(next, i) = pNode; - - SL_GET_FORWARD_POINTER(pNode, i) = next; - SL_GET_FORWARD_POINTER(x, i) = pNode; - } - - atomic_add_fetch_32(&pSkipList->size, 1); - if (pSkipList->lock) { - pthread_rwlock_unlock(pSkipList->lock); - } -} - -SSkipListNode* tSkipListPushFront(SSkipList* pSkipList, SSkipListNode *pNode) { - SSkipListNode* forward[MAX_SKIP_LIST_LEVEL] = {0}; - for(int32_t i = 0; i < pSkipList->level; ++i) { - forward[i] = pSkipList->pHead; - } - - tSkipListDoInsert(pSkipList, forward, pNode); - return pNode; -} - -SSkipListNode* tSkipListPushBack(SSkipList *pSkipList, SSkipListNode *pNode) { - // do clear pointer area - DO_MEMSET_PTR_AREA(pNode); - - for(int32_t i = 0; i < pNode->level; ++i) { - SSkipListNode* prev = SL_GET_BACKWARD_POINTER(pSkipList->pTail, i); - SL_GET_FORWARD_POINTER(prev, i) = pNode; - SL_GET_FORWARD_POINTER(pNode, i) = pSkipList->pTail; - - SL_GET_BACKWARD_POINTER(pNode, i) = prev; - SL_GET_BACKWARD_POINTER(pSkipList->pTail, i) = pNode; - } - - pSkipList->lastKey = SL_GET_NODE_KEY(pSkipList, pNode); - - atomic_add_fetch_32(&pSkipList->size, 1); - if (pSkipList->lock) { - pthread_rwlock_unlock(pSkipList->lock); - } - - return pNode; -} - -SArray* tSkipListGet(SSkipList *pSkipList, SSkipListKey pKey, int16_t keyType) { - int32_t sLevel = pSkipList->level - 1; - - // result list +SArray* tSkipListGet(SSkipList *pSkipList, SSkipListKey key) { SArray* sa = taosArrayInit(1, POINTER_BYTES); - SSkipListNode *pNode = pSkipList->pHead; - - if (pSkipList->lock) { - pthread_rwlock_rdlock(pSkipList->lock); - } - -#if SKIP_LIST_RECORD_PERFORMANCE - pSkipList->state.queryCount++; -#endif - - __compar_fn_t filterComparFn = getComparFunc(pSkipList->keyInfo.type, 0); - int32_t ret = -1; - for (int32_t i = sLevel; i >= 0; --i) { - SSkipListNode *p = SL_GET_FORWARD_POINTER(pNode, i); - while (p != pSkipList->pTail) { - char *key = SL_GET_NODE_KEY(pSkipList, p); - - if ((ret = filterComparFn(key, pKey)) < 0) { - pNode = p; - p = SL_GET_FORWARD_POINTER(p, i); - } else { - break; - } - } - - // find the qualified key - if (ret == 0) { - SSkipListNode* pResult = SL_GET_FORWARD_POINTER(pNode, i); - taosArrayPush(sa, &pResult); - - // skip list does not allowed duplicated key, abort further retrieve data - if (!pSkipList->keyInfo.dupKey) { - break; - } - } - } - - if (pSkipList->lock) { - pthread_rwlock_unlock(pSkipList->lock); - } - + SSkipListNode* pNode = tSkipListDoGet(pSkipList, key); + taosArrayPush(sa, &pNode); return sa; } @@ -367,114 +255,6 @@ size_t tSkipListGetSize(const SSkipList* pSkipList) { return pSkipList->size; } -SSkipListIterator* tSkipListCreateIter(SSkipList *pSkipList) { - if (pSkipList == NULL) { - return NULL; - } - - return doCreateSkipListIterator(pSkipList, TSDB_ORDER_ASC); -} - -SSkipListIterator *tSkipListCreateIterFromVal(SSkipList* pSkipList, const char* val, int32_t type, int32_t order) { - if (pSkipList == NULL) { - return NULL; - } - - assert(order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC); - - if (val == NULL) { - return doCreateSkipListIterator(pSkipList, order); - } else { - - SSkipListNode *forward[MAX_SKIP_LIST_LEVEL] = {0}; - - int32_t ret = -1; - __compar_fn_t filterComparFn = getKeyComparFunc(pSkipList->keyInfo.type); - SSkipListNode* pNode = pSkipList->pHead; - - for (int32_t i = pSkipList->level - 1; i >= 0; --i) { - SSkipListNode *p = SL_GET_FORWARD_POINTER(pNode, i); - while (p != pSkipList->pTail) { - char *key = SL_GET_NODE_KEY(pSkipList, p); - - if ((ret = filterComparFn(key, val)) < 0) { - pNode = p; - p = SL_GET_FORWARD_POINTER(p, i); - } else { - break; - } - } - - forward[i] = pNode; - } - - SSkipListIterator* iter = doCreateSkipListIterator(pSkipList, order); - - // set the initial position - if (order == TSDB_ORDER_ASC) { - iter->cur = forward[0]; // greater equals than the value - } else { - iter->cur = SL_GET_FORWARD_POINTER(forward[0], 0); - - if (ret == 0) { - assert(iter->cur != pSkipList->pTail); - iter->cur = SL_GET_FORWARD_POINTER(iter->cur, 0); - } - } - - return iter; - } -} - -bool tSkipListIterNext(SSkipListIterator *iter) { - if (iter->pSkipList == NULL) { - return false; - } - - SSkipList *pSkipList = iter->pSkipList; - - if (pSkipList->lock) { - pthread_rwlock_rdlock(pSkipList->lock); - } - - if (iter->order == TSDB_ORDER_ASC) { // ascending order iterate - if (iter->cur == NULL) { - iter->cur = SL_GET_FORWARD_POINTER(pSkipList->pHead, 0); - } else { - iter->cur = SL_GET_FORWARD_POINTER(iter->cur, 0); - } - } else { // descending order iterate - if (iter->cur == NULL) { - iter->cur = SL_GET_BACKWARD_POINTER(pSkipList->pTail, 0); - } else { - iter->cur = SL_GET_BACKWARD_POINTER(iter->cur, 0); - } - } - - if (pSkipList->lock) { - pthread_rwlock_unlock(pSkipList->lock); - } - - return (iter->order == TSDB_ORDER_ASC)? (iter->cur != pSkipList->pTail) : (iter->cur != pSkipList->pHead); -} - -SSkipListNode *tSkipListIterGet(SSkipListIterator *iter) { - if (iter == NULL || iter->cur == iter->pSkipList->pTail || iter->cur == iter->pSkipList->pHead) { - return NULL; - } else { - return iter->cur; - } -} - -void* tSkipListDestroyIter(SSkipListIterator* iter) { - if (iter == NULL) { - return NULL; - } - - tfree(iter); - return NULL; -} - // static int32_t tSkipListEndParQuery(SSkipList *pSkipList, SSkipListNode *pStartNode, SSkipListKey *pEndKey, // int32_t cond, SSkipListNode ***pRes) { // pthread_rwlock_rdlock(&pSkipList->lock); @@ -588,25 +368,162 @@ void* tSkipListDestroyIter(SSkipListIterator* iter) { // } // // // compress the minimum level of skip list -// while (pSkipList->level > 0 && pSkipList->pHead.pForward[pSkipList->level - 1] == NULL) { +// while (pSkipList->level > 0 && SL_GET_FORWARD_POINTER(pSkipList->pHead, pSkipList->level - 1) == NULL) { // pSkipList->level -= 1; // } // // return true; //} -// -// void tSkipListRemoveNode(SSkipList *pSkipList, SSkipListNode *pNode) { -// SSkipListNode *forward[MAX_SKIP_LIST_LEVEL] = {0}; -// -// pthread_rwlock_rdlock(&pSkipList->lock); -// for (int32_t i = 0; i < pNode->level; ++i) { -// forward[i] = pNode->pBackward[i]; -// } -// -// removeSupport(pSkipList, forward, &pNode->key); -// pthread_rwlock_unlock(&pSkipList->lock); -//} -// + +bool tSkipListRemove(SSkipList *pSkipList, SSkipListKey key) { + SSkipListNode* pNode = tSkipListDoGet(pSkipList, key); + if (pNode != NULL) { + tSkipListRemoveNode(pSkipList, pNode); + return true; + } + + return false; +} + +void tSkipListRemoveNode(SSkipList *pSkipList, SSkipListNode *pNode) { + int32_t level = pNode->level; + + if (pSkipList->lock) { + pthread_rwlock_wrlock(pSkipList->lock); + } + + for (int32_t j = level - 1; j >= 0; --j) { + SSkipListNode* prev = SL_GET_BACKWARD_POINTER(pNode, j); + SSkipListNode* next = SL_GET_FORWARD_POINTER(pNode, j); + + SL_GET_FORWARD_POINTER(prev, j) = next; + SL_GET_BACKWARD_POINTER(next, j) = prev; + } + + if (pSkipList->keyInfo.freeNode) { + tfree(pNode); + } + + atomic_sub_fetch_32(&pSkipList->size, 1); + + // compress the minimum level of skip list + while (pSkipList->level > 0 && SL_GET_FORWARD_POINTER(pSkipList->pHead, pSkipList->level - 1) == NULL) { + pSkipList->level -= 1; + } + + if (pSkipList->lock) { + pthread_rwlock_unlock(pSkipList->lock); + } +} + +SSkipListIterator* tSkipListCreateIter(SSkipList *pSkipList) { + if (pSkipList == NULL) { + return NULL; + } + + return doCreateSkipListIterator(pSkipList, TSDB_ORDER_ASC); +} + +SSkipListIterator *tSkipListCreateIterFromVal(SSkipList* pSkipList, const char* val, int32_t type, int32_t order) { + if (pSkipList == NULL) { + return NULL; + } + + assert(order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC); + + if (val == NULL) { + return doCreateSkipListIterator(pSkipList, order); + } else { + + SSkipListNode *forward[MAX_SKIP_LIST_LEVEL] = {0}; + + int32_t ret = -1; + __compar_fn_t filterComparFn = getKeyComparFunc(pSkipList->keyInfo.type); + SSkipListNode* pNode = pSkipList->pHead; + + for (int32_t i = pSkipList->level - 1; i >= 0; --i) { + SSkipListNode *p = SL_GET_FORWARD_POINTER(pNode, i); + while (p != pSkipList->pTail) { + char *key = SL_GET_NODE_KEY(pSkipList, p); + + if ((ret = filterComparFn(key, val)) < 0) { + pNode = p; + p = SL_GET_FORWARD_POINTER(p, i); + } else { + break; + } + } + + forward[i] = pNode; + } + + SSkipListIterator* iter = doCreateSkipListIterator(pSkipList, order); + + // set the initial position + if (order == TSDB_ORDER_ASC) { + iter->cur = forward[0]; // greater equals than the value + } else { + iter->cur = SL_GET_FORWARD_POINTER(forward[0], 0); + + if (ret == 0) { + assert(iter->cur != pSkipList->pTail); + iter->cur = SL_GET_FORWARD_POINTER(iter->cur, 0); + } + } + + return iter; + } +} + +bool tSkipListIterNext(SSkipListIterator *iter) { + if (iter->pSkipList == NULL) { + return false; + } + + SSkipList *pSkipList = iter->pSkipList; + + if (pSkipList->lock) { + pthread_rwlock_rdlock(pSkipList->lock); + } + + if (iter->order == TSDB_ORDER_ASC) { // ascending order iterate + if (iter->cur == NULL) { + iter->cur = SL_GET_FORWARD_POINTER(pSkipList->pHead, 0); + } else { + iter->cur = SL_GET_FORWARD_POINTER(iter->cur, 0); + } + } else { // descending order iterate + if (iter->cur == NULL) { + iter->cur = SL_GET_BACKWARD_POINTER(pSkipList->pTail, 0); + } else { + iter->cur = SL_GET_BACKWARD_POINTER(iter->cur, 0); + } + } + + if (pSkipList->lock) { + pthread_rwlock_unlock(pSkipList->lock); + } + + return (iter->order == TSDB_ORDER_ASC)? (iter->cur != pSkipList->pTail) : (iter->cur != pSkipList->pHead); +} + +SSkipListNode *tSkipListIterGet(SSkipListIterator *iter) { + if (iter == NULL || iter->cur == iter->pSkipList->pTail || iter->cur == iter->pSkipList->pHead) { + return NULL; + } else { + return iter->cur; + } +} + +void* tSkipListDestroyIter(SSkipListIterator* iter) { + if (iter == NULL) { + return NULL; + } + + tfree(iter); + return NULL; +} + // bool tSkipListRemove(SSkipList *pSkipList, SSkipListKey *pKey) { // SSkipListNode *forward[MAX_SKIP_LIST_LEVEL] = {0}; // __compar_fn_t filterComparFn = getComparFunc(pSkipList, pKey->nType); @@ -668,6 +585,105 @@ void tSkipListPrint(SSkipList *pSkipList, int16_t nlevel) { } } +void tSkipListDoInsert(SSkipList *pSkipList, SSkipListNode **forward, SSkipListNode *pNode) { + DO_MEMSET_PTR_AREA(pNode); + + for (int32_t i = 0; i < pNode->level; ++i) { + SSkipListNode *x = forward[i]; + SL_GET_BACKWARD_POINTER(pNode, i) = x; + + SSkipListNode *next = SL_GET_FORWARD_POINTER(x, i); + SL_GET_BACKWARD_POINTER(next, i) = pNode; + + SL_GET_FORWARD_POINTER(pNode, i) = next; + SL_GET_FORWARD_POINTER(x, i) = pNode; + } + + atomic_add_fetch_32(&pSkipList->size, 1); + if (pSkipList->lock) { + pthread_rwlock_unlock(pSkipList->lock); + } +} + +SSkipListNode* tSkipListPushFront(SSkipList* pSkipList, SSkipListNode *pNode) { + SSkipListNode* forward[MAX_SKIP_LIST_LEVEL] = {0}; + for(int32_t i = 0; i < pSkipList->level; ++i) { + forward[i] = pSkipList->pHead; + } + + tSkipListDoInsert(pSkipList, forward, pNode); + return pNode; +} + +SSkipListNode* tSkipListPushBack(SSkipList *pSkipList, SSkipListNode *pNode) { + // do clear pointer area + DO_MEMSET_PTR_AREA(pNode); + + for(int32_t i = 0; i < pNode->level; ++i) { + SSkipListNode* prev = SL_GET_BACKWARD_POINTER(pSkipList->pTail, i); + SL_GET_FORWARD_POINTER(prev, i) = pNode; + SL_GET_FORWARD_POINTER(pNode, i) = pSkipList->pTail; + + SL_GET_BACKWARD_POINTER(pNode, i) = prev; + SL_GET_BACKWARD_POINTER(pSkipList->pTail, i) = pNode; + } + + pSkipList->lastKey = SL_GET_NODE_KEY(pSkipList, pNode); + + atomic_add_fetch_32(&pSkipList->size, 1); + if (pSkipList->lock) { + pthread_rwlock_unlock(pSkipList->lock); + } + + return pNode; +} + +SSkipListNode* tSkipListDoGet(SSkipList *pSkipList, SSkipListKey skey) { + SSkipListNode *pNode = pSkipList->pHead; + SSkipListNode *pRes = NULL; + + if (pSkipList->lock) { + pthread_rwlock_rdlock(pSkipList->lock); + } + +#if SKIP_LIST_RECORD_PERFORMANCE + pSkipList->state.queryCount++; +#endif + + __compar_fn_t cmparFn = getComparFunc(pSkipList->keyInfo.type, 0); + + int32_t ret = -1; + for (int32_t i = pSkipList->level - 1; i >= 0; --i) { + SSkipListNode *p = SL_GET_FORWARD_POINTER(pNode, i); + while (p != pSkipList->pTail) { + char *key = SL_GET_NODE_KEY(pSkipList, p); + + if ((ret = cmparFn(key, skey)) < 0) { + pNode = p; + p = SL_GET_FORWARD_POINTER(p, i); + } else { + break; + } + } + + // find the qualified key + if (ret == 0) { + pRes = SL_GET_FORWARD_POINTER(pNode, i); + break; + // skip list does not allowed duplicated key, abort further retrieve data +// if (!pSkipList->keyInfo.dupKey) { +// break; +// } + } + } + + if (pSkipList->lock) { + pthread_rwlock_unlock(pSkipList->lock); + } + + return pRes; +} + SSkipListIterator* doCreateSkipListIterator(SSkipList *pSkipList, int32_t order) { SSkipListIterator* iter = calloc(1, sizeof(SSkipListIterator)); @@ -675,4 +691,4 @@ SSkipListIterator* doCreateSkipListIterator(SSkipList *pSkipList, int32_t order) iter->order = order; return iter; -} +} \ No newline at end of file From 5476ccaad2dcd475721f94258f4c1745fdcde91e Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Fri, 8 May 2020 17:13:11 +0800 Subject: [PATCH 28/36] [td-225] use the dnodeConn instead of mgmtConn and vnodeConn --- src/client/inc/tsclient.h | 4 ++-- src/client/src/tscServer.c | 3 ++- src/client/src/tscSql.c | 13 ++++++++++--- src/client/src/tscSystem.c | 16 +++++----------- src/client/src/tscUtil.c | 4 ++++ 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index cafb0b8fb1..61a5fdd311 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -304,6 +304,7 @@ typedef struct STscObj { struct SSqlObj * pHb; struct SSqlObj * sqlList; struct SSqlStream *streamList; + void* pDnodeConn; pthread_mutex_t mutex; } STscObj; @@ -359,7 +360,7 @@ typedef struct SSqlStream { struct SSqlStream *prev, *next; } SSqlStream; -int32_t tscInitRpc(const char *user, const char *secret); +int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn); void tscInitMsgsFp(); int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion); @@ -425,7 +426,6 @@ void tscQueueAsyncFreeResult(SSqlObj *pSql); int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo); void tscGetResultColumnChr(SSqlRes *pRes, SFieldInfo* pFieldInfo, int32_t column); -extern void * pDnodeConn; extern void * tscCacheHandle; extern void * tscTmr; extern void * tscQhandle; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 6c23b079d1..35e2250dd8 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -191,6 +191,7 @@ void tscProcessActivityTimer(void *handle, void *tmrId) { } int tscSendMsgToServer(SSqlObj *pSql) { + STscObj* pObj = pSql->pTscObj; SSqlCmd* pCmd = &pSql->cmd; char *pMsg = rpcMallocCont(pCmd->payloadLen); @@ -215,7 +216,7 @@ int tscSendMsgToServer(SSqlObj *pSql) { .handle = pSql, .code = 0 }; - rpcSendRequest(pDnodeConn, &pSql->ipList, &rpcMsg); + rpcSendRequest(pObj->pDnodeConn, &pSql->ipList, &rpcMsg); return TSDB_CODE_SUCCESS; } diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 15d7e76b9a..a45db94b49 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -65,8 +65,9 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con terrno = TSDB_CODE_INVALID_PASS; return NULL; } - - if (tscInitRpc(user, pass) != 0) { + + void *pDnodeConn = NULL; + if (tscInitRpc(user, pass, &pDnodeConn) != 0) { terrno = TSDB_CODE_NETWORK_UNAVAIL; return NULL; } @@ -93,6 +94,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con STscObj *pObj = (STscObj *)calloc(1, sizeof(STscObj)); if (NULL == pObj) { terrno = TSDB_CODE_CLI_OUT_OF_MEMORY; + rpcClose(pDnodeConn); return NULL; } @@ -106,8 +108,9 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con int32_t len = strlen(db); /* db name is too long */ if (len > TSDB_DB_NAME_LEN) { - free(pObj); terrno = TSDB_CODE_INVALID_DB; + rpcClose(pDnodeConn); + free(pObj); return NULL; } @@ -123,6 +126,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con SSqlObj *pSql = (SSqlObj *)calloc(1, sizeof(SSqlObj)); if (NULL == pSql) { terrno = TSDB_CODE_CLI_OUT_OF_MEMORY; + rpcClose(pDnodeConn); free(pObj); return NULL; } @@ -134,6 +138,8 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con tsem_init(&pSql->rspSem, 0, 0); pObj->pSql = pSql; + pObj->pDnodeConn = pDnodeConn; + pSql->fp = fp; pSql->param = param; if (taos != NULL) { @@ -143,6 +149,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con pSql->cmd.command = TSDB_SQL_CONNECT; if (TSDB_CODE_SUCCESS != tscAllocPayload(&pSql->cmd, TSDB_DEFAULT_PAYLOAD_SIZE)) { terrno = TSDB_CODE_CLI_OUT_OF_MEMORY; + rpcClose(pDnodeConn); free(pSql); free(pObj); return NULL; diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index f7254468b6..d713a9ee5f 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -30,7 +30,6 @@ #include "tlocale.h" // global, not configurable -void * pDnodeConn; void * tscCacheHandle; void * tscTmr; void * tscQhandle; @@ -48,12 +47,12 @@ void tscCheckDiskUsage(void *UNUSED_PARAM(para), void* UNUSED_PARAM(param)) { taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr); } -int32_t tscInitRpc(const char *user, const char *secret) { +int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn) { SRpcInit rpcInit; char secretEncrypt[32] = {0}; taosEncryptPass((uint8_t *)secret, strlen(secret), secretEncrypt); - if (pDnodeConn == NULL) { + if (*pDnodeConn == NULL) { memset(&rpcInit, 0, sizeof(rpcInit)); rpcInit.localPort = 0; rpcInit.label = "TSC"; @@ -66,9 +65,9 @@ int32_t tscInitRpc(const char *user, const char *secret) { rpcInit.ckey = "key"; rpcInit.secret = secretEncrypt; - pDnodeConn = rpcOpen(&rpcInit); - if (pDnodeConn == NULL) { - tscError("failed to init connection to vnode"); + *pDnodeConn = rpcOpen(&rpcInit); + if (*pDnodeConn == NULL) { + tscError("failed to init connection to TDengine"); return -1; } } @@ -168,11 +167,6 @@ void taos_cleanup() { taosCloseLog(); - if (pDnodeConn != NULL) { - rpcClose(pDnodeConn); - pDnodeConn = NULL; - } - taosTmrCleanUp(tscTmr); } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 47d4de9f21..ccb363d9e8 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -762,6 +762,10 @@ void tscCloseTscObj(STscObj* pObj) { pthread_mutex_destroy(&pObj->mutex); + if (pObj->pDnodeConn != NULL) { + rpcClose(pObj->pDnodeConn); + } + tscTrace("%p DB connection is closed", pObj); tfree(pObj); } From c3bcd6fe1aad06c57b79417efdd3a20609bd1b32 Mon Sep 17 00:00:00 2001 From: liu0x54 Date: Fri, 8 May 2020 09:44:16 +0000 Subject: [PATCH 29/36] [TD251]fix python connector to process NCHAR --- src/connector/python/linux/python2/taos/cinterface.py | 2 +- src/connector/python/linux/python3/taos/cinterface.py | 2 +- src/connector/python/windows/python2/taos/cinterface.py | 2 +- src/connector/python/windows/python3/taos/cinterface.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/connector/python/linux/python2/taos/cinterface.py b/src/connector/python/linux/python2/taos/cinterface.py index d9460efb21..6d792fa92f 100644 --- a/src/connector/python/linux/python2/taos/cinterface.py +++ b/src/connector/python/linux/python2/taos/cinterface.py @@ -96,7 +96,7 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) + res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: diff --git a/src/connector/python/linux/python3/taos/cinterface.py b/src/connector/python/linux/python3/taos/cinterface.py index 6ef54f1ba5..49dd5d00e3 100644 --- a/src/connector/python/linux/python3/taos/cinterface.py +++ b/src/connector/python/linux/python3/taos/cinterface.py @@ -96,7 +96,7 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) + res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: diff --git a/src/connector/python/windows/python2/taos/cinterface.py b/src/connector/python/windows/python2/taos/cinterface.py index a18d372db2..a62ac2801c 100644 --- a/src/connector/python/windows/python2/taos/cinterface.py +++ b/src/connector/python/windows/python2/taos/cinterface.py @@ -96,7 +96,7 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) + res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: diff --git a/src/connector/python/windows/python3/taos/cinterface.py b/src/connector/python/windows/python3/taos/cinterface.py index cbcf2d884e..4d009f0be0 100644 --- a/src/connector/python/windows/python3/taos/cinterface.py +++ b/src/connector/python/windows/python3/taos/cinterface.py @@ -96,7 +96,7 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) + res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: From ccd0e00031e743bc4717f43199123eb9e84b4090 Mon Sep 17 00:00:00 2001 From: hzcheng Date: Fri, 8 May 2020 18:17:01 +0800 Subject: [PATCH 30/36] fix #1844 --- src/tsdb/inc/tsdbMain.h | 1 + src/tsdb/src/tsdbMeta.c | 76 +++++++++++++++++++++++++---------------- 2 files changed, 48 insertions(+), 29 deletions(-) diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h index a681c865c9..278463f0d2 100644 --- a/src/tsdb/inc/tsdbMain.h +++ b/src/tsdb/inc/tsdbMain.h @@ -95,6 +95,7 @@ typedef struct STable { void * streamHandler; // TODO TSKEY lastKey; // lastkey inserted in this table, initialized as 0, TODO: make a structure struct STable *next; // TODO: remove the next + struct STable *prev; } STable; #define TSDB_GET_TABLE_LAST_KEY(pTable) ((pTable)->lastKey) diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 63ccb538ed..a351245220 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -13,10 +13,10 @@ static int tsdbFreeTable(STable *pTable); static int32_t tsdbCheckTableCfg(STableCfg *pCfg); static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx); -static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable); static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable); static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable); static int tsdbEstimateTableEncodeSize(STable *pTable); +static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable); /** * Encode a TSDB table object as a binary content @@ -375,21 +375,9 @@ int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId) { STable *pTable = tsdbGetTableByUid(pMeta, tableId.uid); if (pTable == NULL) return -1; - if (pTable->type == TSDB_SUPER_TABLE) { - // TODO: implement drop super table - return -1; - } else { - pMeta->tables[pTable->tableId.tid] = NULL; - pMeta->nTables--; - assert(pMeta->nTables >= 0); - if (pTable->type == TSDB_CHILD_TABLE) { - tsdbRemoveTableFromIndex(pMeta, pTable); - } - - tsdbFreeTable(pTable); - } - + if (tsdbRemoveTableFromMeta(pMeta, pTable) < 0) return -1; return 0; + } // int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable) { @@ -445,10 +433,12 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx) { if (pMeta->superList == NULL) { pMeta->superList = pTable; pTable->next = NULL; + pTable->prev = NULL; } else { - STable *pTemp = pMeta->superList; + pTable->next = pMeta->superList; + pTable->prev = NULL; + pTable->next->prev = pTable; pMeta->superList = pTable; - pTable->next = pTemp; } } else { // add non-super table to the array @@ -467,22 +457,50 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx) { if (bytes > pMeta->maxRowBytes) pMeta->maxRowBytes = bytes; } - return tsdbAddTableIntoMap(pMeta, pTable); -} - -// static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable) { -// // TODO -// return 0; -// } - -static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable) { - // TODO: add the table to the map - int64_t uid = pTable->tableId.uid; - if (taosHashPut(pMeta->map, (char *)(&uid), sizeof(uid), (void *)(&pTable), sizeof(pTable)) < 0) { + if (taosHashPut(pMeta->map, (char *)(&pTable->tableId.uid), sizeof(pTable->tableId.uid), (void *)(&pTable), sizeof(pTable)) < 0) { return -1; } return 0; } + +static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable) { + if (pTable->type == TSDB_SUPER_TABLE) { + SSkipListIterator *pIter = tSkipListCreateIter(pTable->pIndex); + while (tSkipListIterNext(pIter)) { + STable *tTable = *(STable **)SL_GET_NODE_DATA(tSkipListIterGet(pIter)); + ASSERT(tTable != NULL && tTable->type == TSDB_CHILD_TABLE); + + pMeta->tables[tTable->tableId.tid] = NULL; + taosHashRemove(pMeta->map, (char *)(&(pTable->tableId.uid)), sizeof(pTable->tableId.uid)); + pMeta->nTables--; + tsdbFreeTable(tTable); + } + + tSkipListDestroyIter(pIter); + + // TODO: Remove the table from the list + if (pTable->prev != NULL) { + pTable->prev->next = pTable->next; + if (pTable->next != NULL) { + pTable->next->prev = pTable->prev; + } + } else { + pMeta->superList = pTable->next; + } + } else { + pMeta->tables[pTable->tableId.tid] = NULL; + if (pTable->type == TSDB_CHILD_TABLE) { + tsdbRemoveTableFromIndex(pMeta, pTable); + } + + pMeta->nTables--; + } + + tsdbFreeTable(pTable); + taosHashRemove(pMeta->map, (char *)(&(pTable->tableId.uid)), sizeof(pTable->tableId.uid)); + return 0; +} + static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable) { assert(pTable->type == TSDB_CHILD_TABLE && pTable != NULL); STable* pSTable = tsdbGetTableByUid(pMeta, pTable->superUid); From 5127b9a135ff6f521be3709ef241da9b40b57da8 Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 8 May 2020 19:05:03 +0800 Subject: [PATCH 31/36] fix bug while alter table --- src/mnode/src/mgmtTable.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index 9bd2cde2dc..e9fdee7a0f 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -828,10 +828,10 @@ static void mgmtProcessDropSuperTableMsg(SQueuedMsg *pMsg) { } static int32_t mgmtFindSuperTableTagIndex(SSuperTableObj *pStable, const char *tagName) { - for (int32_t i = 0; i < pStable->numOfTags; i++) { - SSchema *schema = (SSchema *)(pStable->schema + (pStable->numOfColumns + i) * sizeof(SSchema)); - if (strcasecmp(tagName, schema->name) == 0) { - return i; + SSchema *schema = (SSchema *) pStable->schema; + for (int32_t tag = 0; tag < pStable->numOfTags; tag++) { + if (strcasecmp(schema[pStable->numOfColumns + tag].name, tagName) == 0) { + return tag; } } From 36e26330f530ab97d1889f59c99eadc102e87894 Mon Sep 17 00:00:00 2001 From: liu0x54 Date: Fri, 8 May 2020 11:24:39 +0000 Subject: [PATCH 32/36] [TD251]fix python connector to process NCHAR --- src/connector/python/linux/python2/taos/cinterface.py | 3 ++- src/connector/python/linux/python3/taos/cinterface.py | 3 ++- src/connector/python/windows/python2/taos/cinterface.py | 3 ++- src/connector/python/windows/python3/taos/cinterface.py | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/connector/python/linux/python2/taos/cinterface.py b/src/connector/python/linux/python2/taos/cinterface.py index 6d792fa92f..98a2103c09 100644 --- a/src/connector/python/linux/python2/taos/cinterface.py +++ b/src/connector/python/linux/python2/taos/cinterface.py @@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) + tmpstr = ctypes.c_char_p(data) + res.append( tmpstr.value.decode() ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: diff --git a/src/connector/python/linux/python3/taos/cinterface.py b/src/connector/python/linux/python3/taos/cinterface.py index 49dd5d00e3..d516aad5a7 100644 --- a/src/connector/python/linux/python3/taos/cinterface.py +++ b/src/connector/python/linux/python3/taos/cinterface.py @@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) + tmpstr = ctypes.c_char_p(data) + res.append( tmpstr.value.decode() ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: diff --git a/src/connector/python/windows/python2/taos/cinterface.py b/src/connector/python/windows/python2/taos/cinterface.py index a62ac2801c..28130d5cb3 100644 --- a/src/connector/python/windows/python2/taos/cinterface.py +++ b/src/connector/python/windows/python2/taos/cinterface.py @@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) + tmpstr = ctypes.c_char_p(data) + res.append( tmpstr.value.decode() ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: diff --git a/src/connector/python/windows/python3/taos/cinterface.py b/src/connector/python/windows/python3/taos/cinterface.py index 4d009f0be0..f683537661 100644 --- a/src/connector/python/windows/python3/taos/cinterface.py +++ b/src/connector/python/windows/python3/taos/cinterface.py @@ -96,7 +96,8 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, micro=False): for i in range(abs(num_of_rows)): try: if num_of_rows >= 0: - res.append( (ctypes.cast(data+nbytes*(abs(num_of_rows - i -1)), ctypes.POINTER(ctypes.c_char * (nbytes//4))))[0].value ) + tmpstr = ctypes.c_char_p(data) + res.append( tmpstr.value.decode() ) else: res.append( (ctypes.cast(data+nbytes*i, ctypes.POINTER(ctypes.c_wchar * (nbytes//4))))[0].value ) except ValueError: From 599711dd6ba4c5fefae816f41f4c39db112373cf Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Fri, 8 May 2020 12:32:50 +0000 Subject: [PATCH 33/36] port in redirect message shall be htons --- src/dnode/src/dnodeVRead.c | 2 ++ src/rpc/src/rpcMain.c | 28 +++++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/dnode/src/dnodeVRead.c b/src/dnode/src/dnodeVRead.c index ff211bf1b2..aaf71838bf 100644 --- a/src/dnode/src/dnodeVRead.c +++ b/src/dnode/src/dnodeVRead.c @@ -81,6 +81,8 @@ void dnodeCleanupRead() { } taosCloseQset(readQset); + free(readPool.readWorker); + dPrint("dnode read is closed"); } diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 39d773f6a2..cdd2d732e1 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -226,17 +226,6 @@ void *rpcOpen(const SRpcInit *pInit) { pRpc->cfp = pInit->cfp; pRpc->afp = pInit->afp; - pRpc->tcphandle = (*taosInitConn[pRpc->connType|RPC_CONN_TCP])(0, pRpc->localPort, pRpc->label, - pRpc->numOfThreads, rpcProcessMsgFromPeer, pRpc); - pRpc->udphandle = (*taosInitConn[pRpc->connType])(0, pRpc->localPort, pRpc->label, - pRpc->numOfThreads, rpcProcessMsgFromPeer, pRpc); - - if (pRpc->tcphandle == NULL || pRpc->udphandle == NULL) { - tError("%s failed to init network, port:%d", pRpc->label, pRpc->localPort); - rpcClose(pRpc); - return NULL; - } - size_t size = sizeof(SRpcConn) * pRpc->sessions; pRpc->connList = (SRpcConn *)calloc(1, size); if (pRpc->connList == NULL) { @@ -277,6 +266,17 @@ void *rpcOpen(const SRpcInit *pInit) { pthread_mutex_init(&pRpc->mutex, NULL); + pRpc->tcphandle = (*taosInitConn[pRpc->connType|RPC_CONN_TCP])(0, pRpc->localPort, pRpc->label, + pRpc->numOfThreads, rpcProcessMsgFromPeer, pRpc); + pRpc->udphandle = (*taosInitConn[pRpc->connType])(0, pRpc->localPort, pRpc->label, + pRpc->numOfThreads, rpcProcessMsgFromPeer, pRpc); + + if (pRpc->tcphandle == NULL || pRpc->udphandle == NULL) { + tError("%s failed to init network, port:%d", pRpc->label, pRpc->localPort); + rpcClose(pRpc); + return NULL; + } + tTrace("%s RPC is openned, numOfThreads:%d", pRpc->label, pRpc->numOfThreads); return pRpc; @@ -869,9 +869,9 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) { pConn = rpcProcessMsgHead(pRpc, pRecv); if (pHead->msgType < TSDB_MSG_TYPE_CM_HEARTBEAT || (rpcDebugFlag & 16)) { - tTrace("%s %p, %s received from 0x%x:%hu, parse code:0x%x len:%d sig:0x%08x:0x%08x:%d", + tTrace("%s %p, %s received from 0x%x:%hu, parse code:0x%x len:%d sig:0x%08x:0x%08x:%d code:0x%x", pRpc->label, pConn, taosMsg[pHead->msgType], pRecv->ip, pRecv->port, terrno, - pRecv->msgLen, pHead->sourceId, pHead->destId, pHead->tranId, pHead->port); + pRecv->msgLen, pHead->sourceId, pHead->destId, pHead->tranId, pHead->code); } int32_t code = terrno; @@ -939,6 +939,8 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) { pContext->numOfTry = 0; memcpy(&pContext->ipSet, pHead->content, sizeof(pContext->ipSet)); tTrace("%s %p, redirect is received, numOfIps:%d", pRpc->label, pConn, pContext->ipSet.numOfIps); + for (int i=0; iipSet.numOfIps; ++i) + pContext->ipSet.port[i] = htons(pContext->ipSet.port[i]); rpcSendReqToServer(pRpc, pContext); } else if (pHead->code == TSDB_CODE_NOT_READY) { pContext->code = pHead->code; From b8c6d6c0314d2c79512eff73aa9442327a3183da Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 8 May 2020 22:05:02 +0800 Subject: [PATCH 34/36] failed to get bandwidth --- src/mnode/inc/{mgmtLog.h => mgmtInt.h} | 36 ++++++-------------------- src/mnode/src/mgmtAcct.c | 2 +- src/mnode/src/mgmtBalance.c | 2 +- src/mnode/src/mgmtDb.c | 2 +- src/mnode/src/mgmtDnode.c | 2 +- src/mnode/src/mgmtGrant.c | 2 +- src/mnode/src/mgmtMain.c | 2 +- src/mnode/src/mgmtMnode.c | 2 +- src/mnode/src/mgmtProfile.c | 2 +- src/mnode/src/mgmtSdb.c | 2 +- src/mnode/src/mgmtServer.c | 2 +- src/mnode/src/mgmtShell.c | 2 +- src/mnode/src/mgmtTable.c | 2 +- src/mnode/src/mgmtUser.c | 2 +- src/mnode/src/mgmtVgroup.c | 2 +- src/os/linux/src/linuxSysPara.c | 11 +++++--- src/plugins/monitor/src/monitorMain.c | 8 +++--- 17 files changed, 34 insertions(+), 49 deletions(-) rename src/mnode/inc/{mgmtLog.h => mgmtInt.h} (53%) diff --git a/src/mnode/inc/mgmtLog.h b/src/mnode/inc/mgmtInt.h similarity index 53% rename from src/mnode/inc/mgmtLog.h rename to src/mnode/inc/mgmtInt.h index a99fa22593..17553ade72 100644 --- a/src/mnode/inc/mgmtLog.h +++ b/src/mnode/inc/mgmtInt.h @@ -27,39 +27,19 @@ extern int32_t mdebugFlag; extern int32_t sdbDebugFlag; // mnode log function -#define mError(...) \ - if (mdebugFlag & DEBUG_ERROR) { \ - taosPrintLog("ERROR MND ", 255, __VA_ARGS__); \ - } -#define mWarn(...) \ - if (mdebugFlag & DEBUG_WARN) { \ - taosPrintLog("WARN MND ", mdebugFlag, __VA_ARGS__); \ - } -#define mTrace(...) \ - if (mdebugFlag & DEBUG_TRACE) { \ - taosPrintLog("MND ", mdebugFlag, __VA_ARGS__); \ - } -#define mPrint(...) \ - { taosPrintLog("MND ", 255, __VA_ARGS__); } +#define mError(...) if (mdebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MND ", 255, __VA_ARGS__); } +#define mWarn(...) if (mdebugFlag & DEBUG_WARN) { taosPrintLog("WARN MND ", mdebugFlag, __VA_ARGS__); } +#define mTrace(...) if (mdebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mdebugFlag, __VA_ARGS__); } +#define mPrint(...) { taosPrintLog("MND ", 255, __VA_ARGS__); } #define mLError(...) monitorSaveLog(2, __VA_ARGS__); mError(__VA_ARGS__) #define mLWarn(...) monitorSaveLog(1, __VA_ARGS__); mWarn(__VA_ARGS__) #define mLPrint(...) monitorSaveLog(0, __VA_ARGS__); mPrint(__VA_ARGS__) -#define sdbError(...) \ - if (sdbDebugFlag & DEBUG_ERROR) { \ - taosPrintLog("ERROR MND-SDB ", 255, __VA_ARGS__); \ - } -#define sdbWarn(...) \ - if (sdbDebugFlag & DEBUG_WARN) { \ - taosPrintLog("WARN MND-SDB ", sdbDebugFlag, __VA_ARGS__); \ - } -#define sdbTrace(...) \ - if (sdbDebugFlag & DEBUG_TRACE) { \ - taosPrintLog("MND-SDB ", sdbDebugFlag, __VA_ARGS__); \ - } -#define sdbPrint(...) \ - { taosPrintLog("MND-SDB ", 255, __VA_ARGS__); } +#define sdbError(...) if (sdbDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MND-SDB ", 255, __VA_ARGS__); } +#define sdbWarn(...) if (sdbDebugFlag & DEBUG_WARN) { taosPrintLog("WARN MND-SDB ", sdbDebugFlag, __VA_ARGS__); } +#define sdbTrace(...) if (sdbDebugFlag & DEBUG_TRACE) { taosPrintLog("MND-SDB ", sdbDebugFlag, __VA_ARGS__);} +#define sdbPrint(...) { taosPrintLog("MND-SDB ", 255, __VA_ARGS__); } #define sdbLError(...) monitorSaveLog(2, __VA_ARGS__); sdbError(__VA_ARGS__) #define sdbLWarn(...) monitorSaveLog(1, __VA_ARGS__); sdbWarn(__VA_ARGS__) diff --git a/src/mnode/src/mgmtAcct.c b/src/mnode/src/mgmtAcct.c index 9b7815af12..1cacec96ee 100644 --- a/src/mnode/src/mgmtAcct.c +++ b/src/mnode/src/mgmtAcct.c @@ -20,7 +20,7 @@ #include "tutil.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtAcct.h" #include "mgmtDb.h" #include "mgmtSdb.h" diff --git a/src/mnode/src/mgmtBalance.c b/src/mnode/src/mgmtBalance.c index d16a06fc5c..ff5b4008bb 100644 --- a/src/mnode/src/mgmtBalance.c +++ b/src/mnode/src/mgmtBalance.c @@ -19,7 +19,7 @@ #include "tbalance.h" #include "tglobal.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtMnode.h" #include "mgmtDnode.h" #include "mgmtVgroup.h" diff --git a/src/mnode/src/mgmtDb.c b/src/mnode/src/mgmtDb.c index 5cee1f30cd..8c6a80eb61 100644 --- a/src/mnode/src/mgmtDb.c +++ b/src/mnode/src/mgmtDb.c @@ -25,7 +25,7 @@ #include "tbalance.h" #include "tdataformat.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtAcct.h" #include "mgmtDb.h" #include "mgmtDnode.h" diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c index 030123b804..a170aa2d02 100644 --- a/src/mnode/src/mgmtDnode.c +++ b/src/mnode/src/mgmtDnode.c @@ -27,7 +27,7 @@ #include "tdataformat.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtDnode.h" #include "mgmtMnode.h" #include "mgmtSdb.h" diff --git a/src/mnode/src/mgmtGrant.c b/src/mnode/src/mgmtGrant.c index 449799ef95..f44b47e20c 100644 --- a/src/mnode/src/mgmtGrant.c +++ b/src/mnode/src/mgmtGrant.c @@ -18,7 +18,7 @@ #include "os.h" #include "taoserror.h" #include "tgrant.h" -#include "mgmtLog.h" +#include "mgmtInt.h" int32_t grantInit() { return TSDB_CODE_SUCCESS; } void grantCleanUp() {} diff --git a/src/mnode/src/mgmtMain.c b/src/mnode/src/mgmtMain.c index aa95381df3..37edddec10 100644 --- a/src/mnode/src/mgmtMain.c +++ b/src/mnode/src/mgmtMain.c @@ -23,7 +23,7 @@ #include "tglobal.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtServer.h" #include "mgmtAcct.h" #include "mgmtDnode.h" diff --git a/src/mnode/src/mgmtMnode.c b/src/mnode/src/mgmtMnode.c index f28e286f79..a78e5574c0 100644 --- a/src/mnode/src/mgmtMnode.c +++ b/src/mnode/src/mgmtMnode.c @@ -24,7 +24,7 @@ #include "tsocket.h" #include "tdataformat.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtMnode.h" #include "mgmtDnode.h" #include "mgmtSdb.h" diff --git a/src/mnode/src/mgmtProfile.c b/src/mnode/src/mgmtProfile.c index 77871f037b..64ac8ed710 100644 --- a/src/mnode/src/mgmtProfile.c +++ b/src/mnode/src/mgmtProfile.c @@ -19,7 +19,7 @@ #include "taoserror.h" #include "tutil.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtAcct.h" #include "mgmtDnode.h" #include "mgmtDb.h" diff --git a/src/mnode/src/mgmtSdb.c b/src/mnode/src/mgmtSdb.c index fe25699b5f..d2a5287f13 100644 --- a/src/mnode/src/mgmtSdb.c +++ b/src/mnode/src/mgmtSdb.c @@ -27,7 +27,7 @@ #include "hashstr.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtMnode.h" #include "mgmtSdb.h" diff --git a/src/mnode/src/mgmtServer.c b/src/mnode/src/mgmtServer.c index 2fa6e68f65..a6b4362cbf 100644 --- a/src/mnode/src/mgmtServer.c +++ b/src/mnode/src/mgmtServer.c @@ -25,7 +25,7 @@ #include "tglobal.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtDb.h" #include "mgmtMnode.h" #include "mgmtProfile.h" diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index 7264c85027..3cb0225b97 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -26,7 +26,7 @@ #include "tcache.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtAcct.h" #include "mgmtDb.h" #include "mgmtDnode.h" diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index e9fdee7a0f..2225e08f58 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -26,7 +26,7 @@ #include "tglobal.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtAcct.h" #include "mgmtDb.h" #include "mgmtDnode.h" diff --git a/src/mnode/src/mgmtUser.c b/src/mnode/src/mgmtUser.c index ecd3c217ca..b0e58a5052 100644 --- a/src/mnode/src/mgmtUser.c +++ b/src/mnode/src/mgmtUser.c @@ -23,7 +23,7 @@ #include "tdataformat.h" #include "dnode.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtAcct.h" #include "mgmtMnode.h" #include "mgmtSdb.h" diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index 6be2a73444..cbe235a26a 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -26,7 +26,7 @@ #include "dnode.h" #include "tdataformat.h" #include "mgmtDef.h" -#include "mgmtLog.h" +#include "mgmtInt.h" #include "mgmtDb.h" #include "mgmtDnode.h" #include "mgmtMnode.h" diff --git a/src/os/linux/src/linuxSysPara.c b/src/os/linux/src/linuxSysPara.c index f43ed44a4b..6bab418385 100644 --- a/src/os/linux/src/linuxSysPara.c +++ b/src/os/linux/src/linuxSysPara.c @@ -356,10 +356,15 @@ static bool taosGetCardName(char *ip, char *name) { break; } - if (strcmp(host, ip) == 0) { - strcpy(name, ifa->ifa_name); - ret = true; + if (strcmp(host, "127.0.0.1") == 0) { + continue; } + + // TODO: the ip not config + // if (strcmp(host, ip) == 0) { + strcpy(name, ifa->ifa_name); + ret = true; + // } } freeifaddrs(ifaddr); diff --git a/src/plugins/monitor/src/monitorMain.c b/src/plugins/monitor/src/monitorMain.c index 7836dbae85..35787d1dfe 100644 --- a/src/plugins/monitor/src/monitorMain.c +++ b/src/plugins/monitor/src/monitorMain.c @@ -43,7 +43,7 @@ { taosPrintLog("MON ", 255, __VA_ARGS__); } #define SQL_LENGTH 1024 -#define LOG_LEN_STR 80 +#define LOG_LEN_STR 100 #define IP_LEN_STR 18 #define CHECK_INTERVAL 1000 @@ -148,8 +148,8 @@ static void dnodeBuildMonitorSql(char *sql, int32_t cmd) { if (cmd == MONITOR_CMD_CREATE_DB) { snprintf(sql, SQL_LENGTH, - "create database if not exists %s replica 1 days 10 keep 30 cache 2 " - "blocks 2 maxtables 32 precision 'us'", + "create database if not exists %s replica 1 days 10 keep 30 cache 1 " + "blocks 2 maxtables 16 precision 'us'", tsMonitorDbName); } else if (cmd == MONITOR_CMD_CREATE_MT_DN) { snprintf(sql, SQL_LENGTH, @@ -407,7 +407,7 @@ void monitorSaveLog(int32_t level, const char *const format, ...) { if (tsMonitorConn.state != MONITOR_STATE_INITIALIZED) return; - int32_t len = snprintf(sql, (size_t)max_length, "import into %s.log values(%" PRId64 ", %d,'", tsMonitorDbName, + int32_t len = snprintf(sql, (size_t)max_length, "insert into %s.log values(%" PRId64 ", %d,'", tsMonitorDbName, taosGetTimestampUs(), level); va_start(argpointer, format); From 36a2e334dbe0ae612779fdc64830849e13228044 Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 8 May 2020 22:05:45 +0800 Subject: [PATCH 35/36] set max redirect times --- src/rpc/src/rpcMain.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index cdd2d732e1..685b0f2b86 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -934,8 +934,15 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) { // for UDP, port may be changed by server, the port in ipSet shall be used for cache rpcAddConnIntoCache(pRpc->pCache, pConn, pConn->peerFqdn, pContext->ipSet.port[pContext->ipSet.inUse], pConn->connType); + if (pHead->code == TSDB_CODE_REDIRECT) { + pContext->redirect++; + if (pContext->redirect > TSDB_MAX_REPLICA) { + pHead->code = TSDB_CODE_NETWORK_UNAVAIL; + tWarn("%s %p, too many redirects, quit", pRpc->label, pConn); + } + } + if (pHead->code == TSDB_CODE_REDIRECT) { - pContext->redirect = 1; pContext->numOfTry = 0; memcpy(&pContext->ipSet, pHead->content, sizeof(pContext->ipSet)); tTrace("%s %p, redirect is received, numOfIps:%d", pRpc->label, pConn, pContext->ipSet.numOfIps); From 15d6f34de7ddd149f032b6125e6b367e108551f8 Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 8 May 2020 22:06:10 +0800 Subject: [PATCH 36/36] scripts --- tests/script/jenkins/basic.txt | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 1a9862e4ed..44fc24e107 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -102,6 +102,66 @@ cd ../../../debug; make #./test.sh -f general/metrics/vnode3.sim #parser + +# ./test.sh -f general/parser/alter.sim +# ./test.sh -f general/parser/alter1.sim +# ./test.sh -f general/parser/alter_stable.sim +# ./test.sh -f general/parser/auto_create_tb.sim +# ./test.sh -f general/parser/auto_create_tb_drop_tb.sim +./test.sh -f general/parser/binary_escapeCharacter.sim +./test.sh -f general/parser/bug.sim +./test.sh -f general/parser/col_arithmetic_operation.sim +./test.sh -f general/parser/columnValue_bigint.sim +./test.sh -f general/parser/columnValue_bool.sim +./test.sh -f general/parser/columnValue_double.sim +./test.sh -f general/parser/columnValue_float.sim +./test.sh -f general/parser/columnValue_int.sim +# ./test.sh -f general/parser/col_arithmetic_operation.sim +# ./test.sh -f general/parser/columnValue.sim +# ./test.sh -f general/parser/commit.sim +# ./test.sh -f general/parser/create_db.sim +# ./test.sh -f general/parser/create_mt.sim +# ./test.sh -f general/parser/create_tb.sim +# ./test.sh -f general/parser/dbtbnameValidate.sim +# ./test.sh -f general/parser/fill.sim +# ./test.sh -f general/parser/fill_stb.sim +# ./test.sh -f general/parser/first_last.sim +# ./test.sh -f general/parser/import_commit1.sim +# ./test.sh -f general/parser/import_commit2.sim +# ./test.sh -f general/parser/import_commit3.sim +# ./test.sh -f general/parser/import_file.sim +# ./test.sh -f general/parser/insert_tb.sim +# ./test.sh -f general/parser/tags_dynamically_specifiy.sim +# ./test.sh -f general/parser/interp.sim +# ./test.sh -f general/parser/lastrow.sim +# ./test.sh -f general/parser/limit.sim +# ./test.sh -f general/parser/limit1.sim +# ./test.sh -f general/parser/limit1_tblocks100.sim +# ./test.sh -f general/parser/limit2.sim +# ./test.sh -f general/parser/mixed_blocks.sim +# ./test.sh -f general/parser/nchar.sim +# ./test.sh -f general/parser/null_char.sim +# ./test.sh -f general/parser/selectResNum.sim +# ./test.sh -f general/parser/select_across_vnodes.sim +./test.sh -f general/parser/select_from_cache_disk.sim +# ./test.sh -f general/parser/set_tag_vals.sim +# ./test.sh -f general/parser/single_row_in_tb.sim +# ./test.sh -f general/parser/slimit.sim +./test.sh -f general/parser/slimit1.sim +./test.sh -f general/parser/slimit1_query.sim +# ./test.sh -f general/parser/slimit_alter_tags.sim +# ./test.sh -f general/parser/stream_on_sys.sim +# ./test.sh -f general/parser/stream.sim +# ./test.sh -f general/parser/tbnameIn.sim +# ./test.sh -f general/parser/where.sim +# #./test.sh -f general/parser/repeatAlter.sim +# #./test.sh -f general/parser/repeatStream.sim +# ./test.sh -f general/parser/join.sim +# ./test.sh -f general/parser/join_multivnode.sim +# ./test.sh -f general/parser/projection_limit_offset.sim +# ./test.sh -f general/parser/select_with_tags.sim +# ./test.sh -f general/parser/groupby.sim + #stream ./test.sh -f general/table/autocreate.sim