diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 38d142c800..44c0b41784 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1485,6 +1485,7 @@ typedef struct { SClusterCfg clusterCfg; SArray* pVloads; // array of SVnodeLoad int32_t statusSeq; + int64_t ipWhiteVer; } SStatusReq; int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 974e5e73dc..71908b3458 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1117,6 +1117,7 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { if (tEncodeI64(&encoder, reserved) < 0) return -1; } + if (tEncodeI64(&encoder, pReq->ipWhiteVer) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -1227,6 +1228,9 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { if (tDecodeI64(&decoder, &reserved) < 0) return -1; } } + if (!tDecodeIsEnd(&decoder)) { + if (tDecodeI64(&decoder, &pReq->ipWhiteVer) < 0) return -1; + } tEndDecode(&decoder); tDecoderClear(&decoder); @@ -1304,7 +1308,9 @@ int32_t tDeserializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) { } if (tDecodeI32(&decoder, &pRsp->statusSeq) < 0) return -1; - if (tDecodeI64(&decoder, &pRsp->ipWhiteVer) < 0) return -1; + if (!tDecodeIsEnd(&decoder)) { + if (tDecodeI64(&decoder, &pRsp->ipWhiteVer) < 0) return -1; + } tEndDecode(&decoder); tDecoderClear(&decoder); return 0; diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c index cca6276062..e9ba8603e6 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c @@ -136,6 +136,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) { pMgmt->statusSeq++; req.statusSeq = pMgmt->statusSeq; + req.ipWhiteVer = pMgmt->ipWhiteVer; int32_t contLen = tSerializeSStatusReq(NULL, 0, &req); void *pHead = rpcMallocCont(contLen); diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 68dea25d0d..d1a9e2837f 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -527,7 +527,8 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { } } } - int64_t ver = mndGetIpWhiteVer(pMnode); + + pMnode->ipWhiteVer = mndGetIpWhiteVer(pMnode); int64_t dnodeVer = sdbGetTableVer(pMnode->pSdb, SDB_DNODE) + sdbGetTableVer(pMnode->pSdb, SDB_MNODE); int64_t curMs = taosGetTimestampMs(); @@ -535,9 +536,8 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { bool dnodeChanged = (statusReq.dnodeVer == 0) || (statusReq.dnodeVer != dnodeVer); bool reboot = (pDnode->rebootTime != statusReq.rebootTime); bool supportVnodesChanged = pDnode->numOfSupportVnodes != statusReq.numOfSupportVnodes; - bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged || pMnode->ipWhiteVer != ver; - - pMnode->ipWhiteVer = ver; + bool needCheck = + !online || dnodeChanged || reboot || supportVnodesChanged || pMnode->ipWhiteVer != statusReq.ipWhiteVer; const STraceId *trace = &pReq->info.traceId; mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id, @@ -658,7 +658,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { } mndGetDnodeEps(pMnode, statusRsp.pDnodeEps); - statusRsp.ipWhiteVer = ver; + statusRsp.ipWhiteVer = pMnode->ipWhiteVer; int32_t contLen = tSerializeSStatusRsp(NULL, 0, &statusRsp); void *pHead = rpcMallocCont(contLen); diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 01aae39fae..494673c8c1 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -66,7 +66,7 @@ static SIpWhiteMgt ipWhiteMgt; void ipWhiteMgtInit() { ipWhiteMgt.pIpWhiteTab = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), 1, HASH_ENTRY_LOCK); - ipWhiteMgt.ver = 0; + ipWhiteMgt.ver = taosGetTimestampMs(); taosThreadRwlockInit(&ipWhiteMgt.rw, NULL); } void ipWhiteMgtCleanup() { @@ -1194,13 +1194,9 @@ int32_t mndProcesSRetrieveIpWhiteReq(SRpcMsg *pReq) { void *pRsp = rpcMallocCont(len); tSerializeSUpdateIpWhite(pRsp, len, &ipWhite); - if (req.ipWhiteVer == 0) { - pReq->info.rsp = pRsp; - pReq->info.rspLen = len; - } else { - pReq->info.rsp = pRsp; - pReq->info.rspLen = len; - } + pReq->info.rsp = pRsp; + pReq->info.rspLen = len; + //} tFreeSUpdateIpWhiteReq(&ipWhite); return 0;