diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 5b96416fd719ea5b50ddc275f5165a50c4d4f535..4a6455c0eddfee061735fd15e36376c831cacd7f 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -275,16 +275,17 @@ typedef struct { } SDbCfg; typedef struct { - char name[TSDB_DB_FNAME_LEN]; - char acct[TSDB_USER_LEN]; - char createUser[TSDB_USER_LEN]; - int64_t createdTime; - int64_t updateTime; - int64_t uid; - int32_t cfgVersion; - int32_t vgVersion; - int8_t hashMethod; // default is 1 - SDbCfg cfg; + char name[TSDB_DB_FNAME_LEN]; + char acct[TSDB_USER_LEN]; + char createUser[TSDB_USER_LEN]; + int64_t createdTime; + int64_t updateTime; + int64_t uid; + int32_t cfgVersion; + int32_t vgVersion; + int8_t hashMethod; // default is 1 + SDbCfg cfg; + SRWLatch lock; } SDbObj; typedef struct { diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 9889743a826f8f5ea8145a80c54b698f86c3330e..755e2828defb88e41d2c94e652b0e88aeb4085b7 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -219,10 +219,14 @@ static int32_t mndDbActionDelete(SSdb *pSdb, SDbObj *pDb) { static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew) { mTrace("db:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew); + taosWLockLatch(&pOld->lock); + SArray *pOldRetensions = pOld->cfg.pRetensions; pOld->updateTime = pNew->updateTime; pOld->cfgVersion = pNew->cfgVersion; pOld->vgVersion = pNew->vgVersion; memcpy(&pOld->cfg, &pNew->cfg, sizeof(SDbCfg)); + pNew->cfg.pRetensions = pOldRetensions; + taosWUnLockLatch(&pOld->lock); return 0; } diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 0ce73005e882ef9327086c09ccb0203435c6c10e..777141c5d29cc21b3529a7587c07af37c3cefdf0 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -74,59 +74,59 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) { int32_t size = sizeof(SStbObj) + (pStb->numOfColumns + pStb->numOfTags + pStb->numOfSmas) * sizeof(SSchema) + TSDB_STB_RESERVE_SIZE; SSdbRaw *pRaw = sdbAllocRaw(SDB_STB, TSDB_STB_VER_NUMBER, size); - if (pRaw == NULL) goto STB_ENCODE_OVER; + if (pRaw == NULL) goto _OVER; int32_t dataPos = 0; - SDB_SET_BINARY(pRaw, dataPos, pStb->name, TSDB_TABLE_FNAME_LEN, STB_ENCODE_OVER) - SDB_SET_BINARY(pRaw, dataPos, pStb->db, TSDB_DB_FNAME_LEN, STB_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pStb->createdTime, STB_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pStb->updateTime, STB_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pStb->uid, STB_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pStb->dbUid, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->version, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->nextColId, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, (int32_t)(pStb->xFilesFactor * 10000), STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->aggregationMethod, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->delay, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->ttl, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->numOfColumns, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->numOfTags, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->numOfSmas, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pStb->commentLen, STB_ENCODE_OVER) + SDB_SET_BINARY(pRaw, dataPos, pStb->name, TSDB_TABLE_FNAME_LEN, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pStb->db, TSDB_DB_FNAME_LEN, _OVER) + SDB_SET_INT64(pRaw, dataPos, pStb->createdTime, _OVER) + SDB_SET_INT64(pRaw, dataPos, pStb->updateTime, _OVER) + SDB_SET_INT64(pRaw, dataPos, pStb->uid, _OVER) + SDB_SET_INT64(pRaw, dataPos, pStb->dbUid, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->version, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->nextColId, _OVER) + SDB_SET_INT32(pRaw, dataPos, (int32_t)(pStb->xFilesFactor * 10000), _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->aggregationMethod, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->delay, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->ttl, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->numOfColumns, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->numOfTags, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->numOfSmas, _OVER) + SDB_SET_INT32(pRaw, dataPos, pStb->commentLen, _OVER) for (int32_t i = 0; i < pStb->numOfColumns; ++i) { SSchema *pSchema = &pStb->pColumns[i]; - SDB_SET_INT8(pRaw, dataPos, pSchema->type, STB_ENCODE_OVER) - SDB_SET_INT16(pRaw, dataPos, pSchema->colId, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, STB_ENCODE_OVER) - SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, STB_ENCODE_OVER) + SDB_SET_INT8(pRaw, dataPos, pSchema->type, _OVER) + SDB_SET_INT16(pRaw, dataPos, pSchema->colId, _OVER) + SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER) } for (int32_t i = 0; i < pStb->numOfTags; ++i) { SSchema *pSchema = &pStb->pTags[i]; - SDB_SET_INT8(pRaw, dataPos, pSchema->type, STB_ENCODE_OVER) - SDB_SET_INT16(pRaw, dataPos, pSchema->colId, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, STB_ENCODE_OVER) - SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, STB_ENCODE_OVER) + SDB_SET_INT8(pRaw, dataPos, pSchema->type, _OVER) + SDB_SET_INT16(pRaw, dataPos, pSchema->colId, _OVER) + SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER) } for (int32_t i = 0; i < pStb->numOfSmas; ++i) { SSchema *pSchema = &pStb->pSmas[i]; - SDB_SET_INT8(pRaw, dataPos, pSchema->type, STB_ENCODE_OVER) - SDB_SET_INT16(pRaw, dataPos, pSchema->colId, STB_ENCODE_OVER) - SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, STB_ENCODE_OVER) - SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, STB_ENCODE_OVER) + SDB_SET_INT8(pRaw, dataPos, pSchema->type, _OVER) + SDB_SET_INT16(pRaw, dataPos, pSchema->colId, _OVER) + SDB_SET_INT32(pRaw, dataPos, pSchema->bytes, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER) } if (pStb->commentLen > 0) { - SDB_SET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen, STB_ENCODE_OVER) + SDB_SET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen, _OVER) } - SDB_SET_RESERVE(pRaw, dataPos, TSDB_STB_RESERVE_SIZE, STB_ENCODE_OVER) - SDB_SET_DATALEN(pRaw, dataPos, STB_ENCODE_OVER) + SDB_SET_RESERVE(pRaw, dataPos, TSDB_STB_RESERVE_SIZE, _OVER) + SDB_SET_DATALEN(pRaw, dataPos, _OVER) terrno = 0; -STB_ENCODE_OVER: +_OVER: if (terrno != 0) { mError("stb:%s, failed to encode to raw:%p since %s", pStb->name, pRaw, terrstr()); sdbFreeRaw(pRaw); @@ -141,80 +141,80 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; int8_t sver = 0; - if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto STB_DECODE_OVER; + if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; if (sver != TSDB_STB_VER_NUMBER) { terrno = TSDB_CODE_SDB_INVALID_DATA_VER; - goto STB_DECODE_OVER; + goto _OVER; } SSdbRow *pRow = sdbAllocRow(sizeof(SStbObj)); - if (pRow == NULL) goto STB_DECODE_OVER; + if (pRow == NULL) goto _OVER; SStbObj *pStb = sdbGetRowObj(pRow); - if (pStb == NULL) goto STB_DECODE_OVER; + if (pStb == NULL) goto _OVER; int32_t dataPos = 0; - SDB_GET_BINARY(pRaw, dataPos, pStb->name, TSDB_TABLE_FNAME_LEN, STB_DECODE_OVER) - SDB_GET_BINARY(pRaw, dataPos, pStb->db, TSDB_DB_FNAME_LEN, STB_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pStb->createdTime, STB_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pStb->updateTime, STB_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pStb->uid, STB_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pStb->dbUid, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->version, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->nextColId, STB_DECODE_OVER) + SDB_GET_BINARY(pRaw, dataPos, pStb->name, TSDB_TABLE_FNAME_LEN, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pStb->db, TSDB_DB_FNAME_LEN, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pStb->createdTime, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pStb->updateTime, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pStb->uid, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pStb->dbUid, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->version, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->nextColId, _OVER) int32_t xFilesFactor = 0; - SDB_GET_INT32(pRaw, dataPos, &xFilesFactor, STB_DECODE_OVER) + SDB_GET_INT32(pRaw, dataPos, &xFilesFactor, _OVER) pStb->xFilesFactor = xFilesFactor / 10000.0f; - SDB_GET_INT32(pRaw, dataPos, &pStb->aggregationMethod, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->delay, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->ttl, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->numOfColumns, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->numOfTags, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->numOfSmas, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pStb->commentLen, STB_DECODE_OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->aggregationMethod, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->delay, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->ttl, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->numOfColumns, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->numOfTags, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->numOfSmas, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pStb->commentLen, _OVER) pStb->pColumns = taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchema)); pStb->pTags = taosMemoryCalloc(pStb->numOfTags, sizeof(SSchema)); pStb->pSmas = taosMemoryCalloc(pStb->numOfSmas, sizeof(SSchema)); if (pStb->pColumns == NULL || pStb->pTags == NULL || pStb->pSmas == NULL) { - goto STB_DECODE_OVER; + goto _OVER; } for (int32_t i = 0; i < pStb->numOfColumns; ++i) { SSchema *pSchema = &pStb->pColumns[i]; - SDB_GET_INT8(pRaw, dataPos, &pSchema->type, STB_DECODE_OVER) - SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, STB_DECODE_OVER) - SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, STB_DECODE_OVER) + SDB_GET_INT8(pRaw, dataPos, &pSchema->type, _OVER) + SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER) } for (int32_t i = 0; i < pStb->numOfTags; ++i) { SSchema *pSchema = &pStb->pTags[i]; - SDB_GET_INT8(pRaw, dataPos, &pSchema->type, STB_DECODE_OVER) - SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, STB_DECODE_OVER) - SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, STB_DECODE_OVER) + SDB_GET_INT8(pRaw, dataPos, &pSchema->type, _OVER) + SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER) } for (int32_t i = 0; i < pStb->numOfSmas; ++i) { SSchema *pSchema = &pStb->pSmas[i]; - SDB_GET_INT8(pRaw, dataPos, &pSchema->type, STB_DECODE_OVER) - SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, STB_DECODE_OVER) - SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, STB_DECODE_OVER) - SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, STB_DECODE_OVER) + SDB_GET_INT8(pRaw, dataPos, &pSchema->type, _OVER) + SDB_GET_INT16(pRaw, dataPos, &pSchema->colId, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pSchema->bytes, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pSchema->name, TSDB_COL_NAME_LEN, _OVER) } if (pStb->commentLen > 0) { pStb->comment = taosMemoryCalloc(pStb->commentLen, 1); - if (pStb->comment == NULL) goto STB_DECODE_OVER; - SDB_GET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen, STB_DECODE_OVER) + if (pStb->comment == NULL) goto _OVER; + SDB_GET_BINARY(pRaw, dataPos, pStb->comment, pStb->commentLen, _OVER) } - SDB_GET_RESERVE(pRaw, dataPos, TSDB_STB_RESERVE_SIZE, STB_DECODE_OVER) + SDB_GET_RESERVE(pRaw, dataPos, TSDB_STB_RESERVE_SIZE, _OVER) terrno = 0; -STB_DECODE_OVER: +_OVER: if (terrno != 0) { mError("stb:%s, failed to decode from raw:%p since %s", pStb->name, pRaw, terrstr()); taosMemoryFreeClear(pStb->pColumns); @@ -724,21 +724,21 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre int32_t code = -1; STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_STB, &pReq->rpcMsg); - if (pTrans == NULL) goto CREATE_STB_OVER; + if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to create stb:%s", pTrans->id, pCreate->name); mndTransSetDbInfo(pTrans, pDb); - if (mndSetCreateStbRedoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto CREATE_STB_OVER; - if (mndSetCreateStbUndoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto CREATE_STB_OVER; - if (mndSetCreateStbCommitLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto CREATE_STB_OVER; - if (mndSetCreateStbRedoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto CREATE_STB_OVER; - if (mndSetCreateStbUndoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto CREATE_STB_OVER; - if (mndTransPrepare(pMnode, pTrans) != 0) goto CREATE_STB_OVER; + if (mndSetCreateStbRedoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndSetCreateStbUndoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndSetCreateStbCommitLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndSetCreateStbRedoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndSetCreateStbUndoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; -CREATE_STB_OVER: +_OVER: mndTransDrop(pTrans); return code; } @@ -754,13 +754,13 @@ static int32_t mndProcessMCreateStbReq(SNodeMsg *pReq) { if (tDeserializeSMCreateStbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &createReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto CREATE_STB_OVER; + goto _OVER; } mDebug("stb:%s, start to create", createReq.name); if (mndCheckCreateStbReq(&createReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto CREATE_STB_OVER; + goto _OVER; } pStb = mndAcquireStb(pMnode, createReq.name); @@ -768,40 +768,40 @@ static int32_t mndProcessMCreateStbReq(SNodeMsg *pReq) { if (createReq.igExists) { mDebug("stb:%s, already exist, ignore exist is set", createReq.name); code = 0; - goto CREATE_STB_OVER; + goto _OVER; } else { terrno = TSDB_CODE_MND_STB_ALREADY_EXIST; - goto CREATE_STB_OVER; + goto _OVER; } } else if (terrno != TSDB_CODE_MND_STB_NOT_EXIST) { - goto CREATE_STB_OVER; + goto _OVER; } pTopicStb = mndAcquireStb(pMnode, createReq.name); if (pTopicStb != NULL) { terrno = TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC; - goto CREATE_STB_OVER; + goto _OVER; } pDb = mndAcquireDbByStb(pMnode, createReq.name); if (pDb == NULL) { terrno = TSDB_CODE_MND_DB_NOT_SELECTED; - goto CREATE_STB_OVER; + goto _OVER; } pUser = mndAcquireUser(pMnode, pReq->user); if (pUser == NULL) { - goto CREATE_STB_OVER; + goto _OVER; } if (mndCheckWriteAuth(pUser, pDb) != 0) { - goto CREATE_STB_OVER; + goto _OVER; } code = mndCreateStb(pMnode, pReq, &createReq, pDb); if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; -CREATE_STB_OVER: +_OVER: if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("stb:%s, failed to create since %s", createReq.name, terrstr()); } @@ -1211,23 +1211,23 @@ static int32_t mndAlterStb(SMnode *pMnode, SNodeMsg *pReq, const SMAltertbReq *p break; } - if (code != 0) goto ALTER_STB_OVER; + if (code != 0) goto _OVER; code = -1; pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_TYPE_ALTER_STB, &pReq->rpcMsg); - if (pTrans == NULL) goto ALTER_STB_OVER; + if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to alter stb:%s", pTrans->id, pAlter->name); mndTransSetDbInfo(pTrans, pDb); - if (mndSetAlterStbRedoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto ALTER_STB_OVER; - if (mndSetAlterStbCommitLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto ALTER_STB_OVER; - if (mndSetAlterStbRedoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto ALTER_STB_OVER; - if (mndTransPrepare(pMnode, pTrans) != 0) goto ALTER_STB_OVER; + if (mndSetAlterStbRedoLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndSetAlterStbCommitLogs(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndSetAlterStbRedoActions(pMnode, pTrans, pDb, &stbObj) != 0) goto _OVER; + if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; -ALTER_STB_OVER: +_OVER: mndTransDrop(pTrans); taosMemoryFreeClear(stbObj.pTags); taosMemoryFreeClear(stbObj.pColumns); @@ -1244,37 +1244,37 @@ static int32_t mndProcessMAlterStbReq(SNodeMsg *pReq) { if (tDeserializeSMAlterStbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &alterReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto ALTER_STB_OVER; + goto _OVER; } mDebug("stb:%s, start to alter", alterReq.name); - if (mndCheckAlterStbReq(&alterReq) != 0) goto ALTER_STB_OVER; + if (mndCheckAlterStbReq(&alterReq) != 0) goto _OVER; pDb = mndAcquireDbByStb(pMnode, alterReq.name); if (pDb == NULL) { terrno = TSDB_CODE_MND_INVALID_DB; - goto ALTER_STB_OVER; + goto _OVER; } pStb = mndAcquireStb(pMnode, alterReq.name); if (pStb == NULL) { terrno = TSDB_CODE_MND_STB_NOT_EXIST; - goto ALTER_STB_OVER; + goto _OVER; } pUser = mndAcquireUser(pMnode, pReq->user); if (pUser == NULL) { - goto ALTER_STB_OVER; + goto _OVER; } if (mndCheckWriteAuth(pUser, pDb) != 0) { - goto ALTER_STB_OVER; + goto _OVER; } code = mndAlterStb(pMnode, pReq, &alterReq, pDb, pStb); if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; -ALTER_STB_OVER: +_OVER: if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("stb:%s, failed to alter since %s", alterReq.name, terrstr()); } @@ -1353,19 +1353,19 @@ static int32_t mndSetDropStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj * static int32_t mndDropStb(SMnode *pMnode, SNodeMsg *pReq, SDbObj *pDb, SStbObj *pStb) { int32_t code = -1; STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_DROP_STB, &pReq->rpcMsg); - if (pTrans == NULL) goto DROP_STB_OVER; + if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop stb:%s", pTrans->id, pStb->name); mndTransSetDbInfo(pTrans, pDb); - if (mndSetDropStbRedoLogs(pMnode, pTrans, pStb) != 0) goto DROP_STB_OVER; - if (mndSetDropStbCommitLogs(pMnode, pTrans, pStb) != 0) goto DROP_STB_OVER; - if (mndSetDropStbRedoActions(pMnode, pTrans, pDb, pStb) != 0) goto DROP_STB_OVER; - if (mndTransPrepare(pMnode, pTrans) != 0) goto DROP_STB_OVER; + if (mndSetDropStbRedoLogs(pMnode, pTrans, pStb) != 0) goto _OVER; + if (mndSetDropStbCommitLogs(pMnode, pTrans, pStb) != 0) goto _OVER; + if (mndSetDropStbRedoActions(pMnode, pTrans, pDb, pStb) != 0) goto _OVER; + if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; -DROP_STB_OVER: +_OVER: mndTransDrop(pTrans); return code; } @@ -1380,7 +1380,7 @@ static int32_t mndProcessMDropStbReq(SNodeMsg *pReq) { if (tDeserializeSMDropStbReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto DROP_STB_OVER; + goto _OVER; } mDebug("stb:%s, start to drop", dropReq.name); @@ -1390,32 +1390,32 @@ static int32_t mndProcessMDropStbReq(SNodeMsg *pReq) { if (dropReq.igNotExists) { mDebug("stb:%s, not exist, ignore not exist is set", dropReq.name); code = 0; - goto DROP_STB_OVER; + goto _OVER; } else { terrno = TSDB_CODE_MND_STB_NOT_EXIST; - goto DROP_STB_OVER; + goto _OVER; } } pDb = mndAcquireDbByStb(pMnode, dropReq.name); if (pDb == NULL) { terrno = TSDB_CODE_MND_DB_NOT_SELECTED; - goto DROP_STB_OVER; + goto _OVER; } pUser = mndAcquireUser(pMnode, pReq->user); if (pUser == NULL) { - goto DROP_STB_OVER; + goto _OVER; } if (mndCheckWriteAuth(pUser, pDb) != 0) { - goto DROP_STB_OVER; + goto _OVER; } code = mndDropStb(pMnode, pReq, pDb, pStb); if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; -DROP_STB_OVER: +_OVER: if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("stb:%s, failed to drop since %s", dropReq.name, terrstr()); } @@ -1509,36 +1509,36 @@ static int32_t mndProcessTableMetaReq(SNodeMsg *pReq) { if (tDeserializeSTableInfoReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &infoReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto RETRIEVE_META_OVER; + goto _OVER; } if (0 == strcmp(infoReq.dbFName, TSDB_INFORMATION_SCHEMA_DB)) { mDebug("information_schema table:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName); if (mndBuildInsTableSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { - goto RETRIEVE_META_OVER; + goto _OVER; } } else if (0 == strcmp(infoReq.dbFName, TSDB_PERFORMANCE_SCHEMA_DB)) { mDebug("performance_schema table:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName); if (mndBuildPerfsTableSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { - goto RETRIEVE_META_OVER; + goto _OVER; } } else { mDebug("stb:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName); if (mndBuildStbSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { - goto RETRIEVE_META_OVER; + goto _OVER; } } int32_t rspLen = tSerializeSTableMetaRsp(NULL, 0, &metaRsp); if (rspLen < 0) { terrno = TSDB_CODE_INVALID_MSG; - goto RETRIEVE_META_OVER; + goto _OVER; } void *pRsp = rpcMallocCont(rspLen); if (pRsp == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - goto RETRIEVE_META_OVER; + goto _OVER; } tSerializeSTableMetaRsp(pRsp, rspLen, &metaRsp); @@ -1548,7 +1548,7 @@ static int32_t mndProcessTableMetaReq(SNodeMsg *pReq) { mDebug("stb:%s.%s, meta is retrieved", infoReq.dbFName, infoReq.tbName); -RETRIEVE_META_OVER: +_OVER: if (code != 0) { mError("stb:%s.%s, failed to retrieve meta since %s", infoReq.dbFName, infoReq.tbName, terrstr()); }