From 607ca02f30936444dc20e7890d385262cd966a41 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 29 Jul 2020 05:29:54 +0000 Subject: [PATCH 1/9] [TD-997] --- src/inc/mnode.h | 1 + src/mnode/inc/mnodeSdb.h | 12 ++- src/mnode/src/mnodeAcct.c | 2 +- src/mnode/src/mnodeCluster.c | 11 +- src/mnode/src/mnodeDb.c | 41 ++++---- src/mnode/src/mnodeDnode.c | 17 +-- src/mnode/src/mnodeMnode.c | 9 +- src/mnode/src/mnodeSdb.c | 72 +++++++++++-- src/mnode/src/mnodeTable.c | 198 ++++++++++++++++------------------- src/mnode/src/mnodeUser.c | 14 +-- src/mnode/src/mnodeVgroup.c | 70 +++++++++---- 11 files changed, 252 insertions(+), 195 deletions(-) diff --git a/src/inc/mnode.h b/src/inc/mnode.h index 01358fdb44..03a25e0f92 100644 --- a/src/inc/mnode.h +++ b/src/inc/mnode.h @@ -42,6 +42,7 @@ typedef struct SMnodeMsg { int8_t expected; int8_t retry; int32_t code; + void * pObj; struct SAcctObj * pAcct; struct SDnodeObj *pDnode; struct SUserObj * pUser; diff --git a/src/mnode/inc/mnodeSdb.h b/src/mnode/inc/mnodeSdb.h index cadd1b1f3d..f4854f69a0 100644 --- a/src/mnode/inc/mnodeSdb.h +++ b/src/mnode/inc/mnodeSdb.h @@ -47,15 +47,16 @@ typedef enum { SDB_OPER_LOCAL } ESdbOper; -typedef struct { +typedef struct SSdbOper { ESdbOper type; - void * table; - void * pObj; - void * rowData; int32_t rowSize; int32_t retCode; // for callback in sdb queue int32_t processedCount; // for sync fwd callback - int32_t (*cb)(struct SMnodeMsg *pMsg, int32_t code); + int32_t (*reqFp)(struct SMnodeMsg *pMsg); + int32_t (*writeCb)(struct SMnodeMsg *pMsg, int32_t code); + void * table; + void * pObj; + void * rowData; struct SMnodeMsg *pMsg; } SSdbOper; @@ -86,6 +87,7 @@ void sdbUpdateMnodeRoles(); int32_t sdbInsertRow(SSdbOper *pOper); int32_t sdbDeleteRow(SSdbOper *pOper); int32_t sdbUpdateRow(SSdbOper *pOper); +int32_t sdbInsertRowImp(SSdbOper *pOper); void *sdbGetRow(void *handle, void *key); void *sdbFetchRow(void *handle, void *pIter, void **ppRow); diff --git a/src/mnode/src/mnodeAcct.c b/src/mnode/src/mnodeAcct.c index 287e8bb723..c40a696ede 100644 --- a/src/mnode/src/mnodeAcct.c +++ b/src/mnode/src/mnodeAcct.c @@ -85,7 +85,7 @@ static int32_t mnodeAcctActionRestored() { if (numOfRows <= 0 && dnodeIsFirstDeploy()) { mInfo("dnode first deploy, create root acct"); int32_t code = mnodeCreateRootAcct(); - if (code != TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("failed to create root account, reason:%s", tstrerror(code)); return code; } diff --git a/src/mnode/src/mnodeCluster.c b/src/mnode/src/mnodeCluster.c index 8933107dd1..41727712b5 100644 --- a/src/mnode/src/mnodeCluster.c +++ b/src/mnode/src/mnodeCluster.c @@ -71,7 +71,7 @@ static int32_t mnodeClusterActionRestored() { if (numOfRows <= 0 && dnodeIsFirstDeploy()) { mInfo("dnode first deploy, create cluster"); int32_t code = mnodeCreateCluster(); - if (code != TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("failed to create cluster, reason:%s", tstrerror(code)); return code; } @@ -159,16 +159,15 @@ int32_t mnodeGetClusterId() { void mnodeUpdateClusterId() { SClusterObj *pCluster = NULL; - mnodeGetNextCluster(NULL, &pCluster); + void *pIter = mnodeGetNextCluster(NULL, &pCluster); if (pCluster != NULL) { tsClusterId = pCluster->clusterId; - mnodeDecClusterRef(pCluster); mInfo("cluster id is %d", tsClusterId); - } else { - //assert(false); } -} + mnodeDecClusterRef(pCluster); + sdbFreeIter(pIter); +} static int32_t mnodeGetClusterMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) { int32_t cols = 0; diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 199cc63da6..82779e7d69 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -324,8 +324,10 @@ static void mnodeSetDefaultDbCfg(SDbCfg *pCfg) { static int32_t mnodeCreateDbCb(SMnodeMsg *pMsg, int32_t code) { SDbObj *pDb = pMsg->pDb; - if (pDb != NULL) { + if (code == TSDB_CODE_SUCCESS) { mLInfo("db:%s, is created by %s", pDb->name, mnodeGetUserFromMsg(pMsg)); + } else { + mError("db:%s, failed to create by %s, reason:%s", pDb->name, mnodeGetUserFromMsg(pMsg), tstrerror(code)); } return code; @@ -386,17 +388,16 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate, void *pMs .pObj = pDb, .rowSize = sizeof(SDbObj), .pMsg = pMsg, - .cb = mnodeCreateDbCb + .writeCb = mnodeCreateDbCb }; code = sdbInsertRow(&oper); - if (code != TSDB_CODE_SUCCESS) { - mLInfo("db:%s, failed to create, reason:%s", pDb->name, tstrerror(code)); + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { + mError("db:%s, failed to create, reason:%s", pDb->name, tstrerror(code)); mnodeDestroyDb(pDb); - return code; - } else { - return TSDB_CODE_MND_ACTION_IN_PROGRESS; } + + return code; } bool mnodeCheckIsMonitorDB(char *db, char *monitordb) { @@ -754,8 +755,8 @@ static int32_t mnodeSetDbDropping(SDbObj *pDb) { }; int32_t code = sdbUpdateRow(&oper); - if (code != TSDB_CODE_SUCCESS) { - return TSDB_CODE_MND_SDB_ERROR; + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { + mError("db:%s, failed to set dropping state, reason:%s", pDb->name, tstrerror(code)); } return code; @@ -947,12 +948,12 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SCMAlterDbMsg *pAlter, void *pMsg) { .table = tsDbSdb, .pObj = pDb, .pMsg = pMsg, - .cb = mnodeAlterDbCb + .writeCb = mnodeAlterDbCb }; code = sdbUpdateRow(&oper); - if (code == TSDB_CODE_SUCCESS) { - if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { + mError("db:%s, failed to alter, reason:%s", pDb->name, tstrerror(code)); } } @@ -995,16 +996,16 @@ static int32_t mnodeDropDb(SMnodeMsg *pMsg) { mInfo("db:%s, drop db from sdb", pDb->name); SSdbOper oper = { - .type = SDB_OPER_GLOBAL, - .table = tsDbSdb, - .pObj = pDb, - .pMsg = pMsg, - .cb = mnodeDropDbCb + .type = SDB_OPER_GLOBAL, + .table = tsDbSdb, + .pObj = pDb, + .pMsg = pMsg, + .writeCb = mnodeDropDbCb }; int32_t code = sdbDeleteRow(&oper); - if (code == TSDB_CODE_SUCCESS) { - code = TSDB_CODE_MND_ACTION_IN_PROGRESS; + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { + mError("db:%s, failed to drop, reason:%s", pDb->name, tstrerror(code)); } return code; @@ -1031,7 +1032,7 @@ static int32_t mnodeProcessDropDbMsg(SMnodeMsg *pMsg) { } int32_t code = mnodeSetDbDropping(pMsg->pDb); - if (code != TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("db:%s, failed to drop, reason:%s", pDrop->db, tstrerror(code)); return code; } diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index aa05eade24..0b4162c772 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -261,7 +261,8 @@ void mnodeUpdateDnode(SDnodeObj *pDnode) { .pObj = pDnode }; - if (sdbUpdateRow(&oper) != 0) { + int32_t code = sdbUpdateRow(&oper); + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("dnodeId:%d, failed update", pDnode->dnodeId); } } @@ -501,13 +502,12 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) { }; int32_t code = sdbInsertRow(&oper); - if (code != TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { int dnodeId = pDnode->dnodeId; tfree(pDnode); - mError("failed to create dnode:%d, result:%s", dnodeId, tstrerror(code)); + mError("failed to create dnode:%d, reason:%s", dnodeId, tstrerror(code)); } else { - mInfo("dnode:%d is created, result:%s", pDnode->dnodeId, tstrerror(code)); - if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; + mLInfo("dnode:%d is created", pDnode->dnodeId); } return code; @@ -522,9 +522,10 @@ int32_t mnodeDropDnode(SDnodeObj *pDnode, void *pMsg) { }; int32_t code = sdbDeleteRow(&oper); - if (code == TSDB_CODE_SUCCESS) { - mLInfo("dnode:%d, is dropped from cluster, result:%s", pDnode->dnodeId, tstrerror(code)); - if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { + mError("dnode:%d, failed to drop from cluster, result:%s", pDnode->dnodeId, tstrerror(code)); + } else { + mLInfo("dnode:%d, is dropped from cluster", pDnode->dnodeId); } return code; diff --git a/src/mnode/src/mnodeMnode.c b/src/mnode/src/mnodeMnode.c index 2fff885fca..5f82a9afad 100644 --- a/src/mnode/src/mnodeMnode.c +++ b/src/mnode/src/mnodeMnode.c @@ -16,6 +16,7 @@ #define _DEFAULT_SOURCE #include "os.h" #include "taoserror.h" +#include "tglobal.h" #include "trpc.h" #include "tsync.h" #include "tbalance.h" @@ -31,8 +32,6 @@ #include "mnodeShow.h" #include "mnodeUser.h" -#include "tglobal.h" - static void * tsMnodeSdb = NULL; static int32_t tsMnodeUpdateSize = 0; static SRpcEpSet tsMnodeEpSetForShell; @@ -279,9 +278,8 @@ int32_t mnodeAddMnode(int32_t dnodeId) { }; int32_t code = sdbInsertRow(&oper); - if (code != TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { tfree(pMnode); - code = TSDB_CODE_MND_SDB_ERROR; } mnodeUpdateMnodeEpSet(); @@ -313,9 +311,6 @@ int32_t mnodeDropMnode(int32_t dnodeId) { }; int32_t code = sdbDeleteRow(&oper); - if (code != TSDB_CODE_SUCCESS) { - code = TSDB_CODE_MND_SDB_ERROR; - } sdbDecRef(tsMnodeSdb, pMnode); diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index 26efcfeac0..374430879d 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -101,6 +101,11 @@ static int32_t sdbInitWriteWorker(); static void sdbCleanupWriteWorker(); static int32_t sdbAllocWriteQueue(); static void sdbFreeWritequeue(); +static int32_t sdbUpdateRowImp(SSdbOper *pOper); +static int32_t sdbDeleteRowImp(SSdbOper *pOper); +static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper); +static int32_t sdbUpdateHash(SSdbTable *pTable, SSdbOper *pOper); +static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbOper *pOper); int32_t sdbGetId(void *handle) { return ((SSdbTable *)handle)->autoIndex; @@ -260,8 +265,20 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) { tstrerror(code)); } - if (pOper->cb != NULL) { - pOper->retCode = (*pOper->cb)(pMsg, pOper->retCode); + // failed to forward, need revert insert + if (pOper->retCode != TSDB_CODE_SUCCESS) { + SWalHead *pHead = (void *)pOper + sizeof(SSdbOper) + SDB_SYNC_HACK; + int32_t action = pHead->msgType % 10; + sdbError("table:%s record:%p:%s ver:%" PRIu64 ", action:%d failed to foward reason:%s", + ((SSdbTable *)pOper->table)->tableName, pOper->pObj, sdbGetKeyStr(pOper->table, pHead->cont), + pHead->version, action, tstrerror(pOper->retCode)); + if (action == SDB_ACTION_INSERT) { + sdbDeleteHash(pOper->table, pOper); + } + } + + if (pOper->writeCb != NULL) { + pOper->retCode = (*pOper->writeCb)(pMsg, pOper->retCode); } dnodeSendRpcMnodeWriteRsp(pMsg, pOper->retCode); @@ -269,6 +286,7 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) { if (ahandle == NULL) { sdbDecRef(pOper->table, pOper->pObj); } + taosFreeQitem(pOper); } @@ -609,7 +627,8 @@ int32_t sdbInsertRow(SSdbOper *pOper) { if (pTable == NULL) return TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE; if (sdbGetRowFromObj(pTable, pOper->pObj)) { - sdbError("table:%s, failed to insert record:%s, already exist", pTable->tableName, sdbGetKeyStrFromObj(pTable, pOper->pObj)); + sdbError("table:%s, failed to insert record:%s, already exist", pTable->tableName, + sdbGetKeyStrFromObj(pTable, pOper->pObj)); sdbDecRef(pTable, pOper->pObj); return TSDB_CODE_MND_SDB_OBJ_ALREADY_THERE; } @@ -634,9 +653,20 @@ int32_t sdbInsertRow(SSdbOper *pOper) { return TSDB_CODE_SUCCESS; } + if (pOper->reqFp) { + return (*pOper->reqFp)(pOper->pMsg); + } else { + return sdbInsertRowImp(pOper); + } +} + +int32_t sdbInsertRowImp(SSdbOper *pOper) { + SSdbTable *pTable = (SSdbTable *)pOper->table; + if (pTable == NULL) return TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE; + int32_t size = sizeof(SSdbOper) + sizeof(SWalHead) + pTable->maxRowSize + SDB_SYNC_HACK; SSdbOper *pNewOper = taosAllocateQitem(size); - + SWalHead *pHead = (void *)pNewOper + sizeof(SSdbOper) + SDB_SYNC_HACK; pHead->version = 0; pHead->len = pOper->rowSize; @@ -655,7 +685,8 @@ int32_t sdbInsertRow(SSdbOper *pOper) { sdbIncRef(pNewOper->table, pNewOper->pObj); taosWriteQitem(tsSdbWriteQueue, TAOS_QTYPE_RPC, pNewOper); - return TSDB_CODE_SUCCESS; + + return TSDB_CODE_MND_ACTION_IN_PROGRESS; } bool sdbCheckRowDeleted(void *pTableInput, void *pRow) { @@ -664,7 +695,6 @@ bool sdbCheckRowDeleted(void *pTableInput, void *pRow) { int32_t *updateEnd = pRow + pTable->refCountPos - 4; return atomic_val_compare_exchange_32(updateEnd, 1, 1) == 1; - // return (*updateEnd == 1); } int32_t sdbDeleteRow(SSdbOper *pOper) { @@ -692,13 +722,24 @@ int32_t sdbDeleteRow(SSdbOper *pOper) { return TSDB_CODE_SUCCESS; } + if (pOper->reqFp) { + return (*pOper->reqFp)(pOper->pMsg); + } else { + return sdbDeleteRowImp(pOper); + } +} + +int32_t sdbDeleteRowImp(SSdbOper *pOper) { + SSdbTable *pTable = (SSdbTable *)pOper->table; + if (pTable == NULL) return TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE; + int32_t size = sizeof(SSdbOper) + sizeof(SWalHead) + pTable->maxRowSize + SDB_SYNC_HACK; SSdbOper *pNewOper = taosAllocateQitem(size); SWalHead *pHead = (void *)pNewOper + sizeof(SSdbOper) + SDB_SYNC_HACK; pHead->version = 0; pHead->msgType = pTable->tableId * 10 + SDB_ACTION_DELETE; - + pOper->rowData = pHead->cont; (*pTable->encodeFp)(pOper); pHead->len = pOper->rowSize; @@ -711,7 +752,8 @@ int32_t sdbDeleteRow(SSdbOper *pOper) { } taosWriteQitem(tsSdbWriteQueue, TAOS_QTYPE_RPC, pNewOper); - return TSDB_CODE_SUCCESS; + + return TSDB_CODE_MND_ACTION_IN_PROGRESS; } int32_t sdbUpdateRow(SSdbOper *pOper) { @@ -735,6 +777,17 @@ int32_t sdbUpdateRow(SSdbOper *pOper) { return TSDB_CODE_SUCCESS; } + if (pOper->reqFp) { + return (*pOper->reqFp)(pOper->pMsg); + } else { + return sdbUpdateRowImp(pOper); + } +} + +int32_t sdbUpdateRowImp(SSdbOper *pOper) { + SSdbTable *pTable = (SSdbTable *)pOper->table; + if (pTable == NULL) return TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE; + int32_t size = sizeof(SSdbOper) + sizeof(SWalHead) + pTable->maxRowSize + SDB_SYNC_HACK; SSdbOper *pNewOper = taosAllocateQitem(size); @@ -755,7 +808,8 @@ int32_t sdbUpdateRow(SSdbOper *pOper) { sdbIncRef(pNewOper->table, pNewOper->pObj); taosWriteQitem(tsSdbWriteQueue, TAOS_QTYPE_RPC, pNewOper); - return TSDB_CODE_SUCCESS; + + return TSDB_CODE_MND_ACTION_IN_PROGRESS; } void *sdbFetchRow(void *handle, void *pNode, void **ppRow) { diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 053a1522a7..df80fb1c47 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -865,18 +865,17 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) { .pObj = pStable, .rowSize = sizeof(SSuperTableObj) + schemaSize, .pMsg = pMsg, - .cb = mnodeCreateSuperTableCb + .writeCb = mnodeCreateSuperTableCb }; int32_t code = sdbInsertRow(&oper); - if (code != TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mnodeDestroySuperTable(pStable); pMsg->pTable = NULL; mError("app:%p:%p, table:%s, failed to create, sdb error", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId); - return code; - } else { - return TSDB_CODE_MND_ACTION_IN_PROGRESS; } + + return code; } static int32_t mnodeDropSuperTableCb(SMnodeMsg *pMsg, int32_t code) { @@ -924,13 +923,15 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) { .table = tsSuperTableSdb, .pObj = pStable, .pMsg = pMsg, - .cb = mnodeDropSuperTableCb + .writeCb = mnodeDropSuperTableCb }; int32_t code = sdbDeleteRow(&oper); - if (code == TSDB_CODE_SUCCESS) { - return TSDB_CODE_MND_ACTION_IN_PROGRESS; + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { + mError("app:%p:%p, table:%s, failed to drop, reason:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId, + tstrerror(code)); } + return code; } @@ -995,15 +996,10 @@ static int32_t mnodeAddSuperTableTag(SMnodeMsg *pMsg, SSchema schema[], int32_t .table = tsSuperTableSdb, .pObj = pStable, .pMsg = pMsg, - .cb = mnodeAddSuperTableTagCb + .writeCb = mnodeAddSuperTableTagCb }; - int32_t code = sdbUpdateRow(&oper); - if (code == TSDB_CODE_SUCCESS) { - code = TSDB_CODE_MND_ACTION_IN_PROGRESS; - } - - return code; + return sdbUpdateRow(&oper); } static int32_t mnodeDropSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) { @@ -1034,15 +1030,10 @@ static int32_t mnodeDropSuperTableTag(SMnodeMsg *pMsg, char *tagName) { .table = tsSuperTableSdb, .pObj = pStable, .pMsg = pMsg, - .cb = mnodeDropSuperTableTagCb + .writeCb = mnodeDropSuperTableTagCb }; - int32_t code = sdbUpdateRow(&oper); - if (code == TSDB_CODE_SUCCESS) { - code = TSDB_CODE_MND_ACTION_IN_PROGRESS; - } - - return code; + return sdbUpdateRow(&oper); } static int32_t mnodeModifySuperTableTagNameCb(SMnodeMsg *pMsg, int32_t code) { @@ -1083,15 +1074,10 @@ static int32_t mnodeModifySuperTableTagName(SMnodeMsg *pMsg, char *oldTagName, c .table = tsSuperTableSdb, .pObj = pStable, .pMsg = pMsg, - .cb = mnodeModifySuperTableTagNameCb + .writeCb = mnodeModifySuperTableTagNameCb }; - int32_t code = sdbUpdateRow(&oper); - if (code == TSDB_CODE_SUCCESS) { - code = TSDB_CODE_MND_ACTION_IN_PROGRESS; - } - - return code; + return sdbUpdateRow(&oper); } static int32_t mnodeFindSuperTableColumnIndex(SSuperTableObj *pStable, char *colName) { @@ -1162,15 +1148,10 @@ static int32_t mnodeAddSuperTableColumn(SMnodeMsg *pMsg, SSchema schema[], int32 .table = tsSuperTableSdb, .pObj = pStable, .pMsg = pMsg, - .cb = mnodeAddSuperTableColumnCb + .writeCb = mnodeAddSuperTableColumnCb }; - int32_t code = sdbUpdateRow(&oper); - if (code == TSDB_CODE_SUCCESS) { - code = TSDB_CODE_MND_ACTION_IN_PROGRESS; - } - - return code; + return sdbUpdateRow(&oper); } static int32_t mnodeDropSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) { @@ -1212,15 +1193,10 @@ static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, char *colName) { .table = tsSuperTableSdb, .pObj = pStable, .pMsg = pMsg, - .cb = mnodeDropSuperTableColumnCb + .writeCb = mnodeDropSuperTableColumnCb }; - int32_t code = sdbUpdateRow(&oper); - if (code == TSDB_CODE_SUCCESS) { - code = TSDB_CODE_MND_ACTION_IN_PROGRESS; - } - - return code; + return sdbUpdateRow(&oper); } static int32_t mnodeChangeSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) { @@ -1261,15 +1237,10 @@ static int32_t mnodeChangeSuperTableColumn(SMnodeMsg *pMsg, char *oldName, char .table = tsSuperTableSdb, .pObj = pStable, .pMsg = pMsg, - .cb = mnodeChangeSuperTableColumnCb + .writeCb = mnodeChangeSuperTableColumnCb }; - int32_t code = sdbUpdateRow(&oper); - if (code == TSDB_CODE_SUCCESS) { - code = TSDB_CODE_MND_ACTION_IN_PROGRESS; - } - - return code; + return sdbUpdateRow(&oper); } // show super tables @@ -1645,20 +1616,12 @@ static void *mnodeBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableO return pCreate; } -static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) { +static int32_t mnodeDoCreateChildTableFp(SMnodeMsg *pMsg) { SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable; assert(pTable); - if (code == TSDB_CODE_SUCCESS) { - 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)); - } else { - mError("app:%p:%p, table:%s, failed to create table sid:%d, uid:%" PRIu64 ", reason:%s", pMsg->rpcMsg.ahandle, pMsg, - pTable->info.tableId, pTable->sid, pTable->uid, tstrerror(code)); - SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pTable, .table = tsChildTableSdb}; - sdbDeleteRow(&desc); - return code; - } + mDebug("app:%p:%p, table:%s, created in mnode, vgId:%d sid:%d, uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg, + pTable->info.tableId, pTable->vgId, pTable->sid, pTable->uid); SCMCreateTableMsg *pCreate = pMsg->rpcMsg.pCont; SMDCreateTableMsg *pMDCreate = mnodeBuildCreateChildTableMsg(pCreate, pTable); @@ -1679,6 +1642,34 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) { return TSDB_CODE_MND_ACTION_IN_PROGRESS; } +static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) { + SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable; + SCMCreateTableMsg *pCreate = pMsg->rpcMsg.pCont; + assert(pTable); + + if (code == TSDB_CODE_SUCCESS) { + if (pCreate->getMeta) { + mDebug("app:%p:%p, table:%s, created in dnode and continue to get meta, thandle:%p", pMsg->rpcMsg.ahandle, pMsg, + pTable->info.tableId, pMsg->rpcMsg.handle); + + pMsg->retry = 0; + dnodeReprocessMnodeWriteMsg(pMsg); + } else { + mDebug("app:%p:%p, table:%s, created in dnode, thandle:%p", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId, + pMsg->rpcMsg.handle); + + dnodeSendRpcMnodeWriteRsp(pMsg, TSDB_CODE_SUCCESS); + } + return TSDB_CODE_MND_ACTION_IN_PROGRESS; + } else { + mError("app:%p:%p, table:%s, failed to create table sid:%d, uid:%" PRIu64 ", reason:%s", pMsg->rpcMsg.ahandle, pMsg, + pTable->info.tableId, pTable->sid, pTable->uid, tstrerror(code)); + SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pTable, .table = tsChildTableSdb}; + sdbDeleteRow(&desc); + return code; + } +} + static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) { SVgObj *pVgroup = pMsg->pVgroup; SCMCreateTableMsg *pCreate = pMsg->rpcMsg.pCont; @@ -1752,23 +1743,23 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) { pMsg->pTable = (STableObj *)pTable; mnodeIncTableRef(pMsg->pTable); - SSdbOper desc = {0}; - desc.type = SDB_OPER_GLOBAL; - desc.pObj = pTable; - desc.table = tsChildTableSdb; - desc.pMsg = pMsg; - desc.cb = mnodeDoCreateChildTableCb; + SSdbOper desc = { + .type = SDB_OPER_GLOBAL, + .pObj = pTable, + .table = tsChildTableSdb, + .pMsg = pMsg, + .reqFp = mnodeDoCreateChildTableFp + }; int32_t code = sdbInsertRow(&desc); - if (code != TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mnodeDestroyChildTable(pTable); pMsg->pTable = NULL; - mError("app:%p:%p, table:%s, update sdb error, reason:%s", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId, + mError("app:%p:%p, table:%s, failed to create, reason:%s", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId, tstrerror(code)); - return code; - } else { - return TSDB_CODE_MND_ACTION_IN_PROGRESS; } + + return code; } static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) { @@ -1813,7 +1804,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) { return terrno; } else { mDebug("app:%p:%p, table:%s, send create msg to vnode again", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId); - return mnodeDoCreateChildTableCb(pMsg, TSDB_CODE_SUCCESS); + return mnodeDoCreateChildTableFp(pMsg); } } @@ -1878,13 +1869,15 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) { .table = tsChildTableSdb, .pObj = pTable, .pMsg = pMsg, - .cb = mnodeDropChildTableCb + .writeCb = mnodeDropChildTableCb }; int32_t code = sdbDeleteRow(&oper); - if (code == TSDB_CODE_SUCCESS) { - return TSDB_CODE_MND_ACTION_IN_PROGRESS; + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { + mError("app:%p:%p, ctable:%s, failed to drop, reason:%s", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId, + tstrerror(code)); } + return code; } @@ -1980,15 +1973,10 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3 .table = tsChildTableSdb, .pObj = pTable, .pMsg = pMsg, - .cb = mnodeAlterNormalTableColumnCb + .writeCb = mnodeAlterNormalTableColumnCb }; - int32_t code = sdbUpdateRow(&oper); - if (code == TSDB_CODE_SUCCESS) { - return TSDB_CODE_MND_ACTION_IN_PROGRESS; - } - - return code; + return sdbUpdateRow(&oper); } static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) { @@ -2018,15 +2006,10 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) { .table = tsChildTableSdb, .pObj = pTable, .pMsg = pMsg, - .cb = mnodeAlterNormalTableColumnCb + .writeCb = mnodeAlterNormalTableColumnCb }; - int32_t code = sdbUpdateRow(&oper); - if (code == TSDB_CODE_SUCCESS) { - return TSDB_CODE_MND_ACTION_IN_PROGRESS; - } - - return code; + return sdbUpdateRow(&oper); } static int32_t mnodeChangeNormalTableColumn(SMnodeMsg *pMsg, char *oldName, char *newName) { @@ -2060,15 +2043,10 @@ static int32_t mnodeChangeNormalTableColumn(SMnodeMsg *pMsg, char *oldName, char .table = tsChildTableSdb, .pObj = pTable, .pMsg = pMsg, - .cb = mnodeAlterNormalTableColumnCb + .writeCb = mnodeAlterNormalTableColumnCb }; - int32_t code = sdbUpdateRow(&oper); - if (code == TSDB_CODE_SUCCESS) { - code = TSDB_CODE_MND_ACTION_IN_PROGRESS; - } - - return code; + return sdbUpdateRow(&oper); } static int32_t mnodeSetSchemaFromNormalTable(SSchema *pSchema, SChildTableObj *pTable) { @@ -2374,19 +2352,19 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) { } if (rpcMsg->code == TSDB_CODE_SUCCESS || rpcMsg->code == TSDB_CODE_TDB_TABLE_ALREADY_EXIST) { - SCMCreateTableMsg *pCreate = mnodeMsg->rpcMsg.pCont; - if (pCreate->getMeta) { - mDebug("app:%p:%p, table:%s, created in dnode and continue to get meta, thandle:%p result:%s", - mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, mnodeMsg->rpcMsg.handle, - tstrerror(rpcMsg->code)); - - mnodeMsg->retry = 0; - dnodeReprocessMnodeWriteMsg(mnodeMsg); - } else { - mDebug("app:%p:%p, table:%s, created in dnode, thandle:%p result:%s", mnodeMsg->rpcMsg.ahandle, mnodeMsg, - pTable->info.tableId, mnodeMsg->rpcMsg.handle, tstrerror(rpcMsg->code)); - - dnodeSendRpcMnodeWriteRsp(mnodeMsg, TSDB_CODE_SUCCESS); + SSdbOper desc = { + .type = SDB_OPER_GLOBAL, + .pObj = pTable, + .table = tsChildTableSdb, + .pMsg = mnodeMsg, + .writeCb = mnodeDoCreateChildTableCb + }; + + int32_t code = sdbInsertRowImp(&desc); + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { + mnodeMsg->pTable = NULL; + mnodeDestroyChildTable(pTable); + dnodeSendRpcMnodeWriteRsp(mnodeMsg, code); } } else { if (mnodeMsg->retry++ < 10) { diff --git a/src/mnode/src/mnodeUser.c b/src/mnode/src/mnodeUser.c index 8c783eebaf..a875cff4a2 100644 --- a/src/mnode/src/mnodeUser.c +++ b/src/mnode/src/mnodeUser.c @@ -182,9 +182,10 @@ static int32_t mnodeUpdateUser(SUserObj *pUser, void *pMsg) { }; int32_t code = sdbUpdateRow(&oper); - if (code == TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { + mError("user:%s, failed to alter by %s, reason:%s", pUser->user, mnodeGetUserFromMsg(pMsg), tstrerror(code)); + } else { mLInfo("user:%s, is altered by %s", pUser->user, mnodeGetUserFromMsg(pMsg)); - if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; } return code; @@ -236,11 +237,11 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) { }; code = sdbInsertRow(&oper); - if (code != TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { + mError("user:%s, failed to create by %s, reason:%s", pUser->user, mnodeGetUserFromMsg(pMsg), tstrerror(code)); tfree(pUser); } else { mLInfo("user:%s, is created by %s", pUser->user, mnodeGetUserFromMsg(pMsg)); - if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; } return code; @@ -255,9 +256,10 @@ static int32_t mnodeDropUser(SUserObj *pUser, void *pMsg) { }; int32_t code = sdbDeleteRow(&oper); - if (code == TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { + mError("user:%s, failed to drop by %s, reason:%s", pUser->user, mnodeGetUserFromMsg(pMsg), tstrerror(code)); + } else { mLInfo("user:%s, is dropped by %s", pUser->user, mnodeGetUserFromMsg(pMsg)); - if (pMsg != NULL) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; } return code; diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 089168c31e..df5df8c94a 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -256,7 +256,8 @@ void mnodeUpdateVgroup(SVgObj *pVgroup) { .pObj = pVgroup }; - if (sdbUpdateRow(&oper) != TSDB_CODE_SUCCESS) { + int32_t code = sdbUpdateRow(&oper); + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("vgId:%d, failed to update vgroup", pVgroup->vgId); } mnodeSendAlterVgroupMsg(pVgroup); @@ -476,23 +477,11 @@ void *mnodeGetNextVgroup(void *pIter, SVgObj **pVgroup) { return sdbFetchRow(tsVgroupSdb, pIter, (void **)pVgroup); } -static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) { +static int32_t mnodeCreateVgroupFp(SMnodeMsg *pMsg) { SVgObj *pVgroup = pMsg->pVgroup; SDbObj *pDb = pMsg->pDb; assert(pVgroup); - if (code != TSDB_CODE_SUCCESS) { - mError("app:%p:%p, vgId:%d, failed to create in sdb, reason:%s", pMsg->rpcMsg.ahandle, pMsg, pVgroup->vgId, - tstrerror(code)); - SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .table = tsVgroupSdb}; - sdbDeleteRow(&desc); - return code; - } else { - pVgroup->status = TAOS_VG_STATUS_READY; - SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .table = tsVgroupSdb}; - (void)sdbUpdateRow(&desc); - } - mInfo("app:%p:%p, vgId:%d, is created in mnode, db:%s replica:%d", pMsg->rpcMsg.ahandle, pMsg, pVgroup->vgId, pDb->name, pVgroup->numOfVnodes); for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) { @@ -508,6 +497,29 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) { return TSDB_CODE_MND_ACTION_IN_PROGRESS; } +static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) { + SVgObj *pVgroup = pMsg->pVgroup; + SDbObj *pDb = pMsg->pDb; + assert(pVgroup); + + if (code != TSDB_CODE_SUCCESS) { + mError("app:%p:%p, vgId:%d, failed to create in sdb, reason:%s", pMsg->rpcMsg.ahandle, pMsg, pVgroup->vgId, + tstrerror(code)); + SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .table = tsVgroupSdb}; + sdbDeleteRow(&desc); + return code; + } else { + mInfo("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d", pMsg->rpcMsg.ahandle, pMsg, pVgroup->vgId, + pDb->name, pVgroup->numOfVnodes); + pVgroup->status = TAOS_VG_STATUS_READY; + SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .table = tsVgroupSdb}; + (void)sdbUpdateRow(&desc); + + dnodeReprocessMnodeWriteMsg(pMsg); + return TSDB_CODE_MND_ACTION_IN_PROGRESS; + } +} + int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) { if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR; SDbObj *pDb = pMsg->pDb; @@ -527,20 +539,18 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) { mnodeIncVgroupRef(pVgroup); SSdbOper oper = { - .type = SDB_OPER_GLOBAL, - .table = tsVgroupSdb, - .pObj = pVgroup, + .type = SDB_OPER_GLOBAL, + .table = tsVgroupSdb, + .pObj = pVgroup, .rowSize = sizeof(SVgObj), - .pMsg = pMsg, - .cb = mnodeCreateVgroupCb + .pMsg = pMsg, + .reqFp = mnodeCreateVgroupFp }; int32_t code = sdbInsertRow(&oper); - if (code != TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { pMsg->pVgroup = NULL; mnodeDestroyVgroup(pVgroup); - } else { - code = TSDB_CODE_MND_ACTION_IN_PROGRESS; } return code; @@ -891,7 +901,21 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) { if (mnodeMsg->received != mnodeMsg->expected) return; if (mnodeMsg->received == mnodeMsg->successed) { - dnodeReprocessMnodeWriteMsg(mnodeMsg); + SSdbOper oper = { + .type = SDB_OPER_GLOBAL, + .table = tsVgroupSdb, + .pObj = pVgroup, + .rowSize = sizeof(SVgObj), + .pMsg = mnodeMsg, + .writeCb = mnodeCreateVgroupCb + }; + + int32_t code = sdbInsertRowImp(&oper); + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { + mnodeMsg->pVgroup = NULL; + mnodeDestroyVgroup(pVgroup); + dnodeSendRpcMnodeWriteRsp(mnodeMsg, code); + } } else { SSdbOper oper = { .type = SDB_OPER_GLOBAL, From 835a7f440b7d55dcd0080ee2fe0de1b9cc64d159 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 29 Jul 2020 18:57:06 +0800 Subject: [PATCH 2/9] [TD-997] --- src/mnode/src/mnodeSdb.c | 8 ++++---- src/mnode/src/mnodeTable.c | 8 +++++--- src/mnode/src/mnodeVgroup.c | 10 +++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index 374430879d..f3f6e33431 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -414,8 +414,8 @@ void sdbIncRef(void *handle, void *pObj) { SSdbTable *pTable = handle; int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos); - atomic_add_fetch_32(pRefCount, 1); - sdbTrace("add ref to table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); + int32_t refCount = atomic_add_fetch_32(pRefCount, 1); + sdbTrace("add ref to table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), refCount); } void sdbDecRef(void *handle, void *pObj) { @@ -424,11 +424,11 @@ void sdbDecRef(void *handle, void *pObj) { SSdbTable *pTable = handle; int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos); int32_t refCount = atomic_sub_fetch_32(pRefCount, 1); - sdbTrace("def ref of table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); + sdbTrace("def ref of table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), refCount); int32_t *updateEnd = pObj + pTable->refCountPos - 4; if (refCount <= 0 && *updateEnd) { - sdbTrace("table:%s, record:%p:%s:%d is destroyed", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); + sdbTrace("table:%s, record:%p:%s:%d is destroyed", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), refCount); SSdbOper oper = {.pObj = pObj}; (*pTable->destroyFp)(&oper); } diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index df80fb1c47..009633b43b 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -128,9 +128,11 @@ static int32_t mnodeChildTableActionInsert(SSdbOper *pOper) { if (pTable->info.type == TSDB_CHILD_TABLE) { // add ref pTable->superTable = mnodeGetSuperTableByUid(pTable->suid); - mnodeAddTableIntoStable(pTable->superTable, pTable); - grantAdd(TSDB_GRANT_TIMESERIES, pTable->superTable->numOfColumns - 1); - if (pAcct) pAcct->acctInfo.numOfTimeSeries += (pTable->superTable->numOfColumns - 1); + if (pTable->superTable != NULL) { + mnodeAddTableIntoStable(pTable->superTable, pTable); + grantAdd(TSDB_GRANT_TIMESERIES, pTable->superTable->numOfColumns - 1); + if (pAcct) pAcct->acctInfo.numOfTimeSeries += (pTable->superTable->numOfColumns - 1); + } } else { grantAdd(TSDB_GRANT_TIMESERIES, pTable->numOfColumns - 1); if (pAcct) pAcct->acctInfo.numOfTimeSeries += (pTable->numOfColumns - 1); diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index df5df8c94a..0c7a76fd0d 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -535,6 +535,10 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) { return TSDB_CODE_MND_NO_ENOUGH_DNODES; } + if (pMsg->pVgroup != NULL) { + mnodeDecVgroupRef(pMsg->pVgroup); + } + pMsg->pVgroup = pVgroup; mnodeIncVgroupRef(pVgroup); @@ -922,11 +926,7 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) { .table = tsVgroupSdb, .pObj = pVgroup }; - int32_t code = sdbDeleteRow(&oper); - if (code != 0) { - code = TSDB_CODE_MND_SDB_ERROR; - } - + sdbDeleteRow(&oper); dnodeSendRpcMnodeWriteRsp(mnodeMsg, mnodeMsg->code); } } From 45ec0df68ba9bf29e28344d280da76fdd976c7f7 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 29 Jul 2020 11:34:00 +0000 Subject: [PATCH 3/9] failed to compile whle random test enabled --- src/os/inc/osSpec.h | 9 +++++++-- src/tsdb/src/tsdbMain.c | 6 ++++-- src/util/src/tlog.c | 3 +++ src/util/src/tnote.c | 3 +++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/os/inc/osSpec.h b/src/os/inc/osSpec.h index 48ec6ae04f..d93a647206 100644 --- a/src/os/inc/osSpec.h +++ b/src/os/inc/osSpec.h @@ -338,14 +338,15 @@ void taosRemoveDir(char *rootDir); int taosMkDir(const char *pathname, mode_t mode); void taosMvDir(char* destDir, char *srcDir); - - #ifdef TAOS_RANDOM_FILE_FAIL void taosSetRandomFileFailFactor(int factor); void taosSetRandomFileFailOutput(const char *path); ssize_t taosReadFileRandomFail(int fd, void *buf, size_t count, const char *file, uint32_t line); ssize_t taosWriteFileRandomFail(int fd, void *buf, size_t count, const char *file, uint32_t line); off_t taosLSeekRandomFail(int fd, off_t offset, int whence, const char *file, uint32_t line); + #undef taosTRead + #undef taosTWrite + #undef taosLSeek #define taosTRead(fd, buf, count) taosReadFileRandomFail(fd, buf, count, __FILE__, __LINE__) #define taosTWrite(fd, buf, count) taosWriteFileRandomFail(fd, buf, count, __FILE__, __LINE__) #define taosLSeek(fd, offset, whence) taosLSeekRandomFail(fd, offset, whence, __FILE__, __LINE__) @@ -356,6 +357,10 @@ void taosMvDir(char* destDir, char *srcDir); ssize_t taosSendToRandomFail(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); ssize_t taosReadSocketRandomFail(int fd, void *buf, size_t count); ssize_t taosWriteSocketRandomFail(int fd, const void *buf, size_t count); + #undef taosSend + #undef taosSendto + #undef taosReadSocket + #undef taosWriteSocket #define taosSend(sockfd, buf, len, flags) taosSendRandomFail(sockfd, buf, len, flags) #define taosSendto(sockfd, buf, len, flags, dest_addr, addrlen) taosSendToRandomFail(sockfd, buf, len, flags, dest_addr, addrlen) #define taosReadSocket(fd, buf, len) taosReadSocketRandomFail(fd, buf, len) diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 3a453249a9..895bd4ae51 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -12,6 +12,10 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ + +// no test file errors here +#undef TAOS_RANDOM_FILE_FAIL + #include "tsdbMain.h" #include "os.h" #include "talgo.h" @@ -22,8 +26,6 @@ #include "ttime.h" #include "tulog.h" -#include -#include #define TSDB_CFG_FILE_NAME "config" #define TSDB_DATA_DIR_NAME "data" diff --git a/src/util/src/tlog.c b/src/util/src/tlog.c index 2489ae56be..96ae417297 100644 --- a/src/util/src/tlog.c +++ b/src/util/src/tlog.c @@ -14,6 +14,9 @@ */ #define _DEFAULT_SOURCE +// no test file errors here +#undef TAOS_RANDOM_FILE_FAIL + #include "os.h" #include "tulog.h" #include "tlog.h" diff --git a/src/util/src/tnote.c b/src/util/src/tnote.c index fdf11eb5c4..91916c92d7 100644 --- a/src/util/src/tnote.c +++ b/src/util/src/tnote.c @@ -13,6 +13,9 @@ * along with this program. If not, see . */ +// no test file errors here +#undef TAOS_RANDOM_FILE_FAIL + #include "tnote.h" taosNoteInfo m_HttpNote; From 12633aa2915621731eaa371ce31ff9be86214afb Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 29 Jul 2020 14:54:10 +0000 Subject: [PATCH 4/9] [TD-993] add error code of "cluster not ready" --- src/balance/src/balance.c | 11 ++++++++--- src/inc/taoserror.h | 1 + src/mnode/inc/mnodeDnode.h | 2 +- src/mnode/src/mnodeDnode.c | 2 +- src/mnode/src/mnodeShow.c | 2 +- src/mnode/src/mnodeVgroup.c | 17 ++++++++++------- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/balance/src/balance.c b/src/balance/src/balance.c index 3ef616bff0..7aed8c05ca 100644 --- a/src/balance/src/balance.c +++ b/src/balance/src/balance.c @@ -142,9 +142,14 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) { if (vnodes != pVgroup->numOfVnodes) { mDebug("vgId:%d, db:%s need vnodes:%d, but alloc:%d, free them", pVgroup->vgId, pVgroup->dbName, pVgroup->numOfVnodes, vnodes); - balanceReleaseDnodeList(); + balanceReleaseDnodeList(); balanceUnLock(); - return -1; + + if (mnodeGetOnlineDnodesNum() == 0) { + return TSDB_CODE_MND_NOT_READY; + } else { + return TSDB_CODE_MND_NO_ENOUGH_DNODES; + } } /* @@ -179,7 +184,7 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) { balanceReleaseDnodeList(); balanceUnLock(); - return 0; + return TSDB_CODE_SUCCESS; } static bool balanceCheckVgroupReady(SVgObj *pVgroup, SVnodeGid *pRmVnode) { diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index bb3a6ee78e..813443c347 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -132,6 +132,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_NOT_IN_DNODE, 0, 0x0338, "vgroup not TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE, 0, 0x0339, "vgroup already in dnode") TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_NOT_FREE, 0, 0x033A, "dnode not avaliable") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CLUSTER_ID, 0, 0x033B, "cluster id not match") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_NOT_READY, 0, 0x033C, "cluster not ready") TAOS_DEFINE_ERROR(TSDB_CODE_MND_ACCT_ALREADY_EXIST, 0, 0x0340, "mnode accounts already exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_ACCT, 0, 0x0341, "mnode invalid account") diff --git a/src/mnode/inc/mnodeDnode.h b/src/mnode/inc/mnodeDnode.h index f371786524..13b6ec4411 100644 --- a/src/mnode/inc/mnodeDnode.h +++ b/src/mnode/inc/mnodeDnode.h @@ -41,7 +41,7 @@ void mgmtMonitorDnodeModule(); int32_t mnodeGetDnodesNum(); int32_t mnodeGetOnlinDnodesCpuCoreNum(); -int32_t mnodeGetOnlinDnodesNum(); +int32_t mnodeGetOnlineDnodesNum(); void * mnodeGetNextDnode(void *pIter, SDnodeObj **pDnode); void mnodeIncDnodeRef(SDnodeObj *pDnode); void mnodeDecDnodeRef(SDnodeObj *pDnode); diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index 0b4162c772..be15abe354 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -206,7 +206,7 @@ int32_t mnodeGetOnlinDnodesCpuCoreNum() { return cpuCores; } -int32_t mnodeGetOnlinDnodesNum() { +int32_t mnodeGetOnlineDnodesNum() { SDnodeObj *pDnode = NULL; void * pIter = NULL; int32_t onlineDnodes = 0; diff --git a/src/mnode/src/mnodeShow.c b/src/mnode/src/mnodeShow.c index d7f058b3a8..859688cd0d 100644 --- a/src/mnode/src/mnodeShow.c +++ b/src/mnode/src/mnodeShow.c @@ -270,7 +270,7 @@ static int32_t mnodeProcessHeartBeatMsg(SMnodeMsg *pMsg) { } } - pHBRsp->onlineDnodes = htonl(mnodeGetOnlinDnodesNum()); + pHBRsp->onlineDnodes = htonl(mnodeGetOnlineDnodesNum()); pHBRsp->totalDnodes = htonl(mnodeGetDnodesNum()); mnodeGetMnodeEpSetForShell(&pHBRsp->epSet); diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 0c7a76fd0d..95f3e6a6c6 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -434,11 +434,12 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi maxVgroupsPerDb = MAX(maxVgroupsPerDb, 2); } + int32_t code = TSDB_CODE_MND_NO_ENOUGH_DNODES; if (pDb->numOfVgroups < maxVgroupsPerDb) { 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); - int32_t code = mnodeCreateVgroup(pMsg); + code = mnodeCreateVgroup(pMsg); if (code == TSDB_CODE_MND_ACTION_IN_PROGRESS) { return code; } else { @@ -449,10 +450,10 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi SVgObj *pVgroup = pDb->vgList[0]; if (pVgroup == NULL) { pthread_mutex_unlock(&pDb->mutex); - return TSDB_CODE_MND_NO_ENOUGH_DNODES; + return code; } - int32_t code = mnodeAllocVgroupIdPool(pVgroup); + code = mnodeAllocVgroupIdPool(pVgroup); if (code != TSDB_CODE_SUCCESS) { pthread_mutex_unlock(&pDb->mutex); return code; @@ -529,10 +530,12 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) { pVgroup->numOfVnodes = pDb->cfg.replications; pVgroup->createdTime = taosGetTimestampMs(); pVgroup->accessState = TSDB_VN_ALL_ACCCESS; - if (balanceAllocVnodes(pVgroup) != 0) { - mError("db:%s, no enough dnode to alloc %d vnodes to vgroup", pDb->name, pVgroup->numOfVnodes); + int32_t code = balanceAllocVnodes(pVgroup); + if (code != TSDB_CODE_SUCCESS) { + mError("db:%s, no enough dnode to alloc %d vnodes to vgroup, reason:%s", pDb->name, pVgroup->numOfVnodes, + tstrerror(code)); free(pVgroup); - return TSDB_CODE_MND_NO_ENOUGH_DNODES; + return code; } if (pMsg->pVgroup != NULL) { @@ -551,7 +554,7 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) { .reqFp = mnodeCreateVgroupFp }; - int32_t code = sdbInsertRow(&oper); + code = sdbInsertRow(&oper); if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { pMsg->pVgroup = NULL; mnodeDestroyVgroup(pVgroup); From 4d34d09f593d4a958abc9737d506a0392b578698 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 29 Jul 2020 15:53:38 +0000 Subject: [PATCH 5/9] [TD-1003] --- src/mnode/inc/mnodeDef.h | 1 + src/mnode/src/mnodeShow.c | 46 +++++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/mnode/inc/mnodeDef.h b/src/mnode/inc/mnodeDef.h index 02848089cb..f6e3904c64 100644 --- a/src/mnode/inc/mnodeDef.h +++ b/src/mnode/inc/mnodeDef.h @@ -251,6 +251,7 @@ typedef struct { int32_t rowSize; int32_t numOfRows; void * pIter; + void ** ppShow; int16_t offset[TSDB_MAX_COLUMNS]; int16_t bytes[TSDB_MAX_COLUMNS]; int32_t numOfReads; diff --git a/src/mnode/src/mnodeShow.c b/src/mnode/src/mnodeShow.c index 859688cd0d..733bd43c74 100644 --- a/src/mnode/src/mnodeShow.c +++ b/src/mnode/src/mnodeShow.c @@ -49,8 +49,8 @@ static int32_t mnodeProcessUseMsg(SMnodeMsg *mnodeMsg); static void mnodeFreeShowObj(void *data); static bool mnodeAccquireShowObj(SShowObj *pShow); static bool mnodeCheckShowFinished(SShowObj *pShow); -static void *mnodePutShowObj(SShowObj *pShow, int32_t size); -static void mnodeReleaseShowObj(void *pShow, bool forceRemove); +static void *mnodePutShowObj(SShowObj *pShow); +static void mnodeReleaseShowObj(SShowObj *pShow, bool forceRemove); extern void *tsMnodeTmr; static void *tsMnodeShowCache = NULL; @@ -65,7 +65,7 @@ int32_t mnodeInitShow() { mnodeAddReadMsgHandle(TSDB_MSG_TYPE_CM_CONNECT, mnodeProcessConnectMsg); mnodeAddReadMsgHandle(TSDB_MSG_TYPE_CM_USE_DB, mnodeProcessUseMsg); - tsMnodeShowCache = taosCacheInit(TSDB_DATA_TYPE_INT, 5, false, mnodeFreeShowObj, "show"); + tsMnodeShowCache = taosCacheInit(TSDB_DATA_TYPE_BIGINT, 5, false, mnodeFreeShowObj, "show"); return 0; } @@ -121,13 +121,13 @@ static int32_t mnodeProcessShowMsg(SMnodeMsg *pMsg) { } int32_t showObjSize = sizeof(SShowObj) + htons(pShowMsg->payloadLen); - SShowObj *pShow = (SShowObj *) calloc(1, showObjSize); + SShowObj *pShow = calloc(1, showObjSize); pShow->type = pShowMsg->type; pShow->payloadLen = htons(pShowMsg->payloadLen); tstrncpy(pShow->db, pShowMsg->db, TSDB_DB_NAME_LEN); memcpy(pShow->payload, pShowMsg->payload, pShow->payloadLen); - pShow = mnodePutShowObj(pShow, showObjSize); + pShow = mnodePutShowObj(pShow); if (pShow == NULL) { return TSDB_CODE_MND_OUT_OF_MEMORY; } @@ -377,37 +377,41 @@ static bool mnodeCheckShowFinished(SShowObj *pShow) { } static bool mnodeAccquireShowObj(SShowObj *pShow) { - SShowObj *pSaved = taosCacheAcquireByKey(tsMnodeShowCache, &pShow->index, sizeof(int32_t)); - if (pSaved == pShow) { - mDebug("%p, show is accquired from cache", pShow); + SShowObj **ppShow = taosCacheAcquireByKey(tsMnodeShowCache, &pShow, sizeof(int64_t)); + if (ppShow) { + mDebug("%p, show is accquired from cache, data:%p, index:%d", pShow, ppShow, pShow->index); return true; - } else { - return false; } + + return false; } -static void *mnodePutShowObj(SShowObj *pShow, int32_t size) { +static void* mnodePutShowObj(SShowObj *pShow) { if (tsMnodeShowCache != NULL) { pShow->index = atomic_add_fetch_32(&tsShowObjIndex, 1); - SShowObj *newQhandle = taosCachePut(tsMnodeShowCache, &pShow->index, sizeof(int32_t), pShow, size, 6); - mDebug("%p, show is put into cache, index:%d", newQhandle, pShow->index); - free(pShow); - - return newQhandle; + SShowObj **ppShow = taosCachePut(tsMnodeShowCache, &pShow, sizeof(int64_t), &pShow, sizeof(int64_t), 6); + pShow->ppShow = (void**)ppShow; + mDebug("%p, show is put into cache, data:%p index:%d", pShow, ppShow, pShow->index); + return pShow; } return NULL; } static void mnodeFreeShowObj(void *data) { - SShowObj *pShow = data; + SShowObj *pShow = *(SShowObj **)data; sdbFreeIter(pShow->pIter); - mDebug("%p, show is destroyed", pShow); + + mDebug("%p, show is destroyed, data:%p index:%d", pShow, data, pShow->index); + tfree(pShow); } -static void mnodeReleaseShowObj(void *pShow, bool forceRemove) { - mDebug("%p, show is released, force:%s", pShow, forceRemove ? "true" : "false"); - taosCacheRelease(tsMnodeShowCache, &pShow, forceRemove); +static void mnodeReleaseShowObj(SShowObj *pShow, bool forceRemove) { + SShowObj **ppShow = (SShowObj **)pShow->ppShow; + mDebug("%p, show is released, force:%s data:%p index:%d", pShow, forceRemove ? "true" : "false", ppShow, + pShow->index); + + taosCacheRelease(tsMnodeShowCache, (void **)(&ppShow), forceRemove); } void mnodeVacuumResult(char *data, int32_t numOfCols, int32_t rows, int32_t capacity, SShowObj *pShow) { From 4ac04e47ea9b7fcf8790289c3c9642a90f8f7a67 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 30 Jul 2020 10:51:41 +0800 Subject: [PATCH 6/9] [TD-894] --- src/inc/taoserror.h | 336 ++++++++++++++++++++++---------------------- 1 file changed, 168 insertions(+), 168 deletions(-) diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 813443c347..ece08ae173 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -46,200 +46,200 @@ static STaosError errors[] = { #endif // rpc -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_ACTION_IN_PROGRESS, 0, 0x0001, "action in progress") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_AUTH_REQUIRED, 0, 0x0002, "auth required") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_AUTH_FAILURE, 0, 0x0003, "auth failure") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_REDIRECT, 0, 0x0004, "redirect") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NOT_READY, 0, 0x0005, "not ready") // peer is not ready to process data -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_ALREADY_PROCESSED, 0, 0x0006, "message already processed") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_LAST_SESSION_NOT_FINISHED,0, 0x0007, "last session not finished") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_MISMATCHED_LINK_ID, 0, 0x0008, "mismatched meter id") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_TOO_SLOW, 0, 0x0009, "too slow") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_MAX_SESSIONS, 0, 0x000A, "max sessions") // too many sessions -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_UNAVAIL, 0, 0x000B, "network unavailable") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_APP_ERROR, 0, 0x000C, "rpc app error") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_UNEXPECTED_RESPONSE, 0, 0x000D, "unexpected response") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_VALUE, 0, 0x000E, "invalid value") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_TRAN_ID, 0, 0x000F, "invalid transaction id") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_SESSION_ID, 0, 0x0010, "invalid session id") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_MSG_TYPE, 0, 0x0011, "invalid message type") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_RESPONSE_TYPE, 0, 0x0012, "invalid response type") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_TIME_STAMP, 0, 0x0013, "invalid timestamp") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_ACTION_IN_PROGRESS, 0, 0x0001, "Action in progress") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_AUTH_REQUIRED, 0, 0x0002, "Authentication required") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_AUTH_FAILURE, 0, 0x0003, "Authentication failure") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_REDIRECT, 0, 0x0004, "Redirect") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NOT_READY, 0, 0x0005, "System not ready") // peer is not ready to process data +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_ALREADY_PROCESSED, 0, 0x0006, "Message already processed") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_LAST_SESSION_NOT_FINISHED,0, 0x0007, "Last session not finished") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_MISMATCHED_LINK_ID, 0, 0x0008, "Mismatched meter id") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_TOO_SLOW, 0, 0x0009, "Processing of request timed out") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_MAX_SESSIONS, 0, 0x000A, "Number of sessions reached limit") // too many sessions +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_UNAVAIL, 0, 0x000B, "Unable to establish connection") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_APP_ERROR, 0, 0x000C, "Unexpected generic error in RPC") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_UNEXPECTED_RESPONSE, 0, 0x000D, "Unexpected response") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_VALUE, 0, 0x000E, "Invalid value") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_TRAN_ID, 0, 0x000F, "Invalid transaction id") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_SESSION_ID, 0, 0x0010, "Invalid session id") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_MSG_TYPE, 0, 0x0011, "Invalid message type") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_RESPONSE_TYPE, 0, 0x0012, "Invalid response type") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_INVALID_TIME_STAMP, 0, 0x0013, "Invalid timestamp") //common & util -TAOS_DEFINE_ERROR(TSDB_CODE_COM_OPS_NOT_SUPPORT, 0, 0x0100, "operations not support") -TAOS_DEFINE_ERROR(TSDB_CODE_COM_MEMORY_CORRUPTED, 0, 0x0101, "memory corrupted") -TAOS_DEFINE_ERROR(TSDB_CODE_COM_OUT_OF_MEMORY, 0, 0x0102, "out of memory") -TAOS_DEFINE_ERROR(TSDB_CODE_COM_INVALID_CFG_MSG, 0, 0x0103, "invalid config message") -TAOS_DEFINE_ERROR(TSDB_CODE_COM_FILE_CORRUPTED, 0, 0x0104, "file is corrupted") +TAOS_DEFINE_ERROR(TSDB_CODE_COM_OPS_NOT_SUPPORT, 0, 0x0100, "Operation not supported") +TAOS_DEFINE_ERROR(TSDB_CODE_COM_MEMORY_CORRUPTED, 0, 0x0101, "Memory corrupted") +TAOS_DEFINE_ERROR(TSDB_CODE_COM_OUT_OF_MEMORY, 0, 0x0102, "Out of memory") +TAOS_DEFINE_ERROR(TSDB_CODE_COM_INVALID_CFG_MSG, 0, 0x0103, "Invalid config message") +TAOS_DEFINE_ERROR(TSDB_CODE_COM_FILE_CORRUPTED, 0, 0x0104, "Data file corrupted") //client -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_SQL, 0, 0x0200, "invalid sql") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_QHANDLE, 0, 0x0201, "client invalid qhandle") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_TIME_STAMP, 0, 0x0202, "client time/server time can not be mixed up") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_VALUE, 0, 0x0203, "clientinvalid value") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_VERSION, 0, 0x0204, "client invalid version") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_IE, 0, 0x0205, "client invalid ie") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_FQDN, 0, 0x0206, "client invalid fqdn") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_USER_LENGTH, 0, 0x0207, "client invalid username length") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_PASS_LENGTH, 0, 0x0208, "client invalid password length") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_DB_LENGTH, 0, 0x0209, "client invalid database length") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH, 0, 0x020A, "client invalid table length") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_CONNECTION, 0, 0x020B, "client invalid connection") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_OUT_OF_MEMORY, 0, 0x020C, "client out of memory") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_DISKSPACE, 0, 0x020D, "client no disk space") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_QUERY_CACHE_ERASED, 0, 0x020E, "client query cache erased") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_QUERY_CANCELLED, 0, 0x020F, "client query cancelled") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_SORTED_RES_TOO_MANY, 0, 0x0210, "client sorted res too many") // too many result for ordered super table projection query -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_APP_ERROR, 0, 0x0211, "client app error") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_ACTION_IN_PROGRESS, 0, 0x0212, "client action in progress") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_DISCONNECTED, 0, 0x0213, "client disconnected") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_WRITE_AUTH, 0, 0x0214, "client no write auth") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_SQL, 0, 0x0200, "Invalid SQL statement") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_QHANDLE, 0, 0x0201, "Invalid qhandle") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_TIME_STAMP, 0, 0x0202, "Invalid combination of client/service time") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_VALUE, 0, 0x0203, "Invalid value in client") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_VERSION, 0, 0x0204, "Invalid client version") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_IE, 0, 0x0205, "Invalid client ie") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_FQDN, 0, 0x0206, "Invalid host name") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_USER_LENGTH, 0, 0x0207, "Invalid user name") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_PASS_LENGTH, 0, 0x0208, "Invalid password") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_DB_LENGTH, 0, 0x0209, "Database name too long") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH, 0, 0x020A, "Table name too long") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_CONNECTION, 0, 0x020B, "Invalid connection") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_OUT_OF_MEMORY, 0, 0x020C, "System out of memory") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_DISKSPACE, 0, 0x020D, "System out of disk space") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_QUERY_CACHE_ERASED, 0, 0x020E, "Query cache erased") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_QUERY_CANCELLED, 0, 0x020F, "Query terminated") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_SORTED_RES_TOO_MANY, 0, 0x0210, "Result set too large to be sorted") // too many result for ordered super table projection query +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_APP_ERROR, 0, 0x0211, "Application error") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_ACTION_IN_PROGRESS, 0, 0x0212, "Action in progress") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_DISCONNECTED, 0, 0x0213, "Disconnected from service") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_WRITE_AUTH, 0, 0x0214, "No write permission") // mnode -TAOS_DEFINE_ERROR(TSDB_CODE_MND_MSG_NOT_PROCESSED, 0, 0x0300, "mnode message not processed") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_ACTION_IN_PROGRESS, 0, 0x0301, "mnode action in progress") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_ACTION_NEED_REPROCESSED, 0, 0x0302, "mnode action need to be reprocessed") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_RIGHTS, 0, 0x0303, "mnode no rights") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_APP_ERROR, 0, 0x0304, "mnode app error") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CONNECTION, 0, 0x0305, "mnode invalid message connection") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_MSG_VERSION, 0, 0x0306, "mnode invalid message version") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_MSG_LEN, 0, 0x0307, "mnode invalid message length") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_MSG_TYPE, 0, 0x0308, "mnode invalid message type") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_SHELL_CONNS, 0, 0x0309, "mnode too many shell conns") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_OUT_OF_MEMORY, 0, 0x030A, "mnode out of memory") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SHOWOBJ, 0, 0x030B, "mnode invalid show handle") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_QUERY_ID, 0, 0x030C, "mnode invalid query id") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STREAM_ID, 0, 0x030D, "mnode invalid stream id") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CONN_ID, 0, 0x030E, "mnode invalid connection") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_MSG_NOT_PROCESSED, 0, 0x0300, "Message not processed") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_ACTION_IN_PROGRESS, 0, 0x0301, "Message is progressing") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_ACTION_NEED_REPROCESSED, 0, 0x0302, "Messag need to be reprocessed") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_RIGHTS, 0, 0x0303, "Insufficient privilege for operation") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_APP_ERROR, 0, 0x0304, "Unexpected generic error in mnode") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CONNECTION, 0, 0x0305, "Invalid message connection") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_MSG_VERSION, 0, 0x0306, "Incompatible protocol version") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_MSG_LEN, 0, 0x0307, "Invalid message length") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_MSG_TYPE, 0, 0x0308, "Invalid message type") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_SHELL_CONNS, 0, 0x0309, "Too many connections") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_OUT_OF_MEMORY, 0, 0x030A, "Out of memory in mnode") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SHOWOBJ, 0, 0x030B, "Data expired") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_QUERY_ID, 0, 0x030C, "Invalid query id") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STREAM_ID, 0, 0x030D, "Invalid stream id") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CONN_ID, 0, 0x030E, "Invalid connection id") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_OBJ_ALREADY_THERE, 0, 0x0320, "sdb object already there") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_ERROR, 0, 0x0321, "sdb app error") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE, 0, 0x0322, "sdb invalid table type") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_OBJ_NOT_THERE, 0, 0x0323, "sdb object not there") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_INVAID_META_ROW, 0, 0x0324, "sdb invalid meta row") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_INVAID_KEY_TYPE, 0, 0x0325, "sdb invalid key type") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_OBJ_ALREADY_THERE, 0, 0x0320, "Object already there") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_ERROR, 0, 0x0321, "Unexpected generic error in sdb") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE, 0, 0x0322, "Invalid table type") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_OBJ_NOT_THERE, 0, 0x0323, "Object not there") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_INVAID_META_ROW, 0, 0x0324, "Invalid meta row") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_SDB_INVAID_KEY_TYPE, 0, 0x0325, "Invalid key type") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_ALREADY_EXIST, 0, 0x0330, "dnode already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_NOT_EXIST, 0, 0x0331, "dnode not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_NOT_EXIST, 0, 0x0332, "vgroup not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_REMOVE_MASTER, 0, 0x0333, "cant not remove master") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_ENOUGH_DNODES, 0, 0x0334, "no enough dnodes") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_CLUSTER_CFG_INCONSISTENT, 0, 0x0335, "cluster cfg inconsistent") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DNODE_CFG_OPTION, 0, 0x0336, "invalid dnode cfg option") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_BALANCE_ENABLED, 0, 0x0337, "balance already enabled") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_NOT_IN_DNODE, 0, 0x0338, "vgroup not in dnode") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE, 0, 0x0339, "vgroup already in dnode") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_NOT_FREE, 0, 0x033A, "dnode not avaliable") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CLUSTER_ID, 0, 0x033B, "cluster id not match") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_NOT_READY, 0, 0x033C, "cluster not ready") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_ALREADY_EXIST, 0, 0x0330, "DNode already exists") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_NOT_EXIST, 0, 0x0331, "DNode does not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_NOT_EXIST, 0, 0x0332, "VGroup does not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_REMOVE_MASTER, 0, 0x0333, "Master DNode cannot be removed") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_ENOUGH_DNODES, 0, 0x0334, "Out of DNodes") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_CLUSTER_CFG_INCONSISTENT, 0, 0x0335, "Cluster cfg inconsistent") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DNODE_CFG_OPTION, 0, 0x0336, "Invalid dnode cfg option") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_BALANCE_ENABLED, 0, 0x0337, "Balance already enabled") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_NOT_IN_DNODE, 0, 0x0338, "Vgroup not in dnode") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE, 0, 0x0339, "Vgroup already in dnode") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_NOT_FREE, 0, 0x033A, "Dnode not avaliable") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CLUSTER_ID, 0, 0x033B, "Cluster id not match") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_NOT_READY, 0, 0x033C, "Cluster not ready") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_ACCT_ALREADY_EXIST, 0, 0x0340, "mnode accounts already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_ACCT, 0, 0x0341, "mnode invalid account") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_ACCT_OPTION, 0, 0x0342, "mnode invalid acct option") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_ACCT_ALREADY_EXIST, 0, 0x0340, "Account already exists") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_ACCT, 0, 0x0341, "Invalid account") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_ACCT_OPTION, 0, 0x0342, "Invalid account options") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_USER_ALREADY_EXIST, 0, 0x0350, "mnode user already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_USER, 0, 0x0351, "mnode invalid user") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_USER_FORMAT, 0, 0x0352, "mnode invalid user format") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_PASS_FORMAT, 0, 0x0353, "mnode invalid password format") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_USER_FROM_CONN, 0, 0x0354, "mnode can not get user from conn") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_USERS, 0, 0x0355, "mnode too many users") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_USER_ALREADY_EXIST, 0, 0x0350, "User already exists") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_USER, 0, 0x0351, "Invalid user") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_USER_FORMAT, 0, 0x0352, "Invalid user format") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_PASS_FORMAT, 0, 0x0353, "Invalid password format") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_USER_FROM_CONN, 0, 0x0354, "Can not get user from conn") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_USERS, 0, 0x0355, "Too many users") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_TABLE_ALREADY_EXIST, 0, 0x0360, "mnode table already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_TABLE_ID, 0, 0x0361, "mnode invalid table id") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_TABLE_NAME, 0, 0x0362, "mnode invalid table name") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_TABLE_TYPE, 0, 0x0363, "mnode invalid table type") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_TAGS, 0, 0x0364, "mnode too many tags") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_TIMESERIES, 0, 0x0366, "mnode not enough time series") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_NOT_SUPER_TABLE, 0, 0x0367, "mnode no super table") // operation only available for super table -TAOS_DEFINE_ERROR(TSDB_CODE_MND_COL_NAME_TOO_LONG, 0, 0x0368, "mnode column name too long") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_ALREAY_EXIST, 0, 0x0369, "mnode tag already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_NOT_EXIST, 0, 0x036A, "mnode tag not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_ALREAY_EXIST, 0, 0x036B, "mnode field already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_NOT_EXIST, 0, 0x036C, "mnode field not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STABLE_NAME, 0, 0x036D, "mnode invalid stable name") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_TABLE_ALREADY_EXIST, 0, 0x0360, "Table already exists") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_TABLE_ID, 0, 0x0361, "Table name too long") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_TABLE_NAME, 0, 0x0362, "Table does not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_TABLE_TYPE, 0, 0x0363, "Invalid table type in tsdb") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_TAGS, 0, 0x0364, "Too many tags") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_TIMESERIES, 0, 0x0366, "Too many time series") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_NOT_SUPER_TABLE, 0, 0x0367, "Not super table") // operation only available for super table +TAOS_DEFINE_ERROR(TSDB_CODE_MND_COL_NAME_TOO_LONG, 0, 0x0368, "Tag name too long") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_ALREAY_EXIST, 0, 0x0369, "Tag already exists") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_NOT_EXIST, 0, 0x036A, "Tag does not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_ALREAY_EXIST, 0, 0x036B, "Field already exists") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_FIELD_NOT_EXIST, 0, 0x036C, "Field does not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STABLE_NAME, 0, 0x036D, "Super table does not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_NOT_SELECTED, 0, 0x0380, "mnode db not selected") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_ALREADY_EXIST, 0, 0x0381, "mnode database aleady exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DB_OPTION, 0, 0x0382, "mnode invalid db option") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DB, 0, 0x0383, "mnode invalid database") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_MONITOR_DB_FORBIDDEN, 0, 0x0384, "mnode monitor db forbidden") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_DATABASES, 0, 0x0385, "mnode too many databases") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_IN_DROPPING, 0, 0x0386, "mnode db in dropping") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_NOT_SELECTED, 0, 0x0380, "Database not specified or available") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_ALREADY_EXIST, 0, 0x0381, "Database already exists") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DB_OPTION, 0, 0x0382, "Invalid database options") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DB, 0, 0x0383, "Invalid database name") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_MONITOR_DB_FORBIDDEN, 0, 0x0384, "Cannot delete monitor database") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_DATABASES, 0, 0x0385, "Too many databases for account") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_IN_DROPPING, 0, 0x0386, "Database not available") // dnode -TAOS_DEFINE_ERROR(TSDB_CODE_DND_MSG_NOT_PROCESSED, 0, 0x0400, "dnode message not processed") -TAOS_DEFINE_ERROR(TSDB_CODE_DND_OUT_OF_MEMORY, 0, 0x0401, "dnode out of memory") -TAOS_DEFINE_ERROR(TSDB_CODE_DND_NO_WRITE_ACCESS, 0, 0x0402, "dnode no disk write access") -TAOS_DEFINE_ERROR(TSDB_CODE_DND_INVALID_MSG_LEN, 0, 0x0403, "dnode invalid message length") +TAOS_DEFINE_ERROR(TSDB_CODE_DND_MSG_NOT_PROCESSED, 0, 0x0400, "Message not processed") +TAOS_DEFINE_ERROR(TSDB_CODE_DND_OUT_OF_MEMORY, 0, 0x0401, "Dnode out of memory") +TAOS_DEFINE_ERROR(TSDB_CODE_DND_NO_WRITE_ACCESS, 0, 0x0402, "No permission for disk files in dnode") +TAOS_DEFINE_ERROR(TSDB_CODE_DND_INVALID_MSG_LEN, 0, 0x0403, "Invalid message length") // vnode -TAOS_DEFINE_ERROR(TSDB_CODE_VND_ACTION_IN_PROGRESS, 0, 0x0500, "vnode action in progress") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_MSG_NOT_PROCESSED, 0, 0x0501, "vnode message not processed") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_ACTION_NEED_REPROCESSED, 0, 0x0502, "vnode action need to be reprocessed") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_VGROUP_ID, 0, 0x0503, "vnode invalid vgroup id") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_INIT_FAILED, 0, 0x0504, "vnode init failed") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_DISKSPACE, 0, 0x0505, "vnode no diskspace") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_DISK_PERMISSIONS, 0, 0x0506, "vnode no disk permissions") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR, 0, 0x0507, "vnode no such file or directory") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_OUT_OF_MEMORY, 0, 0x0508, "vnode out of memory") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_APP_ERROR, 0, 0x0509, "vnode app error") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_STATUS, 0, 0x0510, "vnode not in ready state") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_NOT_SYNCED, 0, 0x0511, "vnode not in synced state") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_WRITE_AUTH, 0, 0x0512, "vnode no write auth") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_ACTION_IN_PROGRESS, 0, 0x0500, "Action in progress") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_MSG_NOT_PROCESSED, 0, 0x0501, "Message not processed") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_ACTION_NEED_REPROCESSED, 0, 0x0502, "Action need to be reprocessed") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_VGROUP_ID, 0, 0x0503, "Invalid Vgroup ID") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_INIT_FAILED, 0, 0x0504, "Vnode initialization failed") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_DISKSPACE, 0, 0x0505, "System out of disk space") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_DISK_PERMISSIONS, 0, 0x0506, "No write permission for disk files") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR, 0, 0x0507, "Missing data file") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_OUT_OF_MEMORY, 0, 0x0508, "Out of memory") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_APP_ERROR, 0, 0x0509, "Unexpected generic error in vnode") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_STATUS, 0, 0x0510, "Database not ready") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_NOT_SYNCED, 0, 0x0511, "Database suspended") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_WRITE_AUTH, 0, 0x0512, "Write operation denied") // tsdb -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_ID, 0, 0x0600, "tsdb invalid table id") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_TYPE, 0, 0x0601, "tsdb invalid table type") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION, 0, 0x0602, "tsdb invalid table schema version") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_ALREADY_EXIST, 0, 0x0603, "tsdb table already exist") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_CONFIG, 0, 0x0604, "tsdb invalid configuration") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INIT_FAILED, 0, 0x0605, "tsdb init failed") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_DISKSPACE, 0, 0x0606, "tsdb no diskspace") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_DISK_PERMISSIONS, 0, 0x0607, "tsdb no disk permissions") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_FILE_CORRUPTED, 0, 0x0608, "tsdb file corrupted") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_OUT_OF_MEMORY, 0, 0x0609, "tsdb out of memory") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE, 0, 0x060A, "tsdb tag version is out of date") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE, 0, 0x060B, "tsdb timestamp is out of range") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP, 0, 0x060C, "tsdb submit message is messed up") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_ACTION, 0, 0x060D, "tsdb invalid action") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_CREATE_TB_MSG, 0, 0x060E, "tsdb invalid create table message") -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") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_ID, 0, 0x0600, "Invalid table ID") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_TYPE, 0, 0x0601, "Invalid table type") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION, 0, 0x0602, "Invalid table schema version") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_ALREADY_EXIST, 0, 0x0603, "Table already exists") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_CONFIG, 0, 0x0604, "Invalid configuration") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INIT_FAILED, 0, 0x0605, "Tsdb init failed") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_DISKSPACE, 0, 0x0606, "No diskspace for tsdb") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_DISK_PERMISSIONS, 0, 0x0607, "No permission for disk files") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_FILE_CORRUPTED, 0, 0x0608, "Data file(s) corrupted") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_OUT_OF_MEMORY, 0, 0x0609, "Out of memory") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE, 0, 0x060A, "Tag too old") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE, 0, 0x060B, "Timestamp data out of range") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP, 0, 0x060C, "Submit message is messed up") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_ACTION, 0, 0x060D, "Invalid operation") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_CREATE_TB_MSG, 0, 0x060E, "Invalid creation of table") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_TABLE_DATA_IN_MEM, 0, 0x060F, "No table data in memory skiplist") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_FILE_ALREADY_EXISTS, 0, 0x0610, "File already exists") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_RECONFIGURE, 0, 0x0611, "Need to reconfigure table") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO, 0, 0x0612, "Invalid information to create table") // query -TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_QHANDLE, 0, 0x0700, "query invalid handle") -TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_MSG, 0, 0x0701, "query invalid message") // failed to validate the sql expression msg by vnode -TAOS_DEFINE_ERROR(TSDB_CODE_QRY_NO_DISKSPACE, 0, 0x0702, "query no diskspace") -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") -TAOS_DEFINE_ERROR(TSDB_CODE_QRY_NOT_READY, 0, 0x0707, "query not ready") -TAOS_DEFINE_ERROR(TSDB_CODE_QRY_HAS_RSP, 0, 0x0708, "query should response") +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_QHANDLE, 0, 0x0700, "Invalid handle") +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_MSG, 0, 0x0701, "Invalid message") // failed to validate the sql expression msg by vnode +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_NO_DISKSPACE, 0, 0x0702, "No diskspace for query") +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_OUT_OF_MEMORY, 0, 0x0703, "System out of memory") +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_APP_ERROR, 0, 0x0704, "Unexpected generic error in query") +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_DUP_JOIN_KEY, 0, 0x0705, "Duplicated join key") +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_EXCEED_TAGS_LIMIT, 0, 0x0706, "Tag conditon too many") +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_NOT_READY, 0, 0x0707, "Query not ready") +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_HAS_RSP, 0, 0x0708, "Query should response") // grant -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, 0, 0x0800, "grant expired") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DNODE_LIMITED, 0, 0x0801, "grant dnode limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_ACCT_LIMITED, 0, 0x0802, "grant account limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_TIMESERIES_LIMITED, 0, 0x0803, "grant timeseries limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DB_LIMITED, 0, 0x0804, "grant db limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_USER_LIMITED, 0, 0x0805, "grant user limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CONN_LIMITED, 0, 0x0806, "grant conn limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_STREAM_LIMITED, 0, 0x0807, "grant stream limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_SPEED_LIMITED, 0, 0x0808, "grant speed limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_STORAGE_LIMITED, 0, 0x0809, "grant storage limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_QUERYTIME_LIMITED, 0, 0x080A, "grant query time limited") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CPU_LIMITED, 0, 0x080B, "grant cpu limited") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, 0, 0x0800, "License expired") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DNODE_LIMITED, 0, 0x0801, "DNode creation limited by licence") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_ACCT_LIMITED, 0, 0x0802, "Account creation limited by license") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_TIMESERIES_LIMITED, 0, 0x0803, "Table creation limited by license") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_DB_LIMITED, 0, 0x0804, "DB creation limited by license") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_USER_LIMITED, 0, 0x0805, "User creation limited by license") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CONN_LIMITED, 0, 0x0806, "Conn creation limited by license") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_STREAM_LIMITED, 0, 0x0807, "Stream creation limited by license") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_SPEED_LIMITED, 0, 0x0808, "Write speed limited by license") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_STORAGE_LIMITED, 0, 0x0809, "Storage capacity limited by license") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_QUERYTIME_LIMITED, 0, 0x080A, "Query time limited by license") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_CPU_LIMITED, 0, 0x080B, "CPU cores limited by license") // sync -TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_CONFIG, 0, 0x0900, "sync invalid configuration") -TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_ENABLED, 0, 0x0901, "sync module not enabled") +TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_CONFIG, 0, 0x0900, "Invalid Sync Configuration") +TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_ENABLED, 0, 0x0901, "Sync module not enabled") // wal -TAOS_DEFINE_ERROR(TSDB_CODE_WAL_APP_ERROR, 0, 0x1000, "wal app error") +TAOS_DEFINE_ERROR(TSDB_CODE_WAL_APP_ERROR, 0, 0x1000, "Unexpected generic error in wal") #ifdef TAOS_ERROR_C }; From ef3d5b935926771d92890f6d05d3cc95d312fbca Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 30 Jul 2020 03:48:22 +0000 Subject: [PATCH 7/9] [TD-1025] change ip list while vgroup master changed --- src/mnode/src/mnodeVgroup.c | 2 +- tests/test/c/createTablePerformance.c | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 1d1a101270..91aa3fdec2 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -818,7 +818,7 @@ static SMDCreateVnodeMsg *mnodeBuildVnodeMsg(SVgObj *pVgroup) { SRpcEpSet mnodeGetEpSetFromVgroup(SVgObj *pVgroup) { SRpcEpSet epSet = { .numOfEps = pVgroup->numOfVnodes, - .inUse = 0, + .inUse = pVgroup->inUse, }; for (int i = 0; i < pVgroup->numOfVnodes; ++i) { strcpy(epSet.fqdn[i], pVgroup->vnodeGid[i].pDnode->dnodeFqdn); diff --git a/tests/test/c/createTablePerformance.c b/tests/test/c/createTablePerformance.c index 2e334fa9b2..69022bdecf 100644 --- a/tests/test/c/createTablePerformance.c +++ b/tests/test/c/createTablePerformance.c @@ -31,7 +31,6 @@ char dbName[32] = "db"; char stableName[64] = "st"; int32_t numOfThreads = 30; int32_t numOfTables = 100000; -int32_t maxTables = 5000; int32_t replica = 1; int32_t numOfColumns = 2; @@ -98,7 +97,7 @@ void createDbAndSTable() { exit(1); } - sprintf(qstr, "create database if not exists %s maxtables %d replica %d", dbName, maxTables, replica); + sprintf(qstr, "create database if not exists %s replica %d", dbName, replica); TAOS_RES *pSql = taos_query(con, qstr); int32_t code = taos_errno(pSql); if (code != 0) { @@ -195,8 +194,6 @@ void printHelp() { printf("%s%s%s%d\n", indent, indent, "replica, default is ", replica); printf("%s%s\n", indent, "-columns"); printf("%s%s%s%d\n", indent, indent, "numOfColumns, default is ", numOfColumns); - printf("%s%s\n", indent, "-tables"); - printf("%s%s%s%d\n", indent, indent, "Database parameters tables, default is ", maxTables); exit(EXIT_SUCCESS); } @@ -218,8 +215,6 @@ void shellParseArgument(int argc, char *argv[]) { numOfTables = atoi(argv[++i]); } else if (strcmp(argv[i], "-r") == 0) { replica = atoi(argv[++i]); - } else if (strcmp(argv[i], "-tables") == 0) { - maxTables = atoi(argv[++i]); } else if (strcmp(argv[i], "-columns") == 0) { numOfColumns = atoi(argv[++i]); } else { @@ -233,7 +228,6 @@ void shellParseArgument(int argc, char *argv[]) { pPrint("%s numOfThreads:%d %s", GREEN, numOfThreads, NC); pPrint("%s numOfColumns:%d %s", GREEN, numOfColumns, NC); pPrint("%s replica:%d %s", GREEN, replica, NC); - pPrint("%s dbPara maxTables:%d %s", GREEN, maxTables, NC); pPrint("%s start create table performace test %s", GREEN, NC); } From a6a0c40862721dbb4c6fdb55992063a789095fa5 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 30 Jul 2020 12:00:40 +0800 Subject: [PATCH 8/9] [TD-894] update scripts since error code changed --- tests/script/general/http/grafana.sim | 4 ++-- tests/script/general/http/restful.sim | 2 +- tests/script/general/http/restful_full.sim | 12 ++++++------ tests/script/unique/http/admin.sim | 4 ++-- tests/script/unique/http/opentsdb.sim | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/script/general/http/grafana.sim b/tests/script/general/http/grafana.sim index bf2a3b3b58..d2c31a0e59 100644 --- a/tests/script/general/http/grafana.sim +++ b/tests/script/general/http/grafana.sim @@ -66,7 +66,7 @@ endi system_content curl 127.0.0.1:6020/grafana/login/xx/xx/ print 3-> $system_content -if $system_content != @{"status":"error","code":849,"desc":"mnode invalid user"}@ then +if $system_content != @{"status":"error","code":849,"desc":"Invalid user"}@ then return -1 endi @@ -78,7 +78,7 @@ endi system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:6020/grafana/login/1/root/1/ print 5-> $system_content -if $system_content != @{"status":"error","code":849,"desc":"mnode invalid user"}@ then +if $system_content != @{"status":"error","code":849,"desc":"Invalid user"}@ then return -1 endi diff --git a/tests/script/general/http/restful.sim b/tests/script/general/http/restful.sim index 7f39a9c748..a647399758 100644 --- a/tests/script/general/http/restful.sim +++ b/tests/script/general/http/restful.sim @@ -77,7 +77,7 @@ endi system_content curl 127.0.0.1:6020/rest/login/u2/aabcd_1234 print curl 127.0.0.1:6020/rest/login/u2/abcd_1234 -----> $system_content -if $system_content != @{"status":"error","code":3,"desc":"auth failure"}@ then +if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then return -1 endi diff --git a/tests/script/general/http/restful_full.sim b/tests/script/general/http/restful_full.sim index cb493c1456..43511b31d8 100644 --- a/tests/script/general/http/restful_full.sim +++ b/tests/script/general/http/restful_full.sim @@ -39,19 +39,19 @@ endi system_content curl 127.0.0.1:6020/rest/login/root/123 print 5-> $system_content -if $system_content != @{"status":"error","code":3,"desc":"auth failure"}@ then +if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then return -1 endi system_content curl 127.0.0.1:6020/rest/login/root/123/1/1/3 print 6-> $system_content -if $system_content != @{"status":"error","code":3,"desc":"auth failure"}@ then +if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then return -1 endi system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'show databases' 127.0.0.1:6020/rest/login/root/1 print 7-> $system_content -if $system_content != @{"status":"error","code":3,"desc":"auth failure"}@ then +if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then return -1 endi @@ -93,7 +93,7 @@ endi system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d1' 127.0.0.1:6020/rest/sql print 13-> $system_content -if $system_content != @{"status":"error","code":897,"desc":"mnode database aleady exist"}@ then +if $system_content != @{"status":"error","code":897,"desc":"Database already exists"}@ then return -1 endi @@ -126,7 +126,7 @@ endi #18 system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' show tables;' 127.0.0.1:6020/rest/sql print 18-> $system_content -if $system_content != @{"status":"error","code":896,"desc":"mnode db not selected"}@ then +if $system_content != @{"status":"error","code":896,"desc":"Database not specified or available"}@ then return -1 endi @@ -147,7 +147,7 @@ print =============== step3 - db system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' select * from d1.t1;' 127.0.0.1:6020/rest/sql print 21-> $system_content -if $system_content != @{"status":"error","code":866,"desc":"mnode invalid table name"}@ then +if $system_content != @{"status":"error","code":866,"desc":"Table does not exist"}@ then return -1 endi diff --git a/tests/script/unique/http/admin.sim b/tests/script/unique/http/admin.sim index 10fad091b5..aeead817c1 100644 --- a/tests/script/unique/http/admin.sim +++ b/tests/script/unique/http/admin.sim @@ -57,13 +57,13 @@ endi system_content curl 127.0.0.1:6020/admin/login/root/123 print 5-> $system_content -if $system_content != @{"status":"error","code":3,"desc":"auth failure"}@ then +if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then return -1 endi system_content curl 127.0.0.1:6020/admin/login/root/123/1/1/3 print 6-> $system_content -if $system_content != @{"status":"error","code":3,"desc":"auth failure"}@ then +if $system_content != @{"status":"error","code":3,"desc":"Authentication failure"}@ then return -1 endi diff --git a/tests/script/unique/http/opentsdb.sim b/tests/script/unique/http/opentsdb.sim index 7e2400bb15..4c7803c3da 100644 --- a/tests/script/unique/http/opentsdb.sim +++ b/tests/script/unique/http/opentsdb.sim @@ -74,7 +74,7 @@ endi system_content curl -u root:taosdata -d '[{"metric": "ab1234567890123456789012345678ab1234567890123456789012345678","timestamp": 1346846400,"value": 18,"tags": {"host": "web01","group1": "1","dc": "lga"}}]' 127.0.0.1:6020/opentsdb/db/put print $system_content -if $system_content != @{"errors":[{"datapoint":{"metric":"ab1234567890123456789012345678ab1234567890123456789012345678","stable":"ab1234567890123456789012345678ab1234567890123456789012345678_d_bbb","table":"ab1234567890123456789012345678ab1234567890123456789012345678_d_bbb_lga_1_web01","timestamp":1346846400,"value":18.000000,"tags":{"dc":"lga","group1":"1","host":"web01"},"status":"error","code":1547,"desc":"tsdb timestamp is out of range"}}],"failed":1,"success":0,"affected_rows":0}@ then +if $system_content != @{"errors":[{"datapoint":{"metric":"ab1234567890123456789012345678ab1234567890123456789012345678","stable":"ab1234567890123456789012345678ab1234567890123456789012345678_d_bbb","table":"ab1234567890123456789012345678ab1234567890123456789012345678_d_bbb_lga_1_web01","timestamp":1346846400,"value":18.000000,"tags":{"dc":"lga","group1":"1","host":"web01"},"status":"error","code":1547,"desc":"Timestamp data out of range"}}],"failed":1,"success":0,"affected_rows":0}@ then return -1 endi From 4c024aab37f8ec4b5e67d1e20acc8ebb5c50e1d8 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 30 Jul 2020 07:43:54 +0000 Subject: [PATCH 9/9] Ensure that the htpp context is valid before release --- src/mnode/src/mnodeProfile.c | 2 +- src/plugins/http/src/httpContext.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/mnode/src/mnodeProfile.c b/src/mnode/src/mnodeProfile.c index 30a292f522..ff4ddf1b2a 100644 --- a/src/mnode/src/mnodeProfile.c +++ b/src/mnode/src/mnodeProfile.c @@ -120,7 +120,7 @@ SConnObj *mnodeAccquireConn(int32_t connId, char *user, uint32_t ip, uint16_t po } if (/* pConn->ip != ip || */ pConn->port != port /* || strcmp(pConn->user, user) != 0 */) { - mError("connId:%d, incoming conn user:%s ip:%s:%u, not match exist conn user:%s ip:%s:%u", connId, user, + mDebug("connId:%d, incoming conn user:%s ip:%s:%u, not match exist conn user:%s ip:%s:%u", connId, user, taosIpStr(ip), port, pConn->user, taosIpStr(pConn->ip), pConn->port); taosCacheRelease(tsMnodeConnCache, (void **)&pConn, false); return NULL; diff --git a/src/plugins/http/src/httpContext.c b/src/plugins/http/src/httpContext.c index ca65f65608..527e56ea0e 100644 --- a/src/plugins/http/src/httpContext.c +++ b/src/plugins/http/src/httpContext.c @@ -58,7 +58,7 @@ static void httpDestroyContext(void *data) { } bool httpInitContexts() { - tsHttpServer.contextCache = taosCacheInit(TSDB_DATA_TYPE_BIGINT, 2, true, httpDestroyContext, "restc"); + tsHttpServer.contextCache = taosCacheInit(TSDB_DATA_TYPE_BIGINT, 3, true, httpDestroyContext, "restc"); if (tsHttpServer.contextCache == NULL) { httpError("failed to init context cache"); return false; @@ -108,7 +108,7 @@ HttpContext *httpCreateContext(int32_t fd) { pContext->lastAccessTime = taosGetTimestampSec(); pContext->state = HTTP_CONTEXT_STATE_READY; - HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &pContext, sizeof(int64_t), &pContext, sizeof(int64_t), 3); + HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &pContext, sizeof(int64_t), &pContext, sizeof(int64_t), 5); pContext->ppContext = ppContext; httpDebug("context:%p, fd:%d, is created, data:%p", pContext, fd, ppContext); @@ -133,13 +133,22 @@ HttpContext *httpGetContext(void *ptr) { } void httpReleaseContext(HttpContext *pContext) { + // Ensure that the context is valid before release + HttpContext **ppContext = taosCacheAcquireByKey(tsHttpServer.contextCache, &pContext, sizeof(HttpContext *)); + if (ppContext == NULL) { + httpError("context:%p, is already released", pContext); + return; + } + int32_t refCount = atomic_sub_fetch_32(&pContext->refCount, 1); assert(refCount >= 0); + assert(ppContext == pContext->ppContext); - HttpContext **ppContext = pContext->ppContext; httpDebug("context:%p, is released, data:%p refCount:%d", pContext, ppContext, refCount); if (tsHttpServer.contextCache != NULL) { + // and release context twice + taosCacheRelease(tsHttpServer.contextCache, (void **)(&ppContext), false); taosCacheRelease(tsHttpServer.contextCache, (void **)(&ppContext), false); } else { httpDebug("context:%p, won't be destroyed for cache is already released", pContext);