diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 2e25f7f7612bd02cf24e220a0395adcd7567ee85..c24dca57c07871186da66434031722b0c1329343 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -635,6 +635,7 @@ typedef struct SCMSTableVgroupMsg { typedef struct { int32_t vgId; + int8_t numOfIps; SIpAddr ipAddr[TSDB_REPLICA_MAX_NUM]; } SCMVgroupInfo; @@ -687,21 +688,18 @@ typedef struct { } SSuperTableMeta; typedef struct STableMetaMsg { - int32_t contLen; - - char tableId[TSDB_TABLE_ID_LEN]; // table id - char stableId[TSDB_TABLE_ID_LEN]; // stable name if it is created according to super table - uint8_t numOfTags; - uint8_t precision; - uint8_t tableType; - int16_t numOfColumns; - int16_t sversion; - int8_t numOfVpeers; - SVnodeDesc vpeerDesc[TSDB_VNODES_SUPPORT]; - int32_t sid; - int32_t vgId; - uint64_t uid; - SSchema schema[]; + int32_t contLen; + char tableId[TSDB_TABLE_ID_LEN]; // table id + char stableId[TSDB_TABLE_ID_LEN]; // stable name if it is created according to super table + uint8_t numOfTags; + uint8_t precision; + uint8_t tableType; + int16_t numOfColumns; + int16_t sversion; + int32_t sid; + uint64_t uid; + SCMVgroupInfo vgroup; + SSchema schema[]; } STableMetaMsg; typedef struct SMultiTableMeta { diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index 0dd89606482cf3e8a09adf7e61795cb149691999..10cd343a5bb472da7c301ba6202bf8a5b5224696 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -1168,7 +1168,7 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { SCMSTableVgroupMsg *pInfo = pMsg->pCont; SSuperTableObj *pTable = mgmtGetSuperTable(pInfo->tableId); - pMsg->pTable = pTable; + pMsg->pTable = (STableObj *)pTable; if (pMsg->pTable == NULL) { mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_INVALID_TABLE); return; @@ -1196,6 +1196,7 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { pRsp->vgroups[vg].ipAddr[vn].ip = htonl(pDnode->privateIp); pRsp->vgroups[vg].ipAddr[vn].port = htons(tsDnodeShellPort); + pRsp->vgroups[vg].numOfIps++; clusterReleaseDnode(pDnode); } @@ -1575,7 +1576,6 @@ static int32_t mgmtDoGetChildTableMeta(SQueuedMsg *pMsg, STableMetaMsg *pMeta) { pMeta->uid = htobe64(pTable->uid); pMeta->sid = htonl(pTable->sid); - pMeta->vgId = htonl(pTable->vgId); pMeta->precision = pDb->cfg.precision; pMeta->tableType = pTable->info.type; strncpy(pMeta->tableId, pTable->info.tableId, tListLen(pTable->info.tableId)); @@ -1599,16 +1599,20 @@ static int32_t mgmtDoGetChildTableMeta(SQueuedMsg *pMsg, STableMetaMsg *pMeta) { return TSDB_CODE_INVALID_VGROUP_ID; } - for (int32_t i = 0; i < TSDB_VNODES_SUPPORT; ++i) { + for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) { + SDnodeObj *pDnode = clusterGetDnode(pVgroup->vnodeGid[i].dnodeId); + if (pDnode == NULL) break; if (usePublicIp) { - pMeta->vpeerDesc[i].ip = htonl(pVgroup->vnodeGid[i].publicIp); + pMeta->vgroup.ipAddr[i].ip = htonl(pDnode->publicIp); + pMeta->vgroup.ipAddr[i].port = htonl(tsDnodeShellPort); } else { - pMeta->vpeerDesc[i].ip = htonl(pVgroup->vnodeGid[i].privateIp); + pMeta->vgroup.ipAddr[i].ip = htonl(pDnode->privateIp); + pMeta->vgroup.ipAddr[i].port = htonl(tsDnodeShellPort); } -// pMeta->vpeerDesc[i].vgId = htonl(pVgroup->vgId); - pMeta->vpeerDesc[i].dnodeId = htonl(pVgroup->vnodeGid[i].dnodeId); + pMeta->vgroup.numOfIps++; + clusterReleaseDnode(pDnode); } - pMeta->numOfVpeers = pVgroup->numOfVnodes; + pMeta->vgroup.vgId = htonl(pVgroup->vgId); mTrace("table:%s, uid:%" PRIu64 " table meta is retrieved", pTable->info.tableId, pTable->uid);