[TD-413] dnode may be null if mnode list changed
This commit is contained in:
parent
69ff10db2c
commit
a585b1d9be
|
@ -63,7 +63,6 @@ typedef struct SMnodeObj {
|
||||||
int8_t updateEnd[1];
|
int8_t updateEnd[1];
|
||||||
int32_t refCount;
|
int32_t refCount;
|
||||||
int8_t role;
|
int8_t role;
|
||||||
SDnodeObj *pDnode;
|
|
||||||
} SMnodeObj;
|
} SMnodeObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -65,7 +65,6 @@ static int32_t mgmtMnodeActionInsert(SSdbOper *pOper) {
|
||||||
SDnodeObj *pDnode = mgmtGetDnode(pMnode->mnodeId);
|
SDnodeObj *pDnode = mgmtGetDnode(pMnode->mnodeId);
|
||||||
if (pDnode == NULL) return TSDB_CODE_DNODE_NOT_EXIST;
|
if (pDnode == NULL) return TSDB_CODE_DNODE_NOT_EXIST;
|
||||||
|
|
||||||
pMnode->pDnode = pDnode;
|
|
||||||
pDnode->isMgmt = true;
|
pDnode->isMgmt = true;
|
||||||
mgmtDecDnodeRef(pDnode);
|
mgmtDecDnodeRef(pDnode);
|
||||||
|
|
||||||
|
@ -220,22 +219,27 @@ void mgmtUpdateMnodeIpSet() {
|
||||||
pIter = mgmtGetNextMnode(pIter, &pMnode);
|
pIter = mgmtGetNextMnode(pIter, &pMnode);
|
||||||
if (pMnode == NULL) break;
|
if (pMnode == NULL) break;
|
||||||
|
|
||||||
strcpy(ipSet->fqdn[ipSet->numOfIps], pMnode->pDnode->dnodeFqdn);
|
SDnodeObj *pDnode = mgmtGetDnode(pMnode->mnodeId);
|
||||||
ipSet->port[ipSet->numOfIps] = htons(pMnode->pDnode->dnodePort);
|
if (pDnode != NULL) {
|
||||||
|
strcpy(ipSet->fqdn[ipSet->numOfIps], pDnode->dnodeFqdn);
|
||||||
|
ipSet->port[ipSet->numOfIps] = htons(pDnode->dnodePort);
|
||||||
|
|
||||||
mnodes->nodeInfos[index].nodeId = htonl(pMnode->mnodeId);
|
mnodes->nodeInfos[index].nodeId = htonl(pMnode->mnodeId);
|
||||||
strcpy(mnodes->nodeInfos[index].nodeEp, pMnode->pDnode->dnodeEp);
|
strcpy(mnodes->nodeInfos[index].nodeEp, pDnode->dnodeEp);
|
||||||
|
|
||||||
if (pMnode->role == TAOS_SYNC_ROLE_MASTER) {
|
if (pMnode->role == TAOS_SYNC_ROLE_MASTER) {
|
||||||
ipSet->inUse = ipSet->numOfIps;
|
ipSet->inUse = ipSet->numOfIps;
|
||||||
mnodes->inUse = index;
|
mnodes->inUse = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
mPrint("mnode:%d, ep:%s %s", index, pMnode->pDnode->dnodeEp, pMnode->role == TAOS_SYNC_ROLE_MASTER ? "master" : "");
|
mPrint("mnode:%d, ep:%s %s", index, pDnode->dnodeEp,
|
||||||
|
pMnode->role == TAOS_SYNC_ROLE_MASTER ? "master" : "");
|
||||||
|
|
||||||
ipSet->numOfIps++;
|
ipSet->numOfIps++;
|
||||||
index++;
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
mgmtDecDnodeRef(pDnode);
|
||||||
mgmtDecMnodeRef(pMnode);
|
mgmtDecMnodeRef(pMnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +389,15 @@ static int32_t mgmtRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, voi
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pMnode->pDnode->dnodeEp, pShow->bytes[cols] - VARSTR_HEADER_SIZE);
|
|
||||||
|
SDnodeObj *pDnode = mgmtGetDnode(pMnode->mnodeId);
|
||||||
|
if (pDnode != NULL) {
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pDnode->dnodeEp, pShow->bytes[cols] - VARSTR_HEADER_SIZE);
|
||||||
|
} else {
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, "invalid ep", pShow->bytes[cols] - VARSTR_HEADER_SIZE);
|
||||||
|
}
|
||||||
|
mgmtDecDnodeRef(pDnode);
|
||||||
|
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "mgmtDef.h"
|
#include "mgmtDef.h"
|
||||||
#include "mgmtInt.h"
|
#include "mgmtInt.h"
|
||||||
#include "mgmtMnode.h"
|
#include "mgmtMnode.h"
|
||||||
|
#include "mgmtDnode.h"
|
||||||
#include "mgmtSdb.h"
|
#include "mgmtSdb.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -259,10 +260,15 @@ void sdbUpdateSync() {
|
||||||
if (pMnode == NULL) break;
|
if (pMnode == NULL) break;
|
||||||
|
|
||||||
syncCfg.nodeInfo[index].nodeId = pMnode->mnodeId;
|
syncCfg.nodeInfo[index].nodeId = pMnode->mnodeId;
|
||||||
syncCfg.nodeInfo[index].nodePort = pMnode->pDnode->dnodePort + TSDB_PORT_SYNC;
|
|
||||||
strcpy(syncCfg.nodeInfo[index].nodeFqdn, pMnode->pDnode->dnodeEp);
|
|
||||||
index++;
|
|
||||||
|
|
||||||
|
SDnodeObj *pDnode = mgmtGetDnode(pMnode->mnodeId);
|
||||||
|
if (pDnode != NULL) {
|
||||||
|
syncCfg.nodeInfo[index].nodePort = pDnode->dnodePort + TSDB_PORT_SYNC;
|
||||||
|
strcpy(syncCfg.nodeInfo[index].nodeFqdn, pDnode->dnodeEp);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
mgmtDecDnodeRef(pDnode);
|
||||||
mgmtDecMnodeRef(pMnode);
|
mgmtDecMnodeRef(pMnode);
|
||||||
}
|
}
|
||||||
sdbFreeIter(pIter);
|
sdbFreeIter(pIter);
|
||||||
|
|
Loading…
Reference in New Issue