diff --git a/include/common/taosmsg.h b/include/common/taosmsg.h index 1ed02ca21e6e5248ca74d10d7df9e2052d69a112..eb2adda3941fd2b672c25a62513f1be1ec494148 100644 --- a/include/common/taosmsg.h +++ b/include/common/taosmsg.h @@ -807,8 +807,8 @@ typedef struct SSTableVgroupMsg { typedef struct SVgroupInfo { int32_t vgId; - int32_t hashBegin; - int32_t hashEnd; + uint32_t hashBegin; + uint32_t hashEnd; int8_t inUse; int8_t numOfEps; SEpAddrMsg epAddr[TSDB_MAX_REPLICA]; diff --git a/source/dnode/mgmt/impl/test/db/db.cpp b/source/dnode/mgmt/impl/test/db/db.cpp index 65756b7daacf8f11e28cd90e18f86eccd5af63e5..6821dec0a6c83e75412ddd3cacdb105481ccbc69 100644 --- a/source/dnode/mgmt/impl/test/db/db.cpp +++ b/source/dnode/mgmt/impl/test/db/db.cpp @@ -64,10 +64,10 @@ class DndTestDb : public ::testing::Test { ASSERT_NE(pShowRsp, nullptr); pShowRsp->showId = htonl(pShowRsp->showId); pMeta = &pShowRsp->tableMeta; - pMeta->numOfTags = htons(pMeta->numOfTags); - pMeta->numOfColumns = htons(pMeta->numOfColumns); - pMeta->sversion = htons(pMeta->sversion); - pMeta->tversion = htons(pMeta->tversion); + pMeta->numOfTags = htonl(pMeta->numOfTags); + pMeta->numOfColumns = htonl(pMeta->numOfColumns); + pMeta->sversion = htonl(pMeta->sversion); + pMeta->tversion = htonl(pMeta->tversion); pMeta->tuid = htobe64(pMeta->tuid); pMeta->suid = htobe64(pMeta->suid); @@ -436,7 +436,7 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) { pInfo->hashEnd = htonl(pInfo->hashEnd); EXPECT_GT(pInfo->vgId, 0); EXPECT_EQ(pInfo->hashBegin, 0); - EXPECT_EQ(pInfo->hashEnd, INT32_MAX / 2 - 1); + EXPECT_EQ(pInfo->hashEnd, UINT32_MAX / 2 - 1); EXPECT_EQ(pInfo->inUse, 0); EXPECT_EQ(pInfo->numOfEps, 1); SEpAddrMsg* pAddr = &pInfo->epAddr[0]; @@ -451,8 +451,8 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) { pInfo->hashBegin = htonl(pInfo->hashBegin); pInfo->hashEnd = htonl(pInfo->hashEnd); EXPECT_GT(pInfo->vgId, 0); - EXPECT_EQ(pInfo->hashBegin, INT32_MAX / 2); - EXPECT_EQ(pInfo->hashEnd, INT32_MAX); + EXPECT_EQ(pInfo->hashBegin, UINT32_MAX / 2); + EXPECT_EQ(pInfo->hashEnd, UINT32_MAX); EXPECT_EQ(pInfo->inUse, 0); EXPECT_EQ(pInfo->numOfEps, 1); SEpAddrMsg* pAddr = &pInfo->epAddr[0]; diff --git a/source/dnode/mgmt/impl/test/dnode/dnode.cpp b/source/dnode/mgmt/impl/test/dnode/dnode.cpp index 6989edd843688f142b7afaf0acff42310749a5b8..f382f385d785889f5fd76c14e86277e2db9261f0 100644 --- a/source/dnode/mgmt/impl/test/dnode/dnode.cpp +++ b/source/dnode/mgmt/impl/test/dnode/dnode.cpp @@ -78,11 +78,11 @@ class DndTestDnode : public ::testing::Test { ASSERT_NE(pShowRsp, nullptr); pShowRsp->showId = htonl(pShowRsp->showId); pMeta = &pShowRsp->tableMeta; - pMeta->numOfTags = htons(pMeta->numOfTags); - pMeta->numOfColumns = htons(pMeta->numOfColumns); - pMeta->sversion = htons(pMeta->sversion); + pMeta->numOfTags = htonl(pMeta->numOfTags); + pMeta->numOfColumns = htonl(pMeta->numOfColumns); + pMeta->sversion = htonl(pMeta->sversion); pMeta->tversion = htons(pMeta->tversion); - pMeta->tuid = htobe64(pMeta->tuid); + pMeta->tuid = htonl(pMeta->tuid); pMeta->suid = htobe64(pMeta->suid); showId = pShowRsp->showId; @@ -220,7 +220,7 @@ TEST_F(DndTestDnode, 02_ConfigDnode) { ASSERT_EQ(pMsg->code, 0); } -TEST_F(DndTestDnode, 03_Create_Drop_Reatrt_Dnode) { +TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) { { SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(sizeof(SCreateDnodeMsg)); strcpy(pReq->ep, "localhost:9042"); diff --git a/source/dnode/mgmt/impl/test/user/user.cpp b/source/dnode/mgmt/impl/test/user/user.cpp index 3290bec0ccc9b55219e0b98567dee524130f6794..74e8e0db44d340360eb20688b11811b57cea6e99 100644 --- a/source/dnode/mgmt/impl/test/user/user.cpp +++ b/source/dnode/mgmt/impl/test/user/user.cpp @@ -63,10 +63,10 @@ class DndTestUser : public ::testing::Test { ASSERT_NE(pShowRsp, nullptr); pShowRsp->showId = htonl(pShowRsp->showId); pMeta = &pShowRsp->tableMeta; - pMeta->numOfTags = htons(pMeta->numOfTags); - pMeta->numOfColumns = htons(pMeta->numOfColumns); - pMeta->sversion = htons(pMeta->sversion); - pMeta->tversion = htons(pMeta->tversion); + pMeta->numOfTags = htonl(pMeta->numOfTags); + pMeta->numOfColumns = htonl(pMeta->numOfColumns); + pMeta->sversion = htonl(pMeta->sversion); + pMeta->tversion = htonl(pMeta->tversion); pMeta->tuid = htobe64(pMeta->tuid); pMeta->suid = htobe64(pMeta->suid); diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 5a678118f3937ae158a71eaf97b6809f5d1f7843..74138500bdfbe9ebd0f9b393314e666080e904ed 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -224,8 +224,8 @@ typedef struct { int64_t createdTime; int64_t updateTime; int32_t version; - int32_t hashBegin; - int32_t hashEnd; + uint32_t hashBegin; + uint32_t hashEnd; char dbName[TSDB_FULL_DB_NAME_LEN]; int64_t dbUid; int32_t numOfTables; @@ -244,6 +244,7 @@ typedef struct { int64_t createdTime; int64_t updateTime; uint64_t uid; + uint64_t dbUid; int32_t version; int32_t numOfColumns; int32_t numOfTags; diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 1c78ec5408867e255a62106ed9e03b0642f2816e..3509c5b68d7bf61160981dd89a0869ae3357ce92 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -283,6 +283,14 @@ static int32_t mndSetCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVg return 0; } +static int32_t mndSetRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroups) { + return 0; +} + +static int32_t mndSetUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroups) { + return 0; +} + static int32_t mndCreateDb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDbMsg *pCreate, SUserObj *pUser) { SDbObj dbObj = {0}; tstrncpy(dbObj.name, pCreate->db, TSDB_FULL_DB_NAME_LEN); @@ -354,6 +362,16 @@ static int32_t mndCreateDb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDbMsg *pCreat goto CREATE_DB_OVER; } + if (mndSetRedoActions(pMnode, pTrans, &dbObj, pVgroups) != 0) { + mError("trans:%d, failed to set redo actions since %s", pTrans->id, terrstr()); + goto CREATE_DB_OVER; + } + + if (mndSetUndoActions(pMnode, pTrans, &dbObj, pVgroups) != 0) { + mError("trans:%d, failed to set redo actions since %s", pTrans->id, terrstr()); + goto CREATE_DB_OVER; + } + if (mndTransPrepare(pMnode, pTrans) != 0) { mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); goto CREATE_DB_OVER; @@ -816,7 +834,7 @@ static int32_t mndGetDbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMe pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pMeta->numOfColumns = htons(cols); + pMeta->numOfColumns = htonl(cols); pShow->numOfColumns = cols; pShow->offset[0] = 0; diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 791f43c69cda1576ae19b90be4416ddcf0321f34..de365ffb7f6379ba6b28076fe4d7387d98f8a078 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -570,7 +570,7 @@ static int32_t mndGetConfigMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pMeta->numOfColumns = htons(cols); + pMeta->numOfColumns = htonl(cols); pShow->numOfColumns = cols; pShow->offset[0] = 0; @@ -677,7 +677,7 @@ static int32_t mndGetDnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg * pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pMeta->numOfColumns = htons(cols); + pMeta->numOfColumns = htonl(cols); pShow->numOfColumns = cols; pShow->offset[0] = 0; diff --git a/source/dnode/mnode/impl/src/mndFunc.c b/source/dnode/mnode/impl/src/mndFunc.c index b7158bb0947cc85e2700327421f32b1f2b5d7d2d..817acf3067b1e95393aec28309cc8f01aa005bac 100644 --- a/source/dnode/mnode/impl/src/mndFunc.c +++ b/source/dnode/mnode/impl/src/mndFunc.c @@ -419,7 +419,7 @@ static int32_t mndGetFuncMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pMeta->numOfColumns = htons(cols); + pMeta->numOfColumns = htonl(cols); pShow->numOfColumns = cols; pShow->offset[0] = 0; diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index 7b6804d43e3c178aa6b3b46ccd681fb9dc127ec8..b0d986d4564a0f130b46447f1379d0d33fed114f 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -395,7 +395,7 @@ static int32_t mndGetMnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg * pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pMeta->numOfColumns = htons(cols); + pMeta->numOfColumns = htonl(cols); pShow->numOfColumns = cols; pShow->offset[0] = 0; diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 45a63f2dc57f26ebb0e338988b2a4971b81fc26c..1491d75fd2a0d2723761ac8c52659f9db5fca557 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -515,7 +515,7 @@ static int32_t mndGetConnsMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg * pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pMeta->numOfColumns = htons(cols); + pMeta->numOfColumns = htonl(cols); pShow->numOfColumns = cols; pShow->offset[0] = 0; @@ -683,7 +683,7 @@ static int32_t mndGetQueryMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg * pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pMeta->numOfColumns = htons(cols); + pMeta->numOfColumns = htonl(cols); pShow->numOfColumns = cols; pShow->offset[0] = 0; @@ -875,7 +875,7 @@ static int32_t mndGetStreamMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pMeta->numOfColumns = htons(cols); + pMeta->numOfColumns = htonl(cols); pShow->numOfColumns = cols; pShow->offset[0] = 0; diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 791b6f5d12e682061979c1cca2d51a2ff55da9fd..76edb556fa94009d339504fe98049c5b6eabc981 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -74,10 +74,12 @@ static SSdbRaw *mndStbActionEncode(SStbObj *pStb) { if (pRaw == NULL) return NULL; int32_t dataPos = 0; - SDB_SET_BINARY(pRaw, dataPos, pStb->name, TSDB_TABLE_NAME_LEN) + SDB_SET_BINARY(pRaw, dataPos, pStb->name, TSDB_TABLE_FNAME_LEN) + SDB_SET_BINARY(pRaw, dataPos, pStb->db, TSDB_FULL_DB_NAME_LEN) SDB_SET_INT64(pRaw, dataPos, pStb->createdTime) SDB_SET_INT64(pRaw, dataPos, pStb->updateTime) SDB_SET_INT64(pRaw, dataPos, pStb->uid) + SDB_SET_INT64(pRaw, dataPos, pStb->dbUid) SDB_SET_INT64(pRaw, dataPos, pStb->version) SDB_SET_INT32(pRaw, dataPos, pStb->numOfColumns) SDB_SET_INT32(pRaw, dataPos, pStb->numOfTags) @@ -113,10 +115,12 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { if (pStb == NULL) return NULL; int32_t dataPos = 0; - SDB_GET_BINARY(pRaw, pRow, dataPos, pStb->name, TSDB_TABLE_NAME_LEN) + SDB_GET_BINARY(pRaw, pRow, dataPos, pStb->name, TSDB_TABLE_FNAME_LEN) + SDB_GET_BINARY(pRaw, pRow, dataPos, pStb->db, TSDB_FULL_DB_NAME_LEN) SDB_GET_INT64(pRaw, pRow, dataPos, &pStb->createdTime) SDB_GET_INT64(pRaw, pRow, dataPos, &pStb->updateTime) SDB_GET_INT64(pRaw, pRow, dataPos, &pStb->uid) + SDB_GET_INT64(pRaw, pRow, dataPos, &pStb->dbUid) SDB_GET_INT32(pRaw, pRow, dataPos, &pStb->version) SDB_GET_INT32(pRaw, pRow, dataPos, &pStb->numOfColumns) SDB_GET_INT32(pRaw, pRow, dataPos, &pStb->numOfTags) @@ -591,7 +595,7 @@ static int32_t mndGetStbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pM pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pMeta->numOfColumns = htons(cols); + pMeta->numOfColumns = htonl(cols); pShow->numOfColumns = cols; pShow->offset[0] = 0; diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 7dfe8c26ea65f70448dd6cbffc6b407ac2cd7010..f65aebe3f04e0aeca32babaf01c808ed21116b12 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -213,13 +213,13 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) { return -1; } - int32_t alloceVgroups = 0; - int32_t maxVgId = sdbGetMaxId(pMnode->pSdb, SDB_VGROUP); - int32_t hashMin = 0; - int32_t hashMax = INT32_MAX; - int32_t hashInterval = (hashMax - hashMin) / pDb->numOfVgroups; + int32_t alloceVgroups = 0; + int32_t maxVgId = sdbGetMaxId(pMnode->pSdb, SDB_VGROUP); + uint32_t hashMin = 0; + uint32_t hashMax = UINT32_MAX; + uint32_t hashInterval = (hashMax - hashMin) / pDb->numOfVgroups; - for (int32_t v = 0; v < pDb->numOfVgroups; v++) { + for (uint32_t v = 0; v < pDb->numOfVgroups; v++) { SVgObj *pVgroup = &pVgroups[v]; pVgroup->vgId = maxVgId++; pVgroup->createdTime = taosGetTimestampMs(); @@ -323,7 +323,7 @@ static int32_t mndGetVgroupMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg cols++; } - pMeta->numOfColumns = htons(cols); + pMeta->numOfColumns = htonl(cols); pShow->numOfColumns = cols; pShow->offset[0] = 0; @@ -411,7 +411,7 @@ static int32_t mndGetVnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg * pSchema[cols].bytes = htons(pShow->bytes[cols]); cols++; - pMeta->numOfColumns = htons(cols); + pMeta->numOfColumns = htonl(cols); pShow->numOfColumns = cols; pShow->offset[0] = 0;