From c2a9c119688735fcaa11a54206f63c449ab820da Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 11 May 2020 19:46:33 +0800 Subject: [PATCH 1/5] [TD-271] fix bug while drop stable --- src/mnode/inc/mgmtDef.h | 3 +- src/mnode/src/mgmtTable.c | 152 +++++++++++++++++++------------------- 2 files changed, 77 insertions(+), 78 deletions(-) diff --git a/src/mnode/inc/mgmtDef.h b/src/mnode/inc/mgmtDef.h index ba71f9373b..3ac2efb83b 100644 --- a/src/mnode/inc/mgmtDef.h +++ b/src/mnode/inc/mgmtDef.h @@ -85,8 +85,7 @@ typedef struct SSuperTableObj { int32_t numOfTables; int16_t nextColId; SSchema * schema; - int32_t vgLen; - int32_t * vgList; + void * vgHash; } SSuperTableObj; typedef struct { diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index bfe357cf7c..d001114bf0 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -24,6 +24,7 @@ #include "tname.h" #include "tidpool.h" #include "tglobal.h" +#include "hash.h" #include "dnode.h" #include "mgmtDef.h" #include "mgmtInt.h" @@ -363,39 +364,35 @@ static void mgmtCleanUpChildTables() { } static void mgmtAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCtable) { - if (pStable->vgLen == 0) { - pStable->vgLen = 8; - pStable->vgList = calloc(pStable->vgLen, sizeof(int32_t)); - } - - bool find = false; - int32_t pos = 0; - for (pos = 0; pos < pStable->vgLen; ++pos) { - if (pStable->vgList[pos] == 0) break; - if (pStable->vgList[pos] == pCtable->vgId) { - find = true; - break; - } - } - - if (!find) { - if (pos >= pStable->vgLen) { - pStable->vgLen *= 2; - pStable->vgList = realloc(pStable->vgList, pStable->vgLen * sizeof(int32_t)); - } - pStable->vgList[pos] = pCtable->vgId; - } - pStable->numOfTables++; + + if (pStable->vgHash == NULL) { + pStable->vgHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false); + } + + if (pStable->vgHash != NULL) { + taosHashPut(pStable->vgHash, (char *)&pCtable->vgId, sizeof(pCtable->vgId), &pCtable->vgId, sizeof(pCtable->vgId)); + } } static void mgmtRemoveTableFromStable(SSuperTableObj *pStable, SChildTableObj *pCtable) { pStable->numOfTables--; + + if (pStable->vgHash == NULL) return; + + SVgObj *pVgroup = mgmtGetVgroup(pCtable->vgId); + if (pVgroup != NULL) { + taosHashRemove(pStable->vgHash, (char *)&pCtable->vgId, sizeof(pCtable->vgId)); + } + mgmtDecVgroupRef(pVgroup); } static void mgmtDestroySuperTable(SSuperTableObj *pStable) { + if (pStable->vgHash != NULL) { + taosHashCleanup(pStable->vgHash); + pStable->vgHash = NULL; + } tfree(pStable->schema); - tfree(pStable->vgList) tfree(pStable); } @@ -434,7 +431,7 @@ static int32_t mgmtSuperTableActionUpdate(SSdbOper *pOper) { void *oldSchema = pTable->schema; memcpy(pTable, pNew, pOper->rowSize); pTable->schema = pNew->schema; - free(pNew->vgList); + free(pNew->vgHash); free(pNew); free(oldSchema); } @@ -797,26 +794,26 @@ static void mgmtProcessCreateSuperTableMsg(SQueuedMsg *pMsg) { static void mgmtProcessDropSuperTableMsg(SQueuedMsg *pMsg) { SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable; if (pStable->numOfTables != 0) { - mgmtDropAllChildTablesInStable(pStable); - for (int32_t vg = 0; vg < pStable->vgLen; ++vg) { - int32_t vgId = pStable->vgList[vg]; - if (vgId == 0) break; - - SVgObj *pVgroup = mgmtGetVgroup(vgId); + SHashMutableIterator *pIter = taosHashCreateIter(pStable->vgHash); + while (taosHashIterNext(pIter)) { + int32_t *pVgId = taosHashIterGet(pIter); + SVgObj *pVgroup = mgmtGetVgroup(*pVgId); if (pVgroup == NULL) break; - + SMDDropSTableMsg *pDrop = rpcMallocCont(sizeof(SMDDropSTableMsg)); pDrop->contLen = htonl(sizeof(SMDDropSTableMsg)); - pDrop->vgId = htonl(vgId); + pDrop->vgId = htonl(pVgroup->vgId); pDrop->uid = htobe64(pStable->uid); mgmtExtractTableName(pStable->info.tableId, pDrop->tableId); - mPrint("stable:%s, send drop stable msg to vgId:%d", pStable->info.tableId, vgId); + mPrint("stable:%s, send drop stable msg to vgId:%d", pStable->info.tableId, pVgroup->vgId); SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pVgroup); SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE}; dnodeSendMsgToDnode(&ipSet, &rpcMsg); mgmtDecVgroupRef(pVgroup); } + + mgmtDropAllChildTablesInStable(pStable); } SSdbOper oper = { @@ -1243,59 +1240,62 @@ static void mgmtGetSuperTableMeta(SQueuedMsg *pMsg) { static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { SCMSTableVgroupMsg *pInfo = pMsg->pCont; int32_t numOfTable = htonl(pInfo->numOfTables); - - char* name = (char*) pInfo + sizeof(struct SCMSTableVgroupMsg); + SCMSTableVgroupRspMsg *pRsp = NULL; - - // todo set the initial size to be 10, fix me - int32_t contLen = sizeof(SCMSTableVgroupRspMsg) + (sizeof(SCMVgroupInfo) * 10 + sizeof(SVgroupsInfo))*numOfTable; - + int32_t contLen = sizeof(SCMSTableVgroupRspMsg); + for (int32_t i = 0; i < numOfTable; ++i) { + char *stableName = (char*)pInfo + sizeof(SCMSTableVgroupMsg) + (TSDB_TABLE_ID_LEN) * i; + SSuperTableObj *pTable = mgmtGetSuperTable(stableName); + if (pTable != NULL) { + stableName = (char*)pTable; //hack way + } + + if (pTable->vgHash != NULL) { + contLen += (taosHashGetSize(pTable->vgHash) * sizeof(SCMVgroupInfo) + sizeof(SVgroupsInfo)); + } + mgmtDecTableRef(pTable); + } + pRsp = rpcMallocCont(contLen); if (pRsp == NULL) { mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY); return; } - + pRsp->numOfTables = htonl(numOfTable); - char* msg = (char*) pRsp + sizeof(SCMSTableVgroupRspMsg); - - for(int32_t i = 0; i < numOfTable; ++i) { - SSuperTableObj *pTable = mgmtGetSuperTable(name); - - pMsg->pTable = (STableObj *)pTable; - if (pMsg->pTable == NULL) { - mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_INVALID_TABLE); - return; - } - - SVgroupsInfo* pVgroup = (SVgroupsInfo*) msg; - - int32_t vg = 0; - for (; vg < pTable->vgLen; ++vg) { - int32_t vgId = pTable->vgList[vg]; - if (vgId == 0) break; - - SVgObj *vgItem = mgmtGetVgroup(vgId); - if (vgItem == NULL) break; - - pVgroup->vgroups[vg].vgId = htonl(vgId); - for (int32_t vn = 0; vn < vgItem->numOfVnodes; ++vn) { - SDnodeObj *pDnode = vgItem->vnodeGid[vn].pDnode; + char *msg = (char *)pRsp + sizeof(SCMSTableVgroupRspMsg); + + for (int32_t i = 0; i < numOfTable; ++i) { + SSuperTableObj *pTable = (SSuperTableObj *)((char *)pInfo + sizeof(SCMSTableVgroupMsg) + (TSDB_TABLE_ID_LEN)*i); + SVgroupsInfo * pVgroup = (SVgroupsInfo *)msg; + + SHashMutableIterator *pIter = taosHashCreateIter(pTable->vgHash); + int32_t vgSize = 0; + while (taosHashIterNext(pIter)) { + int32_t *pVgId = taosHashIterGet(pIter); + SVgObj * pVgItem = mgmtGetVgroup(*pVgId + ); + if (pVgItem == NULL) continue; + + pVgroup->vgroups[vgSize].vgId = htonl(pVgItem->vgId); + for (int32_t vn = 0; vn < pVgItem->numOfVnodes; ++vn) { + SDnodeObj *pDnode = pVgItem->vnodeGid[vn].pDnode; if (pDnode == NULL) break; - - strncpy(pVgroup->vgroups[vg].ipAddr[vn].fqdn, pDnode->dnodeFqdn, tListLen(pDnode->dnodeFqdn)); - pVgroup->vgroups[vg].ipAddr[vn].port = htons(tsDnodeShellPort); - - pVgroup->vgroups[vg].numOfIps++; + + strncpy(pVgroup->vgroups[vgSize].ipAddr[vn].fqdn, pDnode->dnodeFqdn, tListLen(pDnode->dnodeFqdn)); + pVgroup->vgroups[vgSize].ipAddr[vn].port = htons(tsDnodeShellPort); + + pVgroup->vgroups[vgSize].numOfIps++; } - - mgmtDecVgroupRef(vgItem); + + vgSize++; + mgmtDecVgroupRef(pVgItem); } - - pVgroup->numOfVgroups = htonl(vg); - + + pVgroup->numOfVgroups = htonl(vgSize); + // one table is done, try the next table - msg += sizeof(SVgroupsInfo) + vg * sizeof(SCMVgroupInfo); + msg += sizeof(SVgroupsInfo) + vgSize * sizeof(SCMVgroupInfo); } SRpcMsg rpcRsp = {0}; From feb4bbcde09624343cbed5e8cc58d89c5ffc4e33 Mon Sep 17 00:00:00 2001 From: jtao1735 Date: Mon, 11 May 2020 13:10:56 +0000 Subject: [PATCH 2/5] support RpcIpSet change --- src/client/inc/tsclient.h | 2 +- src/client/src/tscServer.c | 8 +++++++- src/dnode/src/dnodeMgmt.c | 4 ++-- src/dnode/src/dnodePeer.c | 12 ++++++------ src/dnode/src/dnodeShell.c | 4 ++-- src/inc/trpc.h | 5 +---- src/rpc/src/rpcMain.c | 13 ++++++------- src/rpc/test/rclient.c | 13 +++---------- src/rpc/test/rsclient.c | 8 -------- src/rpc/test/rserver.c | 2 +- 10 files changed, 29 insertions(+), 42 deletions(-) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 61a5fdd311..6ea1ee6440 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -365,7 +365,7 @@ void tscInitMsgsFp(); int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion); -void tscProcessMsgFromServer(SRpcMsg *rpcMsg); +void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet); int tscProcessSql(SSqlObj *pSql); int tscRenewMeterMeta(SSqlObj *pSql, char *tableId); diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 8efe89d28a..98cbe9dbde 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -221,7 +221,7 @@ int tscSendMsgToServer(SSqlObj *pSql) { return TSDB_CODE_SUCCESS; } -void tscProcessMsgFromServer(SRpcMsg *rpcMsg) { +void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) { SSqlObj *pSql = (SSqlObj *)rpcMsg->handle; if (pSql == NULL) { tscError("%p sql is already released", pSql->signature); @@ -245,6 +245,12 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) { return; } + if (pCmd->command < TSDB_SQL_MGMT) { + if (pIpSet) pSql->ipList = *pIpSet; + } else { + if (pIpSet) tscMgmtIpSet = *pIpSet; + } + if (rpcMsg->pCont == NULL) { rpcMsg->code = TSDB_CODE_NETWORK_UNAVAIL; } else { diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index 0e91cc7155..36a7c98807 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -266,8 +266,8 @@ static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) { return taosCfgDynamicOptions(pCfg->config); } -void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet) { - dPrint("mnode IP list is changed for ufp is called, numOfIps:%d inUse:%d", pIpSet->numOfIps, pIpSet->inUse); +void dnodeUpdateIpSet(SRpcIpSet *pIpSet) { + dPrint("mnode IP list is changed, numOfIps:%d inUse:%d", pIpSet->numOfIps, pIpSet->inUse); for (int i = 0; i < pIpSet->numOfIps; ++i) { dPrint("mnode index:%d %s:%u", i, pIpSet->fqdn[i], pIpSet->port[i]) } diff --git a/src/dnode/src/dnodePeer.c b/src/dnode/src/dnodePeer.c index ea21ed0206..51913d80c4 100644 --- a/src/dnode/src/dnodePeer.c +++ b/src/dnode/src/dnodePeer.c @@ -29,11 +29,11 @@ #include "dnodeVWrite.h" #include "mnode.h" -extern void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet); +extern void dnodeUpdateIpSet(SRpcIpSet *pIpSet); static void (*dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *); -static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg); +static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcIpSet *); static void (*dnodeProcessRspMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg); -static void dnodeProcessRspFromDnode(SRpcMsg *pMsg); +static void dnodeProcessRspFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet); static void *tsDnodeServerRpc = NULL; static void *tsDnodeClientRpc = NULL; @@ -81,7 +81,7 @@ void dnodeCleanupServer() { } } -static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg) { +static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet) { SRpcMsg rspMsg; rspMsg.handle = pMsg->handle; rspMsg.pCont = NULL; @@ -119,7 +119,6 @@ int32_t dnodeInitClient() { rpcInit.label = "DND-C"; rpcInit.numOfThreads = 1; rpcInit.cfp = dnodeProcessRspFromDnode; - rpcInit.ufp = dnodeUpdateIpSet; rpcInit.sessions = 100; rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.idleTime = tsShellActivityTimer * 1000; @@ -145,9 +144,10 @@ void dnodeCleanupClient() { } } -static void dnodeProcessRspFromDnode(SRpcMsg *pMsg) { +static void dnodeProcessRspFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet) { if (dnodeProcessRspMsgFp[pMsg->msgType]) { + if (pMsg->msgType == TSDB_MSG_TYPE_DM_STATUS_RSP && pIpSet) dnodeUpdateIpSet(pIpSet); (*dnodeProcessRspMsgFp[pMsg->msgType])(pMsg); } else { dError("RPC %p, msg:%s is not processed", pMsg->handle, taosMsg[pMsg->msgType]); diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index 28679262fa..dc0efd405f 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -28,7 +28,7 @@ #include "dnodeShell.h" static void (*dnodeProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *); -static void dnodeProcessMsgFromShell(SRpcMsg *pMsg); +static void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcIpSet *); static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey); static void * tsDnodeShellRpc = NULL; static int32_t tsDnodeQueryReqNum = 0; @@ -106,7 +106,7 @@ void dnodeCleanupShell() { } } -void dnodeProcessMsgFromShell(SRpcMsg *pMsg) { +void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcIpSet *pIpSet) { SRpcMsg rpcMsg; rpcMsg.handle = pMsg->handle; rpcMsg.pCont = NULL; diff --git a/src/inc/trpc.h b/src/inc/trpc.h index 8b082b65b8..eff210433f 100644 --- a/src/inc/trpc.h +++ b/src/inc/trpc.h @@ -66,10 +66,7 @@ typedef struct { char *ckey; // ciphering key // call back to process incoming msg, code shall be ignored by server app - void (*cfp)(SRpcMsg *); - - // call back to process notify the ipSet changes, for client app only - void (*ufp)(void *ahandle, SRpcIpSet *pIpSet); + void (*cfp)(SRpcMsg *, SRpcIpSet *); // call back to retrieve the client auth info, for server app only int (*afp)(char *tableId, char *spi, char *encrypt, char *secret, char *ckey); diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index a2333566f1..ca4b211be8 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -55,9 +55,8 @@ typedef struct { char secret[TSDB_KEY_LEN]; // secret for the link char ckey[TSDB_KEY_LEN]; // ciphering key - void (*cfp)(SRpcMsg *); + void (*cfp)(SRpcMsg *, SRpcIpSet *); int (*afp)(char *user, char *spi, char *encrypt, char *secret, char *ckey); - void (*ufp)(void *ahandle, SRpcIpSet *pIpSet); void *idPool; // handle to ID pool void *tmrCtrl; // handle to timer @@ -222,7 +221,6 @@ void *rpcOpen(const SRpcInit *pInit) { if (pInit->secret) strcpy(pRpc->secret, pInit->secret); if (pInit->ckey) strcpy(pRpc->ckey, pInit->ckey); pRpc->spi = pInit->spi; - pRpc->ufp = pInit->ufp; pRpc->cfp = pInit->cfp; pRpc->afp = pInit->afp; @@ -900,10 +898,11 @@ static void rpcNotifyClient(SRpcReqContext *pContext, SRpcMsg *pMsg) { memcpy(pContext->pRsp, pMsg, sizeof(SRpcMsg)); } else { // for asynchronous API - if (pRpc->ufp && (pContext->ipSet.inUse != pContext->oldInUse || pContext->redirect)) - (*pRpc->ufp)(pContext->ahandle, &pContext->ipSet); // notify the update of ipSet + SRpcIpSet *pIpSet = NULL; + if (pContext->ipSet.inUse != pContext->oldInUse || pContext->redirect) + pIpSet = &pContext->ipSet; - (*pRpc->cfp)(pMsg); + (*pRpc->cfp)(pMsg, pIpSet); } // free the request message @@ -924,7 +923,7 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) { if ( rpcIsReq(pHead->msgType) ) { rpcMsg.handle = pConn; taosTmrReset(rpcProcessProgressTimer, tsRpcTimer/2, pConn, pRpc->tmrCtrl, &pConn->pTimer); - (*(pRpc->cfp))(&rpcMsg); + (*(pRpc->cfp))(&rpcMsg, NULL); } else { // it's a response SRpcReqContext *pContext = pConn->pContext; diff --git a/src/rpc/test/rclient.c b/src/rpc/test/rclient.c index 2aa1f0e4e9..ea1ebb5974 100644 --- a/src/rpc/test/rclient.c +++ b/src/rpc/test/rclient.c @@ -31,22 +31,16 @@ typedef struct { void *pRpc; } SInfo; -static void processResponse(SRpcMsg *pMsg) { +static void processResponse(SRpcMsg *pMsg, SRpcIpSet *pIpSet) { SInfo *pInfo = (SInfo *)pMsg->handle; tTrace("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, pMsg->code); + if (pIpSet) pInfo->ipSet = *pIpSet; + rpcFreeCont(pMsg->pCont); - sem_post(&pInfo->rspSem); } -static void processUpdateIpSet(void *handle, SRpcIpSet *pIpSet) { - SInfo *pInfo = (SInfo *)handle; - - tTrace("thread:%d, ip set is changed, index:%d", pInfo->index, pIpSet->inUse); - pInfo->ipSet = *pIpSet; -} - static int tcount = 0; static void *sendRequest(void *param) { @@ -99,7 +93,6 @@ int main(int argc, char *argv[]) { rpcInit.label = "APP"; rpcInit.numOfThreads = 1; rpcInit.cfp = processResponse; - rpcInit.ufp = processUpdateIpSet; rpcInit.sessions = 100; rpcInit.idleTime = tsShellActivityTimer*1000; rpcInit.user = "michael"; diff --git a/src/rpc/test/rsclient.c b/src/rpc/test/rsclient.c index 683cbb590a..3b19d7a9ea 100644 --- a/src/rpc/test/rsclient.c +++ b/src/rpc/test/rsclient.c @@ -32,12 +32,6 @@ typedef struct { void *pRpc; } SInfo; -static void processUpdateIpSet(void *handle, SRpcIpSet *pIpSet) { - SInfo *pInfo = (SInfo *)handle; - - tTrace("thread:%d, ip set is changed, index:%d", pInfo->index, pIpSet->inUse); - pInfo->ipSet = *pIpSet; -} static int tcount = 0; static int terror = 0; @@ -100,8 +94,6 @@ int main(int argc, char *argv[]) { rpcInit.localPort = 0; rpcInit.label = "APP"; rpcInit.numOfThreads = 1; - // rpcInit.cfp = processResponse; - rpcInit.ufp = processUpdateIpSet; rpcInit.sessions = 100; rpcInit.idleTime = tsShellActivityTimer*1000; rpcInit.user = "michael"; diff --git a/src/rpc/test/rserver.c b/src/rpc/test/rserver.c index 9f781ef276..958d099027 100644 --- a/src/rpc/test/rserver.c +++ b/src/rpc/test/rserver.c @@ -113,7 +113,7 @@ int retrieveAuthInfo(char *meterId, char *spi, char *encrypt, char *secret, char return ret; } -void processRequestMsg(SRpcMsg *pMsg) { +void processRequestMsg(SRpcMsg *pMsg, SRpcIpSet *pIpSet) { SRpcMsg *pTemp; pTemp = taosAllocateQitem(sizeof(SRpcMsg)); From 270e7fc96addc4e20dd5c9639cbc5a0199fc042a Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 11 May 2020 22:26:02 +0800 Subject: [PATCH 3/5] [TD-271] --- src/mnode/src/mgmtTable.c | 14 ++++----- .../script/general/parser/auto_create_tb.sim | 30 +++++++++---------- tests/script/general/table/fill.sim | 2 +- tests/script/jenkins/basic.txt | 19 ++++-------- 4 files changed, 27 insertions(+), 38 deletions(-) diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index d001114bf0..5f1069026f 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -1242,14 +1242,11 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { int32_t numOfTable = htonl(pInfo->numOfTables); SCMSTableVgroupRspMsg *pRsp = NULL; - int32_t contLen = sizeof(SCMSTableVgroupRspMsg); + int32_t contLen = sizeof(SCMSTableVgroupRspMsg) + 32 * sizeof(SCMVgroupInfo) + sizeof(SVgroupsInfo); + //reserve space for (int32_t i = 0; i < numOfTable; ++i) { char *stableName = (char*)pInfo + sizeof(SCMSTableVgroupMsg) + (TSDB_TABLE_ID_LEN) * i; SSuperTableObj *pTable = mgmtGetSuperTable(stableName); - if (pTable != NULL) { - stableName = (char*)pTable; //hack way - } - if (pTable->vgHash != NULL) { contLen += (taosHashGetSize(pTable->vgHash) * sizeof(SCMVgroupInfo) + sizeof(SVgroupsInfo)); } @@ -1263,11 +1260,12 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { } pRsp->numOfTables = htonl(numOfTable); - char *msg = (char *)pRsp + sizeof(SCMSTableVgroupRspMsg); + char* msg = (char*) pRsp + sizeof(SCMSTableVgroupRspMsg); for (int32_t i = 0; i < numOfTable; ++i) { - SSuperTableObj *pTable = (SSuperTableObj *)((char *)pInfo + sizeof(SCMSTableVgroupMsg) + (TSDB_TABLE_ID_LEN)*i); - SVgroupsInfo * pVgroup = (SVgroupsInfo *)msg; + char *stableName = (char*)pInfo + sizeof(SCMSTableVgroupMsg) + (TSDB_TABLE_ID_LEN) * i; + SSuperTableObj *pTable = mgmtGetSuperTable(stableName); + SVgroupsInfo *pVgroup = (SVgroupsInfo *)msg; SHashMutableIterator *pIter = taosHashCreateIter(pTable->vgHash); int32_t vgSize = 0; diff --git a/tests/script/general/parser/auto_create_tb.sim b/tests/script/general/parser/auto_create_tb.sim index 8fb0ddae54..54e028a200 100644 --- a/tests/script/general/parser/auto_create_tb.sim +++ b/tests/script/general/parser/auto_create_tb.sim @@ -96,25 +96,25 @@ $ts1 = $ts0 + 1000 $ts2 = $ts0 + 2000 sql insert into tb_1 using $stb tags (-1) values ( $ts1 , 1,1,1,1,'bin',1,1,1,'涛思数据') ( $ts2 , 2,2,2,2,'binar', 1,1,1,'nchar') sql select * from $stb -if $rows != 3 then +if $rows != 5 then return -1 endi -if $data19 != 涛思数据 then +if $data09 != 涛思数据 then return -1 endi -if $data11 != 1 then +if $data01 != 1 then return -1 endi -if $data22 != 2 then +if $data42 != 2 then return -2 endi -if $data23 != 2.00000 then +if $data43 != 2.00000 then return -1 endi -if $data25 != binar then +if $data45 != binar then return -1 endi -if $data29 != nchar then +if $data49 != nchar then return -1 endi sql drop table tb_1 @@ -127,22 +127,22 @@ sql select * from $stb if $rows != 5 then return -1 endi -if $data19 != 涛思数据 then +if $data09 != 涛思数据 then return -1 endi -if $data11 != 1 then +if $data01 != 1 then return -1 endi -if $data22 != 2 then +if $data42 != 2 then return -2 endi -if $data23 != 2.00000 then +if $data43 != 2.00000 then return -1 endi -if $data25 != binar then +if $data45 != binar then return -1 endi -if $data29 != nchar then +if $data49 != nchar then return -1 endi @@ -154,13 +154,13 @@ sql show tables if $rows != 3 then return -1 endi -if $data00 != tb3 then +if $data00 != tb1 then return -1 endi if $data10 != tb2 then return -1 endi -if $data20 != tb1 then +if $data20 != tb3 then return -1 endi diff --git a/tests/script/general/table/fill.sim b/tests/script/general/table/fill.sim index 00048eb025..333573e577 100644 --- a/tests/script/general/table/fill.sim +++ b/tests/script/general/table/fill.sim @@ -42,7 +42,7 @@ sql select count(*), last(ts), min(k), max(k), avg(k) from db.mt where a=0 and t print =================== step2 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 10000 +sleep 5000 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 f73a23f184..005d2db032 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -1,9 +1,6 @@ cd ../../debug; cmake .. -#cd ../../debug; make clean cd ../../debug; make - cd ../../../debug; cmake .. -#cd ../../../debug; make clean cd ../../../debug; make #./test.sh -f general/alter/cached_schema_after_alter.sim @@ -161,8 +158,6 @@ cd ../../../debug; make #./test.sh -f general/stable/values.sim #./test.sh -f general/stable/vnode3.sim -#stream - ./test.sh -f general/table/autocreate.sim ./test.sh -f general/table/basic1.sim ./test.sh -f general/table/basic2.sim @@ -176,12 +171,12 @@ cd ../../../debug; make ./test.sh -f general/table/column2.sim ./test.sh -f general/table/date.sim ./test.sh -f general/table/db.table.sim -#./test.sh -f general/table/delete_reuse1.sim -#./test.sh -f general/table/delete_reuse2.sim -#./test.sh -f general/table/delete_writing.sim -#./test.sh -f general/table/describe.sim +./test.sh -f general/table/delete_reuse1.sim +./test.sh -f general/table/delete_reuse2.sim +#hongze ./test.sh -f general/table/delete_writing.sim +./test.sh -f general/table/describe.sim ./test.sh -f general/table/double.sim -#./test.sh -f general/table/fill.sim +./test.sh -f general/table/fill.sim ./test.sh -f general/table/float.sim ./test.sh -f general/table/int.sim ./test.sh -f general/table/limit.sim @@ -236,8 +231,6 @@ cd ../../../debug; make ./test.sh -f general/vector/table_query.sim ./test.sh -f general/vector/table_time.sim -################################# - ./test.sh -u -f unique/account/account_create.sim ./test.sh -u -f unique/account/account_delete.sim ./test.sh -u -f unique/account/account_len.sim @@ -307,8 +300,6 @@ cd ../../../debug; make #./test.sh -u -f unique/mnode/mgmtr2.sim #./test.sh -u -f unique/mnode/secondIp.sim -#stream - ##./test.sh -u -f unique/table/delete_part.sim #./test.sh -u -f unique/vnode/commit.sim From 8c0ba3b908eb39663fdc8f22e977b94bbe12676c Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 11 May 2020 22:27:49 +0800 Subject: [PATCH 4/5] scripts --- tests/script/unique/mnode/mgmt22.sim | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/script/unique/mnode/mgmt22.sim b/tests/script/unique/mnode/mgmt22.sim index 37e38fbf66..e4e1235e66 100644 --- a/tests/script/unique/mnode/mgmt22.sim +++ b/tests/script/unique/mnode/mgmt22.sim @@ -8,7 +8,7 @@ system sh/cfg.sh -n dnode2 -c numOfMPeers -v 2 system sh/cfg.sh -n dnode3 -c numOfMPeers -v 2 print ============== step1 -system sh/exec_up.sh -n dnode1 -s start +system sh/exec_up.sh -n dnode1 -s start -t sleep 3000 sql connect @@ -20,7 +20,7 @@ if $data2_1 != master then endi print ============== step2 -system sh/exec_up.sh -n dnode2 -s start +system sh/exec_up.sh -n dnode2 -s start -t sql create dnode $hostname2 $x = 0 @@ -41,6 +41,17 @@ if $data2_2 != slave then goto show2 endi +system sh/exec_up.sh -n dnode1 -s stop -x SIGINT +system sh/exec_up.sh -n dnode2 -s stop -x SIGINT +system sh/exec_up.sh -n dnode3 -s stop -x SIGINT +system sh/exec_up.sh -n dnode4 -s stop -x SIGINT +system sh/exec_up.sh -n dnode5 -s stop -x SIGINT +system sh/exec_up.sh -n dnode6 -s stop -x SIGINT +system sh/exec_up.sh -n dnode7 -s stop -x SIGINT +system sh/exec_up.sh -n dnode8 -s stop -x SIGINT + +return + print ============== step3 sql_error drop dnode $hostname1 -x error1 print should not drop master From aac2a25eb04749a81b8b40c03dea819d96490a89 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 11 May 2020 23:03:04 +0800 Subject: [PATCH 5/5] scripts --- src/mnode/src/mgmtTable.c | 28 +++++++++++++--------------- tests/script/general/db/vnodes.sim | 2 +- tests/script/jenkins/basic.txt | 4 ++-- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index 5f1069026f..49311b0112 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -1241,9 +1241,8 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { SCMSTableVgroupMsg *pInfo = pMsg->pCont; int32_t numOfTable = htonl(pInfo->numOfTables); - SCMSTableVgroupRspMsg *pRsp = NULL; + // reserve space int32_t contLen = sizeof(SCMSTableVgroupRspMsg) + 32 * sizeof(SCMVgroupInfo) + sizeof(SVgroupsInfo); - //reserve space for (int32_t i = 0; i < numOfTable; ++i) { char *stableName = (char*)pInfo + sizeof(SCMSTableVgroupMsg) + (TSDB_TABLE_ID_LEN) * i; SSuperTableObj *pTable = mgmtGetSuperTable(stableName); @@ -1253,7 +1252,7 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { mgmtDecTableRef(pTable); } - pRsp = rpcMallocCont(contLen); + SCMSTableVgroupRspMsg *pRsp = rpcMallocCont(contLen); if (pRsp == NULL) { mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY); return; @@ -1265,32 +1264,31 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { for (int32_t i = 0; i < numOfTable; ++i) { char *stableName = (char*)pInfo + sizeof(SCMSTableVgroupMsg) + (TSDB_TABLE_ID_LEN) * i; SSuperTableObj *pTable = mgmtGetSuperTable(stableName); - SVgroupsInfo *pVgroup = (SVgroupsInfo *)msg; + SVgroupsInfo *pVgroupInfo = (SVgroupsInfo *)msg; SHashMutableIterator *pIter = taosHashCreateIter(pTable->vgHash); int32_t vgSize = 0; while (taosHashIterNext(pIter)) { int32_t *pVgId = taosHashIterGet(pIter); - SVgObj * pVgItem = mgmtGetVgroup(*pVgId - ); - if (pVgItem == NULL) continue; + SVgObj * pVgroup = mgmtGetVgroup(*pVgId); + if (pVgroup == NULL) continue; - pVgroup->vgroups[vgSize].vgId = htonl(pVgItem->vgId); - for (int32_t vn = 0; vn < pVgItem->numOfVnodes; ++vn) { - SDnodeObj *pDnode = pVgItem->vnodeGid[vn].pDnode; + pVgroupInfo->vgroups[vgSize].vgId = htonl(pVgroup->vgId); + for (int32_t vn = 0; vn < pVgroup->numOfVnodes; ++vn) { + SDnodeObj *pDnode = pVgroup->vnodeGid[vn].pDnode; if (pDnode == NULL) break; - strncpy(pVgroup->vgroups[vgSize].ipAddr[vn].fqdn, pDnode->dnodeFqdn, tListLen(pDnode->dnodeFqdn)); - pVgroup->vgroups[vgSize].ipAddr[vn].port = htons(tsDnodeShellPort); + strncpy(pVgroupInfo->vgroups[vgSize].ipAddr[vn].fqdn, pDnode->dnodeFqdn, tListLen(pDnode->dnodeFqdn)); + pVgroupInfo->vgroups[vgSize].ipAddr[vn].port = htons(tsDnodeShellPort); - pVgroup->vgroups[vgSize].numOfIps++; + pVgroupInfo->vgroups[vgSize].numOfIps++; } vgSize++; - mgmtDecVgroupRef(pVgItem); + mgmtDecVgroupRef(pVgroup); } - pVgroup->numOfVgroups = htonl(vgSize); + pVgroupInfo->numOfVgroups = htonl(vgSize); // one table is done, try the next table msg += sizeof(SVgroupsInfo) + vgSize * sizeof(SCMVgroupInfo); diff --git a/tests/script/general/db/vnodes.sim b/tests/script/general/db/vnodes.sim index 87e821fde3..684910884b 100644 --- a/tests/script/general/db/vnodes.sim +++ b/tests/script/general/db/vnodes.sim @@ -1,6 +1,6 @@ system sh/stop_dnodes.sh -$totalVnodes = 100 +$totalVnodes = 10 $maxTables = 4 $totalRows = $totalVnodes * $maxTables diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 005d2db032..62bae1c2a5 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -156,7 +156,7 @@ cd ../../../debug; make #./test.sh -f general/stable/disk.sim #./test.sh -f general/stable/metrics.sim #./test.sh -f general/stable/values.sim -#./test.sh -f general/stable/vnode3.sim +./test.sh -f general/stable/vnode3.sim ./test.sh -f general/table/autocreate.sim ./test.sh -f general/table/basic1.sim @@ -244,7 +244,7 @@ cd ../../../debug; make ./test.sh -u -f unique/account/user_len.sim #./test.sh -u -f unique/big/balance.sim -#./test.sh -u -f unique/big/maxvnodes.sim +#slguan ./test.sh -u -f unique/big/maxvnodes.sim ./test.sh -u -f unique/big/tcp.sim ##./test.sh -u -f unique/cluster/balance1.sim