diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 0f4839392e66212c951237582f8c035398694456..e86ab1c4480bd34e9f2046a80bfc233eb4ba0b8a 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -17,14 +17,16 @@ #define _TD_MND_DEF_H_ #include "os.h" + +#include "cJSON.h" +#include "sync.h" #include "taosmsg.h" +#include "thash.h" #include "tlog.h" #include "trpc.h" #include "ttimer.h" -#include "thash.h" -#include "cJSON.h" + #include "mnode.h" -#include "sync.h" #ifdef __cplusplus extern "C" { @@ -41,10 +43,8 @@ extern int32_t mDebugFlag; #define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }} typedef struct SClusterObj SClusterObj; -typedef struct SDnodeObj SDnodeObj; typedef struct SMnodeObj SMnodeObj; typedef struct SAcctObj SAcctObj; -typedef struct SUserObj SUserObj; typedef struct SDbObj SDbObj; typedef struct SVgObj SVgObj; typedef struct SFuncObj SFuncObj; @@ -119,7 +119,7 @@ typedef struct SClusterObj { int64_t updateTime; } SClusterObj; -typedef struct SDnodeObj { +typedef struct { int32_t id; int64_t createdTime; int64_t updateTime; @@ -178,7 +178,7 @@ typedef struct SAcctObj { SAcctInfo info; } SAcctObj; -typedef struct SUserObj { +typedef struct { char user[TSDB_USER_LEN]; char pass[TSDB_PASSWORD_LEN]; char acct[TSDB_USER_LEN]; diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index b638728647c277761febf3869dff438fb75d5c8f..2d1bfefc2808148417941e5890b855a0b8531c6e 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -65,7 +65,7 @@ int32_t mndInitDb(SMnode *pMnode) { void mndCleanupDb(SMnode *pMnode) {} static SSdbRaw *mndDbActionEncode(SDbObj *pDb) { - SSdbRaw *pRaw = sdbAllocRaw(SDB_DB, TSDB_DB_VER_NUM, sizeof(SDbObj)); + SSdbRaw *pRaw = sdbAllocRaw(SDB_DB, TSDB_DB_VER_NUM, sizeof(SDbObj) + TSDB_DB_RESERVE_SIZE); if (pRaw == NULL) return NULL; int32_t dataPos = 0; diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index e00244d05c9b493b20ebf6464ed9ea925be42e6b..72be28d2b3e755479bce12f5062d50e9ad59433a 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -108,7 +108,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) { } static SSdbRaw *mndDnodeActionEncode(SDnodeObj *pDnode) { - SSdbRaw *pRaw = sdbAllocRaw(SDB_DNODE, TSDB_DNODE_VER, sizeof(SDnodeObj)); + SSdbRaw *pRaw = sdbAllocRaw(SDB_DNODE, TSDB_DNODE_VER, sizeof(SDnodeObj) + TSDB_DNODE_RESERVE_SIZE); if (pRaw == NULL) return NULL; int32_t dataPos = 0; diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 6fb05653a50e0103f87f16f62c2f2ee391dc0cb3..2243f787b96e3e0cd8f40b43abd63d7e3bbbea14 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -20,7 +20,8 @@ #include "mndTrans.h" #include "tkey.h" -#define SDB_USER_VER 1 +#define TSDB_USER_VER 1 +#define TSDB_USER_RESERVE_SIZE 64 static int32_t mndCreateDefaultUsers(SMnode *pMnode); static SSdbRaw *mndUserActionEncode(SUserObj *pUser); @@ -93,7 +94,7 @@ static int32_t mndCreateDefaultUsers(SMnode *pMnode) { } static SSdbRaw *mndUserActionEncode(SUserObj *pUser) { - SSdbRaw *pRaw = sdbAllocRaw(SDB_USER, SDB_USER_VER, sizeof(SUserObj)); + SSdbRaw *pRaw = sdbAllocRaw(SDB_USER, TSDB_USER_VER, sizeof(SUserObj) + TSDB_USER_RESERVE_SIZE); if (pRaw == NULL) return NULL; int32_t dataPos = 0; @@ -103,6 +104,7 @@ static SSdbRaw *mndUserActionEncode(SUserObj *pUser) { SDB_SET_INT64(pRaw, dataPos, pUser->createdTime) SDB_SET_INT64(pRaw, dataPos, pUser->updateTime) SDB_SET_INT8(pRaw, dataPos, pUser->superUser) + SDB_SET_RESERVE(pRaw, dataPos, TSDB_USER_RESERVE_SIZE) SDB_SET_DATALEN(pRaw, dataPos); return pRaw; @@ -112,7 +114,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) { int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) return NULL; - if (sver != SDB_USER_VER) { + if (sver != TSDB_USER_VER) { mError("failed to decode user since %s", terrstr()); terrno = TSDB_CODE_SDB_INVALID_DATA_VER; return NULL; @@ -129,6 +131,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) { SDB_GET_INT64(pRaw, pRow, dataPos, &pUser->createdTime) SDB_GET_INT64(pRaw, pRow, dataPos, &pUser->updateTime) SDB_GET_INT8(pRaw, pRow, dataPos, &pUser->superUser) + SDB_GET_RESERVE(pRaw, pRow, dataPos, TSDB_USER_RESERVE_SIZE) return pRow; }