diff --git a/src/mnode/src/mgmtChildTable.c b/src/mnode/src/mgmtChildTable.c index 2d4f37581df76180173bd1f777c8bfa8cb8bbb9e..58cee331b30d315078155a47c0deacdd610b5015 100644 --- a/src/mnode/src/mgmtChildTable.c +++ b/src/mnode/src/mgmtChildTable.c @@ -725,13 +725,13 @@ static int32_t mgmtDoGetChildTableMeta(SDbObj *pDb, SChildTableObj *pTable, STab if (pTable->info.type == TSDB_CHILD_TABLE) { pMeta->sversion = htons(pTable->superTable->sversion); - pMeta->numOfTags = htons(pTable->superTable->numOfTags); - pMeta->numOfColumns = htons(pTable->superTable->numOfColumns); + pMeta->numOfTags = 0; + pMeta->numOfColumns = htons((int16_t)pTable->superTable->numOfColumns); pMeta->contLen = sizeof(STableMetaMsg) + mgmtSetSchemaFromSuperTable(pMeta->schema, pTable->superTable); } else { pMeta->sversion = htons(pTable->sversion); pMeta->numOfTags = 0; - pMeta->numOfColumns = htons(pTable->numOfColumns); + pMeta->numOfColumns = htons((int16_t)pTable->numOfColumns); pMeta->contLen = sizeof(STableMetaMsg) + mgmtSetSchemaFromNormalTable(pMeta->schema, pTable); } @@ -758,9 +758,9 @@ static int32_t mgmtDoGetChildTableMeta(SDbObj *pDb, SChildTableObj *pTable, STab void mgmtGetChildTableMeta(SQueuedMsg *pMsg, SChildTableObj *pTable) { SCMTableInfoMsg *pInfo = pMsg->pCont; - SDbObj *pDb = mgmtGetDbByTableId(pTable->info.tableId); + SDbObj *pDb = mgmtGetDbByTableId(pInfo->tableId); if (pDb == NULL || pDb->dirty) { - mError("table:%s, failed to get table meta, db not selected", pTable->info.tableId); + mError("table:%s, failed to get table meta, db not selected", pInfo->tableId); mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_DB_NOT_SELECTED); return; } @@ -877,7 +877,7 @@ static STableInfo* mgmtGetTableByPos(uint32_t dnodeId, int32_t vnode, int32_t si return NULL; } - return pVgroup->tableList[sid]; + return (STableInfo *)pVgroup->tableList[sid]; } static void mgmtProcessTableCfgMsg(SRpcMsg *rpcMsg) { diff --git a/src/mnode/src/mgmtSuperTable.c b/src/mnode/src/mgmtSuperTable.c index e340643998bccdc4a1d405d97a1841b4af13b72d..ba7be9ba59d0b1c11aabc2c107a01c9dbb19d235 100644 --- a/src/mnode/src/mgmtSuperTable.c +++ b/src/mnode/src/mgmtSuperTable.c @@ -610,8 +610,8 @@ void mgmtGetSuperTableMeta(SQueuedMsg *pMsg, SSuperTableObj *pTable) { pMeta->uid = htobe64(pTable->uid); pMeta->sversion = htons(pTable->sversion); pMeta->precision = pDb->cfg.precision; - pMeta->numOfTags = pTable->numOfTags; - pMeta->numOfColumns = htons(pTable->numOfColumns); + pMeta->numOfTags = htons((int16_t)pTable->numOfTags); + pMeta->numOfColumns = htons((int16_t)pTable->numOfColumns); pMeta->tableType = pTable->info.type; pMeta->contLen = sizeof(STableMetaMsg) + mgmtSetSchemaFromSuperTable(pMeta->schema, pTable); strcpy(pMeta->tableId, pTable->info.tableId); diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index 3e47a7c277e705cf32d17449f876190de472be3b..5169f4a8174ae6d88d9a4741fcdfa8f8ac01d629 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -230,6 +230,13 @@ static void mgmtProcessTableMetaMsg(SQueuedMsg *pMsg) { SCMTableInfoMsg *pInfo = pMsg->pCont; mTrace("table:%s, table meta msg is received from thandle:%p", pInfo->tableId, pMsg->thandle); + pMsg->pDb = mgmtGetDbByTableId(pInfo->tableId); + if (pMsg->pDb == NULL || pMsg->pDb->dirty) { + mError("table:%s, failed to get table meta, db not selected", pInfo->tableId); + mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_DB_NOT_SELECTED); + return; + } + STableInfo *pTable = mgmtGetTable(pInfo->tableId); if (pTable == NULL || pTable->type != TSDB_SUPER_TABLE) { mgmtGetChildTableMeta(pMsg, (SChildTableObj *)pTable); diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index a8e7219e2ee6dfde74264d045c1d75cc987f297d..f6f0e9b76a31940564e3b0090bbfa23c208686e4 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -25,6 +25,7 @@ #include "mgmtDClient.h" #include "mgmtDnode.h" #include "mgmtDServer.h" +#include "mgmtMnode.h" #include "mgmtProfile.h" #include "mgmtSdb.h" #include "mgmtShell.h" @@ -483,17 +484,6 @@ SMDCreateVnodeMsg *mgmtBuildCreateVnodeMsg(SVgObj *pVgroup) { return pVnode; } -static SVgObj *mgmtGetVgroupInDnode(uint32_t dnodeId, int32_t vgId) { - if (vnovgId < 1 || dnodeId < 1) return NULL; - - SDnodeObj *pDnode = mgmtGetDnode(dnodeId); - if (pDnode == NULL) { - return NULL; - } - - return mgmtGetVgroup(vgId); -} - SRpcIpSet mgmtGetIpSetFromVgroup(SVgObj *pVgroup) { SRpcIpSet ipSet = { .numOfIps = pVgroup->numOfVnodes, @@ -657,19 +647,26 @@ static void mgmtProcessVnodeCfgMsg(SRpcMsg *rpcMsg) { if (mgmtCheckRedirect(rpcMsg->handle)) return; SDMConfigVnodeMsg *pCfg = (SDMConfigVnodeMsg *) rpcMsg->pCont; - pCfg->dnodeId = htonl(pCfg->dnode); - pCfg->vgId = htonl(pCfg->vnode); + pCfg->dnodeId = htonl(pCfg->dnodeId); + pCfg->vgId = htonl(pCfg->vgId); + + SDnodeObj *pDnode = mgmtGetDnode(pCfg->dnodeId); + if (pDnode == NULL) { + mTrace("dnode:%s, invalid dnode", taosIpStr(pCfg->dnodeId), pCfg->vgId); + mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_NOT_ACTIVE_VNODE); + return; + } - SVgObj *pVgroup = mgmtGetVgroupInDnode(pCfg->dnodeId, pCfg->vgId); + SVgObj *pVgroup = mgmtGetVgroup(pCfg->vgId); if (pVgroup == NULL) { - mTrace("dnode:%s, vnode:%d, no vgroup info", taosIpStr(pCfg->dnode), pCfg->vnode); + mTrace("dnode:%s, vgId:%d, no vgroup info", taosIpStr(pCfg->dnodeId), pCfg->vgId); mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_NOT_ACTIVE_VNODE); return; } mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_SUCCESS); - SRpcIpSet ipSet = mgmtGetIpSetFromIp(pCfg->dnode); + SRpcIpSet ipSet = mgmtGetIpSetFromIp(pDnode->privateIp); mgmtSendCreateVnodeMsg(pVgroup, &ipSet, NULL); }