From 0e6c01c03b3c2712f8f1c1d4c3cc45999f5575d7 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 2 Jul 2020 14:08:31 +0000 Subject: [PATCH 01/63] [TD-468] the first version of tables' allocation --- src/common/inc/tglobal.h | 1 + src/common/src/tglobal.c | 19 ++- src/inc/taosdef.h | 5 +- src/mnode/inc/mnodeDb.h | 3 - src/mnode/inc/mnodeDef.h | 11 +- src/mnode/inc/mnodeDnode.h | 1 + src/mnode/inc/mnodeVgroup.h | 6 +- src/mnode/src/mnodeDb.c | 100 ++++++-------- src/mnode/src/mnodeDnode.c | 22 ++- src/mnode/src/mnodeTable.c | 32 ++--- src/mnode/src/mnodeVgroup.c | 267 ++++++++++++++++++++++++------------ 11 files changed, 275 insertions(+), 192 deletions(-) diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index e7927605cb..3a432f2b4c 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -68,6 +68,7 @@ extern int64_t tsMaxRetentWindow; extern int32_t tsCacheBlockSize; extern int32_t tsBlocksPerVnode; extern int32_t tsMaxTablePerVnode; +extern int32_t tsMaxVgroupsPerDb; extern int16_t tsDaysPerFile; extern int32_t tsDaysToKeep; extern int32_t tsMinRowsInFileBlock; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 225f12a210..68abaf1487 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -109,13 +109,8 @@ int32_t tsTimePrecision = TSDB_DEFAULT_PRECISION; int16_t tsCompression = TSDB_DEFAULT_COMP_LEVEL; int16_t tsWAL = TSDB_DEFAULT_WAL_LEVEL; int32_t tsReplications = TSDB_DEFAULT_REPLICA_NUM; - -#ifdef _TD_ARM_32_ - int32_t tsMaxTablePerVnode = 100; -#else - int32_t tsMaxTablePerVnode = TSDB_DEFAULT_TABLES; -#endif - +int32_t tsMaxVgroupsPerDb = 0; +int32_t tsMaxTablePerVnode = TSDB_DEFAULT_TABLES; // balance int32_t tsEnableBalance = 1; int32_t tsAlternativeRole = 0; @@ -594,6 +589,16 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "maxVgroupsPerDb"; + cfg.ptr = &tsMaxVgroupsPerDb; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = 0; + cfg.maxValue = 8192; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + // database configs cfg.option = "maxtablesPerVnode"; cfg.ptr = &tsMaxTablePerVnode; diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 76ca99c9ad..aca8f22887 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -271,8 +271,9 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_DEFAULT_TOTAL_BLOCKS 4 #define TSDB_MIN_TABLES 4 -#define TSDB_MAX_TABLES 200000 -#define TSDB_DEFAULT_TABLES 1000 +#define TSDB_MAX_TABLES 5000000 +#define TSDB_DEFAULT_TABLES 500000 +#define TSDB_TABLES_STEP 10000 #define TSDB_MIN_DAYS_PER_FILE 1 #define TSDB_MAX_DAYS_PER_FILE 3650 diff --git a/src/mnode/inc/mnodeDb.h b/src/mnode/inc/mnodeDb.h index c8557af166..ca6c2a86a2 100644 --- a/src/mnode/inc/mnodeDb.h +++ b/src/mnode/inc/mnodeDb.h @@ -44,10 +44,7 @@ void mnodeRemoveSuperTableFromDb(SDbObj *pDb); void mnodeAddTableIntoDb(SDbObj *pDb); void mnodeRemoveTableFromDb(SDbObj *pDb); void mnodeAddVgroupIntoDb(SVgObj *pVgroup); -void mnodeAddVgroupIntoDbTail(SVgObj *pVgroup); void mnodeRemoveVgroupFromDb(SVgObj *pVgroup); -void mnodeMoveVgroupToTail(SVgObj *pVgroup); -void mnodeMoveVgroupToHead(SVgObj *pVgroup); #ifdef __cplusplus } diff --git a/src/mnode/inc/mnodeDef.h b/src/mnode/inc/mnodeDef.h index 46d2675705..4fce62d8d5 100644 --- a/src/mnode/inc/mnodeDef.h +++ b/src/mnode/inc/mnodeDef.h @@ -144,10 +144,8 @@ typedef struct SVgObj { int64_t totalStorage; int64_t compStorage; int64_t pointsWritten; - struct SVgObj *prev, *next; struct SDbObj *pDb; void * idPool; - SChildTableObj **tableList; } SVgObj; typedef struct { @@ -182,9 +180,11 @@ typedef struct SDbObj { int32_t numOfVgroups; int32_t numOfTables; int32_t numOfSuperTables; - SVgObj *pHead; - SVgObj *pTail; + int32_t vgListSize; + int32_t vgListIndex; + SVgObj **vgList; struct SAcctObj *pAcct; + pthread_mutex_t mutex; } SDbObj; typedef struct SUserObj { @@ -245,7 +245,8 @@ typedef struct { int16_t offset[TSDB_MAX_COLUMNS]; int16_t bytes[TSDB_MAX_COLUMNS]; int32_t numOfReads; - int8_t reserved0[2]; + int8_t maxReplica; + int8_t reserved0[0]; uint16_t payloadLen; char payload[]; } SShowObj; diff --git a/src/mnode/inc/mnodeDnode.h b/src/mnode/inc/mnodeDnode.h index 9e21f8f56a..f371786524 100644 --- a/src/mnode/inc/mnodeDnode.h +++ b/src/mnode/inc/mnodeDnode.h @@ -40,6 +40,7 @@ char* mnodeGetDnodeStatusStr(int32_t dnodeStatus); void mgmtMonitorDnodeModule(); int32_t mnodeGetDnodesNum(); +int32_t mnodeGetOnlinDnodesCpuCoreNum(); int32_t mnodeGetOnlinDnodesNum(); void * mnodeGetNextDnode(void *pIter, SDnodeObj **pDnode); void mnodeIncDnodeRef(SDnodeObj *pDnode); diff --git a/src/mnode/inc/mnodeVgroup.h b/src/mnode/inc/mnodeVgroup.h index 29a0fe1799..6ddf8e44b9 100644 --- a/src/mnode/inc/mnodeVgroup.h +++ b/src/mnode/inc/mnodeVgroup.h @@ -30,17 +30,17 @@ void mnodeDecVgroupRef(SVgObj *pVgroup); void mnodeDropAllDbVgroups(SDbObj *pDropDb); void mnodeSendDropAllDbVgroupsMsg(SDbObj *pDropDb); void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode); -void mnodeUpdateAllDbVgroups(SDbObj *pAlterDb); +//void mnodeUpdateAllDbVgroups(SDbObj *pAlterDb); void * mnodeGetNextVgroup(void *pIter, SVgObj **pVgroup); void mnodeUpdateVgroup(SVgObj *pVgroup); void mnodeUpdateVgroupStatus(SVgObj *pVgroup, SDnodeObj *pDnode, SVnodeLoad *pVload); void mnodeCheckUnCreatedVgroup(SDnodeObj *pDnode, SVnodeLoad *pVloads, int32_t openVnodes); -int32_t mnodeCreateVgroup(struct SMnodeMsg *pMsg, SDbObj *pDb); +int32_t mnodeCreateVgroup(struct SMnodeMsg *pMsg); void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle); void mnodeAlterVgroup(SVgObj *pVgroup, void *ahandle); -SVgObj *mnodeGetAvailableVgroup(SDbObj *pDb); +int32_t mnodeGetAvailableVgroup(struct SMnodeMsg *pMsg, SVgObj **pVgroup, int32_t *sid); void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable); void mnodeRemoveTableFromVgroup(SVgObj *pVgroup, SChildTableObj *pTable); diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 69821e3483..e9004d3e73 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -38,6 +38,7 @@ #include "mnodeUser.h" #include "mnodeVgroup.h" +#define VG_LIST_SIZE 1 static void * tsDbSdb = NULL; static int32_t tsDbUpdateSize; @@ -50,8 +51,14 @@ static int32_t mnodeProcessCreateDbMsg(SMnodeMsg *pMsg); static int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg); static int32_t mnodeProcessDropDbMsg(SMnodeMsg *pMsg); +static void mnodeDestroyDb(SDbObj *pDb) { + pthread_mutex_destroy(&pDb->mutex); + tfree(pDb->vgList); + tfree(pDb); +} + static int32_t mnodeDbActionDestroy(SSdbOper *pOper) { - tfree(pOper->pObj); + mnodeDestroyDb(pOper->pObj); return TSDB_CODE_SUCCESS; } @@ -59,8 +66,9 @@ static int32_t mnodeDbActionInsert(SSdbOper *pOper) { SDbObj *pDb = pOper->pObj; SAcctObj *pAcct = mnodeGetAcct(pDb->acct); - pDb->pHead = NULL; - pDb->pTail = NULL; + pthread_mutex_init(&pDb->mutex, NULL); + pDb->vgListSize = VG_LIST_SIZE; + pDb->vgList = calloc(pDb->vgListSize, sizeof(SVgObj *)); pDb->numOfVgroups = 0; pDb->numOfTables = 0; pDb->numOfSuperTables = 0; @@ -94,14 +102,15 @@ static int32_t mnodeDbActionDelete(SSdbOper *pOper) { } static int32_t mnodeDbActionUpdate(SSdbOper *pOper) { - SDbObj *pDb = pOper->pObj; - SDbObj *pSaved = mnodeGetDb(pDb->name); - if (pDb != pSaved) { - memcpy(pSaved, pDb, pOper->rowSize); - free(pDb); + SDbObj *pNew = pOper->pObj; + SDbObj *pDb = mnodeGetDb(pNew->name); + if (pDb != NULL && pNew != pDb) { + memcpy(pDb, pNew, pOper->rowSize); + free(pNew->vgList); + free(pNew); } - mnodeUpdateAllDbVgroups(pSaved); - mnodeDecDbRef(pSaved); + //mnodeUpdateAllDbVgroups(pDb); + mnodeDecDbRef(pDb); return TSDB_CODE_SUCCESS; } @@ -416,45 +425,33 @@ void mnodePrintVgroups(SDbObj *pDb, char *oper) { void mnodeAddVgroupIntoDb(SVgObj *pVgroup) { SDbObj *pDb = pVgroup->pDb; - pVgroup->next = pDb->pHead; - pVgroup->prev = NULL; + pthread_mutex_lock(&pDb->mutex); + int32_t vgPos = pDb->numOfVgroups++; + if (vgPos >= pDb->vgListSize) { + pDb->vgList = realloc(pDb->vgList, pDb->vgListSize * 2 * sizeof(SVgObj *)); + memset(pDb->vgList + pDb->vgListSize, 0, pDb->vgListSize * sizeof(SVgObj *)); + pDb->vgListSize *= 2; + } - if (pDb->pHead) pDb->pHead->prev = pVgroup; - if (pDb->pTail == NULL) pDb->pTail = pVgroup; - - pDb->pHead = pVgroup; - pDb->numOfVgroups++; -} - -void mnodeAddVgroupIntoDbTail(SVgObj *pVgroup) { - SDbObj *pDb = pVgroup->pDb; - pVgroup->next = NULL; - pVgroup->prev = pDb->pTail; - - if (pDb->pTail) pDb->pTail->next = pVgroup; - if (pDb->pHead == NULL) pDb->pHead = pVgroup; - - pDb->pTail = pVgroup; - pDb->numOfVgroups++; + pDb->vgList[vgPos] = pVgroup; + pthread_mutex_lock(&pDb->mutex); } void mnodeRemoveVgroupFromDb(SVgObj *pVgroup) { SDbObj *pDb = pVgroup->pDb; - if (pVgroup->prev) pVgroup->prev->next = pVgroup->next; - if (pVgroup->next) pVgroup->next->prev = pVgroup->prev; - if (pVgroup->prev == NULL) pDb->pHead = pVgroup->next; - if (pVgroup->next == NULL) pDb->pTail = pVgroup->prev; - pDb->numOfVgroups--; -} -void mnodeMoveVgroupToTail(SVgObj *pVgroup) { - mnodeRemoveVgroupFromDb(pVgroup); - mnodeAddVgroupIntoDbTail(pVgroup); -} + pthread_mutex_lock(&pDb->mutex); + for (int32_t v1 = 0; v1 < pDb->numOfVgroups; ++v1) { + if (pDb->vgList[v1] == pVgroup) { + for (int32_t v2 = v1; v2 < pDb->numOfVgroups - 1; ++v2) { + pDb->vgList[v2] = pDb->vgList[v2 + 1]; + } + pDb->numOfVgroups--; + break; + } + } -void mnodeMoveVgroupToHead(SVgObj *pVgroup) { - mnodeRemoveVgroupFromDb(pVgroup); - mnodeAddVgroupIntoDb(pVgroup); + pthread_mutex_lock(&pDb->mutex); } void mnodeCleanupDbs() { @@ -525,11 +522,6 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn #ifndef __CLOUD_VERSION__ if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0) { #endif - pShow->bytes[cols] = 4; - pSchema[cols].type = TSDB_DATA_TYPE_INT; - strcpy(pSchema[cols].name, "maxtables"); - pSchema[cols].bytes = htons(pShow->bytes[cols]); - cols++; pShow->bytes[cols] = 4; pSchema[cols].type = TSDB_DATA_TYPE_INT; @@ -555,12 +547,6 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pShow->bytes[cols] = 4; - pSchema[cols].type = TSDB_DATA_TYPE_INT; - strcpy(pSchema[cols].name, "ctime(Sec.)"); - pSchema[cols].bytes = htons(pShow->bytes[cols]); - cols++; - pShow->bytes[cols] = 1; pSchema[cols].type = TSDB_DATA_TYPE_TINYINT; strcpy(pSchema[cols].name, "wallevel"); @@ -670,10 +656,6 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void #ifndef __CLOUD_VERSION__ if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0) { #endif - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int32_t *)pWrite = pDb->cfg.maxTables; // table num can be created should minus 1 - cols++; - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; *(int32_t *)pWrite = pDb->cfg.cacheBlockSize; cols++; @@ -690,10 +672,6 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *(int32_t *)pWrite = pDb->cfg.maxRowsPerFileBlock; cols++; - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int32_t *)pWrite = pDb->cfg.commitTime; - cols++; - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; *(int8_t *)pWrite = pDb->cfg.walLevel; cols++; diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index 7e7c12cf08..dc3ddac8aa 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -186,7 +186,27 @@ int32_t mnodeGetDnodesNum() { return sdbGetNumOfRows(tsDnodeSdb); } -int32_t mnodeGetOnlinDnodesNum(char *ep) { +int32_t mnodeGetOnlinDnodesCpuCoreNum() { + SDnodeObj *pDnode = NULL; + void * pIter = NULL; + int32_t cpuCores = 0; + + while (1) { + pIter = mnodeGetNextDnode(pIter, &pDnode); + if (pDnode == NULL) break; + if (pDnode->status != TAOS_DN_STATUS_OFFLINE) { + cpuCores += pDnode->numOfCores; + } + mnodeDecDnodeRef(pDnode); + } + + sdbFreeIter(pIter); + + if (cpuCores < 2) cpuCores = 2; + return cpuCores; +} + +int32_t mnodeGetOnlinDnodesNum() { SDnodeObj *pDnode = NULL; void * pIter = NULL; int32_t onlineDnodes = 0; diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 47add8f7a3..d2c177e922 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -314,15 +314,6 @@ static int32_t mnodeChildTableActionRestored() { continue; } - if (pVgroup->tableList == NULL) { - mError("ctable:%s, vgId:%d tableList is null", pTable->info.tableId, pTable->vgId); - pTable->vgId = 0; - SSdbOper desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .table = tsChildTableSdb}; - sdbDeleteRow(&desc); - mnodeDecTableRef(pTable); - continue; - } - if (pTable->info.type == TSDB_CHILD_TABLE) { SSuperTableObj *pSuperTable = mnodeGetSuperTableByUid(pTable->suid); if (pSuperTable == NULL) { @@ -1686,19 +1677,15 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) { return code; } - SVgObj *pVgroup = mnodeGetAvailableVgroup(pMsg->pDb); - if (pVgroup == NULL) { - mDebug("app:%p:%p, table:%s, start to create a new vgroup", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId); - return mnodeCreateVgroup(pMsg, pMsg->pDb); - } - if (pMsg->retry == 0) { if (pMsg->pTable == NULL) { - int32_t sid = taosAllocateId(pVgroup->idPool); - if (sid <= 0) { - mDebug("app:%p:%p, table:%s, no enough sid in vgId:%d", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId, - pVgroup->vgId); - return mnodeCreateVgroup(pMsg, pMsg->pDb); + SVgObj *pVgroup; + int32_t sid; + code = mnodeGetAvailableVgroup(pMsg, &pVgroup, &sid); + if (code != TSDB_CODE_SUCCESS) { + mDebug("app:%p:%p, table:%s, failed to get available vgroup, reason:%s", pMsg->rpcMsg.ahandle, pMsg, + pCreate->tableId, tstrerror(code)); + return code; } if (pMsg->pVgroup == NULL) { @@ -2105,6 +2092,7 @@ static void mnodeDropAllChildTablesInStable(SSuperTableObj *pStable) { mInfo("stable:%s, all child tables:%d is dropped from sdb", pStable->info.tableId, numOfTables); } +#if 0 static SChildTableObj* mnodeGetTableByPos(int32_t vnode, int32_t sid) { SVgObj *pVgroup = mnodeGetVgroup(vnode); if (pVgroup == NULL) return NULL; @@ -2115,8 +2103,11 @@ static SChildTableObj* mnodeGetTableByPos(int32_t vnode, int32_t sid) { mnodeDecVgroupRef(pVgroup); return pTable; } +#endif static int32_t mnodeProcessTableCfgMsg(SMnodeMsg *pMsg) { + return TSDB_CODE_COM_OPS_NOT_SUPPORT; +#if 0 SDMConfigTableMsg *pCfg = pMsg->rpcMsg.pCont; pCfg->dnodeId = htonl(pCfg->dnodeId); pCfg->vgId = htonl(pCfg->vgId); @@ -2140,6 +2131,7 @@ static int32_t mnodeProcessTableCfgMsg(SMnodeMsg *pMsg) { pMsg->rpcRsp.rsp = pCreate; pMsg->rpcRsp.len = htonl(pCreate->contLen); return TSDB_CODE_SUCCESS; +#endif } // handle drop child response diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 3855de4101..50af61fa69 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -41,6 +41,7 @@ static void *tsVgroupSdb = NULL; static int32_t tsVgUpdateSize = 0; +static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup); static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn); static int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pConn); static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg); @@ -54,9 +55,6 @@ static int32_t mnodeVgroupActionDestroy(SSdbOper *pOper) { taosIdPoolCleanUp(pVgroup->idPool); pVgroup->idPool = NULL; } - if (pVgroup->tableList) { - tfree(pVgroup->tableList); - } tfree(pOper->pObj); return TSDB_CODE_SUCCESS; @@ -72,21 +70,9 @@ static int32_t mnodeVgroupActionInsert(SSdbOper *pOper) { } pVgroup->pDb = pDb; - pVgroup->prev = NULL; - pVgroup->next = NULL; pVgroup->accessState = TSDB_VN_ALL_ACCCESS; - - int32_t size = sizeof(SChildTableObj *) * pDb->cfg.maxTables; - pVgroup->tableList = calloc(pDb->cfg.maxTables, sizeof(SChildTableObj *)); - if (pVgroup->tableList == NULL) { - mError("vgId:%d, failed to malloc(size:%d) for the tableList of vgroups", pVgroup->vgId, size); - return -1; - } - - pVgroup->idPool = taosInitIdPool(pDb->cfg.maxTables); - if (pVgroup->idPool == NULL) { - mError("vgId:%d, failed to taosInitIdPool for vgroups", pVgroup->vgId); - tfree(pVgroup->tableList); + if (mnodeAllocVgroupIdPool(pVgroup) < 0) { + mError("vgId:%d, failed to init idpool for vgroups", pVgroup->vgId); return -1; } @@ -124,20 +110,6 @@ static int32_t mnodeVgroupActionDelete(SSdbOper *pOper) { return TSDB_CODE_SUCCESS; } -static void mnodeVgroupUpdateIdPool(SVgObj *pVgroup) { - int32_t oldTables = taosIdPoolMaxSize(pVgroup->idPool); - SDbObj *pDb = pVgroup->pDb; - if (pDb != NULL) { - if (pDb->cfg.maxTables != oldTables) { - mInfo("vgId:%d tables change from %d to %d", pVgroup->vgId, oldTables, pDb->cfg.maxTables); - taosUpdateIdPool(pVgroup->idPool, pDb->cfg.maxTables); - int32_t size = sizeof(SChildTableObj *) * pDb->cfg.maxTables; - pVgroup->tableList = (SChildTableObj **)realloc(pVgroup->tableList, size); - memset(pVgroup->tableList + oldTables, 0, (pDb->cfg.maxTables - oldTables) * sizeof(SChildTableObj *)); - } - } -} - static int32_t mnodeVgroupActionUpdate(SSdbOper *pOper) { SVgObj *pNew = pOper->pObj; SVgObj *pVgroup = mnodeGetVgroup(pNew->vgId); @@ -162,8 +134,6 @@ static int32_t mnodeVgroupActionUpdate(SSdbOper *pOper) { } } - mnodeVgroupUpdateIdPool(pVgroup); - mnodeDecVgroupRef(pVgroup); mDebug("vgId:%d, is updated, numOfVnode:%d", pVgroup->vgId, pVgroup->numOfVnodes); @@ -325,8 +295,122 @@ void mnodeUpdateVgroupStatus(SVgObj *pVgroup, SDnodeObj *pDnode, SVnodeLoad *pVl } } -SVgObj *mnodeGetAvailableVgroup(SDbObj *pDb) { - return pDb->pHead; +static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) { + SDbObj *pDb = pInputVgroup->pDb; + if (pDb == NULL) return TSDB_CODE_MND_APP_ERROR; + + int32_t currIdPoolSize = TSDB_MIN_TABLES; + for (int32_t v = 0; v < pDb->numOfVgroups; ++v) { + SVgObj *pVgroup = pDb->vgList[v]; + if (pVgroup == NULL) continue; + + int32_t idPoolSize = taosIdPoolMaxSize(pVgroup->idPool); + currIdPoolSize = MAX(currIdPoolSize, idPoolSize); + } + + // new vgroup + if (pInputVgroup->idPool == NULL) { + pInputVgroup->idPool = taosInitIdPool(currIdPoolSize); + if (pInputVgroup->idPool == NULL) { + mError("vgId:%d, failed to init idPool for vgroup, size:%d", pInputVgroup->vgId, currIdPoolSize); + return TSDB_CODE_MND_OUT_OF_MEMORY; + } else { + mDebug("vgId:%d, init idPool for vgroup, size:%d", pInputVgroup->vgId, currIdPoolSize); + return TSDB_CODE_SUCCESS; + } + } + + // realloc all vgroups in db + int32_t newIdPoolSize; + if (currIdPoolSize < TSDB_TABLES_STEP) { + newIdPoolSize = currIdPoolSize * 2; + } else { + newIdPoolSize = ((currIdPoolSize / TSDB_TABLES_STEP) + 1) * TSDB_TABLES_STEP; + } + + if (newIdPoolSize > tsMaxTablePerVnode) { + mDebug("db:%s, currIdPoolSize:%d newIdPoolSize%d larger than %d", pDb->name, currIdPoolSize, newIdPoolSize, + tsMaxTablePerVnode); + return TSDB_CODE_MND_NO_ENOUGH_DNODES; + } + + for (int32_t v = 0; v < pDb->numOfVgroups; ++v) { + SVgObj *pVgroup = pDb->vgList[v]; + if (pVgroup == NULL) continue; + + int32_t oldIdPoolSize = taosIdPoolMaxSize(pVgroup->idPool); + + if (taosUpdateIdPool(pVgroup->idPool, newIdPoolSize) < 0) { + mError("vgId:%d, failed to update idPoolSize from %d to %d", pVgroup->vgId, oldIdPoolSize, newIdPoolSize); + return TSDB_CODE_MND_NO_ENOUGH_DNODES; + } else { + mDebug("vgId:%d, idPoolSize update from %d to %d", pVgroup->vgId, oldIdPoolSize, newIdPoolSize); + } + } + + return TSDB_CODE_SUCCESS; +} + +int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSid) { + SDbObj *pDb = pMsg->pDb; + pthread_mutex_lock(&pDb->mutex); + + for (int32_t v = 0; v < pDb->numOfVgroups; ++v) { + int vgIndex = (v + pDb->vgListIndex) % pDb->numOfVgroups; + SVgObj *pVgroup = pDb->vgList[vgIndex]; + if (pVgroup == NULL) { + mError("db:%s, index:%d vgroup is null", pDb->name, vgIndex); + pthread_mutex_unlock(&pDb->mutex); + return TSDB_CODE_MND_APP_ERROR; + } + + int32_t sid = taosAllocateId(pVgroup->idPool); + if (sid <= 0) { + mDebug("app:%p:%p, db:%s, no enough sid in vgId:%d", pMsg->rpcMsg.ahandle, pMsg, pDb->name, pVgroup->vgId); + continue; + } + + *pSid = sid; + *ppVgroup = pVgroup; + pDb->vgListIndex = vgIndex; + + pthread_mutex_unlock(&pDb->mutex); + return TSDB_CODE_SUCCESS; + } + + int maxVgroupsPerDb = tsMaxVgroupsPerDb; + if (maxVgroupsPerDb <= 0) { + maxVgroupsPerDb = mnodeGetOnlinDnodesCpuCoreNum(); + maxVgroupsPerDb = MIN(maxVgroupsPerDb, 2); + } + + if (pDb->numOfVgroups < maxVgroupsPerDb) { + mDebug("app:%p:%p, db:%s, start to create a new vgroup, numOfVgroups:%d maxVgroupsPerDb:%d", pMsg->rpcMsg.ahandle, pMsg, + pDb->name, pDb->numOfVgroups, maxVgroupsPerDb); + pthread_mutex_unlock(&pDb->mutex); + return mnodeCreateVgroup(pMsg); + } + + SVgObj *pVgroup = pDb->vgList[0]; + int32_t code = mnodeAllocVgroupIdPool(pVgroup); + if (code != TSDB_CODE_SUCCESS) { + pthread_mutex_unlock(&pDb->mutex); + return code; + } + + int32_t sid = taosAllocateId(pVgroup->idPool); + if (sid <= 0) { + mError("app:%p:%p, db:%s, no enough sid in vgId:%d", pMsg->rpcMsg.ahandle, pMsg, pDb->name, pVgroup->vgId); + pthread_mutex_unlock(&pDb->mutex); + return TSDB_CODE_MND_NO_ENOUGH_DNODES; + } + + *pSid = sid; + *ppVgroup = pVgroup; + pDb->vgListIndex = 0; + pthread_mutex_unlock(&pDb->mutex); + + return TSDB_CODE_SUCCESS; } void *mnodeGetNextVgroup(void *pIter, SVgObj **pVgroup) { @@ -354,8 +438,9 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) { return TSDB_CODE_MND_ACTION_IN_PROGRESS; } -int32_t mnodeCreateVgroup(SMnodeMsg *pMsg, SDbObj *pDb) { +int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) { if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR; + SDbObj *pDb = pMsg->pDb; SVgObj *pVgroup = (SVgObj *)calloc(1, sizeof(SVgObj)); tstrncpy(pVgroup->dbName, pDb->name, TSDB_ACCT_LEN + TSDB_DB_NAME_LEN); @@ -430,29 +515,21 @@ int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) { pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - int32_t maxReplica = 0; - SVgObj *pVgroup = NULL; - STableObj *pTable = NULL; - if (pShow->payloadLen > 0 ) { - pTable = mnodeGetTable(pShow->payload); - if (NULL == pTable || pTable->type == TSDB_SUPER_TABLE) { - mnodeDecTableRef(pTable); - return TSDB_CODE_MND_INVALID_TABLE_NAME; - } - mnodeDecTableRef(pTable); - pVgroup = mnodeGetVgroup(((SChildTableObj*)pTable)->vgId); - if (NULL == pVgroup) return TSDB_CODE_MND_INVALID_TABLE_NAME; - mnodeDecVgroupRef(pVgroup); - maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica; - } else { - SVgObj *pVgroup = pDb->pHead; - while (pVgroup != NULL) { - maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica; - pVgroup = pVgroup->next; + pShow->bytes[cols] = 4; + pSchema[cols].type = TSDB_DATA_TYPE_INT; + strcpy(pSchema[cols].name, "maxTables"); + pSchema[cols].bytes = htons(pShow->bytes[cols]); + cols++; + + pShow->maxReplica = 1; + for (int32_t v = 0; v < pDb->numOfVgroups; ++v) { + SVgObj *pVgroup = pDb->vgList[v]; + if (pVgroup != NULL) { + pShow->maxReplica = pVgroup->numOfVnodes > pShow->maxReplica ? pVgroup->numOfVnodes : pShow->maxReplica; } } - for (int32_t i = 0; i < maxReplica; ++i) { + for (int32_t i = 0; i < pShow->maxReplica; ++i) { pShow->bytes[cols] = 2; pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT; strcpy(pSchema[cols].name, "dnode"); @@ -476,43 +553,48 @@ int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) { pShow->numOfColumns = cols; pShow->offset[0] = 0; - for (int32_t i = 1; i < cols; ++i) pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1]; - - pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1]; - - if (NULL == pTable) { - pShow->numOfRows = pDb->numOfVgroups; - pShow->pIter = pDb->pHead; - } else { - pShow->numOfRows = 1; - pShow->pIter = pVgroup; + for (int32_t i = 1; i < cols; ++i) { + pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1]; } - mnodeDecDbRef(pDb); + pShow->numOfRows = pDb->numOfVgroups; + pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1]; + mnodeDecDbRef(pDb); return 0; } +static bool mnodeFilterVgroups(SVgObj *pVgroup, STableObj *pTable) { + if (NULL == pTable || pTable->type == TSDB_SUPER_TABLE) { + return true; + } + + SChildTableObj *pCTable = (SChildTableObj *)pTable; + if (pVgroup->vgId == pCTable->vgId) { + return true; + } else { + return false; + } +} + int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pConn) { int32_t numOfRows = 0; SVgObj *pVgroup = NULL; - int32_t maxReplica = 0; int32_t cols = 0; char * pWrite; SDbObj *pDb = mnodeGetDb(pShow->db); if (pDb == NULL) return 0; - pVgroup = pDb->pHead; - while (pVgroup != NULL) { - maxReplica = pVgroup->numOfVnodes > maxReplica ? pVgroup->numOfVnodes : maxReplica; - pVgroup = pVgroup->next; + STableObj *pTable = NULL; + if (pShow->payloadLen > 0 ) { + pTable = mnodeGetTable(pShow->payload); } while (numOfRows < rows) { - pVgroup = (SVgObj *) pShow->pIter; + pShow->pIter = mnodeGetNextVgroup(pShow->pIter, &pVgroup); if (pVgroup == NULL) break; - pShow->pIter = (void *) pVgroup->next; + if (!mnodeFilterVgroups(pVgroup, pTable)) continue; cols = 0; @@ -524,7 +606,11 @@ int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pC *(int32_t *) pWrite = pVgroup->numOfTables; cols++; - for (int32_t i = 0; i < maxReplica; ++i) { + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int32_t *) pWrite = tsMaxTablePerVnode; + cols++; + + for (int32_t i = 0; i < pShow->maxReplica; ++i) { pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; *(int16_t *) pWrite = pVgroup->vnodeGid[i].dnodeId; cols++; @@ -552,38 +638,36 @@ int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pC } } + mnodeDecVgroupRef(pVgroup); numOfRows++; } pShow->numOfReads += numOfRows; + mnodeDecTableRef(pTable); mnodeDecDbRef(pDb); return numOfRows; } void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable) { - if (pTable->sid >= 1 && pVgroup->tableList[pTable->sid - 1] == NULL) { - pVgroup->tableList[pTable->sid - 1] = pTable; - taosIdPoolMarkStatus(pVgroup->idPool, pTable->sid); - pVgroup->numOfTables++; - } - - if (pVgroup->numOfTables >= pVgroup->pDb->cfg.maxTables) { - mnodeMoveVgroupToTail(pVgroup); + int32_t idPoolSize = taosIdPoolMaxSize(pVgroup->idPool); + if (pTable->sid > idPoolSize) { + mnodeAllocVgroupIdPool(pVgroup); } - mnodeIncVgroupRef(pVgroup); + if (pTable->sid >= 1) { + taosIdPoolMarkStatus(pVgroup->idPool, pTable->sid); + pVgroup->numOfTables++; + mnodeIncVgroupRef(pVgroup); + } } void mnodeRemoveTableFromVgroup(SVgObj *pVgroup, SChildTableObj *pTable) { - if (pTable->sid >= 1 && pVgroup->tableList[pTable->sid - 1] != NULL) { - pVgroup->tableList[pTable->sid - 1] = NULL; + if (pTable->sid >= 1) { taosFreeId(pVgroup->idPool, pTable->sid); pVgroup->numOfTables--; + mnodeDecVgroupRef(pVgroup); } - - mnodeMoveVgroupToHead(pVgroup); - mnodeDecVgroupRef(pVgroup); } SMDCreateVnodeMsg *mnodeBuildCreateVnodeMsg(SVgObj *pVgroup) { @@ -594,13 +678,14 @@ SMDCreateVnodeMsg *mnodeBuildCreateVnodeMsg(SVgObj *pVgroup) { if (pVnode == NULL) return NULL; strcpy(pVnode->db, pVgroup->dbName); + int32_t maxTables = taosIdPoolMaxSize(pVgroup->idPool); SMDVnodeCfg *pCfg = &pVnode->cfg; pCfg->vgId = htonl(pVgroup->vgId); pCfg->cfgVersion = htonl(pDb->cfgVersion); pCfg->cacheBlockSize = htonl(pDb->cfg.cacheBlockSize); pCfg->totalBlocks = htonl(pDb->cfg.totalBlocks); - pCfg->maxTables = htonl(pDb->cfg.maxTables + 1); + pCfg->maxTables = htonl(maxTables + 1); pCfg->daysPerFile = htonl(pDb->cfg.daysPerFile); pCfg->daysToKeep = htonl(pDb->cfg.daysToKeep); pCfg->daysToKeep1 = htonl(pDb->cfg.daysToKeep1); @@ -822,6 +907,7 @@ void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode) { mInfo("dnode:%d, all vgroups is dropped from sdb", pDropDnode->dnodeId); } +#if 0 void mnodeUpdateAllDbVgroups(SDbObj *pAlterDb) { void * pIter = NULL; SVgObj *pVgroup = NULL; @@ -843,6 +929,7 @@ void mnodeUpdateAllDbVgroups(SDbObj *pAlterDb) { mInfo("db:%s, all vgroups is updated in sdb", pAlterDb->name); } +#endif void mnodeDropAllDbVgroups(SDbObj *pDropDb) { void * pIter = NULL; From 4929a943dfd7b76aafd019b8c4f0369ca99dcd05 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 2 Jul 2020 15:59:47 +0000 Subject: [PATCH 02/63] [TD-468] deadlock while create tb --- src/mnode/src/mnodeDb.c | 6 ++-- src/mnode/src/mnodeVgroup.c | 56 ++++++++++++++++++++++++++----------- src/util/src/tidpool.c | 2 +- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index e9004d3e73..490acaf6d3 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -388,7 +388,7 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate, void *pMs code = sdbInsertRow(&oper); if (code != TSDB_CODE_SUCCESS) { - tfree(pDb); + mnodeDestroyDb(pDb); mLInfo("db:%s, failed to create, reason:%s", pDb->name, tstrerror(code)); return code; } else { @@ -434,7 +434,7 @@ void mnodeAddVgroupIntoDb(SVgObj *pVgroup) { } pDb->vgList[vgPos] = pVgroup; - pthread_mutex_lock(&pDb->mutex); + pthread_mutex_unlock(&pDb->mutex); } void mnodeRemoveVgroupFromDb(SVgObj *pVgroup) { @@ -451,7 +451,7 @@ void mnodeRemoveVgroupFromDb(SVgObj *pVgroup) { } } - pthread_mutex_lock(&pDb->mutex); + pthread_mutex_unlock(&pDb->mutex); } void mnodeCleanupDbs() { diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 50af61fa69..25d667c5cf 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -49,14 +49,17 @@ static void mnodeProcessDropVnodeRsp(SRpcMsg *rpcMsg); static int32_t mnodeProcessVnodeCfgMsg(SMnodeMsg *pMsg) ; static void mnodeSendDropVgroupMsg(SVgObj *pVgroup, void *ahandle); -static int32_t mnodeVgroupActionDestroy(SSdbOper *pOper) { - SVgObj *pVgroup = pOper->pObj; +static void mnodeDestroyVgroup(SVgObj *pVgroup) { if (pVgroup->idPool) { taosIdPoolCleanUp(pVgroup->idPool); pVgroup->idPool = NULL; } - tfree(pOper->pObj); + tfree(pVgroup); +} + +static int32_t mnodeVgroupActionDestroy(SSdbOper *pOper) { + mnodeDestroyVgroup(pOper->pObj); return TSDB_CODE_SUCCESS; } @@ -299,39 +302,45 @@ static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) { SDbObj *pDb = pInputVgroup->pDb; if (pDb == NULL) return TSDB_CODE_MND_APP_ERROR; - int32_t currIdPoolSize = TSDB_MIN_TABLES; + int32_t minIdPoolSize = TSDB_MAX_TABLES; + int32_t maxIdPoolSize = TSDB_MIN_TABLES; for (int32_t v = 0; v < pDb->numOfVgroups; ++v) { SVgObj *pVgroup = pDb->vgList[v]; if (pVgroup == NULL) continue; int32_t idPoolSize = taosIdPoolMaxSize(pVgroup->idPool); - currIdPoolSize = MAX(currIdPoolSize, idPoolSize); + minIdPoolSize = MIN(minIdPoolSize, idPoolSize); + maxIdPoolSize = MAX(maxIdPoolSize, idPoolSize); } // new vgroup if (pInputVgroup->idPool == NULL) { - pInputVgroup->idPool = taosInitIdPool(currIdPoolSize); + pInputVgroup->idPool = taosInitIdPool(maxIdPoolSize); if (pInputVgroup->idPool == NULL) { - mError("vgId:%d, failed to init idPool for vgroup, size:%d", pInputVgroup->vgId, currIdPoolSize); + mError("vgId:%d, failed to init idPool for vgroup, size:%d", pInputVgroup->vgId, maxIdPoolSize); return TSDB_CODE_MND_OUT_OF_MEMORY; } else { - mDebug("vgId:%d, init idPool for vgroup, size:%d", pInputVgroup->vgId, currIdPoolSize); + mDebug("vgId:%d, init idPool for vgroup, size:%d", pInputVgroup->vgId, maxIdPoolSize); return TSDB_CODE_SUCCESS; } } // realloc all vgroups in db int32_t newIdPoolSize; - if (currIdPoolSize < TSDB_TABLES_STEP) { - newIdPoolSize = currIdPoolSize * 2; + if (minIdPoolSize < TSDB_TABLES_STEP) { + newIdPoolSize = minIdPoolSize * 2; } else { - newIdPoolSize = ((currIdPoolSize / TSDB_TABLES_STEP) + 1) * TSDB_TABLES_STEP; + newIdPoolSize = ((minIdPoolSize / TSDB_TABLES_STEP) + 1) * TSDB_TABLES_STEP; } if (newIdPoolSize > tsMaxTablePerVnode) { - mDebug("db:%s, currIdPoolSize:%d newIdPoolSize%d larger than %d", pDb->name, currIdPoolSize, newIdPoolSize, - tsMaxTablePerVnode); - return TSDB_CODE_MND_NO_ENOUGH_DNODES; + if (minIdPoolSize >= tsMaxTablePerVnode) { + mError("db:%s, minIdPoolSize:%d newIdPoolSize:%d larger than maxTablesPerVnode:%d", pDb->name, minIdPoolSize, newIdPoolSize, + tsMaxTablePerVnode); + return TSDB_CODE_MND_NO_ENOUGH_DNODES; + } else { + newIdPoolSize = tsMaxTablePerVnode; + } } for (int32_t v = 0; v < pDb->numOfVgroups; ++v) { @@ -339,6 +348,7 @@ static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) { if (pVgroup == NULL) continue; int32_t oldIdPoolSize = taosIdPoolMaxSize(pVgroup->idPool); + if (newIdPoolSize == oldIdPoolSize) continue; if (taosUpdateIdPool(pVgroup->idPool, newIdPoolSize) < 0) { mError("vgId:%d, failed to update idPoolSize from %d to %d", pVgroup->vgId, oldIdPoolSize, newIdPoolSize); @@ -381,7 +391,7 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi int maxVgroupsPerDb = tsMaxVgroupsPerDb; if (maxVgroupsPerDb <= 0) { maxVgroupsPerDb = mnodeGetOnlinDnodesCpuCoreNum(); - maxVgroupsPerDb = MIN(maxVgroupsPerDb, 2); + maxVgroupsPerDb = MAX(maxVgroupsPerDb, 2); } if (pDb->numOfVgroups < maxVgroupsPerDb) { @@ -467,7 +477,7 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) { int32_t code = sdbInsertRow(&oper); if (code != TSDB_CODE_SUCCESS) { pMsg->pVgroup = NULL; - tfree(pVgroup); + mnodeDestroyVgroup(pVgroup); } else { code = TSDB_CODE_MND_ACTION_IN_PROGRESS; } @@ -515,6 +525,12 @@ int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) { pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; + pShow->bytes[cols] = 4; + pSchema[cols].type = TSDB_DATA_TYPE_INT; + strcpy(pSchema[cols].name, "poolSize"); + pSchema[cols].bytes = htons(pShow->bytes[cols]); + cols++; + pShow->bytes[cols] = 4; pSchema[cols].type = TSDB_DATA_TYPE_INT; strcpy(pSchema[cols].name, "maxTables"); @@ -607,7 +623,11 @@ int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pC cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int32_t *) pWrite = tsMaxTablePerVnode; + *(int32_t *)pWrite = taosIdPoolMaxSize(pVgroup->idPool); + cols++; + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int32_t *)pWrite = tsMaxTablePerVnode; cols++; for (int32_t i = 0; i < pShow->maxReplica; ++i) { @@ -679,6 +699,8 @@ SMDCreateVnodeMsg *mnodeBuildCreateVnodeMsg(SVgObj *pVgroup) { strcpy(pVnode->db, pVgroup->dbName); int32_t maxTables = taosIdPoolMaxSize(pVgroup->idPool); + //TODO: dynamic alloc tables in tsdb + maxTables = 10000; SMDVnodeCfg *pCfg = &pVnode->cfg; pCfg->vgId = htonl(pVgroup->vgId); diff --git a/src/util/src/tidpool.c b/src/util/src/tidpool.c index 3764c7966b..53d81bb542 100644 --- a/src/util/src/tidpool.c +++ b/src/util/src/tidpool.c @@ -123,7 +123,7 @@ void taosIdPoolMarkStatus(void *handle, int id) { int taosUpdateIdPool(id_pool_t *handle, int maxId) { id_pool_t *pIdPool = (id_pool_t*)handle; if (maxId <= pIdPool->maxId) { - return -1; + return 0; } bool *idList = calloc(maxId, sizeof(bool)); From fbbe08ffbdd324390f6f6222e3d06de7659fd09b Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 3 Jul 2020 07:44:12 +0000 Subject: [PATCH 03/63] [TD-468] add configs --- src/common/src/tglobal.c | 2 +- src/dnode/src/dnodeMgmt.c | 10 ++++++---- src/inc/taosmsg.h | 2 ++ src/mnode/src/mnodeDnode.c | 10 ++++++---- src/mnode/src/mnodeTable.c | 6 +++--- src/mnode/src/mnodeVgroup.c | 2 +- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 68abaf1487..e90dfa94c2 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -600,7 +600,7 @@ static void doInitGlobalConfig() { taosInitConfigOption(cfg); // database configs - cfg.option = "maxtablesPerVnode"; + cfg.option = "maxTablesPerVnode"; cfg.ptr = &tsMaxTablePerVnode; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index 9cf024ba83..a51a495017 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -681,10 +681,12 @@ static void dnodeSendStatusMsg(void *handle, void *tmrId) { pStatus->alternativeRole = (uint8_t) tsAlternativeRole; // fill cluster cfg parameters - pStatus->clusterCfg.numOfMnodes = tsNumOfMnodes; - pStatus->clusterCfg.mnodeEqualVnodeNum = tsMnodeEqualVnodeNum; - pStatus->clusterCfg.offlineThreshold = tsOfflineThreshold; - pStatus->clusterCfg.statusInterval = tsStatusInterval; + pStatus->clusterCfg.numOfMnodes = htonl(tsNumOfMnodes); + pStatus->clusterCfg.mnodeEqualVnodeNum = htonl(tsMnodeEqualVnodeNum); + pStatus->clusterCfg.offlineThreshold = htonl(tsOfflineThreshold); + pStatus->clusterCfg.statusInterval = htonl(tsStatusInterval); + pStatus->clusterCfg.maxtablesPerVnode = htonl(tsMaxTablePerVnode); + pStatus->clusterCfg.maxVgroupsPerDb = htonl(tsMaxVgroupsPerDb); strcpy(pStatus->clusterCfg.arbitrator, tsArbitrator); strcpy(pStatus->clusterCfg.timezone, tsTimezone); strcpy(pStatus->clusterCfg.locale, tsLocale); diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index cb25242d27..ed86aba54f 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -568,6 +568,8 @@ typedef struct { char timezone[64]; // tsTimezone char locale[TSDB_LOCALE_LEN]; // tsLocale char charset[TSDB_LOCALE_LEN]; // tsCharset + int32_t maxtablesPerVnode; + int32_t maxVgroupsPerDb; } SClusterCfg; typedef struct { diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index a8abddc967..28bd368c74 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -302,10 +302,12 @@ static void mnodeProcessCfgDnodeMsgRsp(SRpcMsg *rpcMsg) { } static bool mnodeCheckClusterCfgPara(const SClusterCfg *clusterCfg) { - if (clusterCfg->numOfMnodes != tsNumOfMnodes) return false; - if (clusterCfg->mnodeEqualVnodeNum != tsMnodeEqualVnodeNum) return false; - if (clusterCfg->offlineThreshold != tsOfflineThreshold) return false; - if (clusterCfg->statusInterval != tsStatusInterval) return false; + if (clusterCfg->numOfMnodes != htonl(tsNumOfMnodes)) return false; + if (clusterCfg->mnodeEqualVnodeNum != htonl(tsMnodeEqualVnodeNum)) return false; + if (clusterCfg->offlineThreshold != htonl(tsOfflineThreshold)) return false; + if (clusterCfg->statusInterval != htonl(tsStatusInterval)) return false; + if (clusterCfg->maxtablesPerVnode != htonl(tsMaxTablePerVnode)) return false; + if (clusterCfg->maxVgroupsPerDb != htonl(tsMaxVgroupsPerDb)) return false; if (0 != strncasecmp(clusterCfg->arbitrator, tsArbitrator, strlen(tsArbitrator))) return false; if (0 != strncasecmp(clusterCfg->timezone, tsTimezone, strlen(tsTimezone))) return false; diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index d2c177e922..a85864c18e 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -1552,8 +1552,8 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) { SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable; assert(pTable); - mDebug("app:%p:%p, table:%s, create table in id:%d, uid:%" PRIu64 ", result:%s", pMsg->rpcMsg.ahandle, pMsg, - pTable->info.tableId, pTable->sid, pTable->uid, tstrerror(code)); + mDebug("app:%p:%p, table:%s, created in mnode, vgId:%d sid:%d, uid:%" PRIu64 ", result:%s", pMsg->rpcMsg.ahandle, + pMsg, pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid, tstrerror(code)); if (code != TSDB_CODE_SUCCESS) return code; @@ -1693,7 +1693,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) { mnodeIncVgroupRef(pVgroup); } - mDebug("app:%p:%p, table:%s, create table in vgroup, vgId:%d sid:%d", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId, + mDebug("app:%p:%p, table:%s, allocated in vgroup, vgId:%d sid:%d", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId, pVgroup->vgId, sid); return mnodeDoCreateChildTable(pMsg, sid); diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index c86d9ad250..01ed82c67c 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -332,7 +332,7 @@ static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) { // realloc all vgroups in db int32_t newIdPoolSize; - if (minIdPoolSize < TSDB_TABLES_STEP) { + if (minIdPoolSize * 2 < TSDB_TABLES_STEP) { newIdPoolSize = minIdPoolSize * 2; } else { newIdPoolSize = ((minIdPoolSize / TSDB_TABLES_STEP) + 1) * TSDB_TABLES_STEP; From e8b7aa8c4960773daaa149db0ad511fc2d9f96b0 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 3 Jul 2020 08:41:31 +0000 Subject: [PATCH 04/63] [TD-468] continue create table on create vgroup failed --- src/mnode/src/mnodeVgroup.c | 7 ++++--- tests/script/sh/deploy.sh | 7 +++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 01ed82c67c..74aa27b6c1 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -400,11 +400,12 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi } if (pDb->numOfVgroups < maxVgroupsPerDb) { - mDebug("app:%p:%p, db:%s, start to create a new vgroup, numOfVgroups:%d maxVgroupsPerDb:%d", pMsg->rpcMsg.ahandle, pMsg, + mDebug("app:%p:%p, db:%s, try to create a new vgroup, numOfVgroups:%d maxVgroupsPerDb:%d", pMsg->rpcMsg.ahandle, pMsg, pDb->name, pDb->numOfVgroups, maxVgroupsPerDb); pthread_mutex_unlock(&pDb->mutex); - return mnodeCreateVgroup(pMsg); - } + int32_t code = mnodeCreateVgroup(pMsg); + if (code == TSDB_CODE_MND_ACTION_IN_PROGRESS) return code; + } SVgObj *pVgroup = pDb->vgList[0]; int32_t code = mnodeAllocVgroupIdPool(pVgroup); diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index 98b402f4ba..92b71417a7 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -117,13 +117,12 @@ echo "vDebugFlag 135" >> $TAOS_CFG echo "cDebugFlag 135" >> $TAOS_CFG echo "jnidebugFlag 135" >> $TAOS_CFG echo "odbcdebugFlag 135" >> $TAOS_CFG -echo "httpDebugFlag 143" >> $TAOS_CFG +echo "httpDebugFlag 135" >> $TAOS_CFG echo "monitorDebugFlag 131" >> $TAOS_CFG echo "mqttDebugFlag 131" >> $TAOS_CFG echo "qdebugFlag 135" >> $TAOS_CFG echo "rpcDebugFlag 135" >> $TAOS_CFG echo "tmrDebugFlag 131" >> $TAOS_CFG -echo "cDebugFlag 135" >> $TAOS_CFG echo "udebugFlag 135" >> $TAOS_CFG echo "sdebugFlag 135" >> $TAOS_CFG echo "wdebugFlag 135" >> $TAOS_CFG @@ -132,8 +131,8 @@ echo "monitorInterval 1" >> $TAOS_CFG echo "http 0" >> $TAOS_CFG echo "numOfThreadsPerCore 2.0" >> $TAOS_CFG echo "defaultPass taosdata" >> $TAOS_CFG -echo "numOfLogLines 100000000" >> $TAOS_CFG -echo "mnodeEqualVnodeNum 0" >> $TAOS_CFG +echo "numOfLogLines 10000000" >> $TAOS_CFG +echo "mnodeEqualVnodeNum 0" >> $TAOS_CFG echo "clog 2" >> $TAOS_CFG echo "statusInterval 1" >> $TAOS_CFG echo "numOfTotalVnodes 4" >> $TAOS_CFG From ae14d3ab6e688b3a9db47b0f10da5e5e83219330 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 3 Jul 2020 12:03:14 +0000 Subject: [PATCH 05/63] scripts --- src/mnode/src/mnodeVgroup.c | 2 + tests/script/general/db/alter_option.sim | 13 ++---- tests/script/general/db/alter_tables_d2.sim | 52 +++++++++++++++------ tests/script/general/db/alter_tables_v1.sim | 37 +++++++++------ tests/script/general/db/alter_tables_v4.sim | 39 +++++++++------- tests/script/general/db/alter_vgroups.sim | 10 ++-- tests/script/general/db/basic.sim | 15 ++---- tests/script/sh/deploy.sh | 2 + 8 files changed, 100 insertions(+), 70 deletions(-) diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 74aa27b6c1..b6e57a0c60 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -408,6 +408,8 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi } SVgObj *pVgroup = pDb->vgList[0]; + if (pVgroup == NULL) return TSDB_CODE_MND_NO_ENOUGH_DNODES; + int32_t code = mnodeAllocVgroupIdPool(pVgroup); if (code != TSDB_CODE_SUCCESS) { pthread_mutex_unlock(&pDb->mutex); diff --git a/tests/script/general/db/alter_option.sim b/tests/script/general/db/alter_option.sim index f871ead11d..076f7364ee 100644 --- a/tests/script/general/db/alter_option.sim +++ b/tests/script/general/db/alter_option.sim @@ -2,7 +2,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000 system sh/exec.sh -n dnode1 -s start @@ -10,7 +10,7 @@ sleep 3000 sql connect print ============================ dnode1 start -sql create database db maxTables 500 cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 +sql create database db cache 2 blocks 4 days 10 keep 20 minRows 300 maxRows 400 ctime 120 precision 'ms' comp 2 wal 1 replica 1 sql show databases print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 if $data00 != db then @@ -31,13 +31,10 @@ endi if $data06 != 20,20,20 then return -1 endi -if $data07 != 500 then +if $data07 != 2 then return -1 endi -if $data08 != 2 then - return -1 -endi -if $data09 != 4 then +if $data08 != 4 then return -1 endi @@ -46,7 +43,6 @@ system sh/exec.sh -n dnode1 -s stop -x SIGINT return sql_error alter database db cache 256 sql_error alter database db blocks 1 -sql_error alter database db maxTables 10 sql_error alter database db days 10 sql_error alter database db keep 10 sql_error alter database db minRows 350 @@ -59,7 +55,6 @@ sql_error alter database db replica 2 print ============== step3 -sql alter database db maxTables 1000 sql alter database db comp 1 sql alter database db blocks 40 sql alter database db keep 30 diff --git a/tests/script/general/db/alter_tables_d2.sim b/tests/script/general/db/alter_tables_d2.sim index bf950a5e49..9ef39fb556 100644 --- a/tests/script/general/db/alter_tables_d2.sim +++ b/tests/script/general/db/alter_tables_d2.sim @@ -1,11 +1,13 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 2 -system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 2 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 5 system sh/deploy.sh -n dnode2 -i 2 system sh/cfg.sh -n dnode2 -c wallevel -v 2 -system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 2 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 5 system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode2 -s start @@ -17,7 +19,7 @@ sleep 1000 print ============================ step1 -sql create database db maxTables 5 +sql create database db sql create table db.st (ts timestamp, i int) tags(t int) sql create table db.t000 using db.st tags(0) sql create table db.t001 using db.st tags(1) @@ -74,9 +76,14 @@ if $rows != 20 then endi print ============================ step3 - -sql alter database db maxTables 10 -sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 10 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 10 +sleep 5000 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sleep 5000 sql create table db.t100 using db.st tags(0) sql create table db.t101 using db.st tags(1) @@ -133,9 +140,14 @@ if $rows != 40 then endi print ============================ step5 - -sql alter database db maxTables 15 -sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 15 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 15 +sleep 5000 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sleep 5000 sql create table db.t200 using db.st tags(0) sql create table db.t201 using db.st tags(1) @@ -252,9 +264,14 @@ if $rows != 60 then endi print ============================ step9 - -sql alter database db maxTables 20 -sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 20 +sleep 5000 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sleep 5000 sql create table db.t300 using db.st tags(0) sql create table db.t301 using db.st tags(1) @@ -380,9 +397,14 @@ if $rows != 80 then endi print ============================ step9 - -sql alter database db maxTables 25 -sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 25 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 25 +sleep 5000 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sleep 5000 sql create table db.t400 using db.st tags(0) sql create table db.t401 using db.st tags(1) diff --git a/tests/script/general/db/alter_tables_v1.sim b/tests/script/general/db/alter_tables_v1.sim index ccddb8f959..dde5eb6d9e 100644 --- a/tests/script/general/db/alter_tables_v1.sim +++ b/tests/script/general/db/alter_tables_v1.sim @@ -1,8 +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 numOfTotalVnodes -v 1 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 10 system sh/exec.sh -n dnode1 -s start @@ -11,7 +11,7 @@ sql connect print ============================ step1 -sql create database db maxTables 10 +sql create database db sql create table db.st (ts timestamp, i int) tags(t int) sql create table db.t0 using db.st tags(0) sql create table db.t1 using db.st tags(1) @@ -49,8 +49,11 @@ endi print ============================ step3 -sql alter database db maxTables 20 -sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20 +sleep 5000 +system sh/exec.sh -n dnode1 -s start +sleep 5000 sql create table db.t10 using db.st tags(0) sql create table db.t11 using db.st tags(1) @@ -86,9 +89,11 @@ if $rows != 20 then endi print ============================ step5 - -sql alter database db maxTables 30 -sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 30 +sleep 5000 +system sh/exec.sh -n dnode1 -s start +sleep 5000 sql create table db.t20 using db.st tags(0) sql create table db.t21 using db.st tags(1) @@ -183,9 +188,11 @@ if $rows != 30 then endi print ============================ step9 - -sql alter database db maxTables 40 -sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 40 +sleep 5000 +system sh/exec.sh -n dnode1 -s start +sleep 5000 sql create table db.t30 using db.st tags(0) sql create table db.t31 using db.st tags(1) @@ -285,9 +292,11 @@ if $rows != 40 then endi print ============================ step12 - -sql alter database db maxTables 50 -sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 50 +sleep 5000 +system sh/exec.sh -n dnode1 -s start +sleep 5000 sql create table db.t40 using db.st tags(0) sql create table db.t41 using db.st tags(1) diff --git a/tests/script/general/db/alter_tables_v4.sim b/tests/script/general/db/alter_tables_v4.sim index 75687b417e..7c9262874d 100644 --- a/tests/script/general/db/alter_tables_v4.sim +++ b/tests/script/general/db/alter_tables_v4.sim @@ -1,8 +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 numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 5 system sh/exec.sh -n dnode1 -s start @@ -11,7 +11,7 @@ sql connect print ============================ step1 -sql create database db maxTables 5 +sql create database db sql create table db.st (ts timestamp, i int) tags(t int) sql create table db.t000 using db.st tags(0) sql create table db.t001 using db.st tags(1) @@ -68,9 +68,11 @@ if $rows != 20 then endi print ============================ step3 - -sql alter database db maxTables 10 -sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 10 +sleep 5000 +system sh/exec.sh -n dnode1 -s start +sleep 5000 sql create table db.t100 using db.st tags(0) sql create table db.t101 using db.st tags(1) @@ -127,9 +129,11 @@ if $rows != 40 then endi print ============================ step5 - -sql alter database db maxTables 15 -sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 15 +sleep 5000 +system sh/exec.sh -n dnode1 -s start +sleep 5000 sql create table db.t200 using db.st tags(0) sql create table db.t201 using db.st tags(1) @@ -244,9 +248,11 @@ if $rows != 60 then endi print ============================ step9 - -sql alter database db maxTables 20 -sleep 1000 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20 +sleep 5000 +system sh/exec.sh -n dnode1 -s start +sleep 5000 sql create table db.t300 using db.st tags(0) sql create table db.t301 using db.st tags(1) @@ -370,10 +376,11 @@ if $rows != 80 then endi print ============================ step12 - -sql alter database db maxTables 25 -sleep 1000 - +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 25 +sleep 5000 +system sh/exec.sh -n dnode1 -s start +sleep 5000 sql create table db.t400 using db.st tags(0) sql create table db.t401 using db.st tags(1) sql create table db.t402 using db.st tags(2) diff --git a/tests/script/general/db/alter_vgroups.sim b/tests/script/general/db/alter_vgroups.sim index 93f3b1c0e5..13928cf033 100644 --- a/tests/script/general/db/alter_vgroups.sim +++ b/tests/script/general/db/alter_vgroups.sim @@ -1,8 +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 numOfTotalVnodes -v 1 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20 system sh/exec.sh -n dnode1 -s start @@ -11,7 +11,7 @@ sql connect print ============================ step1 -sql create database db maxTables 20 +sql create database db sql create table db.st (ts timestamp, i int) tags(t int) sql create table db.t000 using db.st tags(0) sql create table db.t001 using db.st tags(1) @@ -69,7 +69,7 @@ endi print ============================ step3 system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 2 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 2 sleep 5000 system sh/exec.sh -n dnode1 -s start sleep 5000 @@ -131,7 +131,7 @@ endi print ============================ step5 system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 3 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 3 sleep 5000 system sh/exec.sh -n dnode1 -s start sleep 5000 diff --git a/tests/script/general/db/basic.sim b/tests/script/general/db/basic.sim index 43b18abd32..9983df378e 100644 --- a/tests/script/general/db/basic.sim +++ b/tests/script/general/db/basic.sim @@ -1,8 +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 numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000 system sh/exec.sh -n dnode1 -s start @@ -17,7 +17,7 @@ $db = $dbPrefix . $i $tb = $tbPrefix . $i print =============== step1 -sql create database $db replica 1 days 20 keep 2000 +sql create database $db replica 1 days 20 keep 2000 cache 16 sql show databases print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 if $data00 != $db then @@ -35,7 +35,7 @@ endi if $data05 != 20 then return -1 endi -if $data07 != 1000 then +if $data07 != 16 then return -1 endi @@ -76,13 +76,6 @@ if $data05 != 15 then return -1 endi -#if $data06 != 1500,15000,1500 then -# return -1 -#endi -if $data07 != 1000 then - return -1 -endi - print =============== step6 sql use $db sql create table $tb (ts timestamp, speed int) diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index ebbad475f7..66ac1c42ba 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -137,6 +137,8 @@ echo "mnodeEqualVnodeNum 0" >> $TAOS_CFG echo "clog 2" >> $TAOS_CFG echo "statusInterval 1" >> $TAOS_CFG echo "numOfTotalVnodes 4" >> $TAOS_CFG +echo "maxVgroupsPerDb 4" >> $TAOS_CFG +echo "maxTablesPerVnode 1000" >> $TAOS_CFG echo "asyncLog 0" >> $TAOS_CFG echo "numOfMnodes 1" >> $TAOS_CFG echo "locale en_US.UTF-8" >> $TAOS_CFG From f50306de890e4902bfc7126ba5709a5a6ce2b76d Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 4 Jul 2020 07:17:48 +0000 Subject: [PATCH 06/63] scripts --- tests/pytest/util/dnodes.py | 2 ++ tests/script/general/db/delete.sim | 6 ++++-- tests/script/general/db/tables.sim | 16 ++++------------ tests/script/general/db/vnodes.sim | 5 +++-- tests/script/general/http/restful_full.sim | 2 +- tests/script/general/parser/create_db.sim | 8 ++++---- tests/script/general/parser/limit_tb.sim | 5 +++++ tests/script/tmp/prepare.sim | 8 +++++++- 8 files changed, 30 insertions(+), 22 deletions(-) diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 370af1ba13..52215aa053 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -72,6 +72,8 @@ class TDSimClient: self.cfg("charset", "UTF-8") self.cfg("asyncLog", "0") self.cfg("anyIp", "0") + self.cfg("maxVgroupsPerDb", "4") + self.cfg("maxTablesPerVnode", "1000") self.cfg("sdbDebugFlag", "135") self.cfg("rpcDebugFlag", "135") self.cfg("tmrDebugFlag", "131") diff --git a/tests/script/general/db/delete.sim b/tests/script/general/db/delete.sim index 6d0090a78d..477962a32d 100644 --- a/tests/script/general/db/delete.sim +++ b/tests/script/general/db/delete.sim @@ -2,6 +2,8 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c wallevel -v 2 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 10 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 10 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000 print ========= start dnodes system sh/exec.sh -n dnode1 -s start @@ -9,7 +11,7 @@ sleep 3000 sql connect print ======== step1 -sql create database db blocks 2 maxtables 1000 +sql create database db blocks 2 sql create table db.mt (ts timestamp, tbcol int) TAGS(tgcol int) $tbPrefix = db.t @@ -21,7 +23,7 @@ while $i < 2000 endw sql show db.vgroups -if $rows != 2 then +if $rows != 10 then return -1 endi diff --git a/tests/script/general/db/tables.sim b/tests/script/general/db/tables.sim index bf714dbf56..d700bf8068 100644 --- a/tests/script/general/db/tables.sim +++ b/tests/script/general/db/tables.sim @@ -2,15 +2,15 @@ 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 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4 system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect print =============== step2 -sql create database db maxtables 4 +sql create database db sql show databases print $rows $data07 @@ -18,10 +18,6 @@ if $rows != 1 then return -1 endi -if $data07 != 4 then - return -1 -endi - print =============== step3 sql use db sql create table t1 (ts timestamp, i int) @@ -78,7 +74,7 @@ sql reset query cache sleep 4000 print =============== step7 -sql create database db maxtables 4 +sql create database db sql show databases print $rows $data07 @@ -86,10 +82,6 @@ if $rows != 1 then return -1 endi -if $data07 != 4 then - return -1 -endi - print =============== step8 sql use db sql create table t1 (ts timestamp, i int) diff --git a/tests/script/general/db/vnodes.sim b/tests/script/general/db/vnodes.sim index 54d8aa77c3..769eec3241 100644 --- a/tests/script/general/db/vnodes.sim +++ b/tests/script/general/db/vnodes.sim @@ -6,7 +6,8 @@ $totalRows = $totalVnodes * $maxTables 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 maxtablesPerVnode -v $maxTables +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v $maxTables +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v $totalVnodes system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v $totalVnodes system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 100000 system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 100000 @@ -17,7 +18,7 @@ print ========== prepare data system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect -sql create database db blocks 2 cache 1 maxTables $maxTables +sql create database db blocks 2 cache 1 sql use db print ========== step1 diff --git a/tests/script/general/http/restful_full.sim b/tests/script/general/http/restful_full.sim index 60ffa4cb28..7edf394845 100644 --- a/tests/script/general/http/restful_full.sim +++ b/tests/script/general/http/restful_full.sim @@ -81,7 +81,7 @@ print =============== step2 - no db #11 system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:6020/rest/sql print 11-> $system_content -if $system_content != @{"status":"succ","head":["name","created_time","ntables","vgroups","replica","days","keep1,keep2,keep(D)","maxtables","cache(MB)","blocks","minrows","maxrows","ctime(Sec.)","wallevel","comp","precision","status"],"data":[],"rows":0}@ then +if $system_content != @{"status":"succ","head":["name","created_time","ntables","vgroups","replica","days","keep1,keep2,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","comp","precision","status"],"data":[],"rows":0}@ then return -1 endi diff --git a/tests/script/general/parser/create_db.sim b/tests/script/general/parser/create_db.sim index 2fbe03c093..be8587f2ae 100644 --- a/tests/script/general/parser/create_db.sim +++ b/tests/script/general/parser/create_db.sim @@ -128,12 +128,12 @@ endi if $data06 != 365,365,365 then return -1 endi -print data08 = $data08 -if $data08 != $cache then - print expect $cache, actual:$data08 +print data07 = $data07 +if $data07 != $cache then + print expect $cache, actual:$data07 return -1 endi -if $data09 != 4 then +if $data08 != 4 then return -1 endi diff --git a/tests/script/general/parser/limit_tb.sim b/tests/script/general/parser/limit_tb.sim index 9e62d652e2..970c7b75c5 100644 --- a/tests/script/general/parser/limit_tb.sim +++ b/tests/script/general/parser/limit_tb.sim @@ -356,6 +356,11 @@ if $rows != 0 then return -1 endi sql select top(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1 +print select top(c1, 5) from $tb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1 +print $data00 $data01 +print $data10 $data11 +print $data20 $data21 + if $rows != 3 then return -1 endi diff --git a/tests/script/tmp/prepare.sim b/tests/script/tmp/prepare.sim index 2480c20709..85146bd4c3 100644 --- a/tests/script/tmp/prepare.sim +++ b/tests/script/tmp/prepare.sim @@ -25,6 +25,12 @@ system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 20 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 20 system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 20 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 20 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 20 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 20 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 20 + system sh/cfg.sh -n dnode1 -c http -v 1 system sh/cfg.sh -n dnode2 -c http -v 1 -system sh/cfg.sh -n dnode3 -c http -v 1 \ No newline at end of file +system sh/cfg.sh -n dnode3 -c http -v 1 +system sh/cfg.sh -n dnode4 -c http -v 1 \ No newline at end of file From bfab0be4459e6316c5ce1db22d6f9a28cc9ac00d Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 4 Jul 2020 15:43:13 +0800 Subject: [PATCH 07/63] scripts --- src/tsdb/src/tsdbMeta.c | 2 +- src/tsdb/src/tsdbRWHelper.c | 4 ++-- src/util/src/tcache.c | 2 +- src/util/src/tkvstore.c | 2 +- tests/script/general/parser/limit.sim | 1 + tests/script/general/parser/limit1.sim | 1 + tests/script/general/parser/limit1_tblocks100.sim | 1 + tests/script/general/parser/limit_stb.sim | 5 +++++ tests/script/general/parser/set_tag_vals.sim | 1 + tests/script/unique/big/balance.sim | 15 ++++++++++----- 10 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index cbbf51d862..50abe3dc40 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -737,7 +737,7 @@ _err: static void tsdbFreeTable(STable *pTable) { if (pTable) { - tsdbDebug("table %s is destroyed", TABLE_CHAR_NAME(pTable)); + tsdbTrace("table %s is destroyed", TABLE_CHAR_NAME(pTable)); tfree(TABLE_NAME(pTable)); if (TABLE_TYPE(pTable) != TSDB_CHILD_TABLE) { for (int i = 0; i < TSDB_MAX_TABLE_SCHEMAS; i++) { diff --git a/src/tsdb/src/tsdbRWHelper.c b/src/tsdb/src/tsdbRWHelper.c index 934fa8e733..0870d92aa3 100644 --- a/src/tsdb/src/tsdbRWHelper.c +++ b/src/tsdb/src/tsdbRWHelper.c @@ -736,7 +736,7 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa pCompBlock->keyFirst = dataColsKeyFirst(pDataCols); pCompBlock->keyLast = dataColsKeyAt(pDataCols, rowsToWrite - 1); - tsdbDebug("vgId:%d tid:%d a block of data is written to file %s, offset %" PRId64 + tsdbTrace("vgId:%d tid:%d a block of data is written to file %s, offset %" PRId64 " numOfRows %d len %d numOfCols %" PRId16 " keyFirst %" PRId64 " keyLast %" PRId64, REPO_ID(helperRepo(pHelper)), pHelper->tableInfo.tid, pFile->fname, (int64_t)(pCompBlock->offset), (int)(pCompBlock->numOfRows), pCompBlock->len, pCompBlock->numOfCols, pCompBlock->keyFirst, @@ -937,7 +937,7 @@ static int tsdbInsertSuperBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int ASSERT(pHelper->pCompInfo->blocks[0].keyLast < pHelper->pCompInfo->blocks[1].keyFirst); } - tsdbDebug("vgId:%d tid:%d a super block is inserted at index %d", REPO_ID(pHelper->pRepo), pHelper->tableInfo.tid, + tsdbTrace("vgId:%d tid:%d a super block is inserted at index %d", REPO_ID(pHelper->pRepo), pHelper->tableInfo.tid, blkIdx); return 0; diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index 016b352188..535b7b3b7a 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -481,7 +481,7 @@ void taosCacheCleanup(SCacheObj *pCacheObj) { pCacheObj->deleting = 1; pthread_join(pCacheObj->refreshWorker, NULL); - uInfo("cacheName:%p, will be cleanuped", pCacheObj->cacheName); + uInfo("cacheName:%s, will be cleanuped", pCacheObj->cacheName); doCleanupDataCache(pCacheObj); } diff --git a/src/util/src/tkvstore.c b/src/util/src/tkvstore.c index f33941376f..af0aa6b735 100644 --- a/src/util/src/tkvstore.c +++ b/src/util/src/tkvstore.c @@ -259,7 +259,7 @@ int tdUpdateKVStoreRecord(SKVStore *pStore, uint64_t uid, void *cont, int contLe } taosHashPut(pStore->map, (void *)(&uid), sizeof(uid), (void *)(&rInfo), sizeof(rInfo)); - uDebug("put uid %" PRIu64 " into kvStore %s", uid, pStore->fname); + uTrace("put uid %" PRIu64 " into kvStore %s", uid, pStore->fname); return 0; } diff --git a/tests/script/general/parser/limit.sim b/tests/script/general/parser/limit.sim index 2129c6b82a..d8c72349db 100644 --- a/tests/script/general/parser/limit.sim +++ b/tests/script/general/parser/limit.sim @@ -2,6 +2,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect diff --git a/tests/script/general/parser/limit1.sim b/tests/script/general/parser/limit1.sim index 84b760ced9..8b927b2a7f 100644 --- a/tests/script/general/parser/limit1.sim +++ b/tests/script/general/parser/limit1.sim @@ -2,6 +2,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect diff --git a/tests/script/general/parser/limit1_tblocks100.sim b/tests/script/general/parser/limit1_tblocks100.sim index 29b48bdd43..f1702924aa 100644 --- a/tests/script/general/parser/limit1_tblocks100.sim +++ b/tests/script/general/parser/limit1_tblocks100.sim @@ -2,6 +2,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect diff --git a/tests/script/general/parser/limit_stb.sim b/tests/script/general/parser/limit_stb.sim index 9983424dbf..c9df03ab2e 100644 --- a/tests/script/general/parser/limit_stb.sim +++ b/tests/script/general/parser/limit_stb.sim @@ -63,6 +63,11 @@ if $data41 != 9 then endi sql select * from $stb order by ts asc limit 5 +print select * from $stb order by ts asc limit 5 +print $data00 $data01 +print $data10 $data11 +print $data20 $data21 + if $rows != 5 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 9d7ac9678d..38af57c73d 100644 --- a/tests/script/general/parser/set_tag_vals.sim +++ b/tests/script/general/parser/set_tag_vals.sim @@ -2,6 +2,7 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 system sh/exec.sh -n dnode1 -s start sleep 3000 sql connect diff --git a/tests/script/unique/big/balance.sim b/tests/script/unique/big/balance.sim index b2a15b0b96..259951581e 100644 --- a/tests/script/unique/big/balance.sim +++ b/tests/script/unique/big/balance.sim @@ -1,23 +1,28 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000 system sh/deploy.sh -n dnode2 -i 2 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 1000 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 1000 system sh/deploy.sh -n dnode3 -i 3 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 1000 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 1000 system sh/deploy.sh -n dnode4 -i 4 system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 1000 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 1000 system sh/deploy.sh -n dnode5 -i 5 system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 1000 +system sh/cfg.sh -n dnode5 -c maxVgroupsPerDb -v 4 +system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 1000 print =============== prepare data system sh/exec.sh -n dnode1 -s start From 850cc2e2f9d840ed2a7f21677eedb4c1b6028e44 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 4 Jul 2020 16:18:27 +0000 Subject: [PATCH 08/63] scripts --- src/inc/taosdef.h | 4 +- src/mnode/src/mnodeDnode.c | 2 +- src/mnode/src/mnodeVgroup.c | 2 +- tests/script/jenkins/basic.txt | 4 +- .../arbitrator/check_cluster_cfg_para.sim | 2 +- .../dn3_mn1_multiCreateDropTable.sim | 17 +++++--- .../arbitrator/dn3_mn1_r2_vnode_delDir.sim | 29 +++++++------ .../arbitrator/dn3_mn1_r3_vnode_delDir.sim | 33 ++++++++------- .../dn3_mn1_replica2_wal1_AddDelDnode.sim | 2 +- .../arbitrator/dn3_mn1_replica_change.sim | 41 ++++++++++-------- .../dn3_mn1_replica_change_dropDnod.sim | 16 ++++--- .../arbitrator/dn3_mn1_stopDnode_timeout.sim | 10 ++--- .../arbitrator/dn3_mn1_vnode_change.sim | 26 +++++++----- .../dn3_mn1_vnode_corruptFile_offline.sim | 32 ++++++++------ .../dn3_mn1_vnode_corruptFile_online.sim | 26 +++++++----- .../dn3_mn1_vnode_createErrData_online.sim | 28 ++++++++----- .../arbitrator/dn3_mn1_vnode_delDir.sim | 33 ++++++++------- .../dn3_mn1_vnode_noCorruptFile_offline.sim | 32 ++++++++------ .../arbitrator/dn3_mn1_vnode_nomaster.sim | 24 +++++++---- .../offline_replica2_alterTable_online.sim | 18 +++++--- .../offline_replica2_alterTag_online.sim | 18 +++++--- .../offline_replica2_createTable_online.sim | 18 +++++--- .../offline_replica2_dropDb_online.sim | 18 +++++--- .../offline_replica2_dropTable_online.sim | 18 +++++--- .../offline_replica3_alterTable_online.sim | 18 +++++--- .../offline_replica3_alterTag_online.sim | 18 +++++--- .../offline_replica3_createTable_online.sim | 18 +++++--- .../offline_replica3_dropDb_online.sim | 18 +++++--- .../offline_replica3_dropTable_online.sim | 18 +++++--- .../sync_replica2_alterTable_add.sim | 18 +++++--- .../sync_replica2_alterTable_drop.sim | 18 +++++--- .../arbitrator/sync_replica2_dropDb.sim | 18 +++++--- .../arbitrator/sync_replica2_dropTable.sim | 18 +++++--- .../sync_replica3_alterTable_add.sim | 18 +++++--- .../sync_replica3_alterTable_drop.sim | 18 +++++--- .../arbitrator/sync_replica3_createTable.sim | 18 +++++--- ...ca3_dnodeChang_DropAddAlterTableDropDb.sim | 42 +++++++++++-------- .../arbitrator/sync_replica3_dropDb.sim | 18 +++++--- .../arbitrator/sync_replica3_dropTable.sim | 18 +++++--- .../migrate/mn2_vn2_repl2_rmMnodeDir.sim | 12 +++--- .../migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim | 12 +++--- ..._repl2_rmMnodeVnodeDir_stopAll_starAll.sim | 12 +++--- .../migrate/mn2_vn2_repl2_rmVnodeDir.sim | 12 +++--- tests/tsim/inc/sim.h | 4 +- tests/tsim/src/simExe.c | 17 ++++++++ 45 files changed, 512 insertions(+), 304 deletions(-) diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 1943db7575..30a6d0e41c 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -271,8 +271,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_DEFAULT_TOTAL_BLOCKS 4 #define TSDB_MIN_TABLES 4 -#define TSDB_MAX_TABLES 5000000 -#define TSDB_DEFAULT_TABLES 500000 +#define TSDB_MAX_TABLES 2000000 +#define TSDB_DEFAULT_TABLES 200000 #define TSDB_TABLES_STEP 10000 #define TSDB_MIN_DAYS_PER_FILE 1 diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index e648150bc0..f03ed24e75 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -398,7 +398,7 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { if (false == ret) { mnodeDecDnodeRef(pDnode); rpcFreeCont(pRsp); - mError("dnode %s cluster cfg parameters inconsistent", pStatus->dnodeEp); + mError("dnode:%d, %s cluster cfg parameters inconsistent", pDnode->dnodeId, pStatus->dnodeEp); return TSDB_CODE_MND_CLUSTER_CFG_INCONSISTENT; } diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index b6e57a0c60..35a9ee0f4b 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -708,7 +708,7 @@ SMDCreateVnodeMsg *mnodeBuildCreateVnodeMsg(SVgObj *pVgroup) { strcpy(pVnode->db, pVgroup->dbName); int32_t maxTables = taosIdPoolMaxSize(pVgroup->idPool); //TODO: dynamic alloc tables in tsdb - maxTables = 10000; + maxTables = tsMaxTablePerVnode; SMDVnodeCfg *pCfg = &pVnode->cfg; pCfg->vgId = htonl(pVgroup->vgId); diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 3c4733a25b..ab62c86770 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -325,7 +325,7 @@ cd ../../../debug; make ./test.sh -f general/stream/table_replica1_vnoden.sim ./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim -./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim +#./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim ./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim ./test.sh -f unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim ./test.sh -f unique/arbitrator/dn3_mn1_multiCreateDropTable.sim @@ -338,7 +338,7 @@ cd ../../../debug; make #./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim #./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim #./test.sh -f unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim -./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim ./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim ./test.sh -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim ./test.sh -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim diff --git a/tests/script/unique/arbitrator/check_cluster_cfg_para.sim b/tests/script/unique/arbitrator/check_cluster_cfg_para.sim index af2b47d1ea..1b22db9d82 100644 --- a/tests/script/unique/arbitrator/check_cluster_cfg_para.sim +++ b/tests/script/unique/arbitrator/check_cluster_cfg_para.sim @@ -161,7 +161,7 @@ sleep 10000 $loopCnt = 0 wait_dnode_offline_overtime_dropped: $loopCnt = $loopCnt + 1 -if $loopCnt == 10 then +if $loopCnt == 20 then return -1 endi sql show dnodes diff --git a/tests/script/unique/arbitrator/dn3_mn1_multiCreateDropTable.sim b/tests/script/unique/arbitrator/dn3_mn1_multiCreateDropTable.sim index c3bae9005a..5827b25ff4 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_multiCreateDropTable.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_multiCreateDropTable.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -56,11 +62,10 @@ sql create dnode $hostname3 sql create dnode $hostname4 sleep 3000 -$totalTableNum = 10 $sleepTimer = 3000 $db = db -sql create database $db replica 3 maxTables $totalTableNum +sql create database $db replica 3 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim b/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim index 807709b675..dd101bc97c 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -54,11 +60,10 @@ sql create dnode $hostname2 sql create dnode $hostname3 sleep 3000 -$totalTableNum = 10 $sleepTimer = 3000 $db = db -sql create database $db replica 2 maxTables $totalTableNum +sql create database $db replica 2 sql use $db # create table , insert data @@ -137,8 +142,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode3Vtatus = $data4_2 -$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data6_2 +$dnode2Vtatus = $data9_2 if $dnode3Vtatus != offline then sleep 2000 @@ -204,8 +209,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode3Vtatus = $data4_2 -$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data6_2 +$dnode2Vtatus = $data9_2 print dnode2Vtatus: $dnode3Vtatus print dnode3Vtatus: $dnode3Vtatus @@ -319,8 +324,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode3Vtatus = $data4_2 -$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data6_2 +$dnode2Vtatus = $data9_2 print dnode4Vtatus: $dnode4Vtatus print dnode3Vtatus: $dnode3Vtatus diff --git a/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim b/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim index a05681ece2..6cd2e0cca3 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -56,11 +62,10 @@ sql create dnode $hostname3 sql create dnode $hostname4 sleep 3000 -$totalTableNum = 10 $sleepTimer = 3000 $db = db -sql create database $db replica 3 maxTables $totalTableNum +sql create database $db replica 3 sql use $db # create table , insert data @@ -139,8 +144,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 @@ -206,8 +211,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 print dnode4Vtatus: $dnode4Vtatus print dnode3Vtatus: $dnode3Vtatus @@ -325,8 +330,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 print dnode4Vtatus: $dnode4Vtatus print dnode3Vtatus: $dnode3Vtatus @@ -386,8 +391,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 print dnode4Vtatus: $dnode4Vtatus print dnode3Vtatus: $dnode3Vtatus diff --git a/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim b/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim index 02a56a1a8f..26f45cf645 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim @@ -329,7 +329,7 @@ $totalRows = 0 $tsStart = 1420041600000 $db = db1 -sql create database $db replica 2 maxTables 4 +sql create database $db replica 2 sql use $db $stb = stb sql create table $stb (ts timestamp, c1 int) tags(t1 int) diff --git a/tests/script/unique/arbitrator/dn3_mn1_replica_change.sim b/tests/script/unique/arbitrator/dn3_mn1_replica_change.sim index 9b01b2fae3..8abd4460c5 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_replica_change.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_replica_change.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -52,11 +58,10 @@ system sh/exec.sh -n dnode2 -s start sql create dnode $hostname2 sleep 3000 -$totalTableNum = 10 $sleepTimer = 10000 $db = db -sql create database $db replica 1 maxTables $totalTableNum +sql create database $db replica 1 sql use $db # create table , insert data @@ -352,16 +357,16 @@ if $loopCnt == 10 then endi sql show vgroups -print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 -print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 -print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 -print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 $data5_4 $data6_4 $data7_4 $data8_4 +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 $data10_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 $data10_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 $data10_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 $data5_4 $data6_4 $data7_4 $data8_4 $data9_4 $data10_4 #print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 #print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 -$thirdDnode_2 = $data8_1 -$thirdDnode_3 = $data8_2 -$thirdDnode_4 = $data8_3 -$thirdDnode_5 = $data8_4 +$thirdDnode_2 = $data10_1 +$thirdDnode_3 = $data10_2 +$thirdDnode_4 = $data10_3 +$thirdDnode_5 = $data10_4 if $thirdDnode_2 != null then sleep 2000 @@ -405,10 +410,10 @@ print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $dat print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 $data5_4 $data6_4 $data7_4 $data8_4 #print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 #print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 -$sencodDnode_2 = $data5_1 -$sencodDnode_3 = $data5_2 -$sencodDnode_4 = $data5_3 -$sencodDnode_5 = $data5_4 +$sencodDnode_2 = $data7_1 +$sencodDnode_3 = $data7_2 +$sencodDnode_4 = $data7_3 +$sencodDnode_5 = $data7_4 if $sencodDnode_2 != null then sleep 2000 diff --git a/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim b/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim index 9b001820f6..654983bb0f 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -60,7 +66,7 @@ $totalTableNum = 10 $sleepTimer = 10000 $db = db -sql create database $db replica 2 maxTables $totalTableNum +sql create database $db replica 2 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/dn3_mn1_stopDnode_timeout.sim b/tests/script/unique/arbitrator/dn3_mn1_stopDnode_timeout.sim index 152a65a75a..32674acade 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_stopDnode_timeout.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_stopDnode_timeout.sim @@ -39,10 +39,10 @@ system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator -system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10 -system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10 -system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10 -system sh/cfg.sh -n dnode4 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode1 -c offlineThreshold -v 5 +system sh/cfg.sh -n dnode2 -c offlineThreshold -v 5 +system sh/cfg.sh -n dnode3 -c offlineThreshold -v 5 +system sh/cfg.sh -n dnode4 -c offlineThreshold -v 5 system sh/cfg.sh -n dnode1 -c enableCoreFile -v 1 system sh/cfg.sh -n dnode2 -c enableCoreFile -v 1 @@ -182,7 +182,7 @@ system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator -system sh/cfg.sh -n dnode4 -c offlineThreshold -v 10 +system sh/cfg.sh -n dnode4 -c offlineThreshold -v 5 system sh/cfg.sh -n dnode4 -c enableCoreFile -v 1 system sh/exec.sh -n dnode4 -s start diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim index 13c3517e24..3c47fdf93b 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -137,8 +143,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 @@ -212,8 +218,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 print dnode4Vtatus: $dnode4Vtatus print dnode3Vtatus: $dnode3Vtatus @@ -286,8 +292,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 print dnode4Vtatus: $dnode4Vtatus print dnode3Vtatus: $dnode3Vtatus diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim index 0b4e385785..6b107aed60 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -60,7 +66,7 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -sql create database $db replica 2 maxTables $totalTableNum +sql create database $db replica 2 sql use $db # create table , insert data @@ -143,8 +149,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode3Vtatus = $data4_2 -$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data6_2 +$dnode2Vtatus = $data9_2 if $dnode3Vtatus != offline then sleep 2000 @@ -233,8 +239,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode2Vtatus = $data7_2 -$dnode3Vtatus = $data4_2 +$dnode2Vtatus = $data9_2 +$dnode3Vtatus = $data6_2 if $dnode2Vtatus != master then sleep 2000 @@ -312,8 +318,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode2Vtatus = $data7_2 -$dnode3Vtatus = $data4_2 +$dnode2Vtatus = $data9_2 +$dnode3Vtatus = $data6_2 if $dnode2Vtatus != offline then sleep 2000 @@ -392,8 +398,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode2Vtatus = $data7_2 -$dnode3Vtatus = $data4_2 +$dnode2Vtatus = $data9_2 +$dnode3Vtatus = $data6_2 if $dnode2Vtatus == offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim index c464d4023f..7e71fe3a8d 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -195,8 +201,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode2Vtatus = $data7_2 -$dnode3Vtatus = $data4_2 +$dnode2Vtatus = $data9_2 +$dnode3Vtatus = $data6_2 if $dnode2Vtatus != offline then sleep 2000 @@ -268,8 +274,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode2Vtatus = $data7_2 -$dnode3Vtatus = $data4_2 +$dnode2Vtatus = $data9_2 +$dnode3Vtatus = $data6_2 if $dnode2Vtatus != offline then sleep 2000 @@ -324,8 +330,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode2Vtatus = $data7_2 -$dnode3Vtatus = $data4_2 +$dnode2Vtatus = $data9_2 +$dnode3Vtatus = $data6_2 if $dnode2Vtatus != slave then sleep 2000 diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim index f2aa000170..8cd31e4de6 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -60,7 +66,7 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -sql create database $db replica 2 maxTables $totalTableNum +sql create database $db replica 2 sql use $db # create table , insert data @@ -157,8 +163,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode2Vtatus = $data7_2 -$dnode3Vtatus = $data4_2 +$dnode2Vtatus = $data9_2 +$dnode3Vtatus = $data6_2 if $dnode2Vtatus != offline then sleep 2000 @@ -230,8 +236,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode2Vtatus = $data7_2 -$dnode3Vtatus = $data4_2 +$dnode2Vtatus = $data9_2 +$dnode3Vtatus = $data6_2 if $dnode2Vtatus != offline then sleep 2000 @@ -286,8 +292,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode2Vtatus = $data7_2 -$dnode3Vtatus = $data4_2 +$dnode2Vtatus = $data9_2 +$dnode3Vtatus = $data6_2 if $dnode2Vtatus != slave then sleep 2000 diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim index cf20122d4c..43538cf95a 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_delDir.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -56,11 +62,10 @@ sql create dnode $hostname3 sql create dnode $hostname4 sleep 3000 -$totalTableNum = 10 $sleepTimer = 3000 $db = db -sql create database $db replica 3 maxTables $totalTableNum +sql create database $db replica 3 sql use $db # create table , insert data @@ -141,8 +146,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 @@ -201,8 +206,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 print dnode4Vtatus: $dnode4Vtatus print dnode3Vtatus: $dnode3Vtatus @@ -301,8 +306,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 print dnode4Vtatus: $dnode4Vtatus print dnode3Vtatus: $dnode3Vtatus @@ -417,8 +422,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 print dnode4Vtatus: $dnode4Vtatus print dnode3Vtatus: $dnode3Vtatus diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim index ce05b0b5ff..5b5a9deffa 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -60,7 +66,7 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -sql create database $db replica 2 maxTables $totalTableNum +sql create database $db replica 2 sql use $db # create table , insert data @@ -143,8 +149,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode3Vtatus = $data4_2 -$dnode2Vtatus = $data7_2 +$dnode3Vtatus = $data6_2 +$dnode2Vtatus = $data9_2 if $dnode3Vtatus != offline then sleep 2000 @@ -233,8 +239,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode2Vtatus = $data7_2 -$dnode3Vtatus = $data4_2 +$dnode2Vtatus = $data9_2 +$dnode3Vtatus = $data6_2 if $dnode2Vtatus != master then sleep 2000 @@ -312,8 +318,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode2Vtatus = $data7_2 -$dnode3Vtatus = $data4_2 +$dnode2Vtatus = $data9_2 +$dnode3Vtatus = $data6_2 if $dnode2Vtatus != offline then sleep 2000 @@ -391,8 +397,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode2Vtatus = $data7_2 -$dnode3Vtatus = $data4_2 +$dnode2Vtatus = $data9_2 +$dnode3Vtatus = $data6_2 if $dnode2Vtatus == offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim index f5bcd055a0..9d2e6d5f50 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim @@ -34,6 +34,17 @@ system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 + system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator @@ -56,11 +67,10 @@ sql create dnode $hostname3 sql create dnode $hostname4 sleep 3000 -$totalTableNum = 10 $sleepTimer = 3000 $db = db -sql create database $db replica 3 maxTables $totalTableNum +sql create database $db replica 3 sql use $db # create table , insert data @@ -146,8 +156,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 @@ -169,7 +179,7 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db1 -sql create database $db replica 2 maxTables $totalTableNum +sql create database $db replica 2 sql use $db # create table , insert data @@ -254,8 +264,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode3Vtatus = $data4_3 -$dnode2Vtatus = $data7_3 +$dnode3Vtatus = $data6_3 +$dnode2Vtatus = $data9_3 if $dnode3Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim index 18ffb32eed..aad8677a29 100644 --- a/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -138,8 +144,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim b/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim index 6e85429b77..0d24a4826c 100644 --- a/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 #system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 #system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -143,8 +149,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim index 0356f72a97..07b24404fb 100644 --- a/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -144,8 +150,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim b/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim index dc2586b43b..1d294d5cda 100644 --- a/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -142,8 +148,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim index 721c7d60ba..9917b8ba92 100644 --- a/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -142,8 +148,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim index 897c662b51..47e8cdd238 100644 --- a/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -142,8 +148,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim b/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim index 95ae8047fa..472b37c098 100644 --- a/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim @@ -19,10 +19,16 @@ system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 -system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 -system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 #system sh/cfg.sh -n dnode1 -c alternativeRole -v 1 #system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 @@ -143,8 +149,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim index a60f810eea..cb17d6347a 100644 --- a/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -143,8 +149,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim b/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim index a619cbe826..a2d58f54fe 100644 --- a/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -142,8 +148,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim index 3b7ee869ed..54939734a5 100644 --- a/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -142,8 +148,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim b/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim index 4f66e5c135..265359400d 100644 --- a/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim +++ b/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -142,8 +148,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim b/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim index 7bcd148bc9..5b5c3531be 100644 --- a/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim +++ b/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -142,8 +148,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/sync_replica2_dropDb.sim b/tests/script/unique/arbitrator/sync_replica2_dropDb.sim index f61b1e3cb9..1b9ad2b5e8 100644 --- a/tests/script/unique/arbitrator/sync_replica2_dropDb.sim +++ b/tests/script/unique/arbitrator/sync_replica2_dropDb.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -142,8 +148,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/sync_replica2_dropTable.sim b/tests/script/unique/arbitrator/sync_replica2_dropTable.sim index b27558fdf0..e1942b817e 100644 --- a/tests/script/unique/arbitrator/sync_replica2_dropTable.sim +++ b/tests/script/unique/arbitrator/sync_replica2_dropTable.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -142,8 +148,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim b/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim index 2a283a6a0c..3345414cd6 100644 --- a/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim +++ b/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -142,8 +148,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim b/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim index 7d321ed381..4ad01c757c 100644 --- a/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim +++ b/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -142,8 +148,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/sync_replica3_createTable.sim b/tests/script/unique/arbitrator/sync_replica3_createTable.sim index 1b93cc09f2..a07e6dc93d 100644 --- a/tests/script/unique/arbitrator/sync_replica3_createTable.sim +++ b/tests/script/unique/arbitrator/sync_replica3_createTable.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -142,8 +148,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim b/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim index f5ceced668..8a586321e1 100644 --- a/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim +++ b/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -137,8 +143,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 @@ -205,8 +211,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != slave then sleep 2000 @@ -238,8 +244,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != master then sleep 2000 @@ -312,8 +318,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != slave then sleep 2000 @@ -345,8 +351,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != master then sleep 2000 @@ -435,8 +441,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != slave then sleep 2000 @@ -468,8 +474,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != master then sleep 2000 diff --git a/tests/script/unique/arbitrator/sync_replica3_dropDb.sim b/tests/script/unique/arbitrator/sync_replica3_dropDb.sim index 0f7ee50c39..d7e0f04a0e 100644 --- a/tests/script/unique/arbitrator/sync_replica3_dropDb.sim +++ b/tests/script/unique/arbitrator/sync_replica3_dropDb.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -142,8 +148,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/arbitrator/sync_replica3_dropTable.sim b/tests/script/unique/arbitrator/sync_replica3_dropTable.sim index 9c33dd8bb4..205a0dc992 100644 --- a/tests/script/unique/arbitrator/sync_replica3_dropTable.sim +++ b/tests/script/unique/arbitrator/sync_replica3_dropTable.sim @@ -29,10 +29,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -142,8 +148,8 @@ print show vgroups: print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 -$dnode4Vtatus = $data4_2 -$dnode3Vtatus = $data7_2 +$dnode4Vtatus = $data6_2 +$dnode3Vtatus = $data9_2 if $dnode4Vtatus != offline then sleep 2000 diff --git a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim index e0b5e9b931..9d53c9968e 100644 --- a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim +++ b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim @@ -199,13 +199,13 @@ print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $dat print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 $data5_4 $data6_4 $data7_4 $data8_4 $data9_4 -$d2v2status = $data4_4 -$d2v3status = $data4_2 -$d2v4status = $data4_3 +$d2v2status = $data6_4 +$d2v3status = $data6_2 +$d2v4status = $data6_3 -$d1v2status = $data7_4 -$d1v3status = $data7_2 -$d1v4status = $data7_3 +$d1v2status = $data9_4 +$d1v3status = $data9_2 +$d1v4status = $data9_3 if $d2v2status != master then sleep 2000 diff --git a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim index ae7fc6af17..af457f4cba 100644 --- a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim +++ b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim @@ -201,13 +201,13 @@ print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $dat print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 $data5_4 $data6_4 $data7_4 $data8_4 $data9_4 -$d2v2status = $data4_4 -$d2v3status = $data4_2 -$d2v4status = $data4_3 +$d2v2status = $data6_4 +$d2v3status = $data6_2 +$d2v4status = $data6_3 -$d1v2status = $data7_4 -$d1v3status = $data7_2 -$d1v4status = $data7_3 +$d1v2status = $data9_4 +$d1v3status = $data9_2 +$d1v4status = $data9_3 if $d2v2status != master then sleep 2000 diff --git a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim index dc9bc62696..e4ff2c23c8 100644 --- a/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim +++ b/tests/script/unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim @@ -166,13 +166,13 @@ print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $dat print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 $data5_4 $data6_4 $data7_4 $data8_4 $data9_4 -$d2v2status = $data4_4 -$d2v3status = $data4_2 -$d2v4status = $data4_3 +$d2v2status = $data6_4 +$d2v3status = $data6_2 +$d2v4status = $data6_3 -$d1v2status = $data7_4 -$d1v3status = $data7_2 -$d1v4status = $data7_3 +$d1v2status = $data9_4 +$d1v3status = $data9_2 +$d1v4status = $data9_3 if $d2v2status != master then sleep 2000 diff --git a/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim b/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim index b754dc7a49..6736530240 100644 --- a/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim +++ b/tests/script/unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim @@ -199,13 +199,13 @@ print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $dat print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2 $data9_2 print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 $data5_3 $data6_3 $data7_3 $data8_3 $data9_3 print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 $data5_4 $data6_4 $data7_4 $data8_4 $data9_4 -$d2v2status = $data4_4 -$d2v3status = $data4_2 -$d2v4status = $data4_3 +$d2v2status = $data6_4 +$d2v3status = $data6_2 +$d2v4status = $data6_3 -$d1v2status = $data7_4 -$d1v3status = $data7_2 -$d1v4status = $data7_3 +$d1v2status = $data9_4 +$d1v3status = $data9_2 +$d1v4status = $data9_3 if $d2v2status != master then sleep 2000 diff --git a/tests/tsim/inc/sim.h b/tests/tsim/inc/sim.h index ae8848e1ac..f6fa929338 100644 --- a/tests/tsim/inc/sim.h +++ b/tests/tsim/inc/sim.h @@ -30,8 +30,8 @@ #define MAX_FILE_NAME_LEN 256 #define MAX_ERROR_LEN 1024 #define MAX_QUERY_VALUE_LEN 40 -#define MAX_QUERY_COL_NUM 10 -#define MAX_QUERY_ROW_NUM 10 +#define MAX_QUERY_COL_NUM 20 +#define MAX_QUERY_ROW_NUM 20 #define MAX_SYSTEM_RESULT_LEN 2048 #define MAX_VAR_LEN 100 #define MAX_VAR_NAME_LEN 32 diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index 048ee04866..506a2e75c9 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -73,6 +73,23 @@ char *simGetVariable(SScript *script, char *varName, int varLen) { int keyLen; paGetToken(varName + 6, &keyName, &keyLen); + for (int i = 0; i < MAX_QUERY_ROW_NUM; ++i) { + if (strncmp(keyName, script->data[i][0], keyLen) == 0) { + simTrace("script:%s, keyName:%s, keyValue:%s", script->fileName, script->data[i][0], script->data[i][col]); + return script->data[i][col]; + } + } + return "null"; + } else if (varName[6] == '_') { + int col = (varName[4] - '0') * 10 + (varName[5] - '0'); + if (col < 0 || col >= MAX_QUERY_COL_NUM) { + return "null"; + } + + char *keyName; + int keyLen; + paGetToken(varName + 7, &keyName, &keyLen); + for (int i = 0; i < MAX_QUERY_ROW_NUM; ++i) { if (strncmp(keyName, script->data[i][0], keyLen) == 0) { simTrace("script:%s, keyName:%s, keyValue:%s", script->fileName, script->data[i][0], script->data[i][col]); From a0b2cdac5f905f4f55f695adb10e950052a90e04 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 5 Jul 2020 01:02:22 +0800 Subject: [PATCH 09/63] scripts --- tests/script/jenkins/basic.txt | 53 ++++++++++--------- .../offline_replica2_alterTable_online.sim | 4 +- .../offline_replica2_alterTag_online.sim | 5 +- .../offline_replica2_createTable_online.sim | 14 +++-- .../offline_replica2_dropDb_online.sim | 4 +- .../offline_replica2_dropTable_online.sim | 4 +- .../offline_replica3_alterTable_online.sim | 4 +- .../offline_replica3_alterTag_online.sim | 30 +++++------ .../offline_replica3_dropDb_online.sim | 4 +- .../offline_replica3_dropTable_online.sim | 4 +- .../replica_changeWithArbitrator.sim | 16 ++++-- .../sync_replica2_alterTable_add.sim | 4 +- .../sync_replica2_alterTable_drop.sim | 4 +- .../arbitrator/sync_replica2_dropDb.sim | 4 +- .../arbitrator/sync_replica2_dropTable.sim | 4 +- .../sync_replica3_alterTable_add.sim | 4 +- .../sync_replica3_alterTable_drop.sim | 4 +- .../arbitrator/sync_replica3_dropDb.sim | 4 +- .../arbitrator/sync_replica3_dropTable.sim | 4 +- 19 files changed, 86 insertions(+), 88 deletions(-) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index ab62c86770..a0c182876f 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -2,10 +2,10 @@ cd ../../../debug; cmake .. 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/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/insert2.sim ./test.sh -f general/alter/metrics.sim ./test.sh -f general/alter/table.sim @@ -100,8 +100,8 @@ cd ../../../debug; make ./test.sh -f general/insert/query_multi_file.sim ./test.sh -f general/insert/tcp.sim -./test.sh -f general/parser/alter.sim -./test.sh -f general/parser/alter1.sim +###./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 @@ -141,15 +141,15 @@ cd ../../../debug; make ./test.sh -f general/parser/interp.sim ./test.sh -f general/parser/tags_dynamically_specifiy.sim ./test.sh -f general/parser/groupby.sim -./test.sh -f general/parser/set_tag_vals.sim +###./test.sh -f general/parser/set_tag_vals.sim #./test.sh -f general/parser/slimit_alter_tags.sim ./test.sh -f general/parser/join.sim ./test.sh -f general/parser/join_multivnode.sim ./test.sh -f general/parser/binary_escapeCharacter.sim ./test.sh -f general/parser/bug.sim #./test.sh -f general/parser/stream_on_sys.sim -./test.sh -f general/parser/stream.sim -./test.sh -f general/parser/repeatAlter.sim +#./test.sh -f general/parser/stream.sim +###./test.sh -f general/parser/repeatAlter.sim #./test.sh -f general/parser/repeatStream.sim ./test.sh -f general/stable/disk.sim @@ -192,7 +192,7 @@ cd ../../../debug; make ./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/add.sim ./test.sh -f general/tag/bigint.sim ./test.sh -f general/tag/binary_binary.sim ./test.sh -f general/tag/binary.sim @@ -210,7 +210,7 @@ cd ../../../debug; make ./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/set.sim ./test.sh -f general/tag/smallint.sim ./test.sh -f general/tag/tinyint.sim @@ -245,13 +245,13 @@ cd ../../../debug; make ./test.sh -f unique/account/user_create.sim ./test.sh -f unique/account/user_len.sim -./test.sh -f unique/big/balance.sim +###./test.sh -f unique/big/balance.sim ./test.sh -f unique/big/maxvnodes.sim ./test.sh -f unique/big/tcp.sim ./test.sh -f unique/cluster/balance1.sim ./test.sh -f unique/cluster/balance2.sim -./test.sh -f unique/cluster/balance3.sim +###./test.sh -f unique/cluster/balance3.sim ./test.sh -f unique/cluster/cache.sim ./test.sh -f unique/column/replica3.sim @@ -309,16 +309,16 @@ cd ../../../debug; make ./test.sh -f unique/vnode/replica3_repeat.sim ./test.sh -f unique/vnode/replica3_vgroup.sim -./test.sh -f general/stream/metrics_1.sim -./test.sh -f general/stream/metrics_del.sim -./test.sh -f general/stream/metrics_n.sim -./test.sh -f general/stream/metrics_replica1_vnoden.sim +#./test.sh -f general/stream/metrics_1.sim +#./test.sh -f general/stream/metrics_del.sim +#./test.sh -f general/stream/metrics_n.sim +#./test.sh -f general/stream/metrics_replica1_vnoden.sim #./test.sh -f general/stream/new_stream.sim -./test.sh -f general/stream/restart_stream.sim -./test.sh -f general/stream/stream_1.sim -./test.sh -f general/stream/stream_2.sim -./test.sh -f general/stream/stream_3.sim -./test.sh -f general/stream/stream_restart.sim +#./test.sh -f general/stream/restart_stream.sim +#./test.sh -f general/stream/stream_1.sim +#./test.sh -f general/stream/stream_2.sim +#./test.sh -f general/stream/stream_3.sim +#./test.sh -f general/stream/stream_restart.sim ./test.sh -f general/stream/table_1.sim ./test.sh -f general/stream/table_del.sim ./test.sh -f general/stream/table_n.sim @@ -342,22 +342,23 @@ cd ../../../debug; make ./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim ./test.sh -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim ./test.sh -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim -./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim +###./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim ./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim ./test.sh -f unique/arbitrator/insert_duplicationTs.sim -./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim +###./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim ./test.sh -f unique/arbitrator/offline_replica2_alterTag_online.sim ./test.sh -f unique/arbitrator/offline_replica2_createTable_online.sim ./test.sh -f unique/arbitrator/offline_replica2_dropDb_online.sim ./test.sh -f unique/arbitrator/offline_replica2_dropTable_online.sim -./test.sh -f unique/arbitrator/offline_replica3_alterTable_online.sim +###./test.sh -f unique/arbitrator/offline_replica3_alterTable_online.sim ./test.sh -f unique/arbitrator/offline_replica3_alterTag_online.sim ./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim ./test.sh -f unique/arbitrator/offline_replica3_dropDb_online.sim ./test.sh -f unique/arbitrator/offline_replica3_dropTable_online.sim ./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim -./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim -./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim +###./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim +###./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim + ./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim ./test.sh -f unique/arbitrator/sync_replica2_dropTable.sim ./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim diff --git a/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim index aad8677a29..ea5e7608ee 100644 --- a/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim @@ -66,8 +66,8 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -print create database $db replica 2 maxTables $totalTableNum -sql create database $db replica 2 maxTables $totalTableNum +print create database $db replica 2 +sql create database $db replica 2 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim b/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim index 0d24a4826c..6fa1da4e1d 100644 --- a/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim @@ -64,11 +64,10 @@ sleep 3000 $totalTableNum = 10 $sleepTimer = 3000 -$maxTables = $totalTableNum * 2 $db = db -print create database $db replica 2 maxTables $maxTables -sql create database $db replica 2 maxTables $maxTables +print create database $db replica 2 +sql create database $db replica 2 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim index 07b24404fb..1d2a83c825 100644 --- a/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_createTable_online.sim @@ -30,10 +30,10 @@ system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 $totalTableNum = 10 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 20 system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 @@ -65,11 +65,9 @@ sleep 3000 $totalTableNum = 10 $sleepTimer = 3000 -$maxTables = $totalTableNum * 2 - $db = db -print create database $db replica 2 maxTables $maxTables -sql create database $db replica 2 maxTables $maxTables +print create database $db replica 2 +sql create database $db replica 2 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim b/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim index 1d294d5cda..630b4eaab8 100644 --- a/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim @@ -66,8 +66,8 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -print create database $db replica 2 maxTables $totalTableNum -sql create database $db replica 2 maxTables $totalTableNum +print create database $db replica 2 +sql create database $db replica 2 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim b/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim index 9917b8ba92..43dba536c7 100644 --- a/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim @@ -66,8 +66,8 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -print create database $db replica 2 maxTables $totalTableNum -sql create database $db replica 2 maxTables $totalTableNum +print create database $db replica 2 +sql create database $db replica 2 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim index 47e8cdd238..09a2424c85 100644 --- a/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim @@ -66,8 +66,8 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -print create database $db replica 3 maxTables $totalTableNum -sql create database $db replica 3 maxTables $totalTableNum +print create database $db replica 3 +sql create database $db replica 3 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim b/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim index 472b37c098..d94f341236 100644 --- a/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim @@ -19,26 +19,21 @@ system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 -$totalTableNum = 10 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum - -system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 -system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 -system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 -system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 - #system sh/cfg.sh -n dnode1 -c alternativeRole -v 1 #system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 #system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 #system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 10 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 20 + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -64,11 +59,10 @@ sleep 3000 $totalTableNum = 10 $sleepTimer = 3000 -$maxTables = $totalTableNum * 2 $db = db -print create database $db replica 3 maxTables $maxTables -sql create database $db replica 3 maxTables $maxTables +print create database $db replica 3 +sql create database $db replica 3 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim b/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim index a2d58f54fe..72727f3df0 100644 --- a/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim @@ -66,8 +66,8 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -print create database $db replica 3 maxTables $totalTableNum -sql create database $db replica 3 maxTables $totalTableNum +print create database $db replica 3 +sql create database $db replica 3 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim index 54939734a5..7e57b0a971 100644 --- a/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim @@ -66,8 +66,8 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -print create database $db replica 3 maxTables $totalTableNum -sql create database $db replica 3 maxTables $totalTableNum +print create database $db replica 3 +sql create database $db replica 3 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim b/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim index 1b2c8d1db6..a16e765a30 100644 --- a/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim +++ b/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim @@ -34,10 +34,16 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 0 system sh/cfg.sh -n dnode3 -c alternativeRole -v 0 system sh/cfg.sh -n dnode4 -c alternativeRole -v 0 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 +$totalTableNum = 12 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum + +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 1 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator @@ -65,7 +71,7 @@ sql connect $totalTableNum = 12 $db = db -sql create database $db replica 1 maxTables $totalTableNum +sql create database $db replica 1 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim b/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim index 265359400d..8775da607c 100644 --- a/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim +++ b/tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim @@ -66,8 +66,8 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -print create database $db replica 2 maxTables $totalTableNum -sql create database $db replica 2 maxTables $totalTableNum +print create database $db replica 2 +sql create database $db replica 2 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim b/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim index 5b5c3531be..84ae9554f3 100644 --- a/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim +++ b/tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim @@ -66,8 +66,8 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -print create database $db replica 2 maxTables $totalTableNum -sql create database $db replica 2 maxTables $totalTableNum +print create database $db replica 2 +sql create database $db replica 2 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/sync_replica2_dropDb.sim b/tests/script/unique/arbitrator/sync_replica2_dropDb.sim index 1b9ad2b5e8..c9dc302d3c 100644 --- a/tests/script/unique/arbitrator/sync_replica2_dropDb.sim +++ b/tests/script/unique/arbitrator/sync_replica2_dropDb.sim @@ -66,8 +66,8 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -print create database $db replica 2 maxTables $totalTableNum -sql create database $db replica 2 maxTables $totalTableNum +print create database $db replica 2 +sql create database $db replica 2 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/sync_replica2_dropTable.sim b/tests/script/unique/arbitrator/sync_replica2_dropTable.sim index e1942b817e..b7392eb960 100644 --- a/tests/script/unique/arbitrator/sync_replica2_dropTable.sim +++ b/tests/script/unique/arbitrator/sync_replica2_dropTable.sim @@ -66,8 +66,8 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -print create database $db replica 2 maxTables $totalTableNum -sql create database $db replica 2 maxTables $totalTableNum +print create database $db replica 2 +sql create database $db replica 2 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim b/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim index 3345414cd6..2fde90f3db 100644 --- a/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim +++ b/tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim @@ -66,8 +66,8 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -print create database $db replica 3 maxTables $totalTableNum -sql create database $db replica 3 maxTables $totalTableNum +print create database $db replica 3 +sql create database $db replica 3 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim b/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim index 4ad01c757c..f31d01b327 100644 --- a/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim +++ b/tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim @@ -66,8 +66,8 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -print create database $db replica 3 maxTables $totalTableNum -sql create database $db replica 3 maxTables $totalTableNum +print create database $db replica 3 +sql create database $db replica 3 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/sync_replica3_dropDb.sim b/tests/script/unique/arbitrator/sync_replica3_dropDb.sim index d7e0f04a0e..fd07fda2d4 100644 --- a/tests/script/unique/arbitrator/sync_replica3_dropDb.sim +++ b/tests/script/unique/arbitrator/sync_replica3_dropDb.sim @@ -66,8 +66,8 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -print create database $db replica 3 maxTables $totalTableNum -sql create database $db replica 3 maxTables $totalTableNum +print create database $db replica 3 +sql create database $db replica 3 sql use $db # create table , insert data diff --git a/tests/script/unique/arbitrator/sync_replica3_dropTable.sim b/tests/script/unique/arbitrator/sync_replica3_dropTable.sim index 205a0dc992..1749477d64 100644 --- a/tests/script/unique/arbitrator/sync_replica3_dropTable.sim +++ b/tests/script/unique/arbitrator/sync_replica3_dropTable.sim @@ -66,8 +66,8 @@ $totalTableNum = 10 $sleepTimer = 3000 $db = db -print create database $db replica 3 maxTables $totalTableNum -sql create database $db replica 3 maxTables $totalTableNum +print create database $db replica 3 +sql create database $db replica 3 sql use $db # create table , insert data From ac67adc8cb47710b59b46c77ed2beff83350bcad Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 5 Jul 2020 02:47:43 +0000 Subject: [PATCH 10/63] scripts --- src/mnode/src/mnodeVgroup.c | 6 +++--- tests/script/general/table/limit.sim | 7 ++++--- tests/script/jenkins/basic.txt | 10 +++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 35a9ee0f4b..f1c09221fb 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -332,8 +332,8 @@ static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) { // realloc all vgroups in db int32_t newIdPoolSize; - if (minIdPoolSize * 2 < TSDB_TABLES_STEP) { - newIdPoolSize = minIdPoolSize * 2; + if (minIdPoolSize * 4 < TSDB_TABLES_STEP) { + newIdPoolSize = minIdPoolSize * 4; } else { newIdPoolSize = ((minIdPoolSize / TSDB_TABLES_STEP) + 1) * TSDB_TABLES_STEP; } @@ -708,7 +708,7 @@ SMDCreateVnodeMsg *mnodeBuildCreateVnodeMsg(SVgObj *pVgroup) { strcpy(pVnode->db, pVgroup->dbName); int32_t maxTables = taosIdPoolMaxSize(pVgroup->idPool); //TODO: dynamic alloc tables in tsdb - maxTables = tsMaxTablePerVnode; + maxTables = MAX(10000, tsMaxTablePerVnode); SMDVnodeCfg *pCfg = &pVnode->cfg; pCfg->vgId = htonl(pVgroup->vgId); diff --git a/tests/script/general/table/limit.sim b/tests/script/general/table/limit.sim index 46fc5103c1..067182e1c8 100644 --- a/tests/script/general/table/limit.sim +++ b/tests/script/general/table/limit.sim @@ -3,6 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 129 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 8 system sh/exec.sh -n dnode1 -s start sleep 3000 @@ -36,7 +37,7 @@ while $x > $y endw sql show vgroups -if $rows != 2 then +if $rows != 8 then return -1 endi @@ -51,7 +52,7 @@ while $x > $y endw sql show vgroups -if $rows != 4 then +if $rows != 8 then return -1 endi @@ -66,7 +67,7 @@ while $x > $y endw sql show vgroups -if $rows != 6 then +if $rows != 8 then return -1 endi diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index a0c182876f..9f246552ad 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -246,7 +246,7 @@ cd ../../../debug; make ./test.sh -f unique/account/user_len.sim ###./test.sh -f unique/big/balance.sim -./test.sh -f unique/big/maxvnodes.sim +###./test.sh -f unique/big/maxvnodes.sim ./test.sh -f unique/big/tcp.sim ./test.sh -f unique/cluster/balance1.sim @@ -322,7 +322,7 @@ cd ../../../debug; make ./test.sh -f general/stream/table_1.sim ./test.sh -f general/stream/table_del.sim ./test.sh -f general/stream/table_n.sim -./test.sh -f general/stream/table_replica1_vnoden.sim +#./test.sh -f general/stream/table_replica1_vnoden.sim ./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim #./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim @@ -352,7 +352,7 @@ cd ../../../debug; make ./test.sh -f unique/arbitrator/offline_replica2_dropTable_online.sim ###./test.sh -f unique/arbitrator/offline_replica3_alterTable_online.sim ./test.sh -f unique/arbitrator/offline_replica3_alterTag_online.sim -./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim +###./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim ./test.sh -f unique/arbitrator/offline_replica3_dropDb_online.sim ./test.sh -f unique/arbitrator/offline_replica3_dropTable_online.sim ./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim @@ -361,8 +361,8 @@ cd ../../../debug; make ./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim ./test.sh -f unique/arbitrator/sync_replica2_dropTable.sim -./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim -./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim +###./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim +###./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim ./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim ./test.sh -f unique/arbitrator/sync_replica3_dropTable.sim From e7eccba5ef6e44917f1b60ca5ea7c3bc23c29437 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 10 Jul 2020 10:26:43 +0000 Subject: [PATCH 11/63] change regression test --- tests/script/jenkins/basic.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index be2e1edfff..cb07093a89 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -1,11 +1,11 @@ cd ../../../debug; cmake .. 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/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 @@ -100,8 +100,8 @@ cd ../../../debug; make ./test.sh -f general/insert/query_multi_file.sim ./test.sh -f general/insert/tcp.sim -###./test.sh -f general/parser/alter.sim -###./test.sh -f general/parser/alter1.sim +./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 @@ -143,16 +143,16 @@ cd ../../../debug; make ./test.sh -f general/parser/interp.sim ./test.sh -f general/parser/tags_dynamically_specifiy.sim ./test.sh -f general/parser/groupby.sim -###./test.sh -f general/parser/set_tag_vals.sim +./test.sh -f general/parser/set_tag_vals.sim #./test.sh -f general/parser/sliding.sim ./test.sh -f general/parser/tags_dynamically_specifiy.sim ./test.sh -f general/parser/tags_filter.sim -#./test.sh -f general/parser/slimit_alter_tags.sim +./test.sh -f general/parser/slimit_alter_tags.sim ./test.sh -f general/parser/join.sim ./test.sh -f general/parser/join_multivnode.sim ./test.sh -f general/parser/binary_escapeCharacter.sim ./test.sh -f general/parser/bug.sim -###./test.sh -f general/parser/repeatAlter.sim +./test.sh -f general/parser/repeatAlter.sim ./test.sh -f general/stable/disk.sim ./test.sh -f general/stable/dnode3.sim @@ -194,7 +194,7 @@ cd ../../../debug; make ./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/add.sim ./test.sh -f general/tag/bigint.sim ./test.sh -f general/tag/binary_binary.sim ./test.sh -f general/tag/binary.sim @@ -212,7 +212,7 @@ cd ../../../debug; make ./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/set.sim ./test.sh -f general/tag/smallint.sim ./test.sh -f general/tag/tinyint.sim @@ -247,7 +247,7 @@ cd ../../../debug; make ./test.sh -f unique/account/user_create.sim ./test.sh -f unique/account/user_len.sim -###./test.sh -f unique/big/balance.sim +./test.sh -f unique/big/balance.sim ###./test.sh -f unique/big/maxvnodes.sim ./test.sh -f unique/big/tcp.sim From c337fc773260d06402c3d54776ec7bce4febe6c7 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 10 Jul 2020 14:27:09 +0000 Subject: [PATCH 12/63] [TD-468] update tests cases for this issue --- src/client/src/tscSubquery.c | 1 - src/mnode/src/mnodeVgroup.c | 3 ++- .../general/stream/table_replica1_vnoden.sim | 3 ++- tests/script/jenkins/basic.txt | 24 +++++++++---------- .../arbitrator/dn3_mn1_vnode_nomaster.sim | 8 +++---- .../offline_replica3_createTable_online.sim | 12 +++++----- tests/script/unique/big/maxvnodes.sim | 2 ++ 7 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index d3f298c2b2..29b42d7963 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -1778,7 +1778,6 @@ static SSqlObj *tscCreateSqlObjForSubquery(SSqlObj *pSql, SRetrieveSupport *trsu pSql->pSubs[trsupport->subqueryIndex] = pNew; } - printf("------------alloc:%p\n", pNew); return pNew; } diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 0715f182b1..6c8f21fec6 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -636,7 +636,7 @@ int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pC SDbObj *pDb = mnodeGetDb(pShow->db); if (pDb == NULL) return 0; - + if (pDb->status != TSDB_DB_STATUS_READY) { mError("db:%s, status:%d, in dropping", pDb->name, pDb->status); return 0; @@ -650,6 +650,7 @@ int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pC while (numOfRows < rows) { pShow->pIter = mnodeGetNextVgroup(pShow->pIter, &pVgroup); if (pVgroup == NULL) break; + if (pVgroup->pDb != pDb) continue; if (!mnodeFilterVgroups(pVgroup, pTable)) continue; cols = 0; diff --git a/tests/script/general/stream/table_replica1_vnoden.sim b/tests/script/general/stream/table_replica1_vnoden.sim index e1d5a9babf..ee0c871d98 100644 --- a/tests/script/general/stream/table_replica1_vnoden.sim +++ b/tests/script/general/stream/table_replica1_vnoden.sim @@ -4,7 +4,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 numOfTotalVnodes -v 8 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 3 system sh/exec.sh -n dnode1 -s start sleep 3000 diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 99af6cf676..ee9daa97c9 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -245,12 +245,12 @@ cd ../../../debug; make ./test.sh -f unique/account/user_len.sim ./test.sh -f unique/big/balance.sim -###./test.sh -f unique/big/maxvnodes.sim +./test.sh -f unique/big/maxvnodes.sim ./test.sh -f unique/big/tcp.sim ./test.sh -f unique/cluster/balance1.sim ./test.sh -f unique/cluster/balance2.sim -###./test.sh -f unique/cluster/balance3.sim +./test.sh -f unique/cluster/balance3.sim ./test.sh -f unique/cluster/cache.sim ./test.sh -f unique/column/replica3.sim @@ -321,7 +321,7 @@ cd ../../../debug; make ./test.sh -f general/stream/table_1.sim ./test.sh -f general/stream/table_del.sim ./test.sh -f general/stream/table_n.sim -#./test.sh -f general/stream/table_replica1_vnoden.sim +###./test.sh -f general/stream/table_replica1_vnoden.sim ./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim #./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim @@ -338,31 +338,31 @@ cd ../../../debug; make #./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim #./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim #./test.sh -f unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim -#./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim +./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim ./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim ./test.sh -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim ./test.sh -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim -###./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim +./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim ./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim ./test.sh -f unique/arbitrator/insert_duplicationTs.sim -###./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim +./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim ./test.sh -f unique/arbitrator/offline_replica2_alterTag_online.sim ./test.sh -f unique/arbitrator/offline_replica2_createTable_online.sim ./test.sh -f unique/arbitrator/offline_replica2_dropDb_online.sim ./test.sh -f unique/arbitrator/offline_replica2_dropTable_online.sim -###./test.sh -f unique/arbitrator/offline_replica3_alterTable_online.sim +./test.sh -f unique/arbitrator/offline_replica3_alterTable_online.sim ./test.sh -f unique/arbitrator/offline_replica3_alterTag_online.sim -###./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim +./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim ./test.sh -f unique/arbitrator/offline_replica3_dropDb_online.sim ./test.sh -f unique/arbitrator/offline_replica3_dropTable_online.sim ./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim -###./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim -###./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim +./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim +./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim ./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim ./test.sh -f unique/arbitrator/sync_replica2_dropTable.sim -###./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim -###./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim +./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim +./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim ./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim ./test.sh -f unique/arbitrator/sync_replica3_dropTable.sim diff --git a/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim b/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim index 9d2e6d5f50..7696168bb9 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim @@ -35,10 +35,10 @@ system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4 system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4 $totalTableNum = 10 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 20 system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 diff --git a/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim b/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim index cb17d6347a..fc1c69709a 100644 --- a/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim +++ b/tests/script/unique/arbitrator/offline_replica3_createTable_online.sim @@ -30,10 +30,10 @@ system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 $totalTableNum = 10 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum -system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum -system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum -system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v $totalTableNum +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 20 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 20 system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 1 system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 1 @@ -67,8 +67,8 @@ $sleepTimer = 3000 $maxTables = $totalTableNum * 2 $db = db -print create database $db replica 3 maxTables $maxTables -sql create database $db replica 3 maxTables $maxTables +print create database $db replica 3 +sql create database $db replica 3 sql use $db # create table , insert data diff --git a/tests/script/unique/big/maxvnodes.sim b/tests/script/unique/big/maxvnodes.sim index ab93474a43..9603b5de64 100644 --- a/tests/script/unique/big/maxvnodes.sim +++ b/tests/script/unique/big/maxvnodes.sim @@ -9,9 +9,11 @@ $totalRows = $totalVnodes * $maxTables system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c walLevel -v 2 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v $totalVnodes +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v $totalVnodes system sh/deploy.sh -n dnode2 -i 2 system sh/cfg.sh -n dnode2 -c walLevel -v 2 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v $totalVnodes +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v $totalVnodes print ========== prepare data From 8770762c1cae0f223736ec5a30b4c19ff987b8c7 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 10 Jul 2020 15:06:11 +0000 Subject: [PATCH 13/63] [TD-468] change code formats --- src/mnode/src/mnodeDb.c | 2 +- src/mnode/src/mnodeDnode.c | 8 ++++---- src/mnode/src/mnodeTable.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 3723e66528..497d64eabf 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -38,7 +38,7 @@ #include "mnodeUser.h" #include "mnodeVgroup.h" -#define VG_LIST_SIZE 1 +#define VG_LIST_SIZE 8 static void * tsDbSdb = NULL; static int32_t tsDbUpdateSize; diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index 17bb8715a4..86eaaceef7 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -308,13 +308,13 @@ static bool mnodeCheckClusterCfgPara(const SClusterCfg *clusterCfg) { if (clusterCfg->mnodeEqualVnodeNum != htonl(tsMnodeEqualVnodeNum)) return false; if (clusterCfg->offlineThreshold != htonl(tsOfflineThreshold)) return false; if (clusterCfg->statusInterval != htonl(tsStatusInterval)) return false; - if (clusterCfg->maxtablesPerVnode != htonl(tsMaxTablePerVnode)) return false; - if (clusterCfg->maxVgroupsPerDb != htonl(tsMaxVgroupsPerDb)) return false; + if (clusterCfg->maxtablesPerVnode != htonl(tsMaxTablePerVnode)) return false; + if (clusterCfg->maxVgroupsPerDb != htonl(tsMaxVgroupsPerDb)) return false; if (0 != strncasecmp(clusterCfg->arbitrator, tsArbitrator, strlen(tsArbitrator))) return false; if (0 != strncasecmp(clusterCfg->timezone, tsTimezone, strlen(tsTimezone))) return false; - if (0 != strncasecmp(clusterCfg->locale, tsLocale, strlen(tsLocale))) return false; - if (0 != strncasecmp(clusterCfg->charset, tsCharset, strlen(tsCharset))) return false; + if (0 != strncasecmp(clusterCfg->locale, tsLocale, strlen(tsLocale))) return false; + if (0 != strncasecmp(clusterCfg->charset, tsCharset, strlen(tsCharset))) return false; return true; } diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 3ada1165f2..58eaecb20a 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -1723,8 +1723,8 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) { if (pMsg->retry == 0) { if (pMsg->pTable == NULL) { - SVgObj *pVgroup; - int32_t sid; + SVgObj *pVgroup = NULL; + int32_t sid = 0; code = mnodeGetAvailableVgroup(pMsg, &pVgroup, &sid); if (code != TSDB_CODE_SUCCESS) { mDebug("app:%p:%p, table:%s, failed to get available vgroup, reason:%s", pMsg->rpcMsg.ahandle, pMsg, From 7fccb2f0cf7eef780e63d4d3ebdc87a0fcf33e75 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 11 Jul 2020 02:13:51 +0000 Subject: [PATCH 14/63] scripts --- tests/script/general/stream/metrics_replica1_vnoden.sim | 3 ++- tests/script/jenkins/basic.txt | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/script/general/stream/metrics_replica1_vnoden.sim b/tests/script/general/stream/metrics_replica1_vnoden.sim index ee071fd681..abe3e2ffdf 100644 --- a/tests/script/general/stream/metrics_replica1_vnoden.sim +++ b/tests/script/general/stream/metrics_replica1_vnoden.sim @@ -4,7 +4,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 numOfTotalVnodes -v 8 -system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4 +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 1000 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 3 system sh/exec.sh -n dnode1 -s start sleep 3000 diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index ee9daa97c9..3b9806558e 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -312,16 +312,16 @@ cd ../../../debug; make #./test.sh -f general/parser/stream_on_sys.sim #./test.sh -f general/parser/repeatStream.sim -./test.sh -f general/stream/metrics_del.sim +#./test.sh -f general/stream/metrics_del.sim ./test.sh -f general/stream/metrics_n.sim -./test.sh -f general/stream/metrics_replica1_vnoden.sim +#./test.sh -f general/stream/metrics_replica1_vnoden.sim ./test.sh -f general/stream/restart_stream.sim ./test.sh -f general/stream/stream_3.sim ./test.sh -f general/stream/stream_restart.sim ./test.sh -f general/stream/table_1.sim ./test.sh -f general/stream/table_del.sim ./test.sh -f general/stream/table_n.sim -###./test.sh -f general/stream/table_replica1_vnoden.sim +./test.sh -f general/stream/table_replica1_vnoden.sim ./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim #./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim From 22d60979f89459bb8b16f17e5979e4cab0e948ea Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Sat, 11 Jul 2020 06:52:45 +0000 Subject: [PATCH 15/63] [TD-810] fix the shellTableSQLFile length --- src/kit/shell/src/shellImport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kit/shell/src/shellImport.c b/src/kit/shell/src/shellImport.c index a440db7301..afd2d85dae 100644 --- a/src/kit/shell/src/shellImport.c +++ b/src/kit/shell/src/shellImport.c @@ -136,7 +136,7 @@ static void shellGetDirectoryFileList(char *inputDir) static void shellSourceFile(TAOS *con, char *fptr) { wordexp_t full_path; int read_len = 0; - char * cmd = malloc(MAX_COMMAND_SIZE); + char * cmd = malloc(tsMaxSQLStringLen); size_t cmd_len = 0; char * line = NULL; size_t line_len = 0; @@ -185,7 +185,7 @@ static void shellSourceFile(TAOS *con, char *fptr) { int lineNo = 0; while ((read_len = getline(&line, &line_len, f)) != -1) { ++lineNo; - if (read_len >= MAX_COMMAND_SIZE) continue; + if (read_len >= tsMaxSQLStringLen) continue; line[--read_len] = '\0'; if (read_len == 0 || isCommentLine(line)) { // line starts with # From 6b0095e04cfcdf6b36417d36330b2961035d4eb8 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 11 Jul 2020 07:44:38 +0000 Subject: [PATCH 16/63] [TD-901] sdb crash while drop dnode --- src/mnode/src/mnodeDnode.c | 10 +++++++--- src/mnode/src/mnodeSdb.c | 33 +++++++++++++++++++++++++-------- src/mnode/src/mnodeVgroup.c | 2 +- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index 86eaaceef7..a65f54cd8b 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -491,18 +491,22 @@ static int32_t mnodeDropDnodeByEp(char *ep, SMnodeMsg *pMsg) { return TSDB_CODE_MND_DNODE_NOT_EXIST; } - mnodeDecDnodeRef(pDnode); if (strcmp(pDnode->dnodeEp, mnodeGetMnodeMasterEp()) == 0) { mError("dnode:%d, can't drop dnode:%s which is master", pDnode->dnodeId, ep); + mnodeDecDnodeRef(pDnode); return TSDB_CODE_MND_NO_REMOVE_MASTER; } mInfo("dnode:%d, start to drop it", pDnode->dnodeId); + #ifndef _SYNC - return mnodeDropDnode(pDnode, pMsg); + int32_t code = mnodeDropDnode(pDnode, pMsg); #else - return balanceDropDnode(pDnode); + int32_t code = balanceDropDnode(pDnode); #endif + + mnodeDecDnodeRef(pDnode); + return code; } static int32_t mnodeProcessCreateDnodeMsg(SMnodeMsg *pMsg) { diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index cdcb7357f1..554a075db0 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -264,8 +264,12 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) { if (pOper->cb != NULL) { pOper->retCode = (*pOper->cb)(pMsg, pOper->retCode); } - dnodeSendRpcMnodeWriteRsp(pMsg, pOper->retCode); + + // if ahandle, means this func is called by sdb write + if (ahandle == NULL) { + sdbDecRef(pOper->table, pOper->pObj); + } taosFreeQitem(pOper); } @@ -581,16 +585,26 @@ static int sdbWrite(void *param, void *data, int type) { return sdbInsertHash(pTable, &oper); } else if (action == SDB_ACTION_DELETE) { SSdbRow *rowMeta = sdbGetRowMeta(pTable, pHead->cont); - assert(rowMeta != NULL && rowMeta->row != NULL); + if (rowMeta != NULL && rowMeta->row != NULL) { + sdbError("table:%s, failed to get object:%s from wal while dispose delete action", pTable->tableName, + pHead->cont); + return TSDB_CODE_SUCCESS; + } SSdbOper oper = {.table = pTable, .pObj = rowMeta->row}; return sdbDeleteHash(pTable, &oper); } else if (action == SDB_ACTION_UPDATE) { SSdbRow *rowMeta = sdbGetRowMeta(pTable, pHead->cont); - assert(rowMeta != NULL && rowMeta->row != NULL); + if (rowMeta != NULL && rowMeta->row != NULL) { + sdbError("table:%s, failed to get object:%s from wal while dispose update action", pTable->tableName, + pHead->cont); + return TSDB_CODE_SUCCESS; + } SSdbOper oper = {.rowSize = pHead->len, .rowData = pHead->cont, .table = pTable}; code = (*pTable->decodeFp)(&oper); return sdbUpdateHash(pTable, &oper); - } else { return TSDB_CODE_MND_INVALID_MSG_TYPE; } + } else { + return TSDB_CODE_MND_INVALID_MSG_TYPE; + } } int32_t sdbInsertRow(SSdbOper *pOper) { @@ -663,14 +677,18 @@ int32_t sdbDeleteRow(SSdbOper *pOper) { return TSDB_CODE_MND_SDB_INVAID_META_ROW; } + sdbIncRef(pTable, pOper->pObj); + int32_t code = sdbDeleteHash(pTable, pOper); if (code != TSDB_CODE_SUCCESS) { sdbError("table:%s, failed to delete from hash", pTable->tableName); + sdbDecRef(pTable, pOper->pObj); return code; } // just delete data from memory if (pOper->type != SDB_OPER_GLOBAL) { + sdbDecRef(pTable, pOper->pObj); return TSDB_CODE_SUCCESS; } @@ -692,7 +710,6 @@ int32_t sdbDeleteRow(SSdbOper *pOper) { pNewOper->pMsg, pTable->tableName, pOper->pObj, sdbGetKeyStrFromObj(pTable, pOper->pObj)); } - sdbIncRef(pNewOper->table, pNewOper->pObj); taosWriteQitem(tsSdbWriteQueue, TAOS_QTYPE_RPC, pNewOper); return TSDB_CODE_SUCCESS; } @@ -968,10 +985,11 @@ static void *sdbWorkerFp(void *param) { int32_t code = sdbWrite(pOper, pHead, type); if (code > 0) code = 0; - if (pOper) + if (pOper) { pOper->retCode = code; - else + } else { pHead->len = code; // hackway + } } walFsync(tsSdbObj.wal); @@ -983,7 +1001,6 @@ static void *sdbWorkerFp(void *param) { if (type == TAOS_QTYPE_RPC) { pOper = (SSdbOper *)item; - sdbDecRef(pOper->table, pOper->pObj); sdbConfirmForward(NULL, pOper, pOper->retCode); } else if (type == TAOS_QTYPE_FWD) { pHead = (SWalHead *)item; diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 6c8f21fec6..5658f4bcbf 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -969,7 +969,7 @@ void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode) { sdbFreeIter(pIter); - mInfo("dnode:%d, all vgroups is dropped from sdb", pDropDnode->dnodeId); + mInfo("dnode:%d, all vgroups:%d is dropped from sdb", pDropDnode->dnodeId, numOfVgroups); } #if 0 From a765cf6efecfbd4f41167becaf0c057c3763fe8f Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 11 Jul 2020 07:51:04 +0000 Subject: [PATCH 17/63] change a definition --- src/inc/taosdef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 2a58f9186c..8e4d8c4253 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -296,7 +296,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_DEFAULT_TOTAL_BLOCKS 4 #define TSDB_MIN_TABLES 4 -#define TSDB_MAX_TABLES 2000000 +#define TSDB_MAX_TABLES 5000000 #define TSDB_DEFAULT_TABLES 200000 #define TSDB_TABLES_STEP 10000 From 1eb62ce38ca0653d5a09d50352a8a05c2a446bb3 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sat, 11 Jul 2020 15:51:06 +0800 Subject: [PATCH 18/63] [td-225] fix bugs in error handling. --- src/client/src/tscSubquery.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 6c3580bad4..dbb3c90a0e 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -550,7 +550,7 @@ static bool checkForDuplicateTagVal(SQueryInfo* pQueryInfo, SJoinSupporter* p1, return true; } -static void getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pParentSql, SArray** s1, SArray** s2) { +static int32_t getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pParentSql, SArray** s1, SArray** s2) { tscDebug("%p all subqueries retrieve complete, do tags match", pParentSql); SJoinSupporter* p1 = pParentSql->pSubs[0]->param; @@ -568,10 +568,7 @@ static void getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pParent *s2 = taosArrayInit(p2->num, p2->tagSize); if (!(checkForDuplicateTagVal(pQueryInfo, p1, pParentSql) && checkForDuplicateTagVal(pQueryInfo, p2, pParentSql))) { - freeJoinSubqueryObj(pParentSql); - pParentSql->res.code = TSDB_CODE_QRY_DUP_JOIN_KEY; - tscQueueAsyncRes(pParentSql); - return; + return TSDB_CODE_QRY_DUP_JOIN_KEY; } int32_t i = 0, j = 0; @@ -594,6 +591,8 @@ static void getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pParent i++; } } + + return TSDB_CODE_SUCCESS; } static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRows) { @@ -680,7 +679,14 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow } SArray *s1 = NULL, *s2 = NULL; - getIntersectionOfTableTuple(pQueryInfo, pParentSql, &s1, &s2); + int32_t code = getIntersectionOfTableTuple(pQueryInfo, pParentSql, &s1, &s2); + if (code != TSDB_CODE_SUCCESS) { + freeJoinSubqueryObj(pParentSql); + pParentSql->res.code = code; + tscQueueAsyncRes(pParentSql); + return; + } + if (taosArrayGetSize(s1) == 0 || taosArrayGetSize(s2) == 0) { // no results,return. tscDebug("%p tag intersect does not generated qualified tables for join, free all sub SqlObj and quit", pParentSql); freeJoinSubqueryObj(pParentSql); From 40496f55f341f3ef7bde4693fb58792968f8cde5 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 11 Jul 2020 08:04:12 +0000 Subject: [PATCH 19/63] [TD-901] --- src/mnode/src/mnodeSdb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index 554a075db0..46678cb133 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -585,7 +585,7 @@ static int sdbWrite(void *param, void *data, int type) { return sdbInsertHash(pTable, &oper); } else if (action == SDB_ACTION_DELETE) { SSdbRow *rowMeta = sdbGetRowMeta(pTable, pHead->cont); - if (rowMeta != NULL && rowMeta->row != NULL) { + if (rowMeta == NULL || rowMeta->row == NULL) { sdbError("table:%s, failed to get object:%s from wal while dispose delete action", pTable->tableName, pHead->cont); return TSDB_CODE_SUCCESS; @@ -594,7 +594,7 @@ static int sdbWrite(void *param, void *data, int type) { return sdbDeleteHash(pTable, &oper); } else if (action == SDB_ACTION_UPDATE) { SSdbRow *rowMeta = sdbGetRowMeta(pTable, pHead->cont); - if (rowMeta != NULL && rowMeta->row != NULL) { + if (rowMeta == NULL || rowMeta->row == NULL) { sdbError("table:%s, failed to get object:%s from wal while dispose update action", pTable->tableName, pHead->cont); return TSDB_CODE_SUCCESS; From 9e0ac1ebef3138007f239d02d07e767b69c02136 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sat, 11 Jul 2020 17:01:35 +0800 Subject: [PATCH 20/63] [td-225] fix compiler error. --- src/client/inc/tsclient.h | 2 +- src/util/inc/tarray.h | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index f8ca288a13..be82eb64a8 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -415,7 +415,7 @@ int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo); //void tscGetResultColumnChr(SSqlRes *pRes, SFieldInfo* pFieldInfo, int32_t column); static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pFieldInfo, int32_t columnIndex) { - SFieldSupInfo* pInfo = TARRAY_GET_ELEM(pFieldInfo->pSupportInfo, columnIndex); + SFieldSupInfo* pInfo = (SFieldSupInfo*) TARRAY_GET_ELEM(pFieldInfo->pSupportInfo, columnIndex); assert(pInfo->pSqlExpr != NULL); int32_t type = pInfo->pSqlExpr->resType; diff --git a/src/util/inc/tarray.h b/src/util/inc/tarray.h index c05e2757d6..71838af150 100644 --- a/src/util/inc/tarray.h +++ b/src/util/inc/tarray.h @@ -23,14 +23,13 @@ extern "C" { #include "os.h" #define TARRAY_MIN_SIZE 8 -#define TARRAY_GET_ELEM(array, index) ((void*)((array)->pData + (index) * (array)->elemSize)) +#define TARRAY_GET_ELEM(array, index) ((void*)((char*)((array)->pData) + (index) * (array)->elemSize)) typedef struct SArray { size_t size; size_t capacity; size_t elemSize; - - void* pData; + void* pData; } SArray; /** From a2b9a4cad7d1ad24a13ffa830ab4dbf5ae34eb9b Mon Sep 17 00:00:00 2001 From: Hui Li Date: Sat, 11 Jul 2020 17:18:45 +0800 Subject: [PATCH 21/63] [reset vnode status from update to ready when process failed ] --- src/vnode/src/vnodeMain.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index d5221bae10..695a55d476 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -176,16 +176,28 @@ int32_t vnodeAlter(void *param, SMDCreateVnodeMsg *pVnodeCfg) { pVnode->status = TAOS_VN_STATUS_UPDATING; int32_t code = vnodeSaveCfg(pVnodeCfg); - if (code != TSDB_CODE_SUCCESS) return code; + if (code != TSDB_CODE_SUCCESS) { + pVnode->status = TAOS_VN_STATUS_READY; + return code; + } code = vnodeReadCfg(pVnode); - if (code != TSDB_CODE_SUCCESS) return code; + if (code != TSDB_CODE_SUCCESS) { + pVnode->status = TAOS_VN_STATUS_READY; + return code; + } code = syncReconfig(pVnode->sync, &pVnode->syncCfg); - if (code != TSDB_CODE_SUCCESS) return code; + if (code != TSDB_CODE_SUCCESS) { + pVnode->status = TAOS_VN_STATUS_READY; + return code; + } code = tsdbConfigRepo(pVnode->tsdb, &pVnode->tsdbCfg); - if (code != TSDB_CODE_SUCCESS) return code; + if (code != TSDB_CODE_SUCCESS) { + pVnode->status = TAOS_VN_STATUS_READY; + return code; + } pVnode->status = TAOS_VN_STATUS_READY; vDebug("vgId:%d, vnode is altered", pVnode->vgId); From 46eae6c8dab55fd00c598391acee4126bfe80992 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 11 Jul 2020 09:41:00 +0000 Subject: [PATCH 22/63] [TD-904] change replica definition --- src/client/src/tscAsync.c | 2 +- src/client/src/tscPrepare.c | 2 +- src/client/src/tscSQLParser.c | 4 ++-- src/client/src/tscSql.c | 2 +- src/client/src/tscSub.c | 2 +- src/client/src/tscUtil.c | 4 ++-- src/common/src/tglobal.c | 6 +++--- src/inc/taosdef.h | 6 +++--- src/inc/taosmsg.h | 2 +- src/mnode/src/mnodeDb.c | 6 +++--- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 41464aa660..ffe42de236 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -43,7 +43,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const pSql->signature = pSql; pSql->param = param; pSql->pTscObj = pObj; - pSql->maxRetry = TSDB_MAX_REPLICA_NUM; + pSql->maxRetry = TSDB_MAX_REPLICA; pSql->fp = fp; pSql->sqlstr = calloc(1, sqlLen + 1); diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 9f0d1a26ab..0cf69dfd46 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -497,7 +497,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) { tsem_init(&pSql->rspSem, 0, 0); pSql->signature = pSql; pSql->pTscObj = pObj; - pSql->maxRetry = TSDB_MAX_REPLICA_NUM; + pSql->maxRetry = TSDB_MAX_REPLICA; pStmt->pSql = pSql; return pStmt; diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 44d10ec2c4..ca6dfcee9e 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -5489,9 +5489,9 @@ int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCMCreateDbMsg* pCreate) { } if (pCreate->replications != -1 && - (pCreate->replications < TSDB_MIN_REPLICA_NUM || pCreate->replications > TSDB_MAX_REPLICA_NUM)) { + (pCreate->replications < TSDB_MIN_DB_REPLICA_OPTION || pCreate->replications > TSDB_MAX_DB_REPLICA_OPTION)) { snprintf(msg, tListLen(msg), "invalid db option replications: %d valid range: [%d, %d]", pCreate->replications, - TSDB_MIN_REPLICA_NUM, TSDB_MAX_REPLICA_NUM); + TSDB_MIN_DB_REPLICA_OPTION, TSDB_MAX_DB_REPLICA_OPTION); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg); } diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 6d75aef01f..73b93435ad 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -113,7 +113,7 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con pSql->pTscObj = pObj; pSql->signature = pSql; - pSql->maxRetry = TSDB_MAX_REPLICA_NUM; + pSql->maxRetry = TSDB_MAX_REPLICA; tsem_init(&pSql->rspSem, 0, 0); pObj->pDnodeConn = pDnodeConn; diff --git a/src/client/src/tscSub.c b/src/client/src/tscSub.c index f7d03bd787..2c5035c2ef 100644 --- a/src/client/src/tscSub.c +++ b/src/client/src/tscSub.c @@ -107,7 +107,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char* pSql->signature = pSql; pSql->param = pSql; pSql->pTscObj = pObj; - pSql->maxRetry = TSDB_MAX_REPLICA_NUM; + pSql->maxRetry = TSDB_MAX_REPLICA; pSql->fp = asyncCallback; int code = tscAllocPayload(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index c4641afbf3..eea5d60f64 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1649,7 +1649,7 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm pNew->fp = fp; pNew->param = param; - pNew->maxRetry = TSDB_MAX_REPLICA_NUM; + pNew->maxRetry = TSDB_MAX_REPLICA; pNew->sqlstr = strdup(pSql->sqlstr); if (pNew->sqlstr == NULL) { @@ -1804,7 +1804,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void pNew->fp = fp; pNew->param = param; - pNew->maxRetry = TSDB_MAX_REPLICA_NUM; + pNew->maxRetry = TSDB_MAX_REPLICA; char* name = pTableMetaInfo->name; STableMetaInfo* pFinalInfo = NULL; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 40c1ee4280..a8ef3f8e8d 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -110,7 +110,7 @@ int16_t tsCommitTime = TSDB_DEFAULT_COMMIT_TIME; // seconds int32_t tsTimePrecision = TSDB_DEFAULT_PRECISION; int16_t tsCompression = TSDB_DEFAULT_COMP_LEVEL; int16_t tsWAL = TSDB_DEFAULT_WAL_LEVEL; -int32_t tsReplications = TSDB_DEFAULT_REPLICA_NUM; +int32_t tsReplications = TSDB_DEFAULT_DB_REPLICA_OPTION; int32_t tsMaxVgroupsPerDb = 0; int32_t tsMaxTablePerVnode = TSDB_DEFAULT_TABLES; // balance @@ -706,8 +706,8 @@ static void doInitGlobalConfig() { cfg.ptr = &tsReplications; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; - cfg.minValue = TSDB_MIN_REPLICA_NUM; - cfg.maxValue = TSDB_MAX_REPLICA_NUM; + cfg.minValue = TSDB_MIN_DB_REPLICA_OPTION; + cfg.maxValue = TSDB_MAX_DB_REPLICA_OPTION; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 8e4d8c4253..eb3c3abc84 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -332,9 +332,9 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_MAX_WAL_LEVEL 2 #define TSDB_DEFAULT_WAL_LEVEL 1 -#define TSDB_MIN_REPLICA_NUM 1 -#define TSDB_MAX_REPLICA_NUM 3 -#define TSDB_DEFAULT_REPLICA_NUM 1 +#define TSDB_MIN_DB_REPLICA_OPTION 1 +#define TSDB_MAX_DB_REPLICA_OPTION 3 +#define TSDB_DEFAULT_DB_REPLICA_OPTION 1 #define TSDB_MAX_JOIN_TABLE_NUM 5 #define TSDB_MAX_UNION_CLAUSE 5 diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index f05392b10a..d96e9f68d5 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -646,7 +646,7 @@ typedef struct SCMSTableVgroupMsg { typedef struct { int32_t vgId; int8_t numOfIps; - SIpAddr ipAddr[TSDB_MAX_REPLICA_NUM]; + SIpAddr ipAddr[TSDB_MAX_REPLICA]; } SCMVgroupInfo; typedef struct { diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 497d64eabf..e8183e9089 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -287,9 +287,9 @@ static int32_t mnodeCheckDbCfg(SDbCfg *pCfg) { return TSDB_CODE_MND_INVALID_DB_OPTION; } - if (pCfg->replications < TSDB_MIN_REPLICA_NUM || pCfg->replications > TSDB_MAX_REPLICA_NUM) { - mError("invalid db option replications:%d valid range: [%d, %d]", pCfg->replications, TSDB_MIN_REPLICA_NUM, - TSDB_MAX_REPLICA_NUM); + if (pCfg->replications < TSDB_MIN_DB_REPLICA_OPTION || pCfg->replications > TSDB_MAX_DB_REPLICA_OPTION) { + mError("invalid db option replications:%d valid range: [%d, %d]", pCfg->replications, TSDB_MIN_DB_REPLICA_OPTION, + TSDB_MAX_DB_REPLICA_OPTION); return TSDB_CODE_MND_INVALID_DB_OPTION; } From 798e7f2c99338f30d790a2a984e65e7e1a3ca2ca Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 11 Jul 2020 14:39:03 +0000 Subject: [PATCH 23/63] [TD-888] add protection while deplayed process mnode msg --- src/mnode/src/mnodeSdb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index 46678cb133..d3192a2460 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -393,7 +393,7 @@ void sdbCleanUp() { } void sdbIncRef(void *handle, void *pObj) { - if (pObj == NULL) return; + if (pObj == NULL || handle == NULL) return; SSdbTable *pTable = handle; int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos); @@ -402,7 +402,7 @@ void sdbIncRef(void *handle, void *pObj) { } void sdbDecRef(void *handle, void *pObj) { - if (pObj == NULL) return; + if (pObj == NULL || handle == NULL) return; SSdbTable *pTable = handle; int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos); From 46304e6bd847bc4832a5d2258468c24f066ccb66 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 11 Jul 2020 15:21:55 +0000 Subject: [PATCH 24/63] [TD-825] check http release contexet funciton --- src/plugins/http/inc/httpCode.h | 2 +- src/plugins/http/inc/httpInt.h | 3 +++ src/plugins/http/inc/httpServer.h | 2 +- src/plugins/http/src/httpHandle.c | 25 +++++++++---------------- src/plugins/http/src/httpServer.c | 21 ++++++++++++--------- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/plugins/http/inc/httpCode.h b/src/plugins/http/inc/httpCode.h index 0235040139..08111260e9 100644 --- a/src/plugins/http/inc/httpCode.h +++ b/src/plugins/http/inc/httpCode.h @@ -105,7 +105,7 @@ #define HTTP_OP_VALUE_TYPE 79 //tgf -#define HTTP_TG_STABLE_NOT_EXIST 80 +#define HTTP_TG_STABLE_NOT_EXIST 80 extern char *httpMsg[]; diff --git a/src/plugins/http/inc/httpInt.h b/src/plugins/http/inc/httpInt.h index 8ca1c2ff11..ffd621be7a 100644 --- a/src/plugins/http/inc/httpInt.h +++ b/src/plugins/http/inc/httpInt.h @@ -61,6 +61,9 @@ #define HTTP_CHECK_BODY_CONTINUE 0 #define HTTP_CHECK_BODY_SUCCESS 1 +#define HTTP_READ_DATA_SUCCESS 0 +#define HTTP_READ_DATA_FAILED 1 + #define HTTP_WRITE_RETRY_TIMES 500 #define HTTP_WRITE_WAIT_TIME_MS 5 #define HTTP_EXPIRED_TIME 60000 diff --git a/src/plugins/http/inc/httpServer.h b/src/plugins/http/inc/httpServer.h index 04dadfe04c..508baa6112 100644 --- a/src/plugins/http/inc/httpServer.h +++ b/src/plugins/http/inc/httpServer.h @@ -23,6 +23,6 @@ void httpCleanUpConnect(); void *httpInitServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle); void httpCleanUpServer(HttpServer *pServer); -bool httpReadDataImp(HttpContext *pContext); +int httpReadDataImp(HttpContext *pContext); #endif diff --git a/src/plugins/http/src/httpHandle.c b/src/plugins/http/src/httpHandle.c index 2c94f61950..407d19b307 100644 --- a/src/plugins/http/src/httpHandle.c +++ b/src/plugins/http/src/httpHandle.c @@ -60,6 +60,7 @@ bool httpParseURL(HttpContext* pContext) { char* pSeek; char* pEnd = strchr(pParser->pLast, ' '); if (pEnd == NULL) { + httpSendErrorResp(pContext, HTTP_UNSUPPORT_URL); return false; } @@ -275,14 +276,14 @@ bool httpParseChunkedBody(HttpContext* pContext, HttpParser* pParser, bool test) return true; } -bool httpReadChunkedBody(HttpContext* pContext, HttpParser* pParser) { +int httpReadChunkedBody(HttpContext* pContext, HttpParser* pParser) { bool parsedOk = httpParseChunkedBody(pContext, pParser, true); if (parsedOk) { httpParseChunkedBody(pContext, pParser, false); return HTTP_CHECK_BODY_SUCCESS; } else { httpTrace("context:%p, fd:%d, ip:%s, chunked body not finished, continue read", pContext, pContext->fd, pContext->ipstr); - if (!httpReadDataImp(pContext)) { + if (httpReadDataImp(pContext) != HTTP_READ_DATA_SUCCESS) { httpError("context:%p, fd:%d, ip:%s, read chunked request error", pContext, pContext->fd, pContext->ipstr); return HTTP_CHECK_BODY_ERROR; } else { @@ -296,7 +297,6 @@ int httpReadUnChunkedBody(HttpContext* pContext, HttpParser* pParser) { if (dataReadLen > pParser->data.len) { httpError("context:%p, fd:%d, ip:%s, un-chunked body length invalid, read size:%d dataReadLen:%d > pContext->data.len:%d", pContext, pContext->fd, pContext->ipstr, pContext->parser.bufsize, dataReadLen, pParser->data.len); - httpSendErrorResp(pContext, HTTP_PARSE_BODY_ERROR); return HTTP_CHECK_BODY_ERROR; } else if (dataReadLen < pParser->data.len) { httpTrace("context:%p, fd:%d, ip:%s, un-chunked body not finished, read size:%d dataReadLen:%d < pContext->data.len:%d, continue read", @@ -358,20 +358,13 @@ bool httpParseRequest(HttpContext* pContext) { } int httpCheckReadCompleted(HttpContext* pContext) { - HttpParser *pParser = &pContext->parser; - if (pContext->httpChunked == HTTP_UNCUNKED) { - int ret = httpReadUnChunkedBody(pContext, pParser); - if (ret != HTTP_CHECK_BODY_SUCCESS) { - return ret; - } - } else { - int ret = httpReadChunkedBody(pContext, pParser); - if (ret != HTTP_CHECK_BODY_SUCCESS) { - return ret; - } - } + HttpParser* pParser = &pContext->parser; - return HTTP_CHECK_BODY_SUCCESS; + if (pContext->httpChunked == HTTP_UNCUNKED) { + return httpReadUnChunkedBody(pContext, pParser); + } else { + return httpReadChunkedBody(pContext, pParser); + } } bool httpDecodeRequest(HttpContext* pContext) { diff --git a/src/plugins/http/src/httpServer.c b/src/plugins/http/src/httpServer.c index dbe299cef7..177d447f10 100644 --- a/src/plugins/http/src/httpServer.c +++ b/src/plugins/http/src/httpServer.c @@ -69,7 +69,7 @@ void httpCleanUpConnect() { httpDebug("http server:%s is cleaned up", pServer->label); } -bool httpReadDataImp(HttpContext *pContext) { +int httpReadDataImp(HttpContext *pContext) { HttpParser *pParser = &pContext->parser; while (pParser->bufsize <= (HTTP_BUFFER_SIZE - HTTP_STEP_SIZE)) { @@ -85,8 +85,7 @@ bool httpReadDataImp(HttpContext *pContext) { } else { httpError("context:%p, fd:%d, ip:%s, read from socket error:%d, close connect", pContext, pContext->fd, pContext->ipstr, errno); - httpReleaseContext(pContext); - return false; + return HTTP_READ_DATA_FAILED; } } else { pParser->bufsize += nread; @@ -95,15 +94,13 @@ bool httpReadDataImp(HttpContext *pContext) { if (pParser->bufsize >= (HTTP_BUFFER_SIZE - HTTP_STEP_SIZE)) { httpError("context:%p, fd:%d, ip:%s, thread:%s, request big than:%d", pContext, pContext->fd, pContext->ipstr, pContext->pThread->label, HTTP_BUFFER_SIZE); - httpSendErrorResp(pContext, HTTP_REQUSET_TOO_BIG); - httpNotifyContextClose(pContext); - return false; + return HTTP_REQUSET_TOO_BIG; } } pParser->buffer[pParser->bufsize] = 0; - return true; + return HTTP_READ_DATA_SUCCESS; } static bool httpDecompressData(HttpContext *pContext) { @@ -141,8 +138,14 @@ static bool httpReadData(HttpContext *pContext) { httpInitContext(pContext); } - if (!httpReadDataImp(pContext)) { - httpNotifyContextClose(pContext); + int32_t code = httpReadDataImp(pContext); + if (code != HTTP_READ_DATA_SUCCESS) { + if (code == HTTP_READ_DATA_FAILED) { + httpReleaseContext(pContext); + } else { + httpSendErrorResp(pContext, code); + httpNotifyContextClose(pContext); + } return false; } From 5fa3660f85f44a32992f071127627bc3754a7841 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sun, 12 Jul 2020 01:43:36 +0000 Subject: [PATCH 25/63] TD-816 --- src/inc/taoserror.h | 1 + src/query/src/qExecutor.c | 4 ++++ src/query/src/qast.c | 6 ++++-- src/tsdb/src/tsdbRead.c | 3 ++- src/util/inc/exception.h | 3 ++- src/util/src/exception.c | 3 +++ 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 07b55b6acb..3503e39d31 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -209,6 +209,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_NO_DISKSPACE, 0, 0x0702, "query no d TAOS_DEFINE_ERROR(TSDB_CODE_QRY_OUT_OF_MEMORY, 0, 0x0703, "query out of memory") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_APP_ERROR, 0, 0x0704, "query app error") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_DUP_JOIN_KEY, 0, 0x0705, "query duplicated join key") +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_EXCEED_TAGS_LIMIT, 0, 0x0706, "query tag conditon too many") // grant TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, 0, 0x0800, "grant expired") diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 1d9068be16..d1b336fb4b 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -5370,6 +5370,7 @@ static int32_t buildAirthmeticExprFromMsg(SExprInfo *pArithExprInfo, SQueryTable pExprNode = exprTreeFromBinary(pArithExprInfo->base.arg[0].argValue.pz, pArithExprInfo->base.arg[0].argBytes); } CATCH( code ) { CLEANUP_EXECUTE(); + qError("qmsg:%p failed to create arithmetic expression string from:%s, reason: %s", pQueryMsg, pArithExprInfo->base.arg[0].argValue.pz, tstrerror(code)); return code; } END_TRY @@ -6104,6 +6105,9 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, vo code = tsdbQuerySTableByTagCond(tsdb, id->uid, tagCond, pQueryMsg->tagCondLen, pQueryMsg->tagNameRelType, tbnameCond, &tableGroupInfo, pGroupColIndex, numOfGroupByCols); if (code != TSDB_CODE_SUCCESS) { + if (code == TSDB_CODE_QRY_EXCEED_TAGS_LIMIT) { + qError("qmsg:%p failed to QueryStable, reason: %s", pQueryMsg, tstrerror(code)); + } goto _over; } } else { diff --git a/src/query/src/qast.c b/src/query/src/qast.c index ffd339f111..c5f4a9ce6c 100644 --- a/src/query/src/qast.c +++ b/src/query/src/qast.c @@ -962,10 +962,13 @@ static UNUSED_FUNC char* exception_strdup(const char* str) { static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) { int32_t anchor = CLEANUP_GET_ANCHOR(); + if (CLEANUP_EXCEED_LIMIT()) { + THROW(TSDB_CODE_QRY_EXCEED_TAGS_LIMIT); + return NULL; + } tExprNode* pExpr = exception_calloc(1, sizeof(tExprNode)); CLEANUP_PUSH_VOID_PTR_PTR(true, tExprNodeDestroy, pExpr, NULL); - pExpr->nodeType = tbufReadUint8(br); if (pExpr->nodeType == TSQL_NODE_VALUE) { @@ -995,7 +998,6 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) { pExpr->_node.hasPK = tbufReadUint8(br); pExpr->_node.pLeft = exprTreeFromBinaryImpl(br); pExpr->_node.pRight = exprTreeFromBinaryImpl(br); - assert(pExpr->_node.pLeft != NULL && pExpr->_node.pRight != NULL); } diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index c055a27c39..9e5da903b1 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -2217,7 +2217,8 @@ int32_t tsdbQuerySTableByTagCond(TSDB_REPO_T* tsdb, uint64_t uid, const char* pT } CATCH( code ) { CLEANUP_EXECUTE(); - ret = code; + terrno = code; + goto _error; // TODO: more error handling } END_TRY diff --git a/src/util/inc/exception.h b/src/util/inc/exception.h index 52cd03d830..38f94bfe28 100644 --- a/src/util/inc/exception.h +++ b/src/util/inc/exception.h @@ -78,6 +78,7 @@ void cleanupPush_int_ptr ( bool failOnly, void* func, void* arg ); int32_t cleanupGetActionCount(); void cleanupExecuteTo( int32_t anchor, bool failed ); void cleanupExecute( SExceptionNode* node, bool failed ); +bool cleanupExceedLimit(); #define CLEANUP_PUSH_VOID_PTR_PTR( failOnly, func, arg1, arg2 ) cleanupPush_void_ptr_ptr( (failOnly), (void*)(func), (void*)(arg1), (void*)(arg2) ) #define CLEANUP_PUSH_VOID_PTR_BOOL( failOnly, func, arg1, arg2 ) cleanupPush_void_ptr_bool( (failOnly), (void*)(func), (void*)(arg1), (bool)(arg2) ) @@ -91,7 +92,7 @@ void cleanupExecute( SExceptionNode* node, bool failed ); #define CLEANUP_GET_ANCHOR() cleanupGetActionCount() #define CLEANUP_EXECUTE_TO( anchor, failed ) cleanupExecuteTo( (anchor), (failed) ) - +#define CLEANUP_EXCEED_LIMIT() cleanupExceedLimit() //////////////////////////////////////////////////////////////////////////////// // functions & macros for exception handling diff --git a/src/util/src/exception.c b/src/util/src/exception.c index e1f6516fe7..0b716b6aba 100644 --- a/src/util/src/exception.c +++ b/src/util/src/exception.c @@ -147,3 +147,6 @@ void cleanupExecuteTo( int32_t anchor, bool failed ) { void cleanupExecute( SExceptionNode* node, bool failed ) { doExecuteCleanup( node, 0, failed ); } +bool cleanupExceedLimit() { + return expList->numCleanupAction >= expList->maxCleanupAction; +} From 41d40592dc3798a8b9064dc93b4f1e5136a34f10 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 12 Jul 2020 14:21:02 +0800 Subject: [PATCH 26/63] add uid log while drop ctable --- src/mnode/src/mnodeTable.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 58eaecb20a..f4251e4f83 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -751,7 +751,9 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) { mInfo("app:%p:%p, table:%s, start to drop stable", pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId); return mnodeProcessDropSuperTableMsg(pMsg); } else { - mInfo("app:%p:%p, table:%s, start to drop ctable", pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId); + SChildTableObj *pCTable = (SChildTableObj *)pMsg->pTable; + mInfo("app:%p:%p, table:%s, start to drop ctable, vgId:%d sid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg, + pDrop->tableId, pCTable->vgId, pCTable->sid, pCTable->uid); return mnodeProcessDropChildTableMsg(pMsg); } } @@ -1780,7 +1782,9 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) { SRpcIpSet ipSet = mnodeGetIpSetFromVgroup(pMsg->pVgroup); - mInfo("app:%p:%p, table:%s, send drop ctable msg", pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId); + mInfo("app:%p:%p, table:%s, send drop ctable msg, vgId:%d sid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg, + pDrop->tableId, pTable->vgId, pTable->sid, pTable->uid); + SRpcMsg rpcMsg = { .ahandle = pMsg, .pCont = pDrop, @@ -2187,12 +2191,15 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) { SChildTableObj *pTable = (SChildTableObj *)mnodeMsg->pTable; assert(pTable); - mInfo("app:%p:%p, table:%s, drop table rsp received, thandle:%p result:%s", mnodeMsg->rpcMsg.ahandle, mnodeMsg, - pTable->info.tableId, mnodeMsg->rpcMsg.handle, tstrerror(rpcMsg->code)); + + mInfo("app:%p:%p, table:%s, drop table rsp received, vgId:%d sid:%d uid:%" PRIu64 ", thandle:%p result:%s", + mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid, + mnodeMsg->rpcMsg.handle, tstrerror(rpcMsg->code)); if (rpcMsg->code != TSDB_CODE_SUCCESS) { - mError("app:%p:%p, table:%s, failed to drop in dnode, reason:%s", mnodeMsg->rpcMsg.ahandle, mnodeMsg, - pTable->info.tableId, tstrerror(rpcMsg->code)); + mError("app:%p:%p, table:%s, failed to drop in dnode, vgId:%d sid:%d uid:%" PRIu64 ", reason:%s", + mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid, + tstrerror(rpcMsg->code)); dnodeSendRpcMnodeWriteRsp(mnodeMsg, rpcMsg->code); return; } From 9ead608f2cb3496212d07f80440c964aa30861f0 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 12 Jul 2020 10:10:25 +0000 Subject: [PATCH 27/63] If the table is deleted by another thread during creation, stop creating and send drop msg to vnode --- src/mnode/inc/mnodeSdb.h | 1 + src/mnode/src/mnodeSdb.c | 8 ++++++++ src/mnode/src/mnodeTable.c | 17 ++++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/mnode/inc/mnodeSdb.h b/src/mnode/inc/mnodeSdb.h index eec6d45e23..0c47f684f8 100644 --- a/src/mnode/inc/mnodeSdb.h +++ b/src/mnode/inc/mnodeSdb.h @@ -94,6 +94,7 @@ void sdbDecRef(void *thandle, void *pRow); int64_t sdbGetNumOfRows(void *handle); int32_t sdbGetId(void *handle); uint64_t sdbGetVersion(); +bool sdbCheckRowDeleted(void *thandle, void *pRow); #ifdef __cplusplus } diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index d3192a2460..c8e4ae956c 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -661,6 +661,14 @@ int32_t sdbInsertRow(SSdbOper *pOper) { return TSDB_CODE_SUCCESS; } +bool sdbCheckRowDeleted(void *pTableInput, void *pRow) { + SSdbTable *pTable = pTableInput; + if (pTable == NULL) return false; + + int8_t *updateEnd = pRow + pTable->refCountPos - 1; + return (*updateEnd == 1); +} + int32_t sdbDeleteRow(SSdbOper *pOper) { SSdbTable *pTable = (SSdbTable *)pOper->table; if (pTable == NULL) return TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE; diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index f4251e4f83..8dac135885 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -72,7 +72,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg); static int32_t mnodeProcessDropTableMsg(SMnodeMsg *mnodeMsg); static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg); static void mnodeProcessDropSuperTableRsp(SRpcMsg *rpcMsg); -static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg); +static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn); static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg); static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *mnodeMsg); @@ -754,7 +754,7 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) { SChildTableObj *pCTable = (SChildTableObj *)pMsg->pTable; mInfo("app:%p:%p, table:%s, start to drop ctable, vgId:%d sid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId, pCTable->vgId, pCTable->sid, pCTable->uid); - return mnodeProcessDropChildTableMsg(pMsg); + return mnodeProcessDropChildTableMsg(pMsg, true); } } @@ -1758,7 +1758,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) { } } -static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) { +static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) { SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable; if (pMsg->pVgroup == NULL) pMsg->pVgroup = mnodeGetVgroup(pTable->vgId); if (pMsg->pVgroup == NULL) { @@ -1793,6 +1793,8 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) { .msgType = TSDB_MSG_TYPE_MD_DROP_TABLE }; + if (!needReturn) rpcMsg.ahandle = NULL; + dnodeSendMsgToDnode(&ipSet, &rpcMsg); return TSDB_CODE_MND_ACTION_IN_PROGRESS; @@ -2246,6 +2248,15 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) { SChildTableObj *pTable = (SChildTableObj *)mnodeMsg->pTable; assert(pTable); + // If the table is deleted by another thread during creation, stop creating and send drop msg to vnode + if (sdbCheckRowDeleted(tsChildTableSdb, pTable)) { + mDebug("app:%p:%p, table:%s, create table rsp received, but a deleting opertion incoming, vgId:%d sid:%d uid:%" PRIu64, + mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid); + mnodeProcessDropChildTableMsg(mnodeMsg, false); + dnodeSendRpcMnodeWriteRsp(mnodeMsg, TSDB_CODE_SUCCESS); + return; + } + if (rpcMsg->code == TSDB_CODE_SUCCESS || rpcMsg->code == TSDB_CODE_TDB_TABLE_ALREADY_EXIST) { SCMCreateTableMsg *pCreate = mnodeMsg->rpcMsg.pCont; if (pCreate->getMeta) { From 1111dc48cb5d9dfb5c5c64d9045f1d812bf083b0 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 12 Jul 2020 18:43:16 +0800 Subject: [PATCH 28/63] return meta on table is already dropped --- src/mnode/src/mnodeTable.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 8dac135885..a3dc2b5adb 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -2253,8 +2253,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) { mDebug("app:%p:%p, table:%s, create table rsp received, but a deleting opertion incoming, vgId:%d sid:%d uid:%" PRIu64, mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid); mnodeProcessDropChildTableMsg(mnodeMsg, false); - dnodeSendRpcMnodeWriteRsp(mnodeMsg, TSDB_CODE_SUCCESS); - return; + rpcMsg->code = TSDB_CODE_SUCCESS; } if (rpcMsg->code == TSDB_CODE_SUCCESS || rpcMsg->code == TSDB_CODE_TDB_TABLE_ALREADY_EXIST) { From 749246deb8c8c53f90f2a2397c23e55b07d58635 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 12 Jul 2020 21:16:05 +0800 Subject: [PATCH 29/63] definite lost while drop table in tsdb --- src/mnode/src/mnodeTable.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index a3dc2b5adb..6a47313717 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -376,7 +376,7 @@ static void mnodeCleanupChildTables() { } static void mnodeAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCtable) { - pStable->numOfTables++; + atomic_add_fetch_32(&pStable->numOfTables, 1); if (pStable->vgHash == NULL) { pStable->vgHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false); @@ -390,7 +390,7 @@ static void mnodeAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCt } static void mnodeRemoveTableFromStable(SSuperTableObj *pStable, SChildTableObj *pCtable) { - pStable->numOfTables--; + atomic_sub_fetch_32(&pStable->numOfTables, 1); if (pStable->vgHash == NULL) return; @@ -889,7 +889,7 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) { if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR; SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable; - if (pStable->numOfTables != 0) { + if (pStable->vgHash != NULL /*pStable->numOfTables != 0*/) { SHashMutableIterator *pIter = taosHashCreateIter(pStable->vgHash); while (taosHashIterNext(pIter)) { int32_t *pVgId = taosHashIterGet(pIter); From 6d5735030acd026582b299a42bf97fc32a4b92ae Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 12 Jul 2020 21:32:52 +0800 Subject: [PATCH 30/63] add some log --- src/mnode/src/mnodeTable.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 6a47313717..28661dc1ad 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -385,6 +385,8 @@ static void mnodeAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCt if (pStable->vgHash != NULL) { if (taosHashGet(pStable->vgHash, &pCtable->vgId, sizeof(pCtable->vgId)) == NULL) { taosHashPut(pStable->vgHash, &pCtable->vgId, sizeof(pCtable->vgId), &pCtable->vgId, sizeof(pCtable->vgId)); + mDebug("table:%s, vgId:%d is put into stable vgList, sizeOfVgList:%d", pStable->info.tableId, pCtable->vgId, + (int32_t)taosHashGetSize(pStable->vgHash)); } } } @@ -397,6 +399,8 @@ static void mnodeRemoveTableFromStable(SSuperTableObj *pStable, SChildTableObj * SVgObj *pVgroup = mnodeGetVgroup(pCtable->vgId); if (pVgroup == NULL) { taosHashRemove(pStable->vgHash, (char *)&pCtable->vgId, sizeof(pCtable->vgId)); + mDebug("table:%s, vgId:%d is remove from stable vgList, sizeOfVgList:%d", pStable->info.tableId, pCtable->vgId, + (int32_t)taosHashGetSize(pStable->vgHash)); } mnodeDecVgroupRef(pVgroup); } @@ -748,7 +752,9 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) { } if (pMsg->pTable->type == TSDB_SUPER_TABLE) { - mInfo("app:%p:%p, table:%s, start to drop stable", pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId); + SSuperTableObj *pSTable = (SSuperTableObj *)pMsg->pTable; + mInfo("app:%p:%p, table:%s, start to drop stable, uid:%" PRIu64 ", numOfChildTables:%d, sizeOfVgList:%d", + pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId, pSTable->uid, pSTable->numOfTables, (int32_t)taosHashGetSize(pSTable->vgHash)); return mnodeProcessDropSuperTableMsg(pMsg); } else { SChildTableObj *pCTable = (SChildTableObj *)pMsg->pTable; @@ -801,7 +807,7 @@ static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) { assert(pTable); if (code == TSDB_CODE_SUCCESS) { - mLInfo("stable:%s, is created in sdb", pTable->info.tableId); + mLInfo("stable:%s, is created in sdb, uid:%" PRIu64, pTable->info.tableId, pTable->uid); } else { mError("app:%p:%p, stable:%s, failed to create in sdb, reason:%s", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId, tstrerror(code)); @@ -2118,7 +2124,7 @@ static void mnodeDropAllChildTablesInStable(SSuperTableObj *pStable) { int32_t numOfTables = 0; SChildTableObj *pTable = NULL; - mInfo("stable:%s, all child tables(%d) will dropped from sdb", pStable->info.tableId, numOfTables); + mInfo("stable:%s, all child tables:%d will dropped from sdb", pStable->info.tableId, pStable->numOfTables); while (1) { pIter = mnodeGetNextChildTable(pIter, &pTable); From 53f7a132aa677956bb84eba379bda6307787e9a4 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Sun, 12 Jul 2020 21:54:02 +0800 Subject: [PATCH 31/63] fix table memory leak temporarily --- src/inc/taoserror.h | 1 + src/tsdb/src/tsdbMeta.c | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index d2bef9ea57..07b55b6acb 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -200,6 +200,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_CREATE_TB_MSG, 0, 0x060E, "tsdb inval TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_TABLE_DATA_IN_MEM, 0, 0x060F, "tsdb no table data in memory skiplist") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_FILE_ALREADY_EXISTS, 0, 0x0610, "tsdb file already exists") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_RECONFIGURE, 0, 0x0611, "tsdb need to reconfigure table") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO, 0, 0x0612, "tsdb create table information") // query TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_QHANDLE, 0, 0x0700, "query invalid handle") diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 84c1c8e7d1..6d65e1e743 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -57,8 +57,30 @@ int tsdbCreateTable(TSDB_REPO_T *repo, STableCfg *pCfg) { STable * super = NULL; STable * table = NULL; int newSuper = 0; + int tid = pCfg->tableId.tid; + STable * pTable = NULL; - STable *pTable = tsdbGetTableByUid(pMeta, pCfg->tableId.uid); + if (tid < 0 || tid >= pRepo->config.maxTables) { + tsdbError("vgId:%d failed to create table since invalid tid %d", REPO_ID(pRepo), tid); + terrno = TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO; + goto _err; + } + + if (pMeta->tables[tid] != NULL) { + if (TABLE_UID(pMeta->tables[tid]) == pCfg->tableId.uid) { + tsdbError("vgId:%d table %s already exists, tid %d uid %" PRId64, REPO_ID(pRepo), TABLE_CHAR_NAME(pTable), + TABLE_TID(pTable), TABLE_UID(pTable)); + return TSDB_CODE_TDB_TABLE_ALREADY_EXIST; + } else { + tsdbError("vgId:%d table %s at tid %d uid %" PRIu64 + " exists, replace it with new table, this can be not reasonable", + REPO_ID(pRepo), TABLE_CHAR_NAME(pMeta->tables[tid]), TABLE_TID(pMeta->tables[tid]), + TABLE_UID(pMeta->tables[tid])); + tsdbDropTable(pRepo, pMeta->tables[tid]->tableId); + } + } + + pTable = tsdbGetTableByUid(pMeta, pCfg->tableId.uid); if (pTable != NULL) { tsdbError("vgId:%d table %s already exists, tid %d uid %" PRId64, REPO_ID(pRepo), TABLE_CHAR_NAME(pTable), TABLE_TID(pTable), TABLE_UID(pTable)); @@ -72,10 +94,10 @@ int tsdbCreateTable(TSDB_REPO_T *repo, STableCfg *pCfg) { super = tsdbNewTable(pCfg, true); if (super == NULL) goto _err; } else { - // TODO - if (super->type != TSDB_SUPER_TABLE) return -1; - if (super->tableId.uid != pCfg->superUid) return -1; - // tsdbUpdateTable(pRepo, super, pCfg); + if (TABLE_TYPE(super) != TSDB_SUPER_TABLE || TABLE_UID(super) != pCfg->superUid) { + terrno = TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO; + goto _err; + } } } @@ -705,6 +727,9 @@ static STable *tsdbNewTable(STableCfg *pCfg, bool isSuper) { T_REF_INC(pTable); + tsdbDebug("table %s tid %d uid %" PRIu64 " is created", TABLE_CHAR_NAME(pTable), TABLE_TID(pTable), + TABLE_UID(pTable)); + return pTable; _err: @@ -714,7 +739,9 @@ _err: static void tsdbFreeTable(STable *pTable) { if (pTable) { - if (pTable->name != NULL) tsdbDebug("table %s is destroyed", TABLE_CHAR_NAME(pTable)); + if (pTable->name != NULL) + tsdbDebug("table %s tid %d uid %" PRIu64 " is destroyed", TABLE_CHAR_NAME(pTable), TABLE_TID(pTable), + TABLE_UID(pTable)); tfree(TABLE_NAME(pTable)); if (TABLE_TYPE(pTable) != TSDB_CHILD_TABLE) { for (int i = 0; i < TSDB_MAX_TABLE_SCHEMAS; i++) { @@ -782,7 +809,7 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx, boo tsdbGetTableSchemaImpl(pTable, false, false, -1)); } - tsdbTrace("vgId:%d table %s tid %d uid %" PRIu64 " is added to meta", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable), + tsdbDebug("vgId:%d table %s tid %d uid %" PRIu64 " is added to meta", REPO_ID(pRepo), TABLE_CHAR_NAME(pTable), TABLE_TID(pTable), TABLE_UID(pTable)); return 0; From 47665e5694884c2f9c856679fea5c377b7bc1bdf Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sun, 12 Jul 2020 23:52:55 +0800 Subject: [PATCH 32/63] [td-225] fix bug in error process. --- src/client/src/tscAsync.c | 45 +++++++++++++++--------------------- src/client/src/tscServer.c | 3 +-- src/client/src/tscSql.c | 13 +---------- src/client/src/tscSubquery.c | 8 ++++--- 4 files changed, 26 insertions(+), 43 deletions(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 41464aa660..17998e1981 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -420,15 +420,15 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; + pRes->code = code; if (code != TSDB_CODE_SUCCESS) { - pRes->code = code; - tscQueueAsyncRes(pSql); - return; + tscError("%p ge tableMeta failed, code:%s", pSql, tstrerror(code)); + goto _error; + } else { + tscDebug("%p get tableMeta successfully", pSql); } - tscDebug("%p get tableMeta successfully", pSql); - if (pSql->pStream == NULL) { SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); @@ -453,11 +453,9 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { assert(pParObj->signature == pParObj && trs->subqueryIndex == pTableMetaInfo->vgroupIndex && pTableMetaInfo->vgroupIndex >= 0 && pTableMetaInfo->vgroupList != NULL); - if ((code = tscProcessSql(pSql)) == TSDB_CODE_SUCCESS) { - return; - } - - goto _error; + // tscProcessSql can add error into async res + tscProcessSql(pSql); + return; } else { // continue to process normal async query if (pCmd->parseFinished) { tscDebug("%p update table meta in local cache, continue to process sql and send corresponding query", pSql); @@ -481,26 +479,21 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { return; + } else if (code != TSDB_CODE_SUCCESS) { + goto _error; } - if (code == TSDB_CODE_SUCCESS) { - /* - * Discard previous built submit blocks, and then parse the sql string again and build up all submit blocks, - * and send the required submit block according to index value in supporter to server. - */ - pSql->fp = pSql->fetchFp; // restore the fp - if ((code = tscHandleInsertRetry(pSql)) == TSDB_CODE_SUCCESS) { - return; - } - } - + /* + * Discard previous built submit blocks, and then parse the sql string again and build up all submit blocks, + * and send the required submit block according to index value in supporter to server. + */ + pSql->fp = pSql->fetchFp; // restore the fp + tscHandleInsertRetry(pSql); } else {// in case of other query type, continue - if ((code = tscProcessSql(pSql)) == TSDB_CODE_SUCCESS) { - return; - } + tscProcessSql(pSql); } - goto _error; + return; } else { tscDebug("%p continue parse sql after get table meta", pSql); @@ -538,7 +531,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { goto _error; } - if (code == TSDB_CODE_SUCCESS && UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { + if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { code = tscGetSTableVgroupInfo(pSql, pCmd->clauseIndex); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { return; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 88fcc3828e..1ae12aaf3d 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -412,7 +412,7 @@ int tscProcessSql(SSqlObj *pSql) { return pSql->res.code; } } else if (pCmd->command < TSDB_SQL_LOCAL) { - pSql->ipList = tscMgmtIpSet; //? + pSql->ipList = tscMgmtIpSet; } else { // local handler return (*tscProcessMsgRsp[pCmd->command])(pSql); } @@ -1372,7 +1372,6 @@ static int tscLocalResultCommonBuilder(SSqlObj *pSql, int32_t numOfRes) { SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex); pRes->code = TSDB_CODE_SUCCESS; - if (pRes->rspType == 0) { pRes->numOfRows = numOfRes; pRes->row = 0; diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 6d75aef01f..9f422b2d76 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -487,19 +487,8 @@ static bool tscFreeQhandleInVnode(SSqlObj* pSql) { (pCmd->command == TSDB_SQL_SELECT && pSql->pStream == NULL && pTableMetaInfo->pTableMeta != NULL)) { pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH; - tscDebug("%p send msg to dnode to free qhandle ASAP, command:%s", pSql, sqlCmd[pCmd->command]); + tscDebug("%p send msg to dnode to free qhandle ASAP, command:%s, ", pSql, sqlCmd[pCmd->command]); tscProcessSql(pSql); - - // in case of sync model query, waits for response and then goes on -// if (pSql->fp == waitForQueryRsp || pSql->fp == waitForRetrieveRsp) { -// sem_wait(&pSql->rspSem); - -// tscFreeSqlObj(pSql); -// tscDebug("%p sqlObj is freed by app", pSql); -// } else { - tscDebug("%p sqlObj will be freed while rsp received", pSql); -// } - return true; } diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 5e2ba46fbc..dd4ed991ed 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -1895,9 +1895,11 @@ int32_t tscHandleInsertRetry(SSqlObj* pSql) { assert(pSupporter->index < pSupporter->pState->numOfTotal); STableDataBlocks* pTableDataBlock = taosArrayGetP(pCmd->pDataBlocks, pSupporter->index); - pRes->code = tscCopyDataBlockToPayload(pSql, pTableDataBlock); - if (pRes->code != TSDB_CODE_SUCCESS) { - return pRes->code; + int32_t code = tscCopyDataBlockToPayload(pSql, pTableDataBlock); + + if ((pRes->code = code)!= TSDB_CODE_SUCCESS) { + tscQueueAsyncRes(pSql); + return code; // here the pSql may have been released already. } return tscProcessSql(pSql); From 89722e184280ae723e7deaf9876f7dbd8d2f427a Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Mon, 13 Jul 2020 09:52:37 +0800 Subject: [PATCH 33/63] fix td-902: memory leak --- src/query/src/qExecutor.c | 66 +++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index ed7a86d843..1d9068be16 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -5627,17 +5627,23 @@ static void freeQInfo(SQInfo *pQInfo); static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, SSqlGroupbyExpr *pGroupbyExpr, SExprInfo *pExprs, STableGroupInfo *pTableGroupInfo, SColumnInfo* pTagCols) { - SQInfo *pQInfo = (SQInfo *)calloc(1, sizeof(SQInfo)); - if (pQInfo == NULL) { - return NULL; - } - - SQuery *pQuery = calloc(1, sizeof(SQuery)); - pQInfo->runtimeEnv.pQuery = pQuery; - int16_t numOfCols = pQueryMsg->numOfCols; int16_t numOfOutput = pQueryMsg->numOfOutput; + SQInfo *pQInfo = (SQInfo *)calloc(1, sizeof(SQInfo)); + if (pQInfo == NULL) { + goto _cleanup_qinfo; + } + // to make sure third party won't overwrite this structure + pQInfo->signature = pQInfo; + pQInfo->tableGroupInfo = *pTableGroupInfo; + + SQuery *pQuery = calloc(1, sizeof(SQuery)); + if (pQuery == NULL) { + goto _cleanup_query; + } + pQInfo->runtimeEnv.pQuery = pQuery; + pQuery->numOfCols = numOfCols; pQuery->numOfOutput = numOfOutput; pQuery->limit.limit = pQueryMsg->limit; @@ -5651,6 +5657,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, pQuery->slidingTimeUnit = pQueryMsg->slidingTimeUnit; pQuery->fillType = pQueryMsg->fillType; pQuery->numOfTags = pQueryMsg->numOfTags; + pQuery->tagColList = pTagCols; // todo do not allocate ?? pQuery->colList = calloc(numOfCols, sizeof(SSingleColumnFilterInfo)); @@ -5663,8 +5670,6 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, pQuery->colList[i].filters = tscFilterInfoClone(pQueryMsg->colList[i].filters, pQuery->colList[i].numOfFilters); } - pQuery->tagColList = pTagCols; - // calculate the result row size for (int16_t col = 0; col < numOfOutput; ++col) { assert(pExprs[col].bytes > 0); @@ -5709,10 +5714,6 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, memcpy(pQuery->fillVal, (char *)pQueryMsg->fillVal, pQuery->numOfOutput * sizeof(int64_t)); } - // to make sure third party won't overwrite this structure - pQInfo->signature = pQInfo; - - pQInfo->tableGroupInfo = *pTableGroupInfo; size_t numOfGroups = 0; if (pTableGroupInfo->pGroupList != NULL) { numOfGroups = taosArrayGetSize(pTableGroupInfo->pGroupList); @@ -5775,6 +5776,21 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, qDebug("qmsg:%p QInfo:%p created", pQueryMsg, pQInfo); return pQInfo; +_cleanup_qinfo: + tsdbDestoryTableGroup(pTableGroupInfo); + +_cleanup_query: + taosArrayDestroy(pGroupbyExpr->columnInfo); + tfree(pGroupbyExpr); + tfree(pTagCols); + for (int32_t i = 0; i < numOfOutput; ++i) { + SExprInfo* pExprInfo = &pExprs[i]; + if (pExprInfo->pExpr != NULL) { + tExprTreeDestroy(&pExprInfo->pExpr, NULL); + } + } + tfree(pExprs); + _cleanup: freeQInfo(pQInfo); return NULL; @@ -5893,19 +5909,21 @@ static void freeQInfo(SQInfo *pQInfo) { } // todo refactor, extract method to destroytableDataInfo - int32_t numOfGroups = GET_NUM_OF_TABLEGROUP(pQInfo); - for (int32_t i = 0; i < numOfGroups; ++i) { - SArray *p = GET_TABLEGROUP(pQInfo, i); + if (pQInfo->tableqinfoGroupInfo.pGroupList != NULL) { + int32_t numOfGroups = GET_NUM_OF_TABLEGROUP(pQInfo); + for (int32_t i = 0; i < numOfGroups; ++i) { + SArray *p = GET_TABLEGROUP(pQInfo, i); - size_t num = taosArrayGetSize(p); - for(int32_t j = 0; j < num; ++j) { - STableQueryInfo* item = taosArrayGetP(p, j); - if (item != NULL) { - destroyTableQueryInfo(item, pQuery->numOfOutput); + size_t num = taosArrayGetSize(p); + for(int32_t j = 0; j < num; ++j) { + STableQueryInfo* item = taosArrayGetP(p, j); + if (item != NULL) { + destroyTableQueryInfo(item, pQuery->numOfOutput); + } } - } - taosArrayDestroy(p); + taosArrayDestroy(p); + } } tfree(pQInfo->pBuf); From 411d034d29b5a705f5ce6341433f2c8d77e3b12c Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 13 Jul 2020 12:42:46 +0800 Subject: [PATCH 34/63] [td-225] fix bugs in cache. --- src/client/src/tscSql.c | 8 ++-- src/util/src/tcache.c | 103 ++++++++++++++++++++++++++-------------- 2 files changed, 72 insertions(+), 39 deletions(-) diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 9f422b2d76..874923aea7 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -481,10 +481,10 @@ static bool tscFreeQhandleInVnode(SSqlObj* pSql) { if (pRes->code == TSDB_CODE_SUCCESS && pRes->completed == false && !tscIsTwoStageSTableQuery(pQueryInfo, 0) && (pCmd->command == TSDB_SQL_SELECT || - pCmd->command == TSDB_SQL_SHOW || - pCmd->command == TSDB_SQL_RETRIEVE || - pCmd->command == TSDB_SQL_FETCH) && - (pCmd->command == TSDB_SQL_SELECT && pSql->pStream == NULL && pTableMetaInfo->pTableMeta != NULL)) { + pCmd->command == TSDB_SQL_SHOW || + pCmd->command == TSDB_SQL_RETRIEVE || + pCmd->command == TSDB_SQL_FETCH) && + (pSql->pStream == NULL && pTableMetaInfo->pTableMeta != NULL)) { pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH; tscDebug("%p send msg to dnode to free qhandle ASAP, command:%s, ", pSql, sqlCmd[pCmd->command]); diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index d3c622633d..df63d567c7 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -413,57 +413,90 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) { *data = NULL; // note: extend lifespan before dec ref count - if (pCacheObj->extendLifespan) { + bool inTrashCan = pNode->inTrashCan; + + if (pCacheObj->extendLifespan && (!inTrashCan)) { atomic_store_64(&pNode->expireTime, pNode->lifespan + taosGetTimestampMs()); uDebug("cache:%s data:%p extend life time to %"PRId64 " before release", pCacheObj->name, pNode->data, pNode->expireTime); } - bool inTrashCan = pNode->inTrashCan; - uDebug("cache:%s, key:%p, %p is released, refcnt:%d", pCacheObj->name, pNode->key, pNode->data, T_REF_VAL_GET(pNode) - 1); + if (_remove) { + __cache_wr_lock(pCacheObj); - // NOTE: once refcount is decrease, pNode may be free by other thread immediately. - int32_t ref = T_REF_DEC(pNode); + // NOTE: once refcount is decrease, pNode may be freed by other thread immediately. + int32_t ref = T_REF_DEC(pNode); + uDebug("cache:%s, key:%p, %p is released, refcnt:%d", pCacheObj->name, pNode->key, pNode->data, ref); - if (inTrashCan) { - // Remove it if the ref count is 0. - // The ref count does not need to load and check again after lock acquired, since ref count can not be increased when - // the node is in trashcan. - if (ref == 0) { - __cache_wr_lock(pCacheObj); - assert(pNode->pTNodeHeader->pData == pNode); - taosRemoveFromTrashCan(pCacheObj, pNode->pTNodeHeader); - __cache_unlock(pCacheObj); + /* + * If it is not referenced by other users, remove it immediately. Otherwise move this node to trashcan wait for all users + * releasing this resources. + * + * NOTE: previous ref is 0, and current ref is still 0, remove it. If previous is not 0, there is another thread + * that tries to do the same thing. + */ + if (pNode->inTrashCan) { + if (ref == 0) { + assert(pNode->pTNodeHeader->pData == pNode); + taosRemoveFromTrashCan(pCacheObj, pNode->pTNodeHeader); + } + } else { + if (ref > 0) { + assert(pNode->pTNodeHeader == NULL); + taosCacheMoveToTrash(pCacheObj, pNode); + } else { + taosCacheReleaseNode(pCacheObj, pNode); + } } + __cache_unlock(pCacheObj); + } else { - assert(pNode->pTNodeHeader == NULL); + uDebug("cache:%s, key:%p, %p is released, refcnt:%d", pCacheObj->name, pNode->key, pNode->data, T_REF_VAL_GET(pNode) - 1); - if (_remove) { // not in trash can, but need to remove it - __cache_wr_lock(pCacheObj); + // NOTE: once refcount is decrease, pNode may be freed by other thread immediately. + int32_t ref = T_REF_DEC(pNode); - /* - * If not referenced by other users. Otherwise move this node to trashcan wait for all users - * releasing this resources. - * - * NOTE: previous ref is 0, and current ref is still 0, remove it. If previous is not 0, there is another thread - * that tries to do the same thing. - */ + if (inTrashCan) { + // Remove it if the ref count is 0. + // The ref count does not need to load and check again after lock acquired, since ref count can not be increased when + // the node is in trashcan. if (ref == 0) { - if (T_REF_VAL_GET(pNode) == 0) { - taosCacheReleaseNode(pCacheObj, pNode); - } else { - taosCacheMoveToTrash(pCacheObj, pNode); - } + __cache_wr_lock(pCacheObj); + assert(pNode->pTNodeHeader->pData == pNode); + taosRemoveFromTrashCan(pCacheObj, pNode->pTNodeHeader); + __cache_unlock(pCacheObj); } - __cache_unlock(pCacheObj); -// } else { // extend its life time -// if (pCacheObj->extendLifespan) { -// atomic_store_64(&pNode->expireTime, pNode->lifespan + taosGetTimestampMs()); -// uDebug("cache:%s data:%p extend life time to %"PRId64 " after release", pCacheObj->name, pNode->data, pNode->expireTime); -// } } } + +// else { +// if (_remove) { // not in trash can, but need to remove it +// __cache_wr_lock(pCacheObj); +// +// /* +// * If not referenced by other users. Otherwise move this node to trashcan wait for all users +// * releasing this resources. +// * +// * NOTE: previous ref is 0, and current ref is still 0, remove it. If previous is not 0, there is another thread +// * that tries to do the same thing. +// */ +// if (ref == 0) { +// if (T_REF_VAL_GET(pNode) == 0) { +// taosCacheReleaseNode(pCacheObj, pNode); +// } else { +// taosCacheMoveToTrash(pCacheObj, pNode); +// } +// } else if (ref > 0) { +// if (!pNode->inTrashCan) { +// assert(pNode->pTNodeHeader == NULL); +// taosCacheMoveToTrash(pCacheObj, pNode); +// } +// } +// +// __cache_unlock(pCacheObj); +// } +// } } void taosCacheEmpty(SCacheObj *pCacheObj) { From f2d5fe86b0721eb9e362885d706f9bf11bf48272 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 13 Jul 2020 12:43:32 +0800 Subject: [PATCH 35/63] [td-225] update the log. --- src/vnode/src/vnodeRead.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c index ff58e219b0..7997abaeb0 100644 --- a/src/vnode/src/vnodeRead.c +++ b/src/vnode/src/vnodeRead.c @@ -110,6 +110,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) { if (handle == NULL) { // failed to register qhandle pRsp->code = TSDB_CODE_QRY_INVALID_QHANDLE; qDestroyQueryInfo(pQInfo); // destroy it directly + vError("vgId:%d QInfo:%p register qhandle failed, return to app, code:%s", pVnode->vgId, (void*) pQInfo, tstrerror(pRsp->code)); } else { assert(*handle == pQInfo); pRsp->qhandle = htobe64((uint64_t) pQInfo); @@ -125,12 +126,14 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) { } else { assert(pQInfo == NULL); } + if (handle != NULL) { + vDebug("vgId:%d, QInfo:%p, dnode query msg disposed, register qhandle and return to app", vgId, *handle); + dnodePutItemIntoReadQueue(pVnode, *handle); qReleaseQInfo(pVnode->qMgmt, (void**) &handle, false); } - vDebug("vgId:%d, QInfo:%p, dnode query msg disposed", vgId, pQInfo); } else { assert(pCont != NULL); handle = qAcquireQInfo(pVnode->qMgmt, (uint64_t) pCont); @@ -138,12 +141,13 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) { vWarn("QInfo:%p invalid qhandle in continuing exec query, conn:%p", (void*) pCont, pReadMsg->rpcMsg.handle); code = TSDB_CODE_QRY_INVALID_QHANDLE; } else { - vDebug("vgId:%d, QInfo:%p, dnode query msg in progress", pVnode->vgId, (void*) pCont); + vDebug("vgId:%d, QInfo:%p, dnode continue exec query", pVnode->vgId, (void*) pCont); code = TSDB_CODE_VND_ACTION_IN_PROGRESS; qTableQuery(*handle); // do execute query } qReleaseQInfo(pVnode->qMgmt, (void**) &handle, false); } + return code; } From a8399213f2dd8131f64ed504f0f6f705b31d64a9 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 13 Jul 2020 12:45:06 +0800 Subject: [PATCH 36/63] [td-225]opt query perf. --- src/client/src/tscFunctionImpl.c | 207 +++++++++++++++---------------- src/client/src/tscSQLParser.c | 4 +- src/query/inc/qExecutor.h | 1 + src/query/inc/tsqlfunction.h | 24 +--- src/query/src/qExecutor.c | 161 +++++++++++------------- 5 files changed, 176 insertions(+), 221 deletions(-) diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index 06e5ff73bf..8e6878f449 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -330,10 +330,6 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI return TSDB_CODE_SUCCESS; } -bool stableQueryFunctChanged(int32_t funcId) { - return (aAggs[funcId].stableFuncId != funcId); -} - /** * the numOfRes should be kept, since it may be used later * and allow the ResultInfo to be re initialized @@ -361,7 +357,6 @@ static bool function_setup(SQLFunctionCtx *pCtx) { } memset(pCtx->aOutputBuf, 0, (size_t)pCtx->outputBytes); - initResultInfo(pResInfo); return true; } @@ -675,16 +670,16 @@ static void sum_func_second_merge(SQLFunctionCtx *pCtx) { } } -static int32_t precal_req_load_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { +static int32_t statisRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { return BLK_DATA_STATIS_NEEDED; } -static int32_t data_req_load_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { +static int32_t dataBlockRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { return BLK_DATA_ALL_NEEDED; } // todo: if column in current data block are null, opt for this case -static int32_t first_data_req_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { +static int32_t firstFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { if (pCtx->order == TSDB_ORDER_DESC) { return BLK_DATA_NO_NEEDED; } @@ -697,7 +692,7 @@ static int32_t first_data_req_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, } } -static int32_t last_data_req_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { +static int32_t lastFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { if (pCtx->order != pCtx->param[0].i64Key) { return BLK_DATA_NO_NEEDED; } @@ -709,34 +704,30 @@ static int32_t last_data_req_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, } } -static int32_t first_dist_data_req_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { +static int32_t firstDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { if (pCtx->order == TSDB_ORDER_DESC) { return BLK_DATA_NO_NEEDED; } - // result buffer has not been set yet. - return BLK_DATA_ALL_NEEDED; - //todo optimize the filter info -// SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes); -// if (pInfo->hasResult != DATA_SET_FLAG) { -// return BLK_DATA_ALL_NEEDED; -// } else { // data in current block is not earlier than current result -// return (pInfo->ts <= start) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED; -// } + SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes); + if (pInfo->hasResult != DATA_SET_FLAG) { + return BLK_DATA_ALL_NEEDED; + } else { // data in current block is not earlier than current result + return (pInfo->ts <= start) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED; + } } -static int32_t last_dist_data_req_info(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { +static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end, int32_t colId) { if (pCtx->order != pCtx->param[0].i64Key) { return BLK_DATA_NO_NEEDED; } - return BLK_DATA_ALL_NEEDED; -// SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes); -// if (pInfo->hasResult != DATA_SET_FLAG) { -// return BLK_DATA_ALL_NEEDED; -// } else { -// return (pInfo->ts > end) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED; -// } + SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes); + if (pInfo->hasResult != DATA_SET_FLAG) { + return BLK_DATA_ALL_NEEDED; + } else { + return (pInfo->ts > end) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED; + } } ////////////////////////////////////////////////////////////////////////////////////////////// @@ -2123,55 +2114,6 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) { tfree(pData); } -bool top_bot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, char *minval, char *maxval) { - STopBotInfo *pTopBotInfo = (STopBotInfo *)GET_RES_INFO(pCtx)->interResultBuf; - - int32_t numOfExistsRes = pTopBotInfo->num; - - // required number of results are not reached, continue load data block - if (numOfExistsRes < pCtx->param[0].i64Key) { - return true; - } - - tValuePair *pRes = (tValuePair*) pTopBotInfo->res; - - if (functionId == TSDB_FUNC_TOP) { - switch (pCtx->inputType) { - case TSDB_DATA_TYPE_TINYINT: - return GET_INT8_VAL(maxval) > pRes[0].v.i64Key; - case TSDB_DATA_TYPE_SMALLINT: - return GET_INT16_VAL(maxval) > pRes[0].v.i64Key; - case TSDB_DATA_TYPE_INT: - return GET_INT32_VAL(maxval) > pRes[0].v.i64Key; - case TSDB_DATA_TYPE_BIGINT: - return GET_INT64_VAL(maxval) > pRes[0].v.i64Key; - case TSDB_DATA_TYPE_FLOAT: - return GET_FLOAT_VAL(maxval) > pRes[0].v.dKey; - case TSDB_DATA_TYPE_DOUBLE: - return GET_DOUBLE_VAL(maxval) > pRes[0].v.dKey; - default: - return true; - } - } else { - switch (pCtx->inputType) { - case TSDB_DATA_TYPE_TINYINT: - return GET_INT8_VAL(minval) < pRes[0].v.i64Key; - case TSDB_DATA_TYPE_SMALLINT: - return GET_INT16_VAL(minval) < pRes[0].v.i64Key; - case TSDB_DATA_TYPE_INT: - return GET_INT32_VAL(minval) < pRes[0].v.i64Key; - case TSDB_DATA_TYPE_BIGINT: - return GET_INT64_VAL(minval) < pRes[0].v.i64Key; - case TSDB_DATA_TYPE_FLOAT: - return GET_FLOAT_VAL(minval) < pRes[0].v.dKey; - case TSDB_DATA_TYPE_DOUBLE: - return GET_DOUBLE_VAL(minval) < pRes[0].v.dKey; - default: - return true; - } - } -} - /* * Parameters values: * 1. param[0]: maximum allowable results @@ -2182,15 +2124,62 @@ bool top_bot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, char *mi */ static STopBotInfo *getTopBotOutputInfo(SQLFunctionCtx *pCtx) { SResultInfo *pResInfo = GET_RES_INFO(pCtx); - + // only the first_stage_merge is directly written data into final output buffer if (pResInfo->superTableQ && pCtx->currentStage != SECONDARY_STAGE_MERGE) { return (STopBotInfo*) pCtx->aOutputBuf; - } else { // during normal table query and super table at the secondary_stage, result is written to intermediate buffer + } else { // during normal table query and super table at the secondary_stage, result is written to intermediate buffer return pResInfo->interResultBuf; } } +bool topbot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, const char *minval, const char *maxval) { + STopBotInfo *pTopBotInfo = getTopBotOutputInfo(pCtx); + + // required number of results are not reached, continue load data block + if (pTopBotInfo->num < pCtx->param[0].i64Key) { + return true; + } + + tValuePair **pRes = (tValuePair**) pTopBotInfo->res; + + if (functionId == TSDB_FUNC_TOP) { + switch (pCtx->inputType) { + case TSDB_DATA_TYPE_TINYINT: + return GET_INT8_VAL(maxval) > pRes[0]->v.i64Key; + case TSDB_DATA_TYPE_SMALLINT: + return GET_INT16_VAL(maxval) > pRes[0]->v.i64Key; + case TSDB_DATA_TYPE_INT: + return GET_INT32_VAL(maxval) > pRes[0]->v.i64Key; + case TSDB_DATA_TYPE_BIGINT: + return GET_INT64_VAL(maxval) > pRes[0]->v.i64Key; + case TSDB_DATA_TYPE_FLOAT: + return GET_FLOAT_VAL(maxval) > pRes[0]->v.dKey; + case TSDB_DATA_TYPE_DOUBLE: + return GET_DOUBLE_VAL(maxval) > pRes[0]->v.dKey; + default: + return true; + } + } else { + switch (pCtx->inputType) { + case TSDB_DATA_TYPE_TINYINT: + return GET_INT8_VAL(minval) < pRes[0]->v.i64Key; + case TSDB_DATA_TYPE_SMALLINT: + return GET_INT16_VAL(minval) < pRes[0]->v.i64Key; + case TSDB_DATA_TYPE_INT: + return GET_INT32_VAL(minval) < pRes[0]->v.i64Key; + case TSDB_DATA_TYPE_BIGINT: + return GET_INT64_VAL(minval) < pRes[0]->v.i64Key; + case TSDB_DATA_TYPE_FLOAT: + return GET_FLOAT_VAL(minval) < pRes[0]->v.dKey; + case TSDB_DATA_TYPE_DOUBLE: + return GET_DOUBLE_VAL(minval) < pRes[0]->v.dKey; + default: + return true; + } + } +} + /* * keep the intermediate results during scan data blocks in the format of: * +-----------------------------------+-------------one value pair-----------+------------next value pair-----------+ @@ -3376,7 +3365,7 @@ static void spread_function(SQLFunctionCtx *pCtx) { SResultInfo *pResInfo = GET_RES_INFO(pCtx); SSpreadInfo *pInfo = pResInfo->interResultBuf; - int32_t numOfElems = pCtx->size; + int32_t numOfElems = 0; // todo : opt with pre-calculated result // column missing cause the hasNull to be true @@ -4412,7 +4401,7 @@ static void sumrate_finalizer(SQLFunctionCtx *pCtx) { * e.g., count/sum/avg/min/max/stddev/percentile/apercentile/first/last... * */ -int32_t funcCompatDefList[] = { +int32_t functionCompatList[] = { // count, sum, avg, min, max, stddev, percentile, apercentile, first, last 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // last_row, top, bottom, spread, twa, leastsqr, ts, ts_dummy, tag_dummy, ts_z @@ -4451,7 +4440,7 @@ SQLAggFuncElem aAggs[] = {{ function_finalizer, sum_func_merge, sum_func_second_merge, - precal_req_load_info, + statisRequired, }, { // 2 @@ -4466,7 +4455,7 @@ SQLAggFuncElem aAggs[] = {{ avg_finalizer, avg_func_merge, avg_func_second_merge, - precal_req_load_info, + statisRequired, }, { // 3 @@ -4481,7 +4470,7 @@ SQLAggFuncElem aAggs[] = {{ function_finalizer, min_func_merge, min_func_second_merge, - precal_req_load_info, + statisRequired, }, { // 4 @@ -4496,7 +4485,7 @@ SQLAggFuncElem aAggs[] = {{ function_finalizer, max_func_merge, max_func_second_merge, - precal_req_load_info, + statisRequired, }, { // 5 @@ -4511,7 +4500,7 @@ SQLAggFuncElem aAggs[] = {{ stddev_finalizer, noop1, noop1, - data_req_load_info, + dataBlockRequired, }, { // 6 @@ -4526,7 +4515,7 @@ SQLAggFuncElem aAggs[] = {{ percentile_finalizer, noop1, noop1, - data_req_load_info, + dataBlockRequired, }, { // 7 @@ -4541,7 +4530,7 @@ SQLAggFuncElem aAggs[] = {{ apercentile_finalizer, apercentile_func_merge, apercentile_func_second_merge, - data_req_load_info, + dataBlockRequired, }, { // 8 @@ -4556,7 +4545,7 @@ SQLAggFuncElem aAggs[] = {{ function_finalizer, noop1, noop1, - first_data_req_info, + firstFuncRequired, }, { // 9 @@ -4571,7 +4560,7 @@ SQLAggFuncElem aAggs[] = {{ function_finalizer, noop1, noop1, - last_data_req_info, + lastFuncRequired, }, { // 10 @@ -4587,7 +4576,7 @@ SQLAggFuncElem aAggs[] = {{ last_row_finalizer, noop1, last_dist_func_second_merge, - data_req_load_info, + dataBlockRequired, }, { // 11 @@ -4603,7 +4592,7 @@ SQLAggFuncElem aAggs[] = {{ top_bottom_func_finalizer, top_func_merge, top_func_second_merge, - data_req_load_info, + dataBlockRequired, }, { // 12 @@ -4619,7 +4608,7 @@ SQLAggFuncElem aAggs[] = {{ top_bottom_func_finalizer, bottom_func_merge, bottom_func_second_merge, - data_req_load_info, + dataBlockRequired, }, { // 13 @@ -4649,7 +4638,7 @@ SQLAggFuncElem aAggs[] = {{ twa_function_finalizer, twa_func_merge, twa_function_copy, - data_req_load_info, + dataBlockRequired, }, { // 15 @@ -4664,7 +4653,7 @@ SQLAggFuncElem aAggs[] = {{ leastsquares_finalizer, noop1, noop1, - data_req_load_info, + dataBlockRequired, }, { // 16 @@ -4694,7 +4683,7 @@ SQLAggFuncElem aAggs[] = {{ doFinalizer, copy_function, copy_function, - data_req_load_info, + dataBlockRequired, }, { // 18 @@ -4724,7 +4713,7 @@ SQLAggFuncElem aAggs[] = {{ ts_comp_finalize, copy_function, copy_function, - data_req_load_info, + dataBlockRequired, }, { // 20 @@ -4754,7 +4743,7 @@ SQLAggFuncElem aAggs[] = {{ doFinalizer, copy_function, copy_function, - data_req_load_info, + dataBlockRequired, }, { // 22, multi-output, tag function has only one result @@ -4784,7 +4773,7 @@ SQLAggFuncElem aAggs[] = {{ doFinalizer, copy_function, copy_function, - data_req_load_info, + dataBlockRequired, }, { // 24 @@ -4799,7 +4788,7 @@ SQLAggFuncElem aAggs[] = {{ doFinalizer, noop1, noop1, - data_req_load_info, + dataBlockRequired, }, // distributed version used in two-stage aggregation processes { @@ -4815,7 +4804,7 @@ SQLAggFuncElem aAggs[] = {{ function_finalizer, first_dist_func_merge, first_dist_func_second_merge, - first_dist_data_req_info, + firstDistFuncRequired, }, { // 26 @@ -4830,7 +4819,7 @@ SQLAggFuncElem aAggs[] = {{ function_finalizer, last_dist_func_merge, last_dist_func_second_merge, - last_dist_data_req_info, + lastDistFuncRequired, }, { // 27 @@ -4845,7 +4834,7 @@ SQLAggFuncElem aAggs[] = {{ doFinalizer, noop1, copy_function, - data_req_load_info, + dataBlockRequired, }, { // 28 @@ -4860,7 +4849,7 @@ SQLAggFuncElem aAggs[] = {{ rate_finalizer, rate_func_merge, rate_func_copy, - data_req_load_info, + dataBlockRequired, }, { // 29 @@ -4875,7 +4864,7 @@ SQLAggFuncElem aAggs[] = {{ rate_finalizer, rate_func_merge, rate_func_copy, - data_req_load_info, + dataBlockRequired, }, { // 30 @@ -4890,7 +4879,7 @@ SQLAggFuncElem aAggs[] = {{ sumrate_finalizer, sumrate_func_merge, sumrate_func_second_merge, - data_req_load_info, + dataBlockRequired, }, { // 31 @@ -4905,7 +4894,7 @@ SQLAggFuncElem aAggs[] = {{ sumrate_finalizer, sumrate_func_merge, sumrate_func_second_merge, - data_req_load_info, + dataBlockRequired, }, { // 32 @@ -4920,7 +4909,7 @@ SQLAggFuncElem aAggs[] = {{ sumrate_finalizer, sumrate_func_merge, sumrate_func_second_merge, - data_req_load_info, + dataBlockRequired, }, { // 33 @@ -4935,7 +4924,7 @@ SQLAggFuncElem aAggs[] = {{ sumrate_finalizer, sumrate_func_merge, sumrate_func_second_merge, - data_req_load_info, + dataBlockRequired, }, { // 34 @@ -4950,5 +4939,5 @@ SQLAggFuncElem aAggs[] = {{ noop1, noop1, noop1, - data_req_load_info, + dataBlockRequired, }}; diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 44d10ec2c4..e65d99fb5d 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2471,7 +2471,7 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo) { startIdx++; } - int32_t factor = funcCompatDefList[tscSqlExprGet(pQueryInfo, startIdx)->functionId]; + int32_t factor = functionCompatList[tscSqlExprGet(pQueryInfo, startIdx)->functionId]; // diff function cannot be executed with other function // arithmetic function can be executed with other arithmetic functions @@ -2489,7 +2489,7 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo) { continue; } - if (funcCompatDefList[functionId] != factor) { + if (functionCompatList[functionId] != factor) { return false; } } diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index 1faad6b141..cdf5f9612c 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -121,6 +121,7 @@ typedef struct SQueryCostInfo { uint32_t loadBlockStatis; uint32_t discardBlocks; uint64_t elapsedTime; + uint64_t ioTime; uint64_t computTime; } SQueryCostInfo; diff --git a/src/query/inc/tsqlfunction.h b/src/query/inc/tsqlfunction.h index 0c69bc02d3..6a4b9874d7 100644 --- a/src/query/inc/tsqlfunction.h +++ b/src/query/inc/tsqlfunction.h @@ -224,25 +224,14 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI #define IS_SINGLEOUTPUT(x) (((x)&TSDB_FUNCSTATE_SO) != 0) #define IS_OUTER_FORWARD(x) (((x)&TSDB_FUNCSTATE_OF) != 0) -/* - * the status of one block, used in metric query. all blocks are mixed together, - * we need the status to decide if one block is a first/end/inter block of one meter - */ -enum { - BLK_FILE_BLOCK = 0x1, - BLK_BLOCK_LOADED = 0x2, - BLK_CACHE_BLOCK = 0x4, // in case of cache block, block must be loaded -}; - /* determine the real data need to calculated the result */ enum { - BLK_DATA_NO_NEEDED = 0x0, + BLK_DATA_NO_NEEDED = 0x0, BLK_DATA_STATIS_NEEDED = 0x1, - BLK_DATA_ALL_NEEDED = 0x3, + BLK_DATA_ALL_NEEDED = 0x3, + BLK_DATA_DISCARD = 0x4, // discard current data block since it is not qualified for filter }; -#define SET_DATA_BLOCK_NOT_LOADED(x) ((x) &= (~BLK_BLOCK_LOADED)); - typedef struct STwaInfo { TSKEY lastKey; int8_t hasResult; // flag to denote has value @@ -264,12 +253,9 @@ typedef struct STwaInfo { /* global sql function array */ extern struct SQLAggFuncElem aAggs[]; -/* compatible check array list */ -extern int32_t funcCompatDefList[]; +extern int32_t functionCompatList[]; // compatible check array list -bool top_bot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, char *minval, char *maxval); - -bool stableQueryFunctChanged(int32_t funcId); +bool topbot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, const char *minval, const char *maxval); void resetResultInfo(SResultInfo *pResInfo); void setResultInfoBuf(SResultInfo *pResInfo, int32_t size, bool superTable, char* buf); diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index ed7a86d843..841e75249f 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -1928,73 +1928,45 @@ char *getPosInResultPage(SQueryRuntimeEnv *pRuntimeEnv, int32_t columnIndex, SWi pQuery->pSelectExpr[columnIndex].bytes * realRowId; } -/** - * decrease the refcount for each table involved in this query - * @param pQInfo - */ -UNUSED_FUNC void vnodeDecMeterRefcnt(SQInfo *pQInfo) { - if (pQInfo != NULL) { - // assert(taosHashGetSize(pQInfo->tableqinfoGroupInfo) >= 1); - } +#define IS_PREFILTER_TYPE(_t) ((_t) != TSDB_DATA_TYPE_DOUBLE && (_t) != TSDB_DATA_TYPE_FLOAT) -#if 0 - if (pQInfo == NULL || pQInfo->tableqinfoGroupInfo.numOfTables == 1) { - atomic_fetch_sub_32(&pQInfo->pObj->numOfQueries, 1); - qDebug("QInfo:%p vid:%d sid:%d meterId:%s, query is over, numOfQueries:%d", pQInfo, pQInfo->pObj->vnode, - pQInfo->pObj->sid, pQInfo->pObj->meterId, pQInfo->pObj->numOfQueries); - } else { - int32_t num = 0; - for (int32_t i = 0; i < pQInfo->tableqinfoGroupInfo.numOfTables; ++i) { - SMeterObj *pMeter = getMeterObj(pQInfo->tableqinfoGroupInfo, pQInfo->pSidSet->pTableIdList[i]->sid); - atomic_fetch_sub_32(&(pMeter->numOfQueries), 1); - - if (pMeter->numOfQueries > 0) { - qDebug("QInfo:%p vid:%d sid:%d meterId:%s, query is over, numOfQueries:%d", pQInfo, pMeter->vnode, pMeter->sid, - pMeter->meterId, pMeter->numOfQueries); - num++; - } - } - - /* - * in order to reduce log output, for all meters of which numOfQueries count are 0, - * we do not output corresponding information - */ - num = pQInfo->tableqinfoGroupInfo.numOfTables - num; - qDebug("QInfo:%p metric query is over, dec query ref for %d meters, numOfQueries on %d meters are 0", pQInfo, - pQInfo->tableqinfoGroupInfo.numOfTables, num); - } -#endif -} - -static bool needToLoadDataBlock(SQuery *pQuery, SDataStatis *pDataStatis, SQLFunctionCtx *pCtx, - int32_t numOfTotalPoints) { - if (pDataStatis == NULL) { +static bool needToLoadDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis *pDataStatis, SQLFunctionCtx *pCtx, + int32_t numOfRows) { + SQuery* pQuery = pRuntimeEnv->pQuery; + if (pDataStatis == NULL || (pQuery->numOfFilterCols == 0 && (!pRuntimeEnv->topBotQuery))) { return true; } -#if 0 for (int32_t k = 0; k < pQuery->numOfFilterCols; ++k) { SSingleColumnFilterInfo *pFilterInfo = &pQuery->pFilterInfo[k]; - int32_t colIndex = pFilterInfo->info.colIndex; - // this column not valid in current data block - if (colIndex < 0 || pDataStatis[colIndex].colId != pFilterInfo->info.data.colId) { + int32_t index = -1; + for(int32_t i = 0; i < pQuery->numOfCols; ++i) { + if (pDataStatis[i].colId == pFilterInfo->info.colId) { + index = i; + break; + } + } + + if (index == -1) { continue; } // not support pre-filter operation on binary/nchar data type - if (!vnodeSupportPrefilter(pFilterInfo->info.data.type)) { + if (!IS_PREFILTER_TYPE(pFilterInfo->info.type)) { continue; } // all points in current column are NULL, no need to check its boundary value - if (pDataStatis[colIndex].numOfNull == numOfTotalPoints) { + if (pDataStatis[index].numOfNull == numOfRows) { continue; } - if (pFilterInfo->info.info.type == TSDB_DATA_TYPE_FLOAT) { - float minval = *(double *)(&pDataStatis[colIndex].min); - float maxval = *(double *)(&pDataStatis[colIndex].max); + SDataStatis* pDataBlockst = &pDataStatis[index]; + + if (pFilterInfo->info.type == TSDB_DATA_TYPE_FLOAT) { + float minval = *(double *)(&pDataBlockst->min); + float maxval = *(double *)(&pDataBlockst->max); for (int32_t i = 0; i < pFilterInfo->numOfFilters; ++i) { if (pFilterInfo->pFilters[i].fp(&pFilterInfo->pFilters[i], (char *)&minval, (char *)&maxval)) { @@ -2003,53 +1975,50 @@ static bool needToLoadDataBlock(SQuery *pQuery, SDataStatis *pDataStatis, SQLFun } } else { for (int32_t i = 0; i < pFilterInfo->numOfFilters; ++i) { - if (pFilterInfo->pFilters[i].fp(&pFilterInfo->pFilters[i], (char *)&pDataStatis[colIndex].min, - (char *)&pDataStatis[colIndex].max)) { + if (pFilterInfo->pFilters[i].fp(&pFilterInfo->pFilters[i], (char *)&pDataBlockst->min, (char *)&pDataBlockst->max)) { return true; } } } } - // todo disable this opt code block temporarily - // for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { - // int32_t functId = pQuery->pSelectExpr[i].base.functionId; - // if (functId == TSDB_FUNC_TOP || functId == TSDB_FUNC_BOTTOM) { - // return top_bot_datablock_filter(&pCtx[i], functId, (char *)&pField[i].min, (char *)&pField[i].max); - // } - // } + if (pRuntimeEnv->topBotQuery) { + for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { + int32_t functionId = pQuery->pSelectExpr[i].base.functionId; + if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM) { + return topbot_datablock_filter(&pCtx[i], functionId, (char *)&pDataStatis[i].min, (char *)&pDataStatis[i].max); + } + } + } -#endif - return true; + return false; } -SArray *loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, void* pQueryHandle, SDataBlockInfo* pBlockInfo, SDataStatis **pStatis) { +int32_t loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, void* pQueryHandle, SDataBlockInfo* pBlockInfo, SDataStatis **pStatis, SArray** pDataBlock) { SQuery *pQuery = pRuntimeEnv->pQuery; - uint32_t r = 0; - SArray * pDataBlock = NULL; - + uint32_t status = 0; if (pQuery->numOfFilterCols > 0) { - r = BLK_DATA_ALL_NEEDED; - } else { - // check if this data block is required to load + status = BLK_DATA_ALL_NEEDED; + } else { // check if this data block is required to load for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { SSqlFuncMsg* pSqlFunc = &pQuery->pSelectExpr[i].base; int32_t functionId = pSqlFunc->functionId; int32_t colId = pSqlFunc->colInfo.colId; - r |= aAggs[functionId].dataReqFunc(&pRuntimeEnv->pCtx[i], pQuery->window.skey, pQuery->window.ekey, colId); + status |= aAggs[functionId].dataReqFunc(&pRuntimeEnv->pCtx[i], pBlockInfo->window.skey, pBlockInfo->window.ekey, colId); } if (pRuntimeEnv->pTSBuf > 0 || QUERY_IS_INTERVAL_QUERY(pQuery)) { - r |= BLK_DATA_ALL_NEEDED; + status |= BLK_DATA_ALL_NEEDED; } } - if (r == BLK_DATA_NO_NEEDED) { - qDebug("QInfo:%p data block discard, rows:%d", GET_QINFO_ADDR(pRuntimeEnv), pBlockInfo->rows); + if (status == BLK_DATA_NO_NEEDED) { + qDebug("QInfo:%p data block discard, brange:%"PRId64 "-%"PRId64", rows:%d", GET_QINFO_ADDR(pRuntimeEnv), + pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); pRuntimeEnv->summary.discardBlocks += 1; - } else if (r == BLK_DATA_STATIS_NEEDED) { + } else if (status == BLK_DATA_STATIS_NEEDED) { if (tsdbRetrieveDataBlockStatisInfo(pQueryHandle, pStatis) != TSDB_CODE_SUCCESS) { // return DISK_DATA_LOAD_FAILED; } @@ -2057,32 +2026,34 @@ SArray *loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, void* pQueryHandle, pRuntimeEnv->summary.loadBlockStatis += 1; if (*pStatis == NULL) { // data block statistics does not exist, load data block - pDataBlock = tsdbRetrieveDataBlock(pQueryHandle, NULL); + *pDataBlock = tsdbRetrieveDataBlock(pQueryHandle, NULL); pRuntimeEnv->summary.totalCheckedRows += pBlockInfo->rows; } } else { - assert(r == BLK_DATA_ALL_NEEDED); + assert(status == BLK_DATA_ALL_NEEDED); // load the data block statistics to perform further filter - pRuntimeEnv->summary.loadBlockStatis +=1; + pRuntimeEnv->summary.loadBlockStatis += 1; if (tsdbRetrieveDataBlockStatisInfo(pQueryHandle, pStatis) != TSDB_CODE_SUCCESS) { } - if (!needToLoadDataBlock(pQuery,*pStatis, pRuntimeEnv->pCtx, pBlockInfo->rows)) { + if (!needToLoadDataBlock(pRuntimeEnv, *pStatis, pRuntimeEnv->pCtx, pBlockInfo->rows)) { #if defined(_DEBUG_VIEW) qDebug("QInfo:%p block discarded by per-filter", GET_QINFO_ADDR(pRuntimeEnv)); #endif // current block has been discard due to filter applied pRuntimeEnv->summary.discardBlocks += 1; - // return DISK_DATA_DISCARDED; + qDebug("QInfo:%p data block discard, brange:%"PRId64 "-%"PRId64", rows:%d", GET_QINFO_ADDR(pRuntimeEnv), + pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); + return BLK_DATA_DISCARD; } pRuntimeEnv->summary.totalCheckedRows += pBlockInfo->rows; pRuntimeEnv->summary.loadBlocks += 1; - pDataBlock = tsdbRetrieveDataBlock(pQueryHandle, NULL); + *pDataBlock = tsdbRetrieveDataBlock(pQueryHandle, NULL); } - return pDataBlock; + return TSDB_CODE_SUCCESS; } int32_t binarySearchForKey(char *pValue, int num, TSKEY key, int order) { @@ -2225,6 +2196,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { pQuery->order.order); TsdbQueryHandleT pQueryHandle = IS_MASTER_SCAN(pRuntimeEnv)? pRuntimeEnv->pQueryHandle : pRuntimeEnv->pSecQueryHandle; + int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); SDataBlockInfo blockInfo = SDATA_BLOCK_INITIALIZER; while (tsdbNextDataBlock(pQueryHandle)) { @@ -2259,7 +2231,11 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { ensureOutputBuffer(pRuntimeEnv, &blockInfo); SDataStatis *pStatis = NULL; - SArray *pDataBlock = loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis); + SArray *pDataBlock = NULL; + if (loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis, &pDataBlock) == BLK_DATA_DISCARD) { + pQuery->current->lastKey = QUERY_IS_ASC_QUERY(pQuery)? blockInfo.window.ekey + step:blockInfo.window.skey + step; + continue; + } // query start position can not move into tableApplyFunctionsOnBlock due to limit/offset condition pQuery->pos = QUERY_IS_ASC_QUERY(pQuery)? 0 : blockInfo.rows - 1; @@ -2282,8 +2258,6 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { if (QUERY_IS_INTERVAL_QUERY(pQuery) && IS_MASTER_SCAN(pRuntimeEnv)) { if (Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED)) { -// int32_t step = QUERY_IS_ASC_QUERY(pQuery) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP; - closeAllTimeWindow(&pRuntimeEnv->windowResInfo); // removeRedundantWindow(&pRuntimeEnv->windowResInfo, pTableQueryInfo->lastKey - step, step); pRuntimeEnv->windowResInfo.curIndex = pRuntimeEnv->windowResInfo.size - 1; // point to the last time window @@ -3700,7 +3674,7 @@ static void updateWindowResNumOfRes(SQueryRuntimeEnv *pRuntimeEnv) { } } -void stableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pDataBlockInfo, SDataStatis *pStatis, +static void stableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pDataBlockInfo, SDataStatis *pStatis, SArray *pDataBlock, __block_search_fn_t searchFn) { SQuery * pQuery = pRuntimeEnv->pQuery; STableQueryInfo* pTableQueryInfo = pQuery->current; @@ -3859,9 +3833,10 @@ static void queryCostStatis(SQInfo *pQInfo) { // pQInfo, pSummary->readDiskBlocks, pSummary->totalBlockSize, pSummary->loadBlocksUs / 1000.0, // pSummary->skippedFileBlocks, pSummary->totalGenData); - qDebug("QInfo:%p :cost summary: elpased time:%"PRId64" us, total blocks:%d, use block statis:%d, use block data:%d, " - "total rows:%"PRId64 ", check rows:%"PRId64, pQInfo, pSummary->elapsedTime, pSummary->totalBlocks, - pSummary->loadBlockStatis, pSummary->loadBlocks, pSummary->totalRows, pSummary->totalCheckedRows); + qDebug("QInfo:%p :cost summary: elapsed time:%"PRId64" us, io time:%"PRId64" us, total blocks:%d, load block statis:%d," + " load data block:%d, total rows:%"PRId64 ", check rows:%"PRId64, + pQInfo, pSummary->elapsedTime, pSummary->ioTime, pSummary->totalBlocks, pSummary->loadBlockStatis, + pSummary->loadBlocks, pSummary->totalRows, pSummary->totalCheckedRows); // qDebug("QInfo:%p cost: temp file:%d Bytes", pQInfo, pSummary->tmpBufferInDisk); // @@ -4247,10 +4222,11 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) { TsdbQueryHandleT pQueryHandle = IS_MASTER_SCAN(pRuntimeEnv)? pRuntimeEnv->pQueryHandle : pRuntimeEnv->pSecQueryHandle; SDataBlockInfo blockInfo = SDATA_BLOCK_INITIALIZER; + int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); + while (tsdbNextDataBlock(pQueryHandle)) { summary->totalBlocks += 1; if (IS_QUERY_KILLED(pQInfo)) { - finalizeQueryResult(pRuntimeEnv); // clean up allocated resource during query longjmp(pRuntimeEnv->env, TSDB_CODE_TSC_QUERY_CANCELLED); } @@ -4263,12 +4239,8 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) { assert(*pTableQueryInfo != NULL); SET_CURRENT_QUERY_TABLE_INFO(pRuntimeEnv, *pTableQueryInfo); - SDataStatis *pStatis = NULL; - SArray *pDataBlock = loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis); - if (!pRuntimeEnv->groupbyNormalCol) { if (!QUERY_IS_INTERVAL_QUERY(pQuery)) { - int32_t step = QUERY_IS_ASC_QUERY(pQuery)? 1:-1; setExecutionContext(pQInfo, (*pTableQueryInfo)->groupIndex, blockInfo.window.ekey + step); } else { // interval query TSKEY nextKey = blockInfo.window.skey; @@ -4280,6 +4252,13 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) { } } + SDataStatis *pStatis = NULL; + SArray *pDataBlock = NULL; + if (loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis, &pDataBlock) == BLK_DATA_DISCARD) { + pQuery->current->lastKey = QUERY_IS_ASC_QUERY(pQuery)? blockInfo.window.ekey + step:blockInfo.window.skey + step; + continue; + } + summary->totalRows += blockInfo.rows; stableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, pStatis, pDataBlock, binarySearchForKey); From 3c707138d738b073ec7bd17de192bd66b052190d Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 13 Jul 2020 14:14:58 +0800 Subject: [PATCH 37/63] add some log --- src/dnode/src/dnodeVWrite.c | 3 ++- src/vnode/src/vnodeWrite.c | 2 ++ tests/script/sh/deploy.sh | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dnode/src/dnodeVWrite.c b/src/dnode/src/dnodeVWrite.c index 546e8cecb9..4a69b525ea 100644 --- a/src/dnode/src/dnodeVWrite.c +++ b/src/dnode/src/dnodeVWrite.c @@ -232,8 +232,9 @@ static void *dnodeProcessWriteQueue(void *param) { pHead->msgType = pWrite->rpcMsg.msgType; pHead->version = 0; pHead->len = pWrite->contLen; - dDebug("%p, msg:%s will be processed in vwrite queue", pWrite->rpcMsg.ahandle, taosMsg[pWrite->rpcMsg.msgType]); + dDebug("%p, rpc msg:%s will be processed in vwrite queue", pWrite->rpcMsg.ahandle, taosMsg[pWrite->rpcMsg.msgType]); } else { + dDebug("%p, wal msg:%s will be processed in vwrite queue", pWrite->rpcMsg.ahandle, taosMsg[pWrite->rpcMsg.msgType]); pHead = (SWalHead *)item; } diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 5ed5e747f2..09e4b43ed3 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -184,6 +184,8 @@ int vnodeWriteToQueue(void *param, void *data, int type) { memcpy(pWal, pHead, size); atomic_add_fetch_32(&pVnode->refCount, 1); + vDebug("vgId:%d, get vnode wqueue, refCount:%d", pVnode->vgId, pVnode->refCount); + taosWriteQitem(pVnode->wqueue, type, pWal); return 0; diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index 8f9569e09d..5573db0739 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -110,7 +110,7 @@ echo "second ${HOSTNAME}:7200" >> $TAOS_CFG echo "serverPort ${NODE}" >> $TAOS_CFG echo "dataDir $DATA_DIR" >> $TAOS_CFG echo "logDir $LOG_DIR" >> $TAOS_CFG -echo "debugFlag 135" >> $TAOS_CFG +echo "debugFlag 131" >> $TAOS_CFG echo "mDebugFlag 135" >> $TAOS_CFG echo "sdbDebugFlag 135" >> $TAOS_CFG echo "dDebugFlag 135" >> $TAOS_CFG From 81fb914b26e8d7456bc46566c47b81c6f7667ee7 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 13 Jul 2020 14:28:05 +0800 Subject: [PATCH 38/63] change log print --- src/dnode/src/dnodeVWrite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dnode/src/dnodeVWrite.c b/src/dnode/src/dnodeVWrite.c index 4a69b525ea..e1a17236ac 100644 --- a/src/dnode/src/dnodeVWrite.c +++ b/src/dnode/src/dnodeVWrite.c @@ -234,8 +234,8 @@ static void *dnodeProcessWriteQueue(void *param) { pHead->len = pWrite->contLen; dDebug("%p, rpc msg:%s will be processed in vwrite queue", pWrite->rpcMsg.ahandle, taosMsg[pWrite->rpcMsg.msgType]); } else { - dDebug("%p, wal msg:%s will be processed in vwrite queue", pWrite->rpcMsg.ahandle, taosMsg[pWrite->rpcMsg.msgType]); pHead = (SWalHead *)item; + dDebug("%p, wal msg:%s will be processed in vwrite queue, version:%" PRIu64, pHead, taosMsg[pHead->msgType], pHead->version); } int32_t code = vnodeProcessWrite(pVnode, type, pHead, pRspRet); From 33c8ddd49c56763588c67dfd25c547d8578cd3e7 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Mon, 13 Jul 2020 14:28:16 +0800 Subject: [PATCH 39/63] add --random-file-fail-output argument to support redirect debug info to a file. --- src/dnode/src/dnodeSystem.c | 8 ++++++- src/util/inc/tfile.h | 13 +++++----- src/util/src/tfile.c | 47 ++++++++++++++++++++++++++++++++++--- 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/src/dnode/src/dnodeSystem.c b/src/dnode/src/dnodeSystem.c index 971bd0a110..4eba81e29d 100644 --- a/src/dnode/src/dnodeSystem.c +++ b/src/dnode/src/dnodeSystem.c @@ -70,7 +70,13 @@ int32_t main(int32_t argc, char *argv[]) { } #endif #ifdef TAOS_RANDOM_FILE_FAIL - else if (strcmp(argv[i], "--random-file-fail-factor") == 0) { + else if (strcmp(argv[i], "--random-file-fail-output") == 0) { + if ((i < argc - 1) && (argv[i + 1][0] != '-')) { + taosSetRandomFileFailOutput(argv[++i]); + } else { + taosSetRandomFileFailOutput(NULL); + } + } else if (strcmp(argv[i], "--random-file-fail-factor") == 0) { if ( (i+1) < argc ) { int factor = atoi(argv[i+1]); printf("The factor of random failure is %d\n", factor); diff --git a/src/util/inc/tfile.h b/src/util/inc/tfile.h index 04e500743c..de52a40967 100644 --- a/src/util/inc/tfile.h +++ b/src/util/inc/tfile.h @@ -19,13 +19,14 @@ #ifdef TAOS_RANDOM_FILE_FAIL void taosSetRandomFileFailFactor(int factor); -ssize_t taos_tread(int fd, void *buf, size_t count); -ssize_t taos_twrite(int fd, void *buf, size_t count); -off_t taos_lseek(int fd, off_t offset, int whence); +void taosSetRandomFileFailOutput(const char *path); +ssize_t taos_tread(int fd, void *buf, size_t count, const char *file, uint32_t line); +ssize_t taos_twrite(int fd, void *buf, size_t count, const char *file, uint32_t line); +off_t taos_lseek(int fd, off_t offset, int whence, const char *file, uint32_t line); -#define tread(fd, buf, count) taos_tread(fd, buf, count) -#define twrite(fd, buf, count) taos_twrite(fd, buf, count) -#define lseek(fd, offset, whence) taos_lseek(fd, offset, whence) +#define tread(fd, buf, count) taos_tread(fd, buf, count, __FILE__, __LINE__) +#define twrite(fd, buf, count) taos_twrite(fd, buf, count, __FILE__, __LINE__) +#define lseek(fd, offset, whence) taos_lseek(fd, offset, whence, __FILE__, __LINE__) #endif // TAOS_RANDOM_FILE_FAIL diff --git a/src/util/src/tfile.c b/src/util/src/tfile.c index 92eeaef126..d1a9c24615 100644 --- a/src/util/src/tfile.c +++ b/src/util/src/tfile.c @@ -29,14 +29,55 @@ #ifdef TAOS_RANDOM_FILE_FAIL static int random_file_fail_factor = 20; +static FILE *fpRandomFileFailOutput = NULL; void taosSetRandomFileFailFactor(int factor) { random_file_fail_factor = factor; } + +static void close_random_file_fail_output() +{ + if (fpRandomFileFailOutput != NULL) { + if (fpRandomFileFailOutput != stdout) { + fclose(fpRandomFileFailOutput); + } + fpRandomFileFailOutput = NULL; + } +} + +static void random_file_fail_output_sig(int sig) +{ + fprintf(fpRandomFileFailOutput, "signal %d received.\n", sig); + + struct sigaction act = {0}; + act.sa_handler = SIG_DFL; + sigaction(sig, &act, NULL); + + close_random_file_fail_output(); + exit(EXIT_FAILURE); +} + +void taosSetRandomFileFailOutput(const char *path) +{ + if (path == NULL) { + fpRandomFileFailOutput = stdout; + } else if ((fpRandomFileFailOutput = fopen(path, "w")) != NULL) { + atexit(close_random_file_fail_output); + } else { + printf("failed to open random file fail log file '%s', errno=%d\n", path, errno); + return; + } + + struct sigaction act = {0}; + act.sa_handler = random_file_fail_output_sig; + sigaction(SIGFPE, &act, NULL); + sigaction(SIGSEGV, &act, NULL); + sigaction(SIGILL, &act, NULL); +} #endif -ssize_t taos_tread(int fd, void *buf, size_t count) +ssize_t taos_tread(int fd, void *buf, size_t count, const char *file, uint32_t line) { #ifdef TAOS_RANDOM_FILE_FAIL if (random_file_fail_factor > 0) { @@ -49,7 +90,7 @@ ssize_t taos_tread(int fd, void *buf, size_t count) return tread(fd, buf, count); } -ssize_t taos_twrite(int fd, void *buf, size_t count) +ssize_t taos_twrite(int fd, void *buf, size_t count, const char *file, uint32_t line) { #ifdef TAOS_RANDOM_FILE_FAIL if (random_file_fail_factor > 0) { @@ -62,7 +103,7 @@ ssize_t taos_twrite(int fd, void *buf, size_t count) return twrite(fd, buf, count); } -off_t taos_lseek(int fd, off_t offset, int whence) +off_t taos_lseek(int fd, off_t offset, int whence, const char *file, uint32_t line) { #ifdef TAOS_RANDOM_FILE_FAIL if (random_file_fail_factor > 0) { From f53f80fbc60e152302e838ec1304eb559b39c0e8 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 13 Jul 2020 14:33:16 +0800 Subject: [PATCH 40/63] log --- src/dnode/src/dnodeVWrite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dnode/src/dnodeVWrite.c b/src/dnode/src/dnodeVWrite.c index e1a17236ac..ba36e537a6 100644 --- a/src/dnode/src/dnodeVWrite.c +++ b/src/dnode/src/dnodeVWrite.c @@ -235,7 +235,7 @@ static void *dnodeProcessWriteQueue(void *param) { dDebug("%p, rpc msg:%s will be processed in vwrite queue", pWrite->rpcMsg.ahandle, taosMsg[pWrite->rpcMsg.msgType]); } else { pHead = (SWalHead *)item; - dDebug("%p, wal msg:%s will be processed in vwrite queue, version:%" PRIu64, pHead, taosMsg[pHead->msgType], pHead->version); + dTrace("%p, wal msg:%s will be processed in vwrite queue, version:%" PRIu64, pHead, taosMsg[pHead->msgType], pHead->version); } int32_t code = vnodeProcessWrite(pVnode, type, pHead, pRspRet); From d9bd4f451805fbf11d69cad3d97461a93812e3b6 Mon Sep 17 00:00:00 2001 From: Hui Li Date: Mon, 13 Jul 2020 14:36:23 +0800 Subject: [PATCH 41/63] [add cluster sim cases] --- tests/script/unique/cluster/client3.sim | 55 +++ tests/script/unique/cluster/client4.sim | 113 ++++++ tests/script/unique/cluster/client5.sim | 113 ++++++ tests/script/unique/cluster/cluster_main.sim | 45 +-- tests/script/unique/cluster/cluster_main1.sim | 326 +++++++++++++++++ tests/script/unique/cluster/cluster_main2.sim | 330 ++++++++++++++++++ .../script/unique/cluster/main1_client1_0.sim | 94 +++++ .../script/unique/cluster/main1_client1_1.sim | 82 +++++ .../script/unique/cluster/main1_client1_2.sim | 81 +++++ .../script/unique/cluster/main1_client1_3.sim | 81 +++++ 10 files changed, 1299 insertions(+), 21 deletions(-) create mode 100644 tests/script/unique/cluster/client3.sim create mode 100644 tests/script/unique/cluster/client4.sim create mode 100644 tests/script/unique/cluster/client5.sim create mode 100644 tests/script/unique/cluster/cluster_main1.sim create mode 100644 tests/script/unique/cluster/cluster_main2.sim create mode 100644 tests/script/unique/cluster/main1_client1_0.sim create mode 100644 tests/script/unique/cluster/main1_client1_1.sim create mode 100644 tests/script/unique/cluster/main1_client1_2.sim create mode 100644 tests/script/unique/cluster/main1_client1_3.sim diff --git a/tests/script/unique/cluster/client3.sim b/tests/script/unique/cluster/client3.sim new file mode 100644 index 0000000000..4b3024f881 --- /dev/null +++ b/tests/script/unique/cluster/client3.sim @@ -0,0 +1,55 @@ +$tblStart = 0 +$tblEnd = 10000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +loop_lable: +print ====================== client3 start loop: dynamic create table and insert data, select, drop table ............ + +$totalRows = 0 + +#sql create table $stb ( ts timestamp, c1 int) tags ( t1 int, t2 binary(16) ) +$tagBinary = ' . client3 +$tagBinary = $tagBinary . ' + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb = dtb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb using $stb tags ( $i , $tagBinary ) values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x +# print ====== app insert totalRows: $totalRows + $i = $i + 1 +endw + +sql select count(*) from $stb where t2 == $tagBinary +if $data00 != $totalRows then + print data00 $data00 totalRows $totalRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client3 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +endi + +print ====================== client3 drop table +$i = $tblStart +while $i < $tblEnd + $tb = dtb . $i + sql drop table if exists $tb + $i = $i + 1 +endw +goto loop_lable \ No newline at end of file diff --git a/tests/script/unique/cluster/client4.sim b/tests/script/unique/cluster/client4.sim new file mode 100644 index 0000000000..a4c347695e --- /dev/null +++ b/tests/script/unique/cluster/client4.sim @@ -0,0 +1,113 @@ +$tblStart = 0 +$tblEnd = 2000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +loop_lable: +print ====================== client4 start loop: create db2, tables and insert data, select, drop db2 ............ + +$db = db2 +$stb = stb2 + +print create database if not exists $db replica 2 +sql create database if not exists $db replica 2 +sql use $db + +print ==== client4start create table +$i = $tblStart +while $i < $tblEnd + $tb = dtb . $i + sql create table $tb (ts timestamp, c1 int) + $i = $i + 1 +endw + + +print ==== client4start insert, include multi table data in one insert sql +$totalRows = 0 +$totalRowsPerTbl = 0 + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb0 = dtb . $i + $i = $i + 1 + $tb1 = dtb . $i + $i = $i + 1 + $tb2 = dtb . $i + $i = $i + 1 + $tb3 = dtb . $i + $i = $i + 1 + $tb4 = dtb . $i + $i = $i + 1 + + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb0 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb1 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb2 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb3 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb4 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRowsPerTbl = $totalRowsPerTbl + $x + $x = $x * 5 + $totalRows = $totalRows + $x +endw + +sql select count(*) from tb10 +if $data00 != $totalRowsPerTbl then + print data00 $data00 totalRowsPerTbl $totalRowsPerTbl + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client4 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +endi + + +print ====client4 start alter table +$i = $tblStart +while $i < $tblEnd + $tb = dtb . $i + sql alter table $tb add c2 float + $i = $i + 1 +endw + +print ====client4 continue insert, include multi table data in one insert sql + +$i = $tblStart +while $i < $tblEnd + $tb0 = dtb . $i + $i = $i + 1 + $tb1 = dtb . $i + $i = $i + 1 + $tb2 = dtb . $i + $i = $i + 1 + $tb3 = dtb . $i + $i = $i + 1 + $tb4 = dtb . $i + $i = $i + 1 + + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb0 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb1 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb2 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb3 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb4 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRowsPerTbl = $totalRowsPerTbl + $x + $x = $x * 5 + $totalRows = $totalRows + $x +endw + +sql select count(*) from tb10 +if $data00 != $totalRowsPerTbl then + print data00 $data00 totalRowsPerTbl $totalRowsPerTbl + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client4 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +endi + +print ====================== client4 drop database +sql drop if exists database $db +goto loop_lable \ No newline at end of file diff --git a/tests/script/unique/cluster/client5.sim b/tests/script/unique/cluster/client5.sim new file mode 100644 index 0000000000..5960b28fdd --- /dev/null +++ b/tests/script/unique/cluster/client5.sim @@ -0,0 +1,113 @@ +$tblStart = 0 +$tblEnd = 2000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +loop_lable: +print ====================== client5 start loop query + +$db = db2 +$stb = stb2 + +print create database if not exists $db replica 2 +sql create database if not exists $db replica 2 +sql use $db + +print ==== client4start create table +$i = $tblStart +while $i < $tblEnd + $tb = dtb . $i + sql create table $tb (ts timestamp, c1 int) + $i = $i + 1 +endw + + +print ==== client4start insert, include multi table data in one insert sql +$totalRows = 0 +$totalRowsPerTbl = 0 + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb0 = dtb . $i + $i = $i + 1 + $tb1 = dtb . $i + $i = $i + 1 + $tb2 = dtb . $i + $i = $i + 1 + $tb3 = dtb . $i + $i = $i + 1 + $tb4 = dtb . $i + $i = $i + 1 + + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb0 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb1 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb2 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb3 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb4 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRowsPerTbl = $totalRowsPerTbl + $x + $x = $x * 5 + $totalRows = $totalRows + $x +endw + +sql select count(*) from tb10 +if $data00 != $totalRowsPerTbl then + print data00 $data00 totalRowsPerTbl $totalRowsPerTbl + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client4 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +endi + + +print ====client4 start alter table +$i = $tblStart +while $i < $tblEnd + $tb = dtb . $i + sql alter table $tb add c2 float + $i = $i + 1 +endw + +print ====client4 continue insert, include multi table data in one insert sql + +$i = $tblStart +while $i < $tblEnd + $tb0 = dtb . $i + $i = $i + 1 + $tb1 = dtb . $i + $i = $i + 1 + $tb2 = dtb . $i + $i = $i + 1 + $tb3 = dtb . $i + $i = $i + 1 + $tb4 = dtb . $i + $i = $i + 1 + + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb0 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb1 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb2 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb3 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb4 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRowsPerTbl = $totalRowsPerTbl + $x + $x = $x * 5 + $totalRows = $totalRows + $x +endw + +sql select count(*) from tb10 +if $data00 != $totalRowsPerTbl then + print data00 $data00 totalRowsPerTbl $totalRowsPerTbl + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client4 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +endi + +print ====================== client4 drop database +sql drop if exists database $db +goto loop_lable \ No newline at end of file diff --git a/tests/script/unique/cluster/cluster_main.sim b/tests/script/unique/cluster/cluster_main.sim index 236f1aa59a..f3cce9fd45 100644 --- a/tests/script/unique/cluster/cluster_main.sim +++ b/tests/script/unique/cluster/cluster_main.sim @@ -69,13 +69,14 @@ sql use $db print ============== step3: create stable stb1 $stb = stb1 -sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +print create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) +sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) -print ============== step4: start 10 client1/ 10 client2/ 10 client3/ 10 client4/ 1 client5 +print ============== step4: start others client run_back unique/cluster/client1_0.sim -#run_back unique/cluster/client1_1.sim -#run_back unique/cluster/client1_2.sim -#run_back unique/cluster/client1_3.sim +run_back unique/cluster/client1_1.sim +run_back unique/cluster/client1_2.sim +run_back unique/cluster/client1_3.sim #run_back unique/cluster/client2_0.sim #run_back unique/cluster/client2_1.sim #run_back unique/cluster/client2_2.sim @@ -118,14 +119,16 @@ sql create dnode $hostname5 sleep 5000 -print ============== step6: stop and drop dnode1, then remove data dir of dnode1 +print ============== step6: stop dnode1 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 -sql drop dnode $hostname1 -sleep 5000 - -system rm -rf ../../../sim/dnode1/data -sleep 20000 +sleep 10000 +#sql drop dnode $hostname1 +#sleep 5000 +#system rm -rf ../../../sim/dnode1/data +#sleep 20000 +print ============== step6-1: restart dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 10000 sql show mnodes print show mnodes @@ -139,7 +142,6 @@ print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 -return -1 print ============== step7: stop dnode2 system sh/exec.sh -n dnode2 -s stop -x SIGINT @@ -239,11 +241,12 @@ endi print ============== step14: stop and drop dnode4/dnode5, then remove data dir of dnode4/dnode5 system sh/exec.sh -n dnode4 -s stop -x SIGINT system sh/exec.sh -n dnode5 -s stop -x SIGINT -sleep 20000 +sleep 3000 sql drop dnode $hostname4 sql drop dnode $hostname5 system rm -rf ../../../sim/dnode4/data system rm -rf ../../../sim/dnode5/data +sleep 20000 print ============== step15: alter replica 1 sql alter database $db replica 1 @@ -263,13 +266,13 @@ if $data04 != 2 then return -1 endi -print ============== step17: start dnode1 and add into cluster, then wait dnode1 ready -system sh/cfg.sh -n dnode1 -c first -v $hostname2 -system sh/cfg.sh -n dnode1 -c second -v $hostname3 - -system sh/exec.sh -n dnode1 -s start -sql create dnode $hostname1 -sleep 20000 +#print ============== step17: start dnode1 and add into cluster, then wait dnode1 ready +#system sh/cfg.sh -n dnode1 -c first -v $hostname2 +#system sh/cfg.sh -n dnode1 -c second -v $hostname3 +# +#system sh/exec.sh -n dnode1 -s start +#sql create dnode $hostname1 +#sleep 20000 print ============== step18: alter replica 3 sql alter database $db replica 3 diff --git a/tests/script/unique/cluster/cluster_main1.sim b/tests/script/unique/cluster/cluster_main1.sim new file mode 100644 index 0000000000..343924dfee --- /dev/null +++ b/tests/script/unique/cluster/cluster_main1.sim @@ -0,0 +1,326 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 +system sh/cfg.sh -n dnode5 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 256 + +system sh/cfg.sh -n dnode1 -c alternativeRole -v 0 +system sh/cfg.sh -n dnode2 -c alternativeRole -v 0 +system sh/cfg.sh -n dnode3 -c alternativeRole -v 0 +system sh/cfg.sh -n dnode4 -c alternativeRole -v 0 +system sh/cfg.sh -n dnode5 -c alternativeRole -v 0 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 5000 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode5 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1/dnode2/dnode3 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 3000 +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +sleep 3000 + +print ============== step2: create db1 with replica 3 +$replica = 3 +$db = db1 +print create database $db replica $replica +#sql create database $db replica 3 maxTables $totalTableNum +sql create database $db replica $replica +sql use $db + +print ============== step3: create stable stb1 +$stb = stb1 +print create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) +sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) + +print ============== step4: start others client +run_back unique/cluster/main1_client1_0.sim +run_back unique/cluster/main1_client1_1.sim +run_back unique/cluster/main1_client1_2.sim +run_back unique/cluster/main1_client1_3.sim +run_back unique/cluster/client3.sim +run_back unique/cluster/client4.sim + +sleep 20000 + +wait_subsim_insert_complete_create_tables: +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 +if $data00 < 1000 then + sleep 3000 + goto wait_subsim_insert_complete_create_tables +endi + +wait_subsim_insert_data: +print select count(*) from $stb +sql select count(*) from $stb +print data00 $data00 +if $data00 < 1000 then + sleep 3000 + goto wait_subsim_insert_data +endi + +print wait for a while to let clients start insert data +sleep 5000 + +$loop_cnt = 0 +loop_cluster_do: +print **** **** **** START loop cluster do (loop_cnt: $loop_cnt )**** **** **** **** +print ============== step5: start dnode4/dnode5 and add into cluster, then wait ready +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +sql create dnode $hostname4 +sql create dnode $hostname5 +sleep 5000 + +print ============== step6: stop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 10000 +#sql drop dnode $hostname1 +#sleep 5000 +#system rm -rf ../../../sim/dnode1/data +#sleep 20000 +print ============== step6-1: restart dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 10000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step7: stop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 5000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step8: restart dnode2, then wait sync end +system sh/exec.sh -n dnode2 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step9: stop dnode3, then wait sync end +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step10: restart dnode3, then wait sync end +system sh/exec.sh -n dnode3 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step11: stop dnode4, then wait sync end +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep 20000 + +print ============== step12: restart dnode4, then wait sync end +system sh/exec.sh -n dnode4 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step13: alter replica 2 +sql alter database $db replica 2 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 2 then + print rplica is not modify to 2, error!!!!!! + return -1 +endi + +print ============== step14: drop dnode4, then remove data dir +sql drop dnode $hostname4 +sleep 20000 +system rm -rf ../../../sim/dnode4/data + +print ============== step14-1: drop dnode5, then remove data dir +sql drop dnode $hostname5 +sleep 20000 +system rm -rf ../../../sim/dnode5/data + +print ============== step15: alter replica 1 +sql alter database $db replica 1 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 1 then + print rplica is not modify to 1, error!!!!!! + return -1 +endi + +print ============== step16: alter replica 2 +sql alter database $db replica 2 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 2 then + print rplica is not modify to 2, error!!!!!! + return -1 +endi + +#print ============== step17: start dnode1 and add into cluster, then wait dnode1 ready +#system sh/cfg.sh -n dnode1 -c first -v $hostname2 +#system sh/cfg.sh -n dnode1 -c second -v $hostname3 +# +#system sh/exec.sh -n dnode1 -s start +#sql create dnode $hostname1 +#sleep 20000 + +print ============== step18: alter replica 3 +sql alter database $db replica 3 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 3 then + print rplica is not modify to 3, error!!!!!! + return -1 +endi + +print **** **** **** (loop_cnt: $loop_cnt ) end, continue...... **** **** **** **** +$loop_cnt = $loop_cnt + 1 +goto loop_cluster_do diff --git a/tests/script/unique/cluster/cluster_main2.sim b/tests/script/unique/cluster/cluster_main2.sim new file mode 100644 index 0000000000..83934da457 --- /dev/null +++ b/tests/script/unique/cluster/cluster_main2.sim @@ -0,0 +1,330 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 +system sh/cfg.sh -n dnode5 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 256 + +system sh/cfg.sh -n dnode1 -c alternativeRole -v 0 +system sh/cfg.sh -n dnode2 -c alternativeRole -v 0 +system sh/cfg.sh -n dnode3 -c alternativeRole -v 0 +system sh/cfg.sh -n dnode4 -c alternativeRole -v 0 +system sh/cfg.sh -n dnode5 -c alternativeRole -v 0 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 5000 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode5 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1/dnode2/dnode3 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 3000 +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +sleep 3000 + +print ============== step2: create db1 with replica 3 +$replica = 3 +$db = db1 +print create database $db replica $replica +#sql create database $db replica 3 maxTables $totalTableNum +sql create database $db replica $replica +sql use $db + +print ============== step3: create stable stb1 +$stb = stb1 +print create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) +sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) + +print ============== step4: start others client +run_back unique/cluster/main2_client1_0.sim +run_back unique/cluster/main2_client1_1.sim +run_back unique/cluster/main2_client1_2.sim +run_back unique/cluster/main2_client1_3.sim +run_back unique/cluster/main2_client2_0.sim +run_back unique/cluster/main2_client2_1.sim +run_back unique/cluster/main2_client2_2.sim +run_back unique/cluster/main2_client2_3.sim +run_back unique/cluster/client3.sim +run_back unique/cluster/client4.sim + +sleep 20000 + +wait_subsim_insert_complete_create_tables: +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 +if $data00 < 1000 then + sleep 3000 + goto wait_subsim_insert_complete_create_tables +endi + +wait_subsim_insert_data: +print select count(*) from $stb +sql select count(*) from $stb +print data00 $data00 +if $data00 < 1000 then + sleep 3000 + goto wait_subsim_insert_data +endi + +print wait for a while to let clients start insert data +sleep 5000 + +$loop_cnt = 0 +loop_cluster_do: +print **** **** **** START loop cluster do (loop_cnt: $loop_cnt )**** **** **** **** +print ============== step5: start dnode4/dnode5 and add into cluster, then wait ready +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +sql create dnode $hostname4 +sql create dnode $hostname5 +sleep 5000 + +print ============== step6: stop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 10000 +#sql drop dnode $hostname1 +#sleep 5000 +#system rm -rf ../../../sim/dnode1/data +#sleep 20000 +print ============== step6-1: restart dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 10000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step7: stop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 5000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step8: restart dnode2, then wait sync end +system sh/exec.sh -n dnode2 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step9: stop dnode3, then wait sync end +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step10: restart dnode3, then wait sync end +system sh/exec.sh -n dnode3 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step11: stop dnode4, then wait sync end +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep 20000 + +print ============== step12: restart dnode4, then wait sync end +system sh/exec.sh -n dnode4 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step13: alter replica 2 +sql alter database $db replica 2 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 2 then + print rplica is not modify to 2, error!!!!!! + return -1 +endi + +print ============== step14: drop dnode4, then remove data dir +sql drop dnode $hostname4 +sleep 20000 +system rm -rf ../../../sim/dnode4/data + +print ============== step14-1: drop dnode5, then remove data dir +sql drop dnode $hostname5 +sleep 20000 +system rm -rf ../../../sim/dnode5/data + +print ============== step15: alter replica 1 +sql alter database $db replica 1 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 1 then + print rplica is not modify to 1, error!!!!!! + return -1 +endi + +print ============== step16: alter replica 2 +sql alter database $db replica 2 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 2 then + print rplica is not modify to 2, error!!!!!! + return -1 +endi + +#print ============== step17: start dnode1 and add into cluster, then wait dnode1 ready +#system sh/cfg.sh -n dnode1 -c first -v $hostname2 +#system sh/cfg.sh -n dnode1 -c second -v $hostname3 +# +#system sh/exec.sh -n dnode1 -s start +#sql create dnode $hostname1 +#sleep 20000 + +print ============== step18: alter replica 3 +sql alter database $db replica 3 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 + +if $data00 == db1 then + $replica = $data04 +elif $data10 == db1 then + $replica = $data14 +else then + print ==== db1 already not exists!!!!! + return -1 +endi + +if $replica != 3 then + print rplica is not modify to 3, error!!!!!! + return -1 +endi + +print **** **** **** (loop_cnt: $loop_cnt ) end, continue...... **** **** **** **** +$loop_cnt = $loop_cnt + 1 +goto loop_cluster_do diff --git a/tests/script/unique/cluster/main1_client1_0.sim b/tests/script/unique/cluster/main1_client1_0.sim new file mode 100644 index 0000000000..d4f2aa4294 --- /dev/null +++ b/tests/script/unique/cluster/main1_client1_0.sim @@ -0,0 +1,94 @@ +#system sh/stop_dnodes.sh +#system sh/deploy.sh -n dnode1 -i 1 +#system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 10000 +#system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 256 +#system sh/exec.sh -n dnode1 -s start +#sql connect +#$db = db1 +#sql create database $db +#sql use $db +#$stb = stb1 +#sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) + + +$tblStart = 0 +$tblEnd = 1000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_0 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_0 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) -x insert_error_loop + $x = $x + 20 + $ts = $ts + 40a + goto continue_next_0 + insert_error_loop: + print ============== main1_client1_0 run error: sql insert into $tb values ( $ts + 0a , $x ) ... ... + continue_next_0: + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + if $data00 != $totalRows then + print data00 $data00 totalRows $totalRows + $deltaRows = $totalRows - $data00 + if $lastLossRows == 0 then + $lastLossRows = $deltaRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_0 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + elif $deltaRows != $lastLossRows + $tmp = $deltaRows - $lastLossRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_0 insert loss: $tmp *********** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + $lastLossRows = $deltaRows + endi +# return -1 + endi + goto continue_next_1 + query_error_loop: + print ============== main1_client1_0 run error: sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + continue_next_1: + print ====================== client1_0 insert data complete once ............ + endi +endw +print ====================== client1_0 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main1_client1_1.sim b/tests/script/unique/cluster/main1_client1_1.sim new file mode 100644 index 0000000000..b50f533ce1 --- /dev/null +++ b/tests/script/unique/cluster/main1_client1_1.sim @@ -0,0 +1,82 @@ +$tblStart = 1000 +$tblEnd = 2000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_1 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_1 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) -x insert_error_loop + $x = $x + 20 + $ts = $ts + 40a + goto continue_next_0 + insert_error_loop: + print ============== main1_client1_1 run error: sql insert into $tb values ( $ts + 0a , $x ) ... ... + continue_next_0: + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + if $data00 != $totalRows then + print data00 $data00 totalRows $totalRows + $deltaRows = $totalRows - $data00 + if $lastLossRows == 0 then + $lastLossRows = $deltaRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_1 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + elif $deltaRows != $lastLossRows + $tmp = $deltaRows - $lastLossRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_1 insert loss: $tmp *********** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + $lastLossRows = $deltaRows + endi +# return -1 + endi + goto continue_next_1 + query_error_loop: + print ============== main1_client1_1 run error: sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + continue_next_1: + print ====================== client1_2 insert data complete once ............ + endi +endw +print ====================== client1_1 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main1_client1_2.sim b/tests/script/unique/cluster/main1_client1_2.sim new file mode 100644 index 0000000000..8cc39ded04 --- /dev/null +++ b/tests/script/unique/cluster/main1_client1_2.sim @@ -0,0 +1,81 @@ +$tblStart = 2000 +$tblEnd = 3000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_2 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_2 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) -x insert_error_loop + $x = $x + 20 + $ts = $ts + 40a + goto continue_next_0 + insert_error_loop: + print ============== main1_client1_2 run error: sql insert into $tb values ( $ts + 0a , $x ) ... ... + continue_next_0: + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + if $data00 != $totalRows then + print data00 $data00 totalRows $totalRows + $deltaRows = $totalRows - $data00 + if $lastLossRows == 0 then + $lastLossRows = $deltaRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_2 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + elif $deltaRows != $lastLossRows + $tmp = $deltaRows - $lastLossRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_2 insert loss: $tmp *********** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + $lastLossRows = $deltaRows + endi +# return -1 + endi + goto continue_next_1 + query_error_loop: + print ============== main1_client1_2 run error: sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + continue_next_1: + print ====================== client1_2 insert data complete once ............ + endi +endw +print ====================== client1_2 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main1_client1_3.sim b/tests/script/unique/cluster/main1_client1_3.sim new file mode 100644 index 0000000000..72e1be48ac --- /dev/null +++ b/tests/script/unique/cluster/main1_client1_3.sim @@ -0,0 +1,81 @@ +$tblStart = 3000 +$tblEnd = 4000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_3 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_3 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) -x insert_error_loop + $x = $x + 20 + $ts = $ts + 40a + goto continue_next_0 + insert_error_loop: + print ============== main1_client1_3 run error: sql insert into $tb values ( $ts + 0a , $x ) ... ... + continue_next_0: + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + if $data00 != $totalRows then + print data00 $data00 totalRows $totalRows + $deltaRows = $totalRows - $data00 + if $lastLossRows == 0 then + $lastLossRows = $deltaRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_3 insert loss: $deltaRows ***** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + elif $deltaRows != $lastLossRows + $tmp = $deltaRows - $lastLossRows + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + print ************ client1_3 insert loss: $tmp *********** + print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + $lastLossRows = $deltaRows + endi +# return -1 + endi + goto continue_next_1 + query_error_loop: + print ============== main1_client1_3 run error: sql select count(*) from $stb where t2 == $tagBinary -x query_error_loop + continue_next_1: + print ====================== client1_3 insert data complete once ............ + endi +endw +print ====================== client1_3 success and auto end ===================== \ No newline at end of file From a08c7405c06151cfd0ade3ad64e6f78591453ad2 Mon Sep 17 00:00:00 2001 From: Hui Li Date: Mon, 13 Jul 2020 15:07:11 +0800 Subject: [PATCH 42/63] [add cluster sim cases] --- tests/script/unique/cluster/cluster_main0.sim | 288 ++++++++++++++++++ tests/script/unique/cluster/main1_client4.sim | 127 ++++++++ .../script/unique/cluster/main2_client1_0.sim | 69 +++++ .../script/unique/cluster/main2_client1_1.sim | 57 ++++ .../script/unique/cluster/main2_client1_2.sim | 56 ++++ .../script/unique/cluster/main2_client1_3.sim | 56 ++++ .../script/unique/cluster/main2_client2_0.sim | 56 ++++ .../script/unique/cluster/main2_client2_1.sim | 57 ++++ .../script/unique/cluster/main2_client2_2.sim | 57 ++++ .../script/unique/cluster/main2_client2_3.sim | 57 ++++ 10 files changed, 880 insertions(+) create mode 100644 tests/script/unique/cluster/cluster_main0.sim create mode 100644 tests/script/unique/cluster/main1_client4.sim create mode 100644 tests/script/unique/cluster/main2_client1_0.sim create mode 100644 tests/script/unique/cluster/main2_client1_1.sim create mode 100644 tests/script/unique/cluster/main2_client1_2.sim create mode 100644 tests/script/unique/cluster/main2_client1_3.sim create mode 100644 tests/script/unique/cluster/main2_client2_0.sim create mode 100644 tests/script/unique/cluster/main2_client2_1.sim create mode 100644 tests/script/unique/cluster/main2_client2_2.sim create mode 100644 tests/script/unique/cluster/main2_client2_3.sim diff --git a/tests/script/unique/cluster/cluster_main0.sim b/tests/script/unique/cluster/cluster_main0.sim new file mode 100644 index 0000000000..f3cce9fd45 --- /dev/null +++ b/tests/script/unique/cluster/cluster_main0.sim @@ -0,0 +1,288 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 3 +system sh/cfg.sh -n dnode5 -c numOfMnodes -v 3 + +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode2 -c walLevel -v 1 +system sh/cfg.sh -n dnode3 -c walLevel -v 1 +system sh/cfg.sh -n dnode4 -c walLevel -v 1 +system sh/cfg.sh -n dnode5 -c walLevel -v 1 + +system sh/cfg.sh -n dnode1 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode2 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode3 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode4 -c balanceInterval -v 10 +system sh/cfg.sh -n dnode5 -c balanceInterval -v 10 + +system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 256 +system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 256 + +system sh/cfg.sh -n dnode1 -c alternativeRole -v 0 +system sh/cfg.sh -n dnode2 -c alternativeRole -v 0 +system sh/cfg.sh -n dnode3 -c alternativeRole -v 0 +system sh/cfg.sh -n dnode4 -c alternativeRole -v 0 +system sh/cfg.sh -n dnode5 -c alternativeRole -v 0 + +system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 5000 +system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 5000 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode5 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1/dnode2/dnode3 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sleep 3000 +sql connect +sql create dnode $hostname2 +sql create dnode $hostname3 +sleep 3000 + +print ============== step2: create db1 with replica 3 +$db = db1 +print create database $db replica 3 +#sql create database $db replica 3 maxTables $totalTableNum +sql create database $db replica 3 +sql use $db + +print ============== step3: create stable stb1 +$stb = stb1 +print create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) +sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) + +print ============== step4: start others client +run_back unique/cluster/client1_0.sim +run_back unique/cluster/client1_1.sim +run_back unique/cluster/client1_2.sim +run_back unique/cluster/client1_3.sim +#run_back unique/cluster/client2_0.sim +#run_back unique/cluster/client2_1.sim +#run_back unique/cluster/client2_2.sim +#run_back unique/cluster/client2_3.sim +#run_back unique/cluster/client3.sim +#run_back unique/cluster/client4.sim + +sleep 20000 + +wait_subsim_insert_complete_create_tables: +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 +if $data00 < 1000 then + sleep 3000 + goto wait_subsim_insert_complete_create_tables +endi + +wait_subsim_insert_data: +print select count(*) from $stb +sql select count(*) from $stb +print data00 $data00 +if $data00 < 1000 then + sleep 3000 + goto wait_subsim_insert_data +endi + +print wait for a while to let clients start insert data +sleep 5000 + +$loop_cnt = 0 +loop_cluster_do: +print **** **** **** START loop cluster do (loop_cnt: $loop_cnt )**** **** **** **** +print ============== step5: start dnode4/dnode5 and add into cluster, then wait ready +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +sql create dnode $hostname4 +sql create dnode $hostname5 + +sleep 5000 + + +print ============== step6: stop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 10000 +#sql drop dnode $hostname1 +#sleep 5000 +#system rm -rf ../../../sim/dnode1/data +#sleep 20000 +print ============== step6-1: restart dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 10000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step7: stop dnode2 +system sh/exec.sh -n dnode2 -s stop -x SIGINT +sleep 5000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step8: restart dnode2, then wait sync end +system sh/exec.sh -n dnode2 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step9: stop dnode3, then wait sync end +system sh/exec.sh -n dnode3 -s stop -x SIGINT +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step10: restart dnode3, then wait sync end +system sh/exec.sh -n dnode3 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step11: stop dnode4, then wait sync end +system sh/exec.sh -n dnode4 -s stop -x SIGINT +sleep 20000 + +print ============== step12: restart dnode4, then wait sync end +system sh/exec.sh -n dnode4 -s start +sleep 20000 +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step13: alter replica 2 +sql alter database $db replica 2 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +if $data04 != 2 then + print rplica is not modify to 2, error!!!!!! + return -1 +endi + +print ============== step14: stop and drop dnode4/dnode5, then remove data dir of dnode4/dnode5 +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT +sleep 3000 +sql drop dnode $hostname4 +sql drop dnode $hostname5 +system rm -rf ../../../sim/dnode4/data +system rm -rf ../../../sim/dnode5/data +sleep 20000 + +print ============== step15: alter replica 1 +sql alter database $db replica 1 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 1 then + print rplica is not modify to 1, error!!!!!! + return -1 +endi + +print ============== step16: alter replica 2 +sql alter database $db replica 2 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 2 then + print rplica is not modify to 2, error!!!!!! + return -1 +endi + +#print ============== step17: start dnode1 and add into cluster, then wait dnode1 ready +#system sh/cfg.sh -n dnode1 -c first -v $hostname2 +#system sh/cfg.sh -n dnode1 -c second -v $hostname3 +# +#system sh/exec.sh -n dnode1 -s start +#sql create dnode $hostname1 +#sleep 20000 + +print ============== step18: alter replica 3 +sql alter database $db replica 3 +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $data04 != 3 then + print rplica is not modify to 3, error!!!!!! + return -1 +endi + +print **** **** **** (loop_cnt: $loop_cnt ) end, continue...... **** **** **** **** +$loop_cnt = $loop_cnt + 1 +goto loop_cluster_do diff --git a/tests/script/unique/cluster/main1_client4.sim b/tests/script/unique/cluster/main1_client4.sim new file mode 100644 index 0000000000..eb8049b04b --- /dev/null +++ b/tests/script/unique/cluster/main1_client4.sim @@ -0,0 +1,127 @@ +$tblStart = 0 +$tblEnd = 10000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db2 +$stb = stb2 + +loop_lable: +print ========= start loop create db, table, inset data, alter column/tag, select, drop db + +sql create database if not exists $db +sql use $db +sql create table if not exists $stb ( ts timestamp, c1 int, c2 float ) tags ( t1 int , t2 binary(16) ) +$tagBinary = ' . client4 +$tagBinary = $tagBinary . ' + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x , $x ) ( $ts + 2a , $x , $x ) ( $ts + 4a , $x , $x ) ( $ts + 6a , $x , $x ) ( $ts + 8a , $x , $x ) ( $ts + 10a , $x , $x ) ( $ts + 12a , $x , $x ) ( $ts + 14a , $x , $x ) ( $ts + 16a , $x , $x ) ( $ts + 18a , $x , $x ) ( $ts + 20a , $x , $x ) ( $ts + 22a , $x , $x ) ( $ts + 24a , $x , $x ) ( $ts + 26a , $x , $x ) ( $ts + 28a , $x , $x ) ( $ts + 30a , $x , $x ) ( $ts + 32a , $x , $x ) ( $ts + 34a , $x , $x ) ( $ts + 36a , $x , $x ) ( $ts + 38a , $x , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb -x continue_loop + print data00 $data00 totalRows $totalRows + if $data00 != $totalRows then + print ********************** select error ********************** + endi + continue_loop: + print ====================== client4 insert data complete once ............ + endi +endw + +##################### alter column +sql alter table $stb add column c3 double +sql alter table $stb drop column c2 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x , $x ) ( $ts + 2a , $x , $x ) ( $ts + 4a , $x , $x ) ( $ts + 6a , $x , $x ) ( $ts + 8a , $x , $x ) ( $ts + 10a , $x , $x ) ( $ts + 12a , $x , $x ) ( $ts + 14a , $x , $x ) ( $ts + 16a , $x , $x ) ( $ts + 18a , $x , $x ) ( $ts + 20a , $x , $x ) ( $ts + 22a , $x , $x ) ( $ts + 24a , $x , $x ) ( $ts + 26a , $x , $x ) ( $ts + 28a , $x , $x ) ( $ts + 30a , $x , $x ) ( $ts + 32a , $x , $x ) ( $ts + 34a , $x , $x ) ( $ts + 36a , $x , $x ) ( $ts + 38a , $x , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb -x continue_loop + print data00 $data00 totalRows $totalRows + if $data00 != $totalRows then + print ********************** select error ********************** + endi + continue_loop: + print ====================== client4 insert data complete once ............ + endi +endw + + +##################### alter tag +sql alter table $stb add tag t3 int +sql alter table $stb drop tag t2 + +$i = $tblStart +while $i < $tblEnd + $tb = ttb . $i + sql create table if not exists $tb using $stb tags ($i, $i) + $i = $i + 1 +endw + +$rowsPerLoop = 100 +$ts = $tsStart + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x , $x ) ( $ts + 2a , $x , $x ) ( $ts + 4a , $x , $x ) ( $ts + 6a , $x , $x ) ( $ts + 8a , $x , $x ) ( $ts + 10a , $x , $x ) ( $ts + 12a , $x , $x ) ( $ts + 14a , $x , $x ) ( $ts + 16a , $x , $x ) ( $ts + 18a , $x , $x ) ( $ts + 20a , $x , $x ) ( $ts + 22a , $x , $x ) ( $ts + 24a , $x , $x ) ( $ts + 26a , $x , $x ) ( $ts + 28a , $x , $x ) ( $ts + 30a , $x , $x ) ( $ts + 32a , $x , $x ) ( $ts + 34a , $x , $x ) ( $ts + 36a , $x , $x ) ( $ts + 38a , $x , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb -x continue_loop + print data00 $data00 totalRows $totalRows + if $data00 != $totalRows then + print ********************** select error ********************** + endi + continue_loop: + print ====================== client4 insert data complete once ............ + endi +endw + +goto loop_lable \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client1_0.sim b/tests/script/unique/cluster/main2_client1_0.sim new file mode 100644 index 0000000000..a7fd181363 --- /dev/null +++ b/tests/script/unique/cluster/main2_client1_0.sim @@ -0,0 +1,69 @@ +#system sh/stop_dnodes.sh +#system sh/deploy.sh -n dnode1 -i 1 +#system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 10000 +#system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 256 +#system sh/exec.sh -n dnode1 -s start +#sql connect +#$db = db1 +#sql create database $db +#sql use $db +#$stb = stb1 +#sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) + + +$tblStart = 0 +$tblEnd = 1000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_0 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_0 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client1_0 insert data complete once ............ + endi +endw +print ====================== client1_0 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client1_1.sim b/tests/script/unique/cluster/main2_client1_1.sim new file mode 100644 index 0000000000..f22d62a741 --- /dev/null +++ b/tests/script/unique/cluster/main2_client1_1.sim @@ -0,0 +1,57 @@ +$tblStart = 1000 +$tblEnd = 2000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_1 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_1 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client1_1 insert data complete once ............ + endi +endw +print ====================== client1_1 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client1_2.sim b/tests/script/unique/cluster/main2_client1_2.sim new file mode 100644 index 0000000000..df3a925c59 --- /dev/null +++ b/tests/script/unique/cluster/main2_client1_2.sim @@ -0,0 +1,56 @@ +$tblStart = 2000 +$tblEnd = 3000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_2 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_2 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client1_2 insert data complete once ............ + endi +endw +print ====================== client1_2 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client1_3.sim b/tests/script/unique/cluster/main2_client1_3.sim new file mode 100644 index 0000000000..9c22432fa5 --- /dev/null +++ b/tests/script/unique/cluster/main2_client1_3.sim @@ -0,0 +1,56 @@ +$tblStart = 3000 +$tblEnd = 4000 +$tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client1_3 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client1_3 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client1_3 insert data complete once ............ + endi +endw +print ====================== client1_3 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client2_0.sim b/tests/script/unique/cluster/main2_client2_0.sim new file mode 100644 index 0000000000..e44efc49fc --- /dev/null +++ b/tests/script/unique/cluster/main2_client2_0.sim @@ -0,0 +1,56 @@ +$tblStart = 0 +$tblEnd = 1000 +$tsStart = 1325347200001 # 2012-01-01 00:00:00.001 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client2_0 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client2_0 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lastLossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client2_0 insert data complete once ............ + endi +endw +print ====================== client2_0 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client2_1.sim b/tests/script/unique/cluster/main2_client2_1.sim new file mode 100644 index 0000000000..19de147d3e --- /dev/null +++ b/tests/script/unique/cluster/main2_client2_1.sim @@ -0,0 +1,57 @@ +$tblStart = 1000 +$tblEnd = 2000 +$tsStart = 1325347200001 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client2_1 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client2_1 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client2_1 insert data complete once ............ + endi +endw +print ====================== client2_1 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client2_2.sim b/tests/script/unique/cluster/main2_client2_2.sim new file mode 100644 index 0000000000..19e3540bd1 --- /dev/null +++ b/tests/script/unique/cluster/main2_client2_2.sim @@ -0,0 +1,57 @@ +$tblStart = 2000 +$tblEnd = 3000 +$tsStart = 1325347200001 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client2_2 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client2_2 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client2_2 insert data complete once ............ + endi +endw +print ====================== client2_2 success and auto end ===================== \ No newline at end of file diff --git a/tests/script/unique/cluster/main2_client2_3.sim b/tests/script/unique/cluster/main2_client2_3.sim new file mode 100644 index 0000000000..219df131c8 --- /dev/null +++ b/tests/script/unique/cluster/main2_client2_3.sim @@ -0,0 +1,57 @@ +$tblStart = 3000 +$tblEnd = 4000 +$tsStart = 1325347200001 # 2012-01-01 00:00:00.000 +############################################################### + +sql connect + +$db = db1 +$stb = stb1 + +sql use $db + + +######sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) +$tagBinary = ' . client2_3 +$tagBinary = $tagBinary . ' +#print ======= tag: $tagBinary + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i +# print create table if not exists $tb using $stb tags ( $i , $tagBinary ) + sql create table if not exists $tb using $stb tags ( $i , $tagBinary ) + $i = $i + 1 +endw + +print ====================== client2_3 create table end, start insert data ............ +sql select count(tbname) from $stb +print select count(tbname) from $stb +print data00 $data00 + +$rowsPerLoop = 100 +$ts = $tsStart + +$lossRows = 0 + +$i = $tblStart +while $i < $tblEnd + $tb = tb . $i + $x = 0 + while $x < $rowsPerLoop + sql insert into $tb values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) + $x = $x + 20 + $ts = $ts + 40a + endw + + $totalRows = $totalRows + $x + $i = $i + 1 + + if $i == $tblEnd then + $i = $tblStart + + sql select count(*) from $stb where t2 == $tagBinary + print ====================== client2_3 insert data complete once ............ + endi +endw +print ====================== client2_3 success and auto end ===================== \ No newline at end of file From 5539b262f1a73047eb2730a2a550fc178b0ee331 Mon Sep 17 00:00:00 2001 From: Hui Li Date: Mon, 13 Jul 2020 15:08:07 +0800 Subject: [PATCH 43/63] [modify] --- tests/script/unique/cluster/cluster_main.sim | 44 +++++++++----------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/tests/script/unique/cluster/cluster_main.sim b/tests/script/unique/cluster/cluster_main.sim index f3cce9fd45..da4f709f46 100644 --- a/tests/script/unique/cluster/cluster_main.sim +++ b/tests/script/unique/cluster/cluster_main.sim @@ -69,14 +69,13 @@ sql use $db print ============== step3: create stable stb1 $stb = stb1 -print create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) -sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) +sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) -print ============== step4: start others client +print ============== step4: start 10 client1/ 10 client2/ 10 client3/ 10 client4/ 1 client5 run_back unique/cluster/client1_0.sim -run_back unique/cluster/client1_1.sim -run_back unique/cluster/client1_2.sim -run_back unique/cluster/client1_3.sim +#run_back unique/cluster/client1_1.sim +#run_back unique/cluster/client1_2.sim +#run_back unique/cluster/client1_3.sim #run_back unique/cluster/client2_0.sim #run_back unique/cluster/client2_1.sim #run_back unique/cluster/client2_2.sim @@ -119,16 +118,14 @@ sql create dnode $hostname5 sleep 5000 -print ============== step6: stop dnode1 +print ============== step6: stop and drop dnode1, then remove data dir of dnode1 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 10000 -#sql drop dnode $hostname1 -#sleep 5000 -#system rm -rf ../../../sim/dnode1/data -#sleep 20000 -print ============== step6-1: restart dnode1 -system sh/exec.sh -n dnode1 -s start -sleep 10000 +sleep 5000 +sql drop dnode $hostname1 +sleep 5000 + +system rm -rf ../../../sim/dnode1/data +sleep 20000 sql show mnodes print show mnodes @@ -241,12 +238,11 @@ endi print ============== step14: stop and drop dnode4/dnode5, then remove data dir of dnode4/dnode5 system sh/exec.sh -n dnode4 -s stop -x SIGINT system sh/exec.sh -n dnode5 -s stop -x SIGINT -sleep 3000 +sleep 20000 sql drop dnode $hostname4 sql drop dnode $hostname5 system rm -rf ../../../sim/dnode4/data system rm -rf ../../../sim/dnode5/data -sleep 20000 print ============== step15: alter replica 1 sql alter database $db replica 1 @@ -266,13 +262,13 @@ if $data04 != 2 then return -1 endi -#print ============== step17: start dnode1 and add into cluster, then wait dnode1 ready -#system sh/cfg.sh -n dnode1 -c first -v $hostname2 -#system sh/cfg.sh -n dnode1 -c second -v $hostname3 -# -#system sh/exec.sh -n dnode1 -s start -#sql create dnode $hostname1 -#sleep 20000 +print ============== step17: start dnode1 and add into cluster, then wait dnode1 ready +system sh/cfg.sh -n dnode1 -c first -v $hostname2 +system sh/cfg.sh -n dnode1 -c second -v $hostname3 + +system sh/exec.sh -n dnode1 -s start +sql create dnode $hostname1 +sleep 20000 print ============== step18: alter replica 3 sql alter database $db replica 3 From e51ea2d305b3fef468e894c3728e974f46710d71 Mon Sep 17 00:00:00 2001 From: Hui Li Date: Mon, 13 Jul 2020 15:11:39 +0800 Subject: [PATCH 44/63] [fix bug] --- src/vnode/src/vnodeRead.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c index ff58e219b0..4c7970076c 100644 --- a/src/vnode/src/vnodeRead.c +++ b/src/vnode/src/vnodeRead.c @@ -155,7 +155,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) { pRetrieve->qhandle = htobe64(pRetrieve->qhandle); pRetrieve->free = htons(pRetrieve->free); - vDebug("vgId:%d, QInfo:%p, retrieve msg is disposed", pVnode->vgId, *(void**) pRetrieve->qhandle); + vDebug("vgId:%d, QInfo:%p, retrieve msg is disposed", pVnode->vgId, (void*) pRetrieve->qhandle); memset(pRet, 0, sizeof(SRspRet)); From 1c40d471ae472c643d8ebfbe1e1e9fd89ee34434 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 13 Jul 2020 15:39:45 +0800 Subject: [PATCH 45/63] [TD-913] change some config paras --- packaging/cfg/taos.cfg | 13 +++++-------- src/common/inc/tglobal.h | 2 ++ src/common/src/tglobal.c | 35 ++++++++++++++++++++++++----------- src/inc/taosdef.h | 12 ++++++------ src/mnode/src/mnodeVgroup.c | 6 +++--- src/vnode/src/vnodeMain.c | 2 +- tests/pytest/util/dnodes.py | 4 +++- tests/script/sh/deploy.sh | 2 ++ 8 files changed, 46 insertions(+), 30 deletions(-) diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg index 40b4c43fdd..f652c65f56 100644 --- a/packaging/cfg/taos.cfg +++ b/packaging/cfg/taos.cfg @@ -51,18 +51,15 @@ # number of threads per CPU core # numOfThreadsPerCore 1.0 -# number of vnodes per core in DNode -# numOfVnodesPerCore 8 +# number of vgroups per db +# maxVgroupsPerDb 0 + +# max number of tables per vnode +# maxTablesPerVnode 1000000 # the ratio of threads responsible for querying in the total thread # ratioOfQueryThreads 0.5 -# number of total vnodes in DNode -# numOfTotalVnodes 0 - -# max number of tables per vnode -# maxtablesPerVnode 1000 - # interval of check load balance when the management node is in normal operation # balanceInterval 300 diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index fbdfc84f5f..1d9a6a2949 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -68,7 +68,9 @@ extern int64_t tsMaxRetentWindow; // db parameters in client extern int32_t tsCacheBlockSize; extern int32_t tsBlocksPerVnode; +extern int32_t tsMinTablePerVnode; extern int32_t tsMaxTablePerVnode; +extern int32_t tsTableIncStepPerVnode; extern int32_t tsMaxVgroupsPerDb; extern int16_t tsDaysPerFile; extern int32_t tsDaysToKeep; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index a8ef3f8e8d..9eabe0cbc8 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -38,7 +38,7 @@ uint16_t tsDnodeShellPort = 6030; // udp[6035-6039] tcp[6035] uint16_t tsDnodeDnodePort = 6035; // udp/tcp uint16_t tsSyncPort = 6040; int32_t tsStatusInterval = 1; // second -int16_t tsNumOfVnodesPerCore = 8; +int16_t tsNumOfVnodesPerCore = 32; int16_t tsNumOfTotalVnodes = TSDB_INVALID_VNODE_NUM; int32_t tsNumOfMnodes = 3; int32_t tsEnableVnodeBak = 1; @@ -112,7 +112,10 @@ int16_t tsCompression = TSDB_DEFAULT_COMP_LEVEL; int16_t tsWAL = TSDB_DEFAULT_WAL_LEVEL; int32_t tsReplications = TSDB_DEFAULT_DB_REPLICA_OPTION; int32_t tsMaxVgroupsPerDb = 0; +int32_t tsMinTablePerVnode = TSDB_MIN_TABLES; int32_t tsMaxTablePerVnode = TSDB_DEFAULT_TABLES; +int32_t tsTableIncStepPerVnode = TSDB_TABLES_STEP; + // balance int32_t tsEnableBalance = 1; int32_t tsAlternativeRole = 0; @@ -389,16 +392,6 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); - cfg.option = "numOfVnodesPerCore"; - cfg.ptr = &tsNumOfVnodesPerCore; - cfg.valType = TAOS_CFG_VTYPE_INT16; - cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; - cfg.minValue = 1; - cfg.maxValue = 64; - cfg.ptrLength = 0; - cfg.unitType = TAOS_CFG_UTYPE_NONE; - taosInitConfigOption(cfg); - cfg.option = "numOfTotalVnodes"; cfg.ptr = &tsNumOfTotalVnodes; cfg.valType = TAOS_CFG_VTYPE_INT16; @@ -622,6 +615,26 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "minTablesPerVnode"; + cfg.ptr = &tsMinTablePerVnode; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = TSDB_MIN_TABLES; + cfg.maxValue = TSDB_MAX_TABLES; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + + cfg.option = "tableIncStepPerVnode"; + cfg.ptr = &tsTableIncStepPerVnode; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = TSDB_MIN_TABLES; + cfg.maxValue = TSDB_MAX_TABLES; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + cfg.option = "cache"; cfg.ptr = &tsCacheBlockSize; cfg.valType = TAOS_CFG_VTYPE_INT32; diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index eb3c3abc84..27f472a2b6 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -274,8 +274,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_DEFAULT_PAYLOAD_SIZE 5120 // default payload size, greater than PATH_MAX value #define TSDB_EXTRA_PAYLOAD_SIZE 128 // extra bytes for auth #define TSDB_CQ_SQL_SIZE 1024 -#define TSDB_MAX_VNODES 256 -#define TSDB_MIN_VNODES 50 +#define TSDB_MAX_VNODES 2048 +#define TSDB_MIN_VNODES 256 #define TSDB_INVALID_VNODE_NUM 0 #define TSDB_DNODE_ROLE_ANY 0 @@ -295,10 +295,10 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_MAX_TOTAL_BLOCKS 10000 #define TSDB_DEFAULT_TOTAL_BLOCKS 4 -#define TSDB_MIN_TABLES 4 -#define TSDB_MAX_TABLES 5000000 -#define TSDB_DEFAULT_TABLES 200000 -#define TSDB_TABLES_STEP 10000 +#define TSDB_MIN_TABLES 100 +#define TSDB_MAX_TABLES 10000000 +#define TSDB_DEFAULT_TABLES 1000000 +#define TSDB_TABLES_STEP 1000 #define TSDB_MIN_DAYS_PER_FILE 1 #define TSDB_MAX_DAYS_PER_FILE 3650 diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 5658f4bcbf..48589fb694 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -323,7 +323,7 @@ static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) { if (pDb == NULL) return TSDB_CODE_MND_APP_ERROR; int32_t minIdPoolSize = TSDB_MAX_TABLES; - int32_t maxIdPoolSize = TSDB_MIN_TABLES; + int32_t maxIdPoolSize = tsMinTablePerVnode; for (int32_t v = 0; v < pDb->numOfVgroups; ++v) { SVgObj *pVgroup = pDb->vgList[v]; if (pVgroup == NULL) continue; @@ -347,10 +347,10 @@ static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) { // realloc all vgroups in db int32_t newIdPoolSize; - if (minIdPoolSize * 4 < TSDB_TABLES_STEP) { + if (minIdPoolSize * 4 < tsTableIncStepPerVnode) { newIdPoolSize = minIdPoolSize * 4; } else { - newIdPoolSize = ((minIdPoolSize / TSDB_TABLES_STEP) + 1) * TSDB_TABLES_STEP; + newIdPoolSize = ((minIdPoolSize / tsTableIncStepPerVnode) + 1) * tsTableIncStepPerVnode; } if (newIdPoolSize > tsMaxTablePerVnode) { diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 695a55d476..01e423e5ec 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -59,7 +59,7 @@ int32_t vnodeInitResources() { vnodeInitWriteFp(); vnodeInitReadFp(); - tsDnodeVnodesHash = taosHashInit(TSDB_MAX_VNODES, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true); + tsDnodeVnodesHash = taosHashInit(TSDB_MIN_VNODES, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true); if (tsDnodeVnodesHash == NULL) { vError("failed to init vnode list"); return TSDB_CODE_VND_OUT_OF_MEMORY; diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 0341b3f136..b67f509cc6 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -28,7 +28,9 @@ class TDSimClient: "locale": "en_US.UTF-8", "charset": "UTF-8", "asyncLog": "0", - "maxTablesPerVnode": "4", + "minTablesPerVnode": "4", + "maxTablesPerVnode": "1000", + "tableIncStepPerVnode": "10000", "maxVgroupsPerDb": "1000", "sdbDebugFlag": "143", "rpcDebugFlag": "135", diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index 5573db0739..cbc6edb831 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -139,7 +139,9 @@ echo "clog 2" >> $TAOS_CFG echo "statusInterval 1" >> $TAOS_CFG echo "numOfTotalVnodes 4" >> $TAOS_CFG echo "maxVgroupsPerDb 4" >> $TAOS_CFG +echo "minTablesPerVnode 4" >> $TAOS_CFG echo "maxTablesPerVnode 1000" >> $TAOS_CFG +echo "tableIncStepPerVnode 10000" >> $TAOS_CFG echo "asyncLog 0" >> $TAOS_CFG echo "numOfMnodes 1" >> $TAOS_CFG echo "locale en_US.UTF-8" >> $TAOS_CFG From a531f81bec4e11380923de4b3e3ddce704adaaff Mon Sep 17 00:00:00 2001 From: Hui Li Date: Mon, 13 Jul 2020 16:12:25 +0800 Subject: [PATCH 46/63] [temp not test drop dnode] --- tests/script/unique/cluster/cluster_main.sim | 77 ++++++++++++------- tests/script/unique/cluster/cluster_main1.sim | 35 +++++---- tests/script/unique/cluster/cluster_main2.sim | 35 +++++---- 3 files changed, 86 insertions(+), 61 deletions(-) diff --git a/tests/script/unique/cluster/cluster_main.sim b/tests/script/unique/cluster/cluster_main.sim index da4f709f46..4c02d416f3 100644 --- a/tests/script/unique/cluster/cluster_main.sim +++ b/tests/script/unique/cluster/cluster_main.sim @@ -71,7 +71,7 @@ print ============== step3: create stable stb1 $stb = stb1 sql create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(8)) -print ============== step4: start 10 client1/ 10 client2/ 10 client3/ 10 client4/ 1 client5 +print ============== step4: start back client1_0.sim run_back unique/cluster/client1_0.sim #run_back unique/cluster/client1_1.sim #run_back unique/cluster/client1_2.sim @@ -106,27 +106,43 @@ endi print wait for a while to let clients start insert data sleep 5000 -$loop_cnt = 0 -loop_cluster_do: -print **** **** **** START loop cluster do (loop_cnt: $loop_cnt )**** **** **** **** -print ============== step5: start dnode4/dnode5 and add into cluster, then wait ready -system sh/exec.sh -n dnode4 -s start -system sh/exec.sh -n dnode5 -s start +print ============== step4-1: add dnode4/dnode5 into cluster sql create dnode $hostname4 sql create dnode $hostname5 -sleep 5000 - - -print ============== step6: stop and drop dnode1, then remove data dir of dnode1 -system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 5000 -sql drop dnode $hostname1 -sleep 5000 - -system rm -rf ../../../sim/dnode1/data +$loop_cnt = 0 +loop_cluster_do: +print **** **** **** START loop cluster do (loop_cnt: $loop_cnt )**** **** **** **** +print ============== step5: start dnode4/dnode5 +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start sleep 20000 +print ============== step6: stop dnode1 +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 10000 +#sql drop dnode $hostname1 +#sleep 5000 + +#system rm -rf ../../../sim/dnode1/data +#sleep 20000 + +sql show mnodes +print show mnodes +print rows: $rows +print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 +print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 +print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3 +print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4 +print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5 +print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6 +print $data0_7 $data1_7 $data2_7 $data3_7 $data4_7 +print $data0_8 $data1_8 $data2_8 $data3_8 $data4_8 +print $data0_9 $data1_9 $data2_9 $data3_9 $data4_9 + +print ============== step6-1: restart dnode1 +system sh/exec.sh -n dnode1 -s start +sleep 10000 sql show mnodes print show mnodes print rows: $rows @@ -235,14 +251,17 @@ if $data04 != 2 then return -1 endi -print ============== step14: stop and drop dnode4/dnode5, then remove data dir of dnode4/dnode5 +print ============== step14: stop dnode4/dnode5 system sh/exec.sh -n dnode4 -s stop -x SIGINT system sh/exec.sh -n dnode5 -s stop -x SIGINT sleep 20000 -sql drop dnode $hostname4 -sql drop dnode $hostname5 -system rm -rf ../../../sim/dnode4/data -system rm -rf ../../../sim/dnode5/data +#system sh/exec.sh -n dnode4 -s start +#system sh/exec.sh -n dnode5 -s start +#sleep 10000 +#sql drop dnode $hostname4 +#sql drop dnode $hostname5 +#system rm -rf ../../../sim/dnode4/data +#system rm -rf ../../../sim/dnode5/data print ============== step15: alter replica 1 sql alter database $db replica 1 @@ -262,13 +281,13 @@ if $data04 != 2 then return -1 endi -print ============== step17: start dnode1 and add into cluster, then wait dnode1 ready -system sh/cfg.sh -n dnode1 -c first -v $hostname2 -system sh/cfg.sh -n dnode1 -c second -v $hostname3 - -system sh/exec.sh -n dnode1 -s start -sql create dnode $hostname1 -sleep 20000 +#print ============== step17: start dnode1 and add into cluster, then wait dnode1 ready +#system sh/cfg.sh -n dnode1 -c first -v $hostname2 +#system sh/cfg.sh -n dnode1 -c second -v $hostname3 +# +#system sh/exec.sh -n dnode1 -s start +#sql create dnode $hostname1 +#sleep 20000 print ============== step18: alter replica 3 sql alter database $db replica 3 diff --git a/tests/script/unique/cluster/cluster_main1.sim b/tests/script/unique/cluster/cluster_main1.sim index 343924dfee..82e1e2be83 100644 --- a/tests/script/unique/cluster/cluster_main1.sim +++ b/tests/script/unique/cluster/cluster_main1.sim @@ -104,16 +104,19 @@ endi print wait for a while to let clients start insert data sleep 5000 -$loop_cnt = 0 -loop_cluster_do: -print **** **** **** START loop cluster do (loop_cnt: $loop_cnt )**** **** **** **** -print ============== step5: start dnode4/dnode5 and add into cluster, then wait ready -system sh/exec.sh -n dnode4 -s start -system sh/exec.sh -n dnode5 -s start +print ============== step4-1: add dnode4/dnode5 into cluster sql create dnode $hostname4 sql create dnode $hostname5 sleep 5000 +$loop_cnt = 0 +loop_cluster_do: +print **** **** **** START loop cluster do (loop_cnt: $loop_cnt )**** **** **** **** +print ============== step5: start dnode4/dnode5 +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start +sleep 20000 + print ============== step6: stop dnode1 system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 10000 @@ -207,9 +210,9 @@ print ============== step11: stop dnode4, then wait sync end system sh/exec.sh -n dnode4 -s stop -x SIGINT sleep 20000 -print ============== step12: restart dnode4, then wait sync end -system sh/exec.sh -n dnode4 -s start -sleep 20000 +#print ============== step12: restart dnode4, then wait sync end +#system sh/exec.sh -n dnode4 -s start +#sleep 20000 sql show mnodes print show mnodes print rows: $rows @@ -243,15 +246,15 @@ if $replica != 2 then return -1 endi -print ============== step14: drop dnode4, then remove data dir -sql drop dnode $hostname4 +print ============== step14: stop dnode5 +system sh/exec.sh -n dnode5 -s stop -x SIGINT sleep 20000 -system rm -rf ../../../sim/dnode4/data +#system rm -rf ../../../sim/dnode5/data -print ============== step14-1: drop dnode5, then remove data dir -sql drop dnode $hostname5 -sleep 20000 -system rm -rf ../../../sim/dnode5/data +#print ============== step14-1: drop dnode5, then remove data dir +#sql drop dnode $hostname5 +#sleep 20000 +#system rm -rf ../../../sim/dnode5/data print ============== step15: alter replica 1 sql alter database $db replica 1 diff --git a/tests/script/unique/cluster/cluster_main2.sim b/tests/script/unique/cluster/cluster_main2.sim index 83934da457..e5fe3f2a21 100644 --- a/tests/script/unique/cluster/cluster_main2.sim +++ b/tests/script/unique/cluster/cluster_main2.sim @@ -108,16 +108,19 @@ endi print wait for a while to let clients start insert data sleep 5000 -$loop_cnt = 0 -loop_cluster_do: -print **** **** **** START loop cluster do (loop_cnt: $loop_cnt )**** **** **** **** -print ============== step5: start dnode4/dnode5 and add into cluster, then wait ready -system sh/exec.sh -n dnode4 -s start -system sh/exec.sh -n dnode5 -s start +print ============== step4-1: add dnode4/dnode5 into cluster sql create dnode $hostname4 sql create dnode $hostname5 sleep 5000 + +$loop_cnt = 0 +loop_cluster_do: +print **** **** **** START loop cluster do (loop_cnt: $loop_cnt )**** **** **** **** +print ============== step5: start dnode4/dnode5 +system sh/exec.sh -n dnode4 -s start +system sh/exec.sh -n dnode5 -s start + print ============== step6: stop dnode1 system sh/exec.sh -n dnode1 -s stop -x SIGINT sleep 10000 @@ -211,9 +214,9 @@ print ============== step11: stop dnode4, then wait sync end system sh/exec.sh -n dnode4 -s stop -x SIGINT sleep 20000 -print ============== step12: restart dnode4, then wait sync end -system sh/exec.sh -n dnode4 -s start -sleep 20000 +#print ============== step12: restart dnode4, then wait sync end +#system sh/exec.sh -n dnode4 -s start +#sleep 20000 sql show mnodes print show mnodes print rows: $rows @@ -247,15 +250,15 @@ if $replica != 2 then return -1 endi -print ============== step14: drop dnode4, then remove data dir -sql drop dnode $hostname4 +print ============== step14: drop dnode5, then remove data dir +system sh/exec.sh -n dnode5 -s stop -x SIGINT sleep 20000 -system rm -rf ../../../sim/dnode4/data +#system rm -rf ../../../sim/dnode5/data -print ============== step14-1: drop dnode5, then remove data dir -sql drop dnode $hostname5 -sleep 20000 -system rm -rf ../../../sim/dnode5/data +#print ============== step14-1: drop dnode5, then remove data dir +#sql drop dnode $hostname5 +#sleep 20000 +#system rm -rf ../../../sim/dnode5/data print ============== step15: alter replica 1 sql alter database $db replica 1 From c019bc98fc01861b8ee32587a5734243d5e2341a Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 13 Jul 2020 16:20:20 +0800 Subject: [PATCH 47/63] update tdengineTest.c for performace test --- tests/CMakeLists.txt | 1 + tests/comparisonTest/tdengine/CMakeLists.txt | 12 +++++ tests/comparisonTest/tdengine/tdengineTest.c | 49 +++++++++++--------- 3 files changed, 41 insertions(+), 21 deletions(-) create mode 100644 tests/comparisonTest/tdengine/CMakeLists.txt diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a6070a2fc1..4e7e9a87ea 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -12,3 +12,4 @@ SET(CMAKE_VERBOSE_MAKEFILE ON) ADD_SUBDIRECTORY(examples/c) ADD_SUBDIRECTORY(tsim) ADD_SUBDIRECTORY(test/c) +ADD_SUBDIRECTORY(comparisonTest/tdengine) diff --git a/tests/comparisonTest/tdengine/CMakeLists.txt b/tests/comparisonTest/tdengine/CMakeLists.txt new file mode 100644 index 0000000000..ccdeefcdaf --- /dev/null +++ b/tests/comparisonTest/tdengine/CMakeLists.txt @@ -0,0 +1,12 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +PROJECT(TDengine) + +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc) +INCLUDE_DIRECTORIES(${TD_OS_DIR}/inc) + +IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) + add_executable(tdengineTest tdengineTest.c) + target_link_libraries(tdengineTest taos_static tutil common pthread) +ENDIF() diff --git a/tests/comparisonTest/tdengine/tdengineTest.c b/tests/comparisonTest/tdengine/tdengineTest.c index a2b048214f..de92526337 100644 --- a/tests/comparisonTest/tdengine/tdengineTest.c +++ b/tests/comparisonTest/tdengine/tdengineTest.c @@ -7,6 +7,7 @@ #include #include #include +#include typedef struct { char sql[256]; @@ -123,19 +124,21 @@ void writeDataImp(void *param) { if (taos == NULL) taos_error(taos); - int code = taos_query(taos, "use db"); + TAOS_RES* result = taos_query(taos, "use db"); + int32_t code = taos_errno(result); if (code != 0) { taos_error(taos); } + taos_free_result(result); - char sql[65000]; + char *sql = calloc(1, 8*1024*1024); int sqlLen = 0; int lastMachineid = 0; int counter = 0; int totalRecords = 0; for (int j = pThread->sID; j <= pThread->eID; j++) { - char fileName[256]; + char fileName[300]; sprintf(fileName, "%s/testdata%d.csv", arguments.dataDir, j); FILE *fp = fopen(fileName, "r"); @@ -162,7 +165,7 @@ void writeDataImp(void *param) { int64_t timestamp; int temperature; float humidity; - sscanf(line, "%d%s%d%lld%d%f", &machineid, machinename, &machinegroup, ×tamp, &temperature, &humidity); + sscanf(line, "%d%s%d%" PRId64 "%d%f", &machineid, machinename, &machinegroup, ×tamp, &temperature, &humidity); if (counter == 0) { sqlLen = sprintf(sql, "insert into"); @@ -174,14 +177,16 @@ void writeDataImp(void *param) { machineid, machineid, machinename, machinegroup); } - sqlLen += sprintf(sql + sqlLen, "(%lld,%d,%f)", timestamp, temperature, humidity); + sqlLen += sprintf(sql + sqlLen, "(%" PRId64 ",%d,%f)", timestamp, temperature, humidity); counter++; if (counter >= arguments.rowsPerRequest) { - int code = taos_query(taos, sql); + TAOS_RES *result = taos_query(taos, sql); + int32_t code = taos_errno(result); if (code != 0) { - printf("thread:%d error:%d reason:%s\n", pThread->pid, code, taos_errstr(taos)); + printf("thread:%d error:%d reason:%s\n", pThread->threadId, code, taos_errstr(taos)); } + taos_free_result(result); totalRecords += counter; counter = 0; @@ -194,15 +199,18 @@ void writeDataImp(void *param) { } if (counter > 0) { - int code = taos_query(taos, sql); + TAOS_RES *result = taos_query(taos, sql); + int32_t code = taos_errno(result); if (code != 0) { - printf("thread:%d error:%d reason:%s\n", pThread->pid, code, taos_errstr(taos)); + printf("thread:%d error:%d reason:%s\n", pThread->threadId, code, taos_errstr(taos)); } + taos_free_result(result); totalRecords += counter; } __sync_fetch_and_add(&statis.totalRows, totalRecords); + free(sql); } void writeData() { @@ -215,19 +223,23 @@ void writeData() { taos_init(); void *taos = taos_connect("127.0.0.1", "root", "taosdata", NULL, 0); - if (taos == NULL) - taos_error(taos); + if (taos == NULL) taos_error(taos); - int code = taos_query(taos, "create database if not exists db"); + TAOS_RES *result = taos_query(taos, "create database if not exists db"); + int32_t code = taos_errno(result); if (code != 0) { taos_error(taos); } + taos_free_result(result); - code = taos_query(taos, "create table if not exists db.devices(ts timestamp, temperature int, humidity float) " - "tags(devid int, devname binary(16), devgroup int)"); + result = taos_query(taos, + "create table if not exists db.devices(ts timestamp, temperature int, humidity float) " + "tags(devid int, devname binary(16), devgroup int)"); + code = taos_errno(result); if (code != 0) { taos_error(taos); } + taos_free_result(result); int64_t st = getTimeStampMs(); @@ -292,17 +304,12 @@ void readData() { int64_t st = getTimeStampMs(); - int code = taos_query(taos, line); + TAOS_RES *result = taos_query(taos, line); + int32_t code = taos_errno(result); if (code != 0) { taos_error(taos); } - void *result = taos_use_result(taos); - if (result == NULL) { - printf("failed to get result, reason:%s\n", taos_errstr(taos)); - exit(1); - } - TAOS_ROW row; int rows = 0; //int num_fields = taos_field_count(taos); From d892040728a3e97efca4de0046de756f6d3a7741 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 13 Jul 2020 16:41:58 +0800 Subject: [PATCH 48/63] [TD-913] --- src/common/src/tglobal.c | 2 +- src/inc/taosdef.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 9eabe0cbc8..b56e27fae7 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -112,7 +112,7 @@ int16_t tsCompression = TSDB_DEFAULT_COMP_LEVEL; int16_t tsWAL = TSDB_DEFAULT_WAL_LEVEL; int32_t tsReplications = TSDB_DEFAULT_DB_REPLICA_OPTION; int32_t tsMaxVgroupsPerDb = 0; -int32_t tsMinTablePerVnode = TSDB_MIN_TABLES; +int32_t tsMinTablePerVnode = 100; int32_t tsMaxTablePerVnode = TSDB_DEFAULT_TABLES; int32_t tsTableIncStepPerVnode = TSDB_TABLES_STEP; diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 27f472a2b6..7fdccfd6d4 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -295,7 +295,7 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); #define TSDB_MAX_TOTAL_BLOCKS 10000 #define TSDB_DEFAULT_TOTAL_BLOCKS 4 -#define TSDB_MIN_TABLES 100 +#define TSDB_MIN_TABLES 4 #define TSDB_MAX_TABLES 10000000 #define TSDB_DEFAULT_TABLES 1000000 #define TSDB_TABLES_STEP 1000 From 8c472009b680ebc0bcf0e7f5dc1f5efef791dd4e Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Mon, 13 Jul 2020 16:56:13 +0800 Subject: [PATCH 49/63] fix td-834 fix bug: parser/commit.sim cause taosd crash when execute with 'alloc-random-fail' --- src/query/inc/qUtil.h | 2 +- src/query/src/qExecutor.c | 33 +++++++++++++++++++++++++++------ src/query/src/qUtil.c | 16 ++++++++++++---- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/query/inc/qUtil.h b/src/query/inc/qUtil.h index 9b818b367f..8fe3c0f495 100644 --- a/src/query/inc/qUtil.h +++ b/src/query/inc/qUtil.h @@ -37,7 +37,7 @@ SWindowResult *getWindowResult(SWindowResInfo *pWindowResInfo, int32_t slot); #define curTimeWindow(_winres) ((_winres)->curIndex) bool isWindowResClosed(SWindowResInfo *pWindowResInfo, int32_t slot); -void createQueryResultInfo(SQuery *pQuery, SWindowResult *pResultRow, bool isSTableQuery, SPosInfo *posInfo, size_t interBufSize); +int32_t createQueryResultInfo(SQuery *pQuery, SWindowResult *pResultRow, bool isSTableQuery, SPosInfo *posInfo, size_t interBufSize); char *getPosInResultPage(SQueryRuntimeEnv *pRuntimeEnv, int32_t columnIndex, SWindowResult *pResult); diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 1d9068be16..95fc838842 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -2978,16 +2978,23 @@ void switchCtxOrder(SQueryRuntimeEnv *pRuntimeEnv) { } } -void createQueryResultInfo(SQuery *pQuery, SWindowResult *pResultRow, bool isSTableQuery, SPosInfo *posInfo, size_t interBufSize) { +int32_t createQueryResultInfo(SQuery *pQuery, SWindowResult *pResultRow, bool isSTableQuery, SPosInfo *posInfo, size_t interBufSize) { int32_t numOfCols = pQuery->numOfOutput; pResultRow->resultInfo = calloc((size_t)numOfCols, sizeof(SResultInfo)); + if (pResultRow->resultInfo == NULL) { + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } pResultRow->pos = *posInfo; char* buf = calloc(1, interBufSize); + if (buf == NULL) { + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } // set the intermediate result output buffer setWindowResultInfo(pResultRow->resultInfo, pQuery, isSTableQuery, buf); + return TSDB_CODE_SUCCESS; } void resetCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv) { @@ -3368,7 +3375,10 @@ static STableQueryInfo *createTableQueryInfo(SQueryRuntimeEnv *pRuntimeEnv, void if (QUERY_IS_INTERVAL_QUERY(pQuery) || pRuntimeEnv->groupbyNormalCol) { int32_t initialSize = 16; int32_t initialThreshold = 100; - initWindowResInfo(&pTableQueryInfo->windowResInfo, pRuntimeEnv, initialSize, initialThreshold, TSDB_DATA_TYPE_INT); + int32_t code = initWindowResInfo(&pTableQueryInfo->windowResInfo, pRuntimeEnv, initialSize, initialThreshold, TSDB_DATA_TYPE_INT); + if (code != TSDB_CODE_SUCCESS) { + return NULL; + } } else { // in other aggregate query, do not initialize the windowResInfo } @@ -4189,7 +4199,10 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo type = TSDB_DATA_TYPE_INT; // group id } - initWindowResInfo(&pRuntimeEnv->windowResInfo, pRuntimeEnv, 32, 4096, type); + code = initWindowResInfo(&pRuntimeEnv->windowResInfo, pRuntimeEnv, 32, 4096, type); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } } else if (pRuntimeEnv->groupbyNormalCol || QUERY_IS_INTERVAL_QUERY(pQuery)) { @@ -4206,7 +4219,10 @@ int32_t doInitQInfo(SQInfo *pQInfo, STSBuf *pTsBuf, void *tsdb, int32_t vgId, bo type = TSDB_DATA_TYPE_TIMESTAMP; } - initWindowResInfo(&pRuntimeEnv->windowResInfo, pRuntimeEnv, rows, 4096, type); + code = initWindowResInfo(&pRuntimeEnv->windowResInfo, pRuntimeEnv, rows, 4096, type); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } if (pQuery->fillType != TSDB_FILL_NONE && !isPointInterpoQuery(pQuery)) { @@ -5737,6 +5753,10 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, size_t s = taosArrayGetSize(pa); SArray* p1 = taosArrayInit(s, POINTER_BYTES); + if (p1 == NULL) { + goto _cleanup; + } + taosArrayPush(pQInfo->tableqinfoGroupInfo.pGroupList, &p1); for(int32_t j = 0; j < s; ++j) { void* pTable = taosArrayGetP(pa, j); @@ -5751,13 +5771,14 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList, void* buf = pQInfo->pBuf + index * sizeof(STableQueryInfo); STableQueryInfo* item = createTableQueryInfo(&pQInfo->runtimeEnv, pTable, window, buf); + if (item == NULL) { + goto _cleanup; + } item->groupIndex = i; taosArrayPush(p1, &item); taosHashPut(pQInfo->tableqinfoGroupInfo.map, &id->tid, sizeof(id->tid), &item, POINTER_BYTES); index += 1; } - - taosArrayPush(pQInfo->tableqinfoGroupInfo.pGroupList, &p1); } pQInfo->arrTableIdInfo = taosArrayInit(tableIndex, sizeof(STableIdInfo)); diff --git a/src/query/src/qUtil.c b/src/query/src/qUtil.c index dce2c24ea0..acdc46fcc1 100644 --- a/src/query/src/qUtil.c +++ b/src/query/src/qUtil.c @@ -50,9 +50,15 @@ int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRun // use the pointer arraylist pWindowResInfo->pResult = calloc(threshold, sizeof(SWindowResult)); + if (pWindowResInfo->pResult == NULL) { + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } for (int32_t i = 0; i < pWindowResInfo->capacity; ++i) { SPosInfo posInfo = {-1, -1}; - createQueryResultInfo(pRuntimeEnv->pQuery, &pWindowResInfo->pResult[i], pRuntimeEnv->stableQuery, &posInfo, pRuntimeEnv->interBufSize); + int32_t code = createQueryResultInfo(pRuntimeEnv->pQuery, &pWindowResInfo->pResult[i], pRuntimeEnv->stableQuery, &posInfo, pRuntimeEnv->interBufSize); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } return TSDB_CODE_SUCCESS; @@ -76,9 +82,11 @@ void cleanupTimeWindowInfo(SWindowResInfo *pWindowResInfo, int32_t numOfCols) { return; } - for (int32_t i = 0; i < pWindowResInfo->capacity; ++i) { - SWindowResult *pResult = &pWindowResInfo->pResult[i]; - destroyTimeWindowRes(pResult, numOfCols); + if (pWindowResInfo->pResult != NULL) { + for (int32_t i = 0; i < pWindowResInfo->capacity; ++i) { + SWindowResult *pResult = &pWindowResInfo->pResult[i]; + destroyTimeWindowRes(pResult, numOfCols); + } } taosHashCleanup(pWindowResInfo->hashList); From 452e702a15f2389c302592f6db892289beb6477e Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 13 Jul 2020 17:05:54 +0800 Subject: [PATCH 50/63] reset msg while create vgroup --- src/mnode/src/mnodeVgroup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 48589fb694..d48b8997e5 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -471,6 +471,8 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) { } pMsg->expected = pVgroup->numOfVnodes; + pMsg->successed = 0; + pMsg->received = 0; mnodeSendCreateVgroupMsg(pVgroup, pMsg); return TSDB_CODE_MND_ACTION_IN_PROGRESS; @@ -836,6 +838,8 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) { pVgroup->vgId, tstrerror(rpcMsg->code), mnodeMsg->received, mnodeMsg->successed, mnodeMsg->expected, mnodeMsg->rpcMsg.handle, rpcMsg->ahandle); + assert(mnodeMsg->received <= mnodeMsg->expected); + if (mnodeMsg->received != mnodeMsg->expected) return; if (mnodeMsg->received == mnodeMsg->successed) { From 6e5cb647db521ef9485394dbd7a4398ede3f2f01 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 13 Jul 2020 17:10:33 +0800 Subject: [PATCH 51/63] scripts --- tests/script/tmp/prepare.sim | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/script/tmp/prepare.sim b/tests/script/tmp/prepare.sim index 85146bd4c3..459f6e7665 100644 --- a/tests/script/tmp/prepare.sim +++ b/tests/script/tmp/prepare.sim @@ -25,10 +25,15 @@ system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 20 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 20 system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 20 -system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 20 -system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 20 -system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 20 -system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 20 +system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 2 +system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 2 +system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 2 +system sh/cfg.sh -n dnode4 -c maxVgroupsPerDb -v 2 + +system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 100000 +system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 100000 +system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 100000 +system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 100000 system sh/cfg.sh -n dnode1 -c http -v 1 system sh/cfg.sh -n dnode2 -c http -v 1 From d496869ee72141e2511d90df47613b10c0f7a375 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 13 Jul 2020 18:04:52 +0800 Subject: [PATCH 52/63] [td-225] opt query perf --- src/client/src/tscAsync.c | 36 ++++++++++--------- src/client/src/tscFunctionImpl.c | 36 +++++++++++++------ src/client/src/tscUtil.c | 9 ++--- src/query/inc/tsqlfunction.h | 3 +- src/query/src/qExecutor.c | 61 +++++++++++++++++--------------- src/tsdb/src/tsdbRead.c | 10 +++++- 6 files changed, 93 insertions(+), 62 deletions(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 17998e1981..7371a8a578 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -45,6 +45,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const pSql->pTscObj = pObj; pSql->maxRetry = TSDB_MAX_REPLICA_NUM; pSql->fp = fp; + pSql->fetchFp = fp; pSql->sqlstr = calloc(1, sqlLen + 1); if (pSql->sqlstr == NULL) { @@ -159,7 +160,7 @@ static void tscProcessAsyncRetrieveImpl(void *param, TAOS_RES *tres, int numOfRo pRes->code = numOfRows; } - tscQueueAsyncError(pSql->fetchFp, param, pRes->code); + tscQueueAsyncRes(pSql); return; } @@ -346,31 +347,32 @@ void tscProcessFetchRow(SSchedMsg *pMsg) { void tscProcessAsyncRes(SSchedMsg *pMsg) { SSqlObj *pSql = (SSqlObj *)pMsg->ahandle; - SSqlCmd *pCmd = &pSql->cmd; +// SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; - void *taosres = pSql; +// void *taosres = pSql; // pCmd may be released, so cache pCmd->command - int cmd = pCmd->command; - int code = pRes->code; +// int cmd = pCmd->command; +// int code = pRes->code; // in case of async insert, restore the user specified callback function - bool shouldFree = tscShouldBeFreed(pSql); +// bool shouldFree = tscShouldBeFreed(pSql); - if (cmd == TSDB_SQL_INSERT) { - assert(pSql->fp != NULL); - pSql->fp = pSql->fetchFp; - } +// if (pCmd->command == TSDB_SQL_INSERT) { +// assert(pSql->fp != NULL); + assert(pSql->fp != NULL && pSql->fetchFp != NULL); +// } - if (pSql->fp) { - (*pSql->fp)(pSql->param, taosres, code); - } +// if (pSql->fp) { + pSql->fp = pSql->fetchFp; + (*pSql->fp)(pSql->param, pSql, pRes->code); +// } - if (shouldFree) { - tscDebug("%p sqlObj is automatically freed in async res", pSql); - tscFreeSqlObj(pSql); - } +// if (shouldFree) { +// tscDebug("%p sqlObj is automatically freed in async res", pSql); +// tscFreeSqlObj(pSql); +// } } static void tscProcessAsyncError(SSchedMsg *pMsg) { diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index 8e6878f449..1ec84f023a 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -708,6 +708,11 @@ static int32_t firstDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY en if (pCtx->order == TSDB_ORDER_DESC) { return BLK_DATA_NO_NEEDED; } + + // not initialized yet, it is the first block, load it. + if (pCtx->aOutputBuf == NULL) { + return BLK_DATA_ALL_NEEDED; + } SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes); if (pInfo->hasResult != DATA_SET_FLAG) { @@ -721,7 +726,12 @@ static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end if (pCtx->order != pCtx->param[0].i64Key) { return BLK_DATA_NO_NEEDED; } - + + // not initialized yet, it is the first block, load it. + if (pCtx->aOutputBuf == NULL) { + return BLK_DATA_ALL_NEEDED; + } + SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes); if (pInfo->hasResult != DATA_SET_FLAG) { return BLK_DATA_ALL_NEEDED; @@ -1540,6 +1550,8 @@ static void first_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t in * to decide if the value is earlier than current intermediate result */ static void first_dist_function(SQLFunctionCtx *pCtx) { + assert(pCtx->size > 0); + if (pCtx->size == 0) { return; } @@ -1554,7 +1566,12 @@ static void first_dist_function(SQLFunctionCtx *pCtx) { } int32_t notNullElems = 0; - + + // data block is discard, not loaded, do not need to check it + if (!pCtx->preAggVals.dataBlockLoaded) { + return; + } + // find the first not null value for (int32_t i = 0; i < pCtx->size; ++i) { char *data = GET_INPUT_CHAR_INDEX(pCtx, i); @@ -1575,10 +1592,6 @@ static void first_dist_function(SQLFunctionCtx *pCtx) { } static void first_dist_function_f(SQLFunctionCtx *pCtx, int32_t index) { - if (pCtx->size == 0) { - return; - } - char *pData = GET_INPUT_CHAR_INDEX(pCtx, index); if (pCtx->hasNull && isNull(pData, pCtx->inputType)) { return; @@ -1706,10 +1719,6 @@ static void last_data_assign_impl(SQLFunctionCtx *pCtx, char *pData, int32_t ind } static void last_dist_function(SQLFunctionCtx *pCtx) { - if (pCtx->size == 0) { - return; - } - /* * 1. for scan data in asc order, no need to check data * 2. for data blocks that are not loaded, no need to check data @@ -1717,7 +1726,12 @@ static void last_dist_function(SQLFunctionCtx *pCtx) { if (pCtx->order != pCtx->param[0].i64Key) { return; } - + + // data block is discard, not loaded, do not need to check it + if (!pCtx->preAggVals.dataBlockLoaded) { + return; + } + int32_t notNullElems = 0; for (int32_t i = pCtx->size - 1; i >= 0; --i) { diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index c4641afbf3..24c78f2534 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1648,6 +1648,7 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm } pNew->fp = fp; + pNew->fetchFp = fp; pNew->param = param; pNew->maxRetry = TSDB_MAX_REPLICA_NUM; @@ -1803,6 +1804,8 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void } pNew->fp = fp; + pNew->fetchFp = fp; + pNew->param = param; pNew->maxRetry = TSDB_MAX_REPLICA_NUM; @@ -2041,10 +2044,8 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) { // set the callback function pSql->fp = fp; - int32_t ret = tscProcessSql(pSql); - if (ret == TSDB_CODE_SUCCESS) { - return; - } else {// todo check for failure + if (tscProcessSql(pSql) != 0) { + break; } } } diff --git a/src/query/inc/tsqlfunction.h b/src/query/inc/tsqlfunction.h index 6a4b9874d7..e57cb26456 100644 --- a/src/query/inc/tsqlfunction.h +++ b/src/query/inc/tsqlfunction.h @@ -125,7 +125,8 @@ typedef struct SArithmeticSupport { } SArithmeticSupport; typedef struct SQLPreAggVal { - bool isSet; + bool isSet; // statistics info set or not + bool dataBlockLoaded; // data block is loaded or not SDataStatis statis; } SQLPreAggVal; diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 841e75249f..26b8454594 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -1358,6 +1358,8 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, TSKEY pCtx->preAggVals.isSet = false; } + pCtx->preAggVals.dataBlockLoaded = (inputData != NULL); + // limit/offset query will affect this value pCtx->startOffset = QUERY_IS_ASC_QUERY(pQuery) ? pQuery->pos:0; pCtx->size = QUERY_IS_ASC_QUERY(pQuery) ? pBlockInfo->rows - pQuery->pos : pQuery->pos + 1; @@ -1928,7 +1930,7 @@ char *getPosInResultPage(SQueryRuntimeEnv *pRuntimeEnv, int32_t columnIndex, SWi pQuery->pSelectExpr[columnIndex].bytes * realRowId; } -#define IS_PREFILTER_TYPE(_t) ((_t) != TSDB_DATA_TYPE_DOUBLE && (_t) != TSDB_DATA_TYPE_FLOAT) +#define IS_PREFILTER_TYPE(_t) ((_t) != TSDB_DATA_TYPE_BINARY && (_t) != TSDB_DATA_TYPE_NCHAR) static bool needToLoadDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis *pDataStatis, SQLFunctionCtx *pCtx, int32_t numOfRows) { @@ -1948,13 +1950,14 @@ static bool needToLoadDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis *pDat } } + // no statistics data if (index == -1) { - continue; + return true; } // not support pre-filter operation on binary/nchar data type if (!IS_PREFILTER_TYPE(pFilterInfo->info.type)) { - continue; + return true; } // all points in current column are NULL, no need to check its boundary value @@ -2203,7 +2206,6 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { summary->totalBlocks += 1; if (IS_QUERY_KILLED(GET_QINFO_ADDR(pRuntimeEnv))) { - finalizeQueryResult(pRuntimeEnv); // clean up allocated resource during query longjmp(pRuntimeEnv->env, TSDB_CODE_TSC_QUERY_CANCELLED); } @@ -3357,12 +3359,10 @@ void destroyTableQueryInfo(STableQueryInfo *pTableQueryInfo, int32_t numOfCols) cleanupTimeWindowInfo(&pTableQueryInfo->windowResInfo, numOfCols); } -#define SET_CURRENT_QUERY_TABLE_INFO(_runtime, _tableInfo) \ - do { \ - SQuery *_query = (_runtime)->pQuery; \ - _query->current = _tableInfo; \ - assert((((_tableInfo)->lastKey >= (_tableInfo)->win.skey) && QUERY_IS_ASC_QUERY(_query)) || \ - (((_tableInfo)->lastKey <= (_tableInfo)->win.skey) && !QUERY_IS_ASC_QUERY(_query))); \ +#define CHECK_QUERY_TIME_RANGE(_q, _tableInfo) \ + do { \ + assert((((_tableInfo)->lastKey >= (_tableInfo)->win.skey) && QUERY_IS_ASC_QUERY(_q)) || \ + (((_tableInfo)->lastKey <= (_tableInfo)->win.skey) && !QUERY_IS_ASC_QUERY(_q))); \ } while (0) /** @@ -4212,6 +4212,23 @@ static void enableExecutionForNextTable(SQueryRuntimeEnv *pRuntimeEnv) { } } +static FORCE_INLINE void setEnvForEachBlock(SQInfo* pQInfo, STableQueryInfo* pTableQueryInfo, SDataBlockInfo* pBlockInfo) { + SQueryRuntimeEnv* pRuntimeEnv = &pQInfo->runtimeEnv; + SQuery* pQuery = pQInfo->runtimeEnv.pQuery; + int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); + + if (!QUERY_IS_INTERVAL_QUERY(pQuery)) { + setExecutionContext(pQInfo, pTableQueryInfo->groupIndex, pBlockInfo->window.ekey + step); + } else { // interval query + TSKEY nextKey = pBlockInfo->window.skey; + setIntervalQueryRange(pQInfo, nextKey); + + if (pRuntimeEnv->hasTagResults || pRuntimeEnv->pTSBuf != NULL) { + setAdditionalInfo(pQInfo, pTableQueryInfo->pTable, pTableQueryInfo); + } + } +} + static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) { SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; SQuery* pQuery = pRuntimeEnv->pQuery; @@ -4226,6 +4243,7 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) { while (tsdbNextDataBlock(pQueryHandle)) { summary->totalBlocks += 1; + if (IS_QUERY_KILLED(pQInfo)) { longjmp(pRuntimeEnv->env, TSDB_CODE_TSC_QUERY_CANCELLED); } @@ -4236,24 +4254,16 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) { break; } - assert(*pTableQueryInfo != NULL); - SET_CURRENT_QUERY_TABLE_INFO(pRuntimeEnv, *pTableQueryInfo); + pQuery->current = *pTableQueryInfo; + CHECK_QUERY_TIME_RANGE(pQuery, *pTableQueryInfo); if (!pRuntimeEnv->groupbyNormalCol) { - if (!QUERY_IS_INTERVAL_QUERY(pQuery)) { - setExecutionContext(pQInfo, (*pTableQueryInfo)->groupIndex, blockInfo.window.ekey + step); - } else { // interval query - TSKEY nextKey = blockInfo.window.skey; - setIntervalQueryRange(pQInfo, nextKey); - - if (pRuntimeEnv->hasTagResults || pRuntimeEnv->pTSBuf != NULL) { - setAdditionalInfo(pQInfo, (*pTableQueryInfo)->pTable, *pTableQueryInfo); - } - } + setEnvForEachBlock(pQInfo, *pTableQueryInfo, &blockInfo); } SDataStatis *pStatis = NULL; SArray *pDataBlock = NULL; + if (loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis, &pDataBlock) == BLK_DATA_DISCARD) { pQuery->current->lastKey = QUERY_IS_ASC_QUERY(pQuery)? blockInfo.window.ekey + step:blockInfo.window.skey + step; continue; @@ -4516,7 +4526,6 @@ static void sequentialTableProcess(SQInfo *pQInfo) { while (pQInfo->tableIndex < pQInfo->tableqinfoGroupInfo.numOfTables) { if (IS_QUERY_KILLED(pQInfo)) { - finalizeQueryResult(pRuntimeEnv); // clean up allocated resource during query longjmp(pRuntimeEnv->env, TSDB_CODE_TSC_QUERY_CANCELLED); } @@ -5014,6 +5023,7 @@ static void stableQueryImpl(SQInfo *pQInfo) { isFirstLastRowQuery(pQuery) || pRuntimeEnv->groupbyNormalCol); sequentialTableProcess(pQInfo); + } // record the total elapsed time @@ -6112,11 +6122,6 @@ _over: //pQInfo already freed in initQInfo, but *pQInfo may not pointer to null; if (code != TSDB_CODE_SUCCESS) { *pQInfo = NULL; - } else { -// SQInfo* pq = (SQInfo*) (*pQInfo); - -// T_REF_INC(pq); -// T_REF_INC(pq); } // if failed to add ref for all meters in this query, abort current query diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index c055a27c39..3311a0f13c 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -1801,7 +1801,8 @@ int32_t tsdbRetrieveDataBlockStatisInfo(TsdbQueryHandleT* pQueryHandle, SDataSta } tsdbLoadCompData(&pHandle->rhelper, pBlockInfo->compBlock, NULL); - + + // todo opt perf size_t numOfCols = QH_GET_NUM_OF_COLS(pHandle); for(int32_t i = 0; i < numOfCols; ++i) { SDataStatis* st = &pHandle->statis[i]; @@ -1820,6 +1821,13 @@ int32_t tsdbRetrieveDataBlockStatisInfo(TsdbQueryHandleT* pQueryHandle, SDataSta if (pHandle->statis[i].numOfNull == -1) { // set the column data are all NULL pHandle->statis[i].numOfNull = pBlockInfo->compBlock->numOfRows; } + + // todo opt perf + SColumnInfo* pColInfo = taosArrayGet(pHandle->pColumns, i); + if (pColInfo->type == TSDB_DATA_TYPE_TIMESTAMP) { + pHandle->statis[i].min = pBlockInfo->compBlock->keyFirst; + pHandle->statis[i].max = pBlockInfo->compBlock->keyLast; + } } return TSDB_CODE_SUCCESS; From 4918aac1eb4a3501f6429939cfb238484921802b Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 13 Jul 2020 10:41:12 +0000 Subject: [PATCH 53/63] adjust max tags number --- src/query/src/qExecutor.c | 2 +- src/tsdb/src/tsdbRead.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index d1b336fb4b..c0cb79a4ef 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -5366,7 +5366,7 @@ static int32_t buildAirthmeticExprFromMsg(SExprInfo *pArithExprInfo, SQueryTable qDebug("qmsg:%p create arithmetic expr from binary string: %s", pQueryMsg, pArithExprInfo->base.arg[0].argValue.pz); tExprNode* pExprNode = NULL; - TRY(32) { + TRY(TSDB_MAX_TAGS) { pExprNode = exprTreeFromBinary(pArithExprInfo->base.arg[0].argValue.pz, pArithExprInfo->base.arg[0].argBytes); } CATCH( code ) { CLEANUP_EXECUTE(); diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 9e5da903b1..789706506d 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -2193,7 +2193,7 @@ int32_t tsdbQuerySTableByTagCond(TSDB_REPO_T* tsdb, uint64_t uid, const char* pT int32_t ret = TSDB_CODE_SUCCESS; tExprNode* expr = NULL; - TRY(32) { + TRY(TSDB_MAX_TAGS) { expr = exprTreeFromTableName(tbnameCond); if (expr == NULL) { expr = exprTreeFromBinary(pTagCond, len); From 621f842c0fa1f53820fdb127214f42d222c1b41d Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 13 Jul 2020 19:27:07 +0800 Subject: [PATCH 54/63] [td-225] fix bugs. --- src/client/src/tscAsync.c | 1 + src/client/src/tscServer.c | 5 ++++- src/client/src/tscUtil.c | 8 ++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 2eff96bac9..4e05e1ce4c 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -168,6 +168,7 @@ static void tscProcessAsyncRetrieveImpl(void *param, TAOS_RES *tres, int numOfRo if (pCmd->command != TSDB_SQL_RETRIEVE_LOCALMERGE && pCmd->command < TSDB_SQL_LOCAL) { pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH; } + tscProcessSql(pSql); } diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 1ae12aaf3d..564d5ae23f 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -339,7 +339,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) { } if (rpcMsg->code != TSDB_CODE_TSC_ACTION_IN_PROGRESS) { - rpcMsg->code = (pRes->code == TSDB_CODE_SUCCESS) ? pRes->numOfRows: pRes->code; + rpcMsg->code = (pRes->code == TSDB_CODE_SUCCESS)? pRes->numOfRows: pRes->code; bool shouldFree = tscShouldBeFreed(pSql); (*pSql->fp)(pSql->param, pSql, rpcMsg->code); @@ -476,6 +476,8 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int32_t vgIndex = pTableMetaInfo->vgroupIndex; SVgroupsInfo* pVgroupInfo = pTableMetaInfo->vgroupList; + assert(pVgroupInfo->vgroups[vgIndex].vgId > 0 && vgIndex < pTableMetaInfo->vgroupList->numOfVgroups); + pRetrieveMsg->header.vgId = htonl(pVgroupInfo->vgroups[vgIndex].vgId); } else { STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; @@ -549,6 +551,7 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char assert(index >= 0); if (pTableMetaInfo->vgroupList->numOfVgroups > 0) { + assert(index < pTableMetaInfo->vgroupList->numOfVgroups); pVgroupInfo = &pTableMetaInfo->vgroupList->vgroups[index]; } tscDebug("%p query on stable, vgIndex:%d, numOfVgroups:%d", pSql, index, pTableMetaInfo->vgroupList->numOfVgroups); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 6ec25aedf9..3e0fe0b4be 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -2008,7 +2008,7 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); int32_t totalVgroups = pTableMetaInfo->vgroupList->numOfVgroups; - while (++pTableMetaInfo->vgroupIndex < totalVgroups) { + if (++pTableMetaInfo->vgroupIndex < totalVgroups) { tscDebug("%p results from vgroup index:%d completed, try next:%d. total vgroups:%d. current numOfRes:%" PRId64, pSql, pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pRes->numOfClauseTotal); @@ -2044,9 +2044,9 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) { // set the callback function pSql->fp = fp; - if (tscProcessSql(pSql) != 0) { - break; - } + tscProcessSql(pSql); + } else { + tscDebug("%p try all %d vnodes, query complete. current numOfRes:%" PRId64, pSql, totalVgroups, pRes->numOfClauseTotal); } } From a1d992e32105d125ec1240e0adef77764812d1f4 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 13 Jul 2020 20:24:10 +0800 Subject: [PATCH 55/63] [TD-918] --- src/dnode/src/dnodePeer.c | 4 ++-- src/mnode/src/mnodeTable.c | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/dnode/src/dnodePeer.c b/src/dnode/src/dnodePeer.c index 6ab5188934..18fdb4d090 100644 --- a/src/dnode/src/dnodePeer.c +++ b/src/dnode/src/dnodePeer.c @@ -60,7 +60,7 @@ int32_t dnodeInitServer() { rpcInit.label = "DND-S"; rpcInit.numOfThreads = 1; rpcInit.cfp = dnodeProcessReqMsgFromDnode; - rpcInit.sessions = 100; + rpcInit.sessions = TSDB_MAX_VNODES; rpcInit.connType = TAOS_CONN_SERVER; rpcInit.idleTime = tsShellActivityTimer * 1000; @@ -122,7 +122,7 @@ int32_t dnodeInitClient() { rpcInit.label = "DND-C"; rpcInit.numOfThreads = 1; rpcInit.cfp = dnodeProcessRspFromDnode; - rpcInit.sessions = 100; + rpcInit.sessions = TSDB_MAX_VNODES; rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.idleTime = tsShellActivityTimer * 1000; rpcInit.user = "t"; diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 28661dc1ad..80c4fc95ab 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -1740,11 +1740,13 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) { return code; } - if (pMsg->pVgroup == NULL) { - pMsg->pVgroup = pVgroup; - mnodeIncVgroupRef(pVgroup); + if (pMsg->pVgroup != NULL) { + mnodeDecVgroupRef(pMsg->pVgroup); } + pMsg->pVgroup = pVgroup; + mnodeIncVgroupRef(pVgroup); + mDebug("app:%p:%p, table:%s, allocated in vgroup, vgId:%d sid:%d", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId, pVgroup->vgId, sid); From 95c92802f8a89492d24df8c68e73f16d473413fe Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 14 Jul 2020 10:57:36 +0800 Subject: [PATCH 56/63] [TD-825] change conditions of restful interface --- src/plugins/http/src/httpSql.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/plugins/http/src/httpSql.c b/src/plugins/http/src/httpSql.c index 7a515d124e..580f5684ac 100644 --- a/src/plugins/http/src/httpSql.c +++ b/src/plugins/http/src/httpSql.c @@ -47,6 +47,10 @@ void httpProcessMultiSqlRetrieveCallBack(void *param, TAOS_RES *result, int numO } } + if (tscResultsetFetchCompleted(result)) { + isContinue = false; + } + if (isContinue) { // retrieve next batch of rows httpDebug("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, continue retrieve, numOfRows:%d, sql:%s", @@ -75,7 +79,8 @@ void httpProcessMultiSqlCallBack(void *param, TAOS_RES *result, int code) { HttpContext *pContext = (HttpContext *)param; if (pContext == NULL) return; - HttpSqlCmds * multiCmds = pContext->multiCmds; + code = taos_errno(result); + HttpSqlCmds *multiCmds = pContext->multiCmds; HttpEncodeMethod *encode = pContext->encodeMethod; HttpSqlCmd *singleCmd = multiCmds->cmds + multiCmds->pos; @@ -109,8 +114,8 @@ void httpProcessMultiSqlCallBack(void *param, TAOS_RES *result, int code) { return; } - int num_fields = taos_field_count(result); - if (num_fields == 0) { + bool isUpdate = tscIsUpdateQuery(result); + if (isUpdate) { // not select or show commands int affectRows = taos_affected_rows(result); httpDebug("context:%p, fd:%d, ip:%s, user:%s, process pos:%d, affect rows:%d, sql:%s", @@ -238,6 +243,11 @@ void httpProcessSingleSqlCallBack(void *param, TAOS_RES *result, int unUsedCode) if (pContext == NULL) return; int32_t code = taos_errno(result); + if (code != unUsedCode) { + httpError("context:%p, fd:%d, ip:%s, user:%s, resultset code:%s input code:%s not matched, sqlObj:%p", pContext, + pContext->fd, pContext->ipstr, pContext->user, tstrerror(code), tstrerror(unUsedCode), (SSqlObj *)result); + } + HttpEncodeMethod *encode = pContext->encodeMethod; if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { From fad84068107f81b926b30baddda661f8b3ba88e3 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 14 Jul 2020 11:59:20 +0800 Subject: [PATCH 57/63] change a log level --- src/mnode/src/mnodeProfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mnode/src/mnodeProfile.c b/src/mnode/src/mnodeProfile.c index af4a09a45a..9121f31131 100644 --- a/src/mnode/src/mnodeProfile.c +++ b/src/mnode/src/mnodeProfile.c @@ -115,7 +115,7 @@ SConnObj *mnodeAccquireConn(int32_t connId, char *user, uint32_t ip, uint16_t po uint64_t expireTime = CONN_KEEP_TIME * 1000 + (uint64_t)taosGetTimestampMs(); SConnObj *pConn = taosCacheUpdateExpireTimeByName(tsMnodeConnCache, &connId, sizeof(int32_t), expireTime); if (pConn == NULL) { - mError("connId:%d, is already destroyed, user:%s ip:%s:%u", connId, user, taosIpStr(ip), port); + mDebug("connId:%d, is already destroyed, user:%s ip:%s:%u", connId, user, taosIpStr(ip), port); return NULL; } From 4b8428855f7907722f26766a70fe8ba711682308 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 14 Jul 2020 14:10:40 +0800 Subject: [PATCH 58/63] [TD-825] adjust callback sequence in async query --- src/client/src/tscAsync.c | 8 ++++---- src/plugins/http/src/httpContext.c | 2 +- src/plugins/http/src/httpSql.c | 6 +++--- src/query/src/qExecutor.c | 3 ++- src/vnode/src/vnodeRead.c | 3 ++- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 4e05e1ce4c..cae67673e9 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -198,6 +198,10 @@ void taos_fetch_rows_a(TAOS_RES *taosa, void (*fp)(void *, TAOS_RES *, int), voi SSqlRes *pRes = &pSql->res; SSqlCmd *pCmd = &pSql->cmd; + // user-defined callback function is stored in fetchFp + pSql->fetchFp = fp; + pSql->fp = tscAsyncFetchRowsProxy; + if (pRes->qhandle == 0) { tscError("qhandle is NULL"); pRes->code = TSDB_CODE_TSC_INVALID_QHANDLE; @@ -205,10 +209,6 @@ void taos_fetch_rows_a(TAOS_RES *taosa, void (*fp)(void *, TAOS_RES *, int), voi return; } - // user-defined callback function is stored in fetchFp - pSql->fetchFp = fp; - pSql->fp = tscAsyncFetchRowsProxy; - pSql->param = param; tscResetForNextRetrieve(pRes); diff --git a/src/plugins/http/src/httpContext.c b/src/plugins/http/src/httpContext.c index 98fba9cb3b..cefcca7821 100644 --- a/src/plugins/http/src/httpContext.c +++ b/src/plugins/http/src/httpContext.c @@ -137,7 +137,7 @@ void httpReleaseContext(HttpContext *pContext) { assert(refCount >= 0); HttpContext **ppContext = pContext->ppContext; - httpDebug("context:%p, is releasd, data:%p refCount:%d", pContext, ppContext, refCount); + httpDebug("context:%p, is released, data:%p refCount:%d", pContext, ppContext, refCount); if (tsHttpServer.contextCache != NULL) { taosCacheRelease(tsHttpServer.contextCache, (void **)(&ppContext), false); diff --git a/src/plugins/http/src/httpSql.c b/src/plugins/http/src/httpSql.c index 580f5684ac..d8ac170d6d 100644 --- a/src/plugins/http/src/httpSql.c +++ b/src/plugins/http/src/httpSql.c @@ -226,9 +226,9 @@ void httpProcessSingleSqlRetrieveCallBack(void *param, TAOS_RES *result, int num if (numOfRows < 0) { httpError("context:%p, fd:%d, ip:%s, user:%s, retrieve failed, code:%s", pContext, pContext->fd, pContext->ipstr, pContext->user, tstrerror(numOfRows)); - } - - taos_free_result(result); + } + + taos_free_result(result); if (encode->stopJsonFp) { (encode->stopJsonFp)(pContext, &pContext->singleCmd); diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 37defc3ccf..9d005cdb07 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -6545,13 +6545,14 @@ void** qRegisterQInfo(void* pMgmt, uint64_t qInfo) { SQueryMgmt *pQueryMgmt = pMgmt; if (pQueryMgmt->qinfoPool == NULL) { + qError("QInfo:%p failed to add qhandle into qMgmt, since qMgmt is closed", (void *)qInfo); return NULL; } pthread_mutex_lock(&pQueryMgmt->lock); if (pQueryMgmt->closed) { pthread_mutex_unlock(&pQueryMgmt->lock); - + qError("QInfo:%p failed to add qhandle into cache, since qMgmt is colsing", (void *)qInfo); return NULL; } else { uint64_t handleVal = (uint64_t) qInfo; diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c index 987783711b..f529b713cf 100644 --- a/src/vnode/src/vnodeRead.c +++ b/src/vnode/src/vnodeRead.c @@ -108,9 +108,10 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) { if (code == TSDB_CODE_SUCCESS) { handle = qRegisterQInfo(pVnode->qMgmt, (uint64_t) pQInfo); if (handle == NULL) { // failed to register qhandle + vError("vgId:%d QInfo:%p register qhandle failed, return to app, code:%s", pVnode->vgId, (void *)pQInfo, + tstrerror(pRsp->code)); pRsp->code = TSDB_CODE_QRY_INVALID_QHANDLE; qDestroyQueryInfo(pQInfo); // destroy it directly - vError("vgId:%d QInfo:%p register qhandle failed, return to app, code:%s", pVnode->vgId, (void*) pQInfo, tstrerror(pRsp->code)); } else { assert(*handle == pQInfo); pRsp->qhandle = htobe64((uint64_t) pQInfo); From 627cdc07498a58cd32e99460a3ae3ce6b0c9bfdc Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 14 Jul 2020 14:33:55 +0800 Subject: [PATCH 59/63] [TD-825] race condtion while free object in cache --- src/util/src/tcache.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index df63d567c7..6c678c3201 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -453,21 +453,20 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) { } else { uDebug("cache:%s, key:%p, %p is released, refcnt:%d", pCacheObj->name, pNode->key, pNode->data, T_REF_VAL_GET(pNode) - 1); + __cache_wr_lock(pCacheObj); + // NOTE: once refcount is decrease, pNode may be freed by other thread immediately. int32_t ref = T_REF_DEC(pNode); - if (inTrashCan) { + if (inTrashCan && (ref == 0)) { // Remove it if the ref count is 0. // The ref count does not need to load and check again after lock acquired, since ref count can not be increased when // the node is in trashcan. - if (ref == 0) { - __cache_wr_lock(pCacheObj); - assert(pNode->pTNodeHeader->pData == pNode); - taosRemoveFromTrashCan(pCacheObj, pNode->pTNodeHeader); - __cache_unlock(pCacheObj); - } - + assert(pNode->pTNodeHeader->pData == pNode); + taosRemoveFromTrashCan(pCacheObj, pNode->pTNodeHeader); } + + __cache_unlock(pCacheObj); } // else { From cbb06baea130f83435476652acbc68310ac98f79 Mon Sep 17 00:00:00 2001 From: Hui Li Date: Tue, 14 Jul 2020 18:08:06 +0800 Subject: [PATCH 60/63] [modify sim cases] --- ...ca3_dnodeChang_DropAddAlterTableDropDb.sim | 7 +- tests/script/unique/cluster/client5.sim | 130 +++++------------- tests/script/unique/cluster/cluster_main1.sim | 1 + tests/script/unique/cluster/cluster_main2.sim | 1 + 4 files changed, 41 insertions(+), 98 deletions(-) diff --git a/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim b/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim index 8a586321e1..c8663b0009 100644 --- a/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim +++ b/tests/script/unique/arbitrator/sync_replica3_dnodeChang_DropAddAlterTableDropDb.sim @@ -29,7 +29,7 @@ system sh/cfg.sh -n dnode2 -c alternativeRole -v 2 system sh/cfg.sh -n dnode3 -c alternativeRole -v 2 system sh/cfg.sh -n dnode4 -c alternativeRole -v 2 -$totalTableNum = 10 +$totalTableNum = 40 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $totalTableNum system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v $totalTableNum system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v $totalTableNum @@ -65,9 +65,10 @@ sleep 3000 $totalTableNum = 20 $sleepTimer = 3000 +$maxTables = $totalTableNum * 2 $db = db -print create database $db replica 3 maxTables $totalTableNum -sql create database $db replica 3 maxTables $totalTableNum +print create database $db replica 3 maxTables $maxTables +sql create database $db replica 3 maxTables $maxTables sql use $db # create table , insert data diff --git a/tests/script/unique/cluster/client5.sim b/tests/script/unique/cluster/client5.sim index 5960b28fdd..1fe6298ae7 100644 --- a/tests/script/unique/cluster/client5.sim +++ b/tests/script/unique/cluster/client5.sim @@ -1,113 +1,53 @@ $tblStart = 0 $tblEnd = 2000 $tsStart = 1325347200000 # 2012-01-01 00:00:00.000 +$tsEnd = 1325347210000 ############################################################### sql connect +$db = db1 +$stb = stb1 +#subtable: tb0 - tb4999 +#print create table $stb (ts timestamp, c1 int) tags(t1 int, t2 binary(16)) + +sleep 20000 # wait other client insert data loop_lable: print ====================== client5 start loop query -$db = db2 -$stb = stb2 +sql use $db -print create database if not exists $db replica 2 -sql create database if not exists $db replica 2 -sql use $db +sql select count(*) from $stb -print ==== client4start create table -$i = $tblStart -while $i < $tblEnd - $tb = dtb . $i - sql create table $tb (ts timestamp, c1 int) - $i = $i + 1 -endw +$tsQueryStart = $tsStart +$tsQueryStart = $tsStart + 90000 +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart order by ts asc limit 500 offset 7 +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart order by ts desc limit 500 offset 7 +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client1_0' +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client1_1' +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client1_2' +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client1_3' -print ==== client4start insert, include multi table data in one insert sql -$totalRows = 0 -$totalRowsPerTbl = 0 +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client2_0' +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client2_1' +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client2_2' +sql select * from $stb where ts > $tsQueryStart and ts < $tsQueryStart and t2 == 'client2_3' -$rowsPerLoop = 100 -$ts = $tsStart +sql select min(c1) from $stb +sql select max(c1) from $stb +sql select first(*) from $stb +sql select last(*) from $stb +sql select last_row(*) from $stb +sql select sum(c1) from $stb +sql select avg(c1) from $stb -$i = $tblStart -while $i < $tblEnd - $tb0 = dtb . $i - $i = $i + 1 - $tb1 = dtb . $i - $i = $i + 1 - $tb2 = dtb . $i - $i = $i + 1 - $tb3 = dtb . $i - $i = $i + 1 - $tb4 = dtb . $i - $i = $i + 1 - - $x = 0 - while $x < $rowsPerLoop - sql insert into $tb0 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb1 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb2 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb3 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb4 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) - $x = $x + 20 - $ts = $ts + 40a - endw - - $totalRowsPerTbl = $totalRowsPerTbl + $x - $x = $x * 5 - $totalRows = $totalRows + $x -endw - -sql select count(*) from tb10 -if $data00 != $totalRowsPerTbl then - print data00 $data00 totalRowsPerTbl $totalRowsPerTbl - print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - print ************ client4 insert loss: $deltaRows ***** - print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -endi +sql select min(c1) from tb1 +sql select max(c1) from tb10 +sql select first(*) from tb100 +sql select last(*) from tb1000 +sql select last_row(*) from tb20 +sql select sum(c1) from tb200 +sql select avg(c1) from tb2000 - -print ====client4 start alter table -$i = $tblStart -while $i < $tblEnd - $tb = dtb . $i - sql alter table $tb add c2 float - $i = $i + 1 -endw - -print ====client4 continue insert, include multi table data in one insert sql - -$i = $tblStart -while $i < $tblEnd - $tb0 = dtb . $i - $i = $i + 1 - $tb1 = dtb . $i - $i = $i + 1 - $tb2 = dtb . $i - $i = $i + 1 - $tb3 = dtb . $i - $i = $i + 1 - $tb4 = dtb . $i - $i = $i + 1 - - $x = 0 - while $x < $rowsPerLoop - sql insert into $tb0 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb1 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb2 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb3 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) $tb4 values ( $ts + 0a , $x ) ( $ts + 2a , $x ) ( $ts + 4a , $x ) ( $ts + 6a , $x ) ( $ts + 8a , $x ) ( $ts + 10a , $x ) ( $ts + 12a , $x ) ( $ts + 14a , $x ) ( $ts + 16a , $x ) ( $ts + 18a , $x ) ( $ts + 20a , $x ) ( $ts + 22a , $x ) ( $ts + 24a , $x ) ( $ts + 26a , $x ) ( $ts + 28a , $x ) ( $ts + 30a , $x ) ( $ts + 32a , $x ) ( $ts + 34a , $x ) ( $ts + 36a , $x ) ( $ts + 38a , $x ) - $x = $x + 20 - $ts = $ts + 40a - endw - - $totalRowsPerTbl = $totalRowsPerTbl + $x - $x = $x * 5 - $totalRows = $totalRows + $x -endw - -sql select count(*) from tb10 -if $data00 != $totalRowsPerTbl then - print data00 $data00 totalRowsPerTbl $totalRowsPerTbl - print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - print ************ client4 insert loss: $deltaRows ***** - print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -endi - -print ====================== client4 drop database -sql drop if exists database $db goto loop_lable \ No newline at end of file diff --git a/tests/script/unique/cluster/cluster_main1.sim b/tests/script/unique/cluster/cluster_main1.sim index 82e1e2be83..e05c30aa6d 100644 --- a/tests/script/unique/cluster/cluster_main1.sim +++ b/tests/script/unique/cluster/cluster_main1.sim @@ -80,6 +80,7 @@ run_back unique/cluster/main1_client1_2.sim run_back unique/cluster/main1_client1_3.sim run_back unique/cluster/client3.sim run_back unique/cluster/client4.sim +run_back unique/cluster/client5.sim sleep 20000 diff --git a/tests/script/unique/cluster/cluster_main2.sim b/tests/script/unique/cluster/cluster_main2.sim index e5fe3f2a21..9c682de041 100644 --- a/tests/script/unique/cluster/cluster_main2.sim +++ b/tests/script/unique/cluster/cluster_main2.sim @@ -84,6 +84,7 @@ run_back unique/cluster/main2_client2_2.sim run_back unique/cluster/main2_client2_3.sim run_back unique/cluster/client3.sim run_back unique/cluster/client4.sim +run_back unique/cluster/client5.sim sleep 20000 From 7ca488e3ac23c0a6c2eb23a9ad093a47477fbd98 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 14 Jul 2020 18:50:21 +0800 Subject: [PATCH 61/63] [TD-825] --- src/util/src/tcache.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index 6c678c3201..072e9939de 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -294,7 +294,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v } } else { // old data exists, update the node pNode = taosUpdateCacheImpl(pCacheObj, pOld, key, keyLen, pData, dataSize, duration * 1000L); - uDebug("cache:%s, key:%p, %p exist in cache, updated", pCacheObj->name, key, pNode->data); + uDebug("cache:%s, key:%p, %p exist in cache, updated old:%p", pCacheObj->name, key, pNode->data, pOld); } __cache_unlock(pCacheObj); @@ -307,26 +307,30 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen return NULL; } + void *pData = NULL; + __cache_rd_lock(pCacheObj); - + SCacheDataNode **ptNode = (SCacheDataNode **)taosHashGet(pCacheObj->pHashTable, key, keyLen); int32_t ref = 0; if (ptNode != NULL) { ref = T_REF_INC(*ptNode); + pData = (*ptNode)->data; } + __cache_unlock(pCacheObj); - - if (ptNode != NULL) { + + if (pData != NULL) { atomic_add_fetch_32(&pCacheObj->statistics.hitCount, 1); - uDebug("cache:%s, key:%p, %p is retrieved from cache, refcnt:%d", pCacheObj->name, key, (*ptNode)->data, ref); + uDebug("cache:%s, key:%p, %p is retrieved from cache, refcnt:%d", pCacheObj->name, key, pData, ref); } else { atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1); uDebug("cache:%s, key:%p, not in cache, retrieved failed", pCacheObj->name, key); } - + atomic_add_fetch_32(&pCacheObj->statistics.totalAccess, 1); - return (ptNode != NULL) ? (*ptNode)->data : NULL; + return pData; } void* taosCacheUpdateExpireTimeByName(SCacheObj *pCacheObj, void *key, size_t keyLen, uint64_t expireTime) { From d78afdf2dd2b99651b88950000618f103a4aeb1e Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 14 Jul 2020 19:24:57 +0800 Subject: [PATCH 62/63] [TD-825] post semphore while kill query --- src/query/src/qExecutor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 9d005cdb07..f94c65834d 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -6333,6 +6333,7 @@ int32_t qKillQuery(qinfo_t qinfo) { return TSDB_CODE_QRY_INVALID_QHANDLE; } + sem_post(&pQInfo->dataReady); setQueryKilled(pQInfo); return TSDB_CODE_SUCCESS; } From 3302f60e45434432c8bb8f79ef1e861ea2edcc50 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 14 Jul 2020 21:49:19 +0800 Subject: [PATCH 63/63] remove log in restful --- src/plugins/http/src/httpSql.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/plugins/http/src/httpSql.c b/src/plugins/http/src/httpSql.c index d8ac170d6d..8e1bf7d089 100644 --- a/src/plugins/http/src/httpSql.c +++ b/src/plugins/http/src/httpSql.c @@ -243,10 +243,6 @@ void httpProcessSingleSqlCallBack(void *param, TAOS_RES *result, int unUsedCode) if (pContext == NULL) return; int32_t code = taos_errno(result); - if (code != unUsedCode) { - httpError("context:%p, fd:%d, ip:%s, user:%s, resultset code:%s input code:%s not matched, sqlObj:%p", pContext, - pContext->fd, pContext->ipstr, pContext->user, tstrerror(code), tstrerror(unUsedCode), (SSqlObj *)result); - } HttpEncodeMethod *encode = pContext->encodeMethod;