diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 348c0709f17bfcf2bb9c54ddfdd310021f08bd42..7856856606e1ce550307a856b27bf69945ea2a42 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1752,7 +1752,7 @@ int tscBuildMetricMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) { msgLen = pMsg - pStart; pCmd->payloadLen = msgLen; - pCmd->msgType = TSDB_MSG_TYPE_CM_STABLE_META; + pCmd->msgType = TSDB_MSG_TYPE_CM_STABLE_VGROUP; assert(msgLen + minMsgSize() <= size); return TSDB_CODE_SUCCESS; diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index f1e07c98a8728c8e8c1be96e89233f74efdc1d5a..49e498d22fa32babe6af475023ca4372e1a23348 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -738,8 +738,8 @@ typedef struct { } SDMConfigTableMsg; typedef struct { - uint32_t dnode; - int32_t vnode; + uint32_t dnodeId; + int32_t vgId; } SDMConfigVnodeMsg; typedef struct { diff --git a/src/mnode/inc/mgmtDb.h b/src/mnode/inc/mgmtDb.h index f2049f836ceb20a775b25927c91ef040cda78338..27918b9cf94bc2a9591242bc07eaf24fe3d40170 100644 --- a/src/mnode/inc/mgmtDb.h +++ b/src/mnode/inc/mgmtDb.h @@ -22,22 +22,23 @@ extern "C" { #include "mnode.h" -void mgmtAddVgroupIntoDb(SVgObj *pVgroup); -void mgmtAddVgroupIntoDbTail(SVgObj *pVgroup); -void mgmtRemoveVgroupFromDb(SVgObj *pVgroup); -void mgmtMoveVgroupToTail(SVgObj *pVgroup); -void mgmtMoveVgroupToHead(SVgObj *pVgroup); - +// api int32_t mgmtInitDbs(); void mgmtCleanUpDbs(); SDbObj *mgmtGetDb(char *db); SDbObj *mgmtGetDbByTableId(char *db); bool mgmtCheckIsMonitorDB(char *db, char *monitordb); +// util func void mgmtAddSuperTableIntoDb(SDbObj *pDb); void mgmtRemoveSuperTableFromDb(SDbObj *pDb); void mgmtAddTableIntoDb(SDbObj *pDb); void mgmtRemoveTableFromDb(SDbObj *pDb); +void mgmtAddVgroupIntoDb(SVgObj *pVgroup); +void mgmtAddVgroupIntoDbTail(SVgObj *pVgroup); +void mgmtRemoveVgroupFromDb(SVgObj *pVgroup); +void mgmtMoveVgroupToTail(SVgObj *pVgroup); +void mgmtMoveVgroupToHead(SVgObj *pVgroup); #ifdef __cplusplus } diff --git a/src/mnode/inc/mgmtMnode.h b/src/mnode/inc/mgmtMnode.h index 729d31544f4c49f729e8c6d958a5a038661e225b..8cfe3c7e235f3fabfed0ea403b428d579f2f26da 100644 --- a/src/mnode/inc/mgmtMnode.h +++ b/src/mnode/inc/mgmtMnode.h @@ -21,14 +21,14 @@ extern "C" { #endif int32_t mgmtInitMnodes(); -void mgmtCleanupMnodes(); +void mgmtCleanupMnodes(); -bool mgmtInServerStatus(); -bool mgmtIsMaster(); +bool mgmtInServerStatus(); +bool mgmtIsMaster(); -bool mgmtCheckRedirect(void *handle); -void mgmtGetMnodePrivateIpList(SRpcIpSet *ipSet); -void mgmtGetMnodePublicIpList(SRpcIpSet *ipSet); +bool mgmtCheckRedirect(void *handle); +void mgmtGetMnodePrivateIpList(SRpcIpSet *ipSet); +void mgmtGetMnodePublicIpList(SRpcIpSet *ipSet); int32_t mgmtAddMnode(uint32_t privateIp, uint32_t publicIp); int32_t mgmtRemoveMnode(uint32_t privateIp); diff --git a/src/mnode/inc/mgmtProfile.h b/src/mnode/inc/mgmtProfile.h index 8c2e073c2d5981d54f6ca8fc41144bb03f8467b2..a40f572f8bc333aafcb8490a36c5e5c290fa5409 100644 --- a/src/mnode/inc/mgmtProfile.h +++ b/src/mnode/inc/mgmtProfile.h @@ -24,11 +24,11 @@ extern "C" { int32_t mgmtInitProfile(); void mgmtCleanUpProfile(); -bool mgmtCheckQhandle(uint64_t qhandle); -void mgmtSaveQhandle(void *qhandle); -void mgmtFreeQhandle(void *qhandle); +bool mgmtCheckQhandle(uint64_t qhandle); +void mgmtSaveQhandle(void *qhandle); +void mgmtFreeQhandle(void *qhandle); -void mgmtFreeQueuedMsg(SQueuedMsg *pMsg); +void mgmtFreeQueuedMsg(SQueuedMsg *pMsg); #ifdef __cplusplus } diff --git a/src/mnode/inc/mgmtSdb.h b/src/mnode/inc/mgmtSdb.h index ccddc11e04fc32cf2ee8cd0b503c51a993025d4d..f291e9341878bedded173840c77d8d61f7da862d 100644 --- a/src/mnode/inc/mgmtSdb.h +++ b/src/mnode/inc/mgmtSdb.h @@ -53,16 +53,16 @@ typedef struct { int32_t (*destroyFp)(SSdbOperDesc *pDesc); } SSdbTableDesc; -void *sdbOpenTable(SSdbTableDesc *desc); -void sdbCloseTable(void *handle); +void * sdbOpenTable(SSdbTableDesc *desc); +void sdbCloseTable(void *handle); int32_t sdbInsertRow(SSdbOperDesc *pOper); int32_t sdbDeleteRow(SSdbOperDesc *pOper); int32_t sdbUpdateRow(SSdbOperDesc *pOper); -void *sdbGetRow(void *handle, void *key); -void *sdbFetchRow(void *handle, void *pNode, void **ppRow); -int64_t sdbGetNumOfRows(void *handle); +void *sdbGetRow(void *handle, void *key); +void *sdbFetchRow(void *handle, void *pNode, void **ppRow); +int64_t sdbGetNumOfRows(void *handle); uint64_t sdbGetVersion(); #ifdef __cplusplus diff --git a/src/mnode/inc/mgmtShell.h b/src/mnode/inc/mgmtShell.h index 56625b982aed2fa90b39d35be7014ba7ed85e6a4..b92e9de1f463f7e95205ab8c3775d512127e7249 100644 --- a/src/mnode/inc/mgmtShell.h +++ b/src/mnode/inc/mgmtShell.h @@ -22,8 +22,8 @@ extern "C" { #include "mnode.h" int32_t mgmtInitShell(); -void mgmtCleanUpShell(); -void mgmtAddShellMsgHandle(uint8_t msgType, void (*fp)(SQueuedMsg *queuedMsg)); +void mgmtCleanUpShell(); +void mgmtAddShellMsgHandle(uint8_t msgType, void (*fp)(SQueuedMsg *queuedMsg)); typedef int32_t (*SShowMetaFp)(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn); typedef int32_t (*SShowRetrieveFp)(SShowObj *pShow, char *data, int32_t rows, void *pConn); diff --git a/src/mnode/inc/mgmtVgroup.h b/src/mnode/inc/mgmtVgroup.h index aba95fb478fccfe3e78a582c1970bbdb6f779dc5..de0648da44bfec3d007fdcdf565c34dd46022650 100644 --- a/src/mnode/inc/mgmtVgroup.h +++ b/src/mnode/inc/mgmtVgroup.h @@ -27,12 +27,10 @@ extern "C" { int32_t mgmtInitVgroups(); void mgmtCleanUpVgroups(); SVgObj *mgmtGetVgroup(int32_t vgId); -SVgObj *mgmtGetVgroupByVnode(uint32_t dnode, int32_t vnode); void mgmtDropAllVgroups(SDbObj *pDropDb); void mgmtCreateVgroup(SQueuedMsg *pMsg); void mgmtDropVgroup(SVgObj *pVgroup, void *ahandle); -void mgmtUpdateVgroup(SVgObj *pVgroup); void mgmtAlterVgroup(SVgObj *pVgroup, void *ahandle); SVgObj *mgmtGetAvailableVgroup(SDbObj *pDb); diff --git a/src/mnode/src/mgmtChildTable.c b/src/mnode/src/mgmtChildTable.c index a2605cefd513579c2ed13d19fabf652cb0ba5f24..2d4f37581df76180173bd1f777c8bfa8cb8bbb9e 100644 --- a/src/mnode/src/mgmtChildTable.c +++ b/src/mnode/src/mgmtChildTable.c @@ -332,7 +332,6 @@ static void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableOb } memcpy(pCreate->tableId, pTable->info.tableId, TSDB_TABLE_ID_LEN + 1); - memcpy(pCreate->superTableId, pTable->superTable->info.tableId, TSDB_TABLE_ID_LEN + 1); pCreate->contLen = htonl(contLen); pCreate->vgId = htonl(pTable->vgId); pCreate->tableType = pTable->info.type; @@ -342,6 +341,7 @@ static void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableOb pCreate->uid = htobe64(pTable->uid); if (pTable->info.type == TSDB_CHILD_TABLE) { + memcpy(pCreate->superTableId, pTable->superTable->info.tableId, TSDB_TABLE_ID_LEN + 1); pCreate->numOfColumns = htons(pTable->superTable->numOfColumns); pCreate->numOfTags = htons(pTable->superTable->numOfTags); pCreate->sversion = htonl(pTable->superTable->sversion); diff --git a/src/mnode/src/mgmtDb.c b/src/mnode/src/mgmtDb.c index 16f9751e20d4f1edc4ba589c7188d097c2b11c33..8c8173f781e20803910676b629cd5709b3a070a4 100644 --- a/src/mnode/src/mgmtDb.c +++ b/src/mnode/src/mgmtDb.c @@ -41,7 +41,6 @@ static int32_t tsDbUpdateSize; static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate); static void mgmtDropDb(void *handle, void *tmrId); static int32_t mgmtSetDbDirty(SDbObj *pDb); - static int32_t mgmtGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn); static int32_t mgmtRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void *pConn); static void mgmtProcessCreateDbMsg(SQueuedMsg *pMsg); diff --git a/src/mnode/src/mgmtUser.c b/src/mnode/src/mgmtUser.c index c69035c304066053606f40dc928c0c6e206e3516..dc2418efd94fd36be754058b1ec46cadb1505694 100644 --- a/src/mnode/src/mgmtUser.c +++ b/src/mnode/src/mgmtUser.c @@ -25,14 +25,14 @@ #include "mgmtShell.h" #include "mgmtUser.h" -void *tsUserSdb = NULL; +static void *tsUserSdb = NULL; static int32_t tsUserUpdateSize = 0; -static int32_t mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass); -static int32_t mgmtDropUser(SAcctObj *pAcct, char *name); -static int32_t mgmtUpdateUser(SUserObj *pUser); -static int32_t mgmtGetUserMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn); -static int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void *pConn); +static int32_t mgmtCreateUser(SAcctObj *pAcct, char *name, char *pass); +static int32_t mgmtDropUser(SAcctObj *pAcct, char *name); +static int32_t mgmtUpdateUser(SUserObj *pUser); +static int32_t mgmtGetUserMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn); +static int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void *pConn); static void mgmtProcessCreateUserMsg(SQueuedMsg *pMsg); static void mgmtProcessAlterUserMsg(SQueuedMsg *pMsg); @@ -313,7 +313,9 @@ static int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void SUserObj *mgmtGetUserFromConn(void *pConn, bool *usePublicIp) { SRpcConnInfo connInfo; if (rpcGetConnInfo(pConn, &connInfo) == 0) { - *usePublicIp = (connInfo.serverIp == tsPublicIpInt); + if (usePublicIp) { + *usePublicIp = (connInfo.serverIp == tsPublicIpInt); + } return mgmtGetUser(connInfo.user); } diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index deb1da00257b1f0df21a54e7988d8a4d82c4616f..a8e7219e2ee6dfde74264d045c1d75cc987f297d 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -67,8 +67,8 @@ static int32_t mgmtVgroupActionInsert(SSdbOperDesc *pOper) { pVgroup->prev = NULL; pVgroup->next = NULL; - int32_t size = sizeof(STableInfo *) * pDb->cfg.maxSessions; - pVgroup->tableList = (STableInfo **)calloc(pDb->cfg.maxSessions, sizeof(STableInfo *)); + int32_t size = sizeof(SChildTableObj *) * pDb->cfg.maxSessions; + pVgroup->tableList = calloc(pDb->cfg.maxSessions, sizeof(SChildTableObj *)); if (pVgroup->tableList == NULL) { mError("vgroup:%d, failed to malloc(size:%d) for the tableList of vgroups", pVgroup->vgId, size); return -1; @@ -112,8 +112,8 @@ static int32_t mgmtVgroupActionUpdate(SSdbOperDesc *pOper) { if (pDb->cfg.maxSessions != oldTables) { mPrint("vgroup:%d tables change from %d to %d", pVgroup->vgId, oldTables, pDb->cfg.maxSessions); taosUpdateIdPool(pVgroup->idPool, pDb->cfg.maxSessions); - int32_t size = sizeof(STableInfo *) * pDb->cfg.maxSessions; - pVgroup->tableList = (STableInfo **)realloc(pVgroup->tableList, size); + int32_t size = sizeof(SChildTableObj *) * pDb->cfg.maxSessions; + pVgroup->tableList = (SChildTableObj **)realloc(pVgroup->tableList, size); } } @@ -483,17 +483,14 @@ SMDCreateVnodeMsg *mgmtBuildCreateVnodeMsg(SVgObj *pVgroup) { return pVnode; } -SVgObj *mgmtGetVgroupByVnode(uint32_t dnode, int32_t vnode) { - if (vnode < 0 || vnode >= TSDB_MAX_VNODES) { - return NULL; - } +static SVgObj *mgmtGetVgroupInDnode(uint32_t dnodeId, int32_t vgId) { + if (vnovgId < 1 || dnodeId < 1) return NULL; - SDnodeObj *pDnode = mgmtGetDnode(dnode); + SDnodeObj *pDnode = mgmtGetDnode(dnodeId); if (pDnode == NULL) { return NULL; } - int32_t vgId = pDnode->vload[vnode].vgId; return mgmtGetVgroup(vgId); } @@ -660,10 +657,10 @@ static void mgmtProcessVnodeCfgMsg(SRpcMsg *rpcMsg) { if (mgmtCheckRedirect(rpcMsg->handle)) return; SDMConfigVnodeMsg *pCfg = (SDMConfigVnodeMsg *) rpcMsg->pCont; - pCfg->dnode = htonl(pCfg->dnode); - pCfg->vnode = htonl(pCfg->vnode); + pCfg->dnodeId = htonl(pCfg->dnode); + pCfg->vgId = htonl(pCfg->vnode); - SVgObj *pVgroup = mgmtGetVgroupByVnode(pCfg->dnode, pCfg->vnode); + SVgObj *pVgroup = mgmtGetVgroupInDnode(pCfg->dnodeId, pCfg->vgId); if (pVgroup == NULL) { mTrace("dnode:%s, vnode:%d, no vgroup info", taosIpStr(pCfg->dnode), pCfg->vnode); mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_NOT_ACTIVE_VNODE); diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index c6f527a7d2851d71b9fe9d296a5ae571bac364b6..93334333efd47766646a89de69c54304f483d893 100755 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -360,7 +360,7 @@ void rpcSendRequest(void *shandle, SRpcIpSet *pIpSet, SRpcMsg *pMsg) { // for TDengine, all the query, show commands shall have TCP connection char type = pMsg->msgType; if (type == TSDB_MSG_TYPE_QUERY || type == TSDB_MSG_TYPE_RETRIEVE || - type == TSDB_MSG_TYPE_CM_STABLE_META || type == TSDB_MSG_TYPE_CM_TABLES_META || + type == TSDB_MSG_TYPE_CM_STABLE_VGROUP || type == TSDB_MSG_TYPE_CM_TABLES_META || type == TSDB_MSG_TYPE_CM_SHOW ) pContext->connType = RPC_CONN_TCPC;