process the status msg only once
This commit is contained in:
parent
28359096b3
commit
62f620fa65
|
@ -397,7 +397,7 @@ void dndSendStatusMsg(SDnode *pDnode) {
|
||||||
static void dndUpdateDnodeCfg(SDnode *pDnode, SDnodeCfg *pCfg) {
|
static void dndUpdateDnodeCfg(SDnode *pDnode, SDnodeCfg *pCfg) {
|
||||||
SDnodeMgmt *pMgmt = &pDnode->dmgmt;
|
SDnodeMgmt *pMgmt = &pDnode->dmgmt;
|
||||||
if (pMgmt->dnodeId == 0) {
|
if (pMgmt->dnodeId == 0) {
|
||||||
dInfo("set dnodeId:%d clusterId:% " PRId64, pCfg->dnodeId, pCfg->clusterId);
|
dInfo("set dnodeId:%d clusterId:%" PRId64, pCfg->dnodeId, pCfg->clusterId);
|
||||||
taosWLockLatch(&pMgmt->latch);
|
taosWLockLatch(&pMgmt->latch);
|
||||||
pMgmt->dnodeId = pCfg->dnodeId;
|
pMgmt->dnodeId = pCfg->dnodeId;
|
||||||
pMgmt->clusterId = pCfg->clusterId;
|
pMgmt->clusterId = pCfg->clusterId;
|
||||||
|
@ -440,6 +440,7 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SStatusRsp *pRsp = pMsg->pCont;
|
SStatusRsp *pRsp = pMsg->pCont;
|
||||||
|
if (pMsg->pCont != NULL) {
|
||||||
SDnodeCfg *pCfg = &pRsp->dnodeCfg;
|
SDnodeCfg *pCfg = &pRsp->dnodeCfg;
|
||||||
pCfg->dnodeId = htonl(pCfg->dnodeId);
|
pCfg->dnodeId = htonl(pCfg->dnodeId);
|
||||||
pCfg->clusterId = htobe64(pCfg->clusterId);
|
pCfg->clusterId = htobe64(pCfg->clusterId);
|
||||||
|
@ -453,6 +454,7 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dndUpdateDnodeEps(pDnode, pDnodeEps);
|
dndUpdateDnodeEps(pDnode, pDnodeEps);
|
||||||
|
}
|
||||||
pMgmt->statusSent = 0;
|
pMgmt->statusSent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ SDnodeObj *mndAcquireDnode(SMnode *pMnode, int32_t dnodeId);
|
||||||
void mndReleaseDnode(SMnode *pMnode, SDnodeObj *pDnode);
|
void mndReleaseDnode(SMnode *pMnode, SDnodeObj *pDnode);
|
||||||
SEpSet mndGetDnodeEpset(SDnodeObj *pDnode);
|
SEpSet mndGetDnodeEpset(SDnodeObj *pDnode);
|
||||||
int32_t mndGetDnodeSize(SMnode *pMnode);
|
int32_t mndGetDnodeSize(SMnode *pMnode);
|
||||||
bool mndIsDnodeOnline(SMnode *pMnode, SDnodeObj *pDnode);
|
bool mndIsDnodeOnline(SMnode *pMnode, SDnodeObj *pDnode, int64_t curMs);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,9 +206,8 @@ int32_t mndGetDnodeSize(SMnode *pMnode) {
|
||||||
return sdbGetSize(pSdb, SDB_DNODE);
|
return sdbGetSize(pSdb, SDB_DNODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mndIsDnodeOnline(SMnode *pMnode, SDnodeObj *pDnode) {
|
bool mndIsDnodeOnline(SMnode *pMnode, SDnodeObj *pDnode, int64_t curMs) {
|
||||||
int64_t ms = taosGetTimestampMs();
|
int64_t interval = ABS(pDnode->lastAccessTime - curMs);
|
||||||
int64_t interval = ABS(pDnode->lastAccessTime - ms);
|
|
||||||
if (interval > 3500 * pMnode->cfg.statusInterval) {
|
if (interval > 3500 * pMnode->cfg.statusInterval) {
|
||||||
if (pDnode->rebootTime > 0) {
|
if (pDnode->rebootTime > 0) {
|
||||||
pDnode->offlineReason = DND_REASON_STATUS_MSG_TIMEOUT;
|
pDnode->offlineReason = DND_REASON_STATUS_MSG_TIMEOUT;
|
||||||
|
@ -313,6 +312,11 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t curMs = taosGetTimestampMs();
|
||||||
|
bool online = mndIsDnodeOnline(pMnode, pDnode, curMs);
|
||||||
|
bool needCheckCfg = !(online && pDnode->rebootTime == pStatus->rebootTime);
|
||||||
|
|
||||||
|
if (needCheckCfg) {
|
||||||
if (pStatus->sver != pMnode->cfg.sver) {
|
if (pStatus->sver != pMnode->cfg.sver) {
|
||||||
if (pDnode != NULL) {
|
if (pDnode != NULL) {
|
||||||
pDnode->offlineReason = DND_REASON_VERSION_NOT_MATCH;
|
pDnode->offlineReason = DND_REASON_VERSION_NOT_MATCH;
|
||||||
|
@ -339,7 +343,6 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/*pDnode->status == DND_STATUS_OFFLINE*/1) {
|
|
||||||
// Verify whether the cluster parameters are consistent when status change from offline to ready
|
// Verify whether the cluster parameters are consistent when status change from offline to ready
|
||||||
int32_t ret = mndCheckClusterCfgPara(pMnode, &pStatus->clusterCfg);
|
int32_t ret = mndCheckClusterCfgPara(pMnode, &pStatus->clusterCfg);
|
||||||
if (0 != ret) {
|
if (0 != ret) {
|
||||||
|
@ -350,12 +353,10 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("dnode:%d, from offline to online", pDnode->id);
|
mInfo("dnode:%d, from offline to online", pDnode->id);
|
||||||
}
|
|
||||||
|
|
||||||
pDnode->rebootTime = pStatus->rebootTime;
|
pDnode->rebootTime = pStatus->rebootTime;
|
||||||
pDnode->numOfCores = pStatus->numOfCores;
|
pDnode->numOfCores = pStatus->numOfCores;
|
||||||
pDnode->numOfSupportVnodes = pStatus->numOfSupportVnodes;
|
pDnode->numOfSupportVnodes = pStatus->numOfSupportVnodes;
|
||||||
pDnode->lastAccessTime = taosGetTimestampMs();
|
|
||||||
|
|
||||||
int32_t numOfEps = mndGetDnodeSize(pMnode);
|
int32_t numOfEps = mndGetDnodeSize(pMnode);
|
||||||
int32_t contLen = sizeof(SStatusRsp) + numOfEps * sizeof(SDnodeEp);
|
int32_t contLen = sizeof(SStatusRsp) + numOfEps * sizeof(SDnodeEp);
|
||||||
|
@ -367,11 +368,13 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
pRsp->dnodeCfg.dnodeId = htonl(pDnode->id);
|
pRsp->dnodeCfg.dnodeId = htonl(pDnode->id);
|
||||||
pRsp->dnodeCfg.clusterId = htobe64(pMnode->clusterId);
|
pRsp->dnodeCfg.clusterId = htobe64(pMnode->clusterId);
|
||||||
// mndGetDnodeData(pMnode, &pRsp->dnodeEps, numOfEps);
|
mndGetDnodeData(pMnode, &pRsp->dnodeEps, numOfEps);
|
||||||
|
|
||||||
pMsg->contLen = contLen;
|
pMsg->contLen = contLen;
|
||||||
pMsg->pCont = pRsp;
|
pMsg->pCont = pRsp;
|
||||||
|
}
|
||||||
|
|
||||||
|
pDnode->lastAccessTime = curMs;
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
PROCESS_STATUS_MSG_OVER:
|
PROCESS_STATUS_MSG_OVER:
|
||||||
|
@ -682,11 +685,12 @@ static int32_t mndRetrieveDnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, i
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
SDnodeObj *pDnode = NULL;
|
SDnodeObj *pDnode = NULL;
|
||||||
char *pWrite;
|
char *pWrite;
|
||||||
|
int64_t curMs = taosGetTimestampMs();
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
while (numOfRows < rows) {
|
||||||
pShow->pIter = sdbFetch(pSdb, SDB_DNODE, pShow->pIter, (void **)&pDnode);
|
pShow->pIter = sdbFetch(pSdb, SDB_DNODE, pShow->pIter, (void **)&pDnode);
|
||||||
if (pShow->pIter == NULL) break;
|
if (pShow->pIter == NULL) break;
|
||||||
bool online = mndIsDnodeOnline(pMnode, pDnode);
|
bool online = mndIsDnodeOnline(pMnode, pDnode, curMs);
|
||||||
|
|
||||||
cols = 0;
|
cols = 0;
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,8 @@ static SArray *mndBuildDnodesArray(SMnode *pMnode) {
|
||||||
pDnode->numOfVnodes++;
|
pDnode->numOfVnodes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool online = mndIsDnodeOnline(pMnode, pDnode);
|
int64_t curMs = taosGetTimestampMs();
|
||||||
|
bool online = mndIsDnodeOnline(pMnode, pDnode, curMs);
|
||||||
if (online) {
|
if (online) {
|
||||||
taosArrayPush(pArray, pDnode);
|
taosArrayPush(pArray, pDnode);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue