diff --git a/src/balance/src/bnMain.c b/src/balance/src/bnMain.c index 3055f77e81021c4877d97147033fc34f4c525df9..25f316cb5e46025ff28f7364ce62a027505b57a4 100644 --- a/src/balance/src/bnMain.c +++ b/src/balance/src/bnMain.c @@ -405,7 +405,7 @@ void bnReset() { if (pDnode == NULL) break; // while master change, should reset dnode to offline - mInfo("dnode:%d set access:%d to 0", pDnode->dnodeId, pDnode->lastAccess); + mInfo("dnode:%d set access:%" PRId64 " to 0", pDnode->dnodeId, pDnode->lastAccess); pDnode->lastAccess = 0; if (pDnode->status != TAOS_DN_STATUS_DROPPING) { pDnode->status = TAOS_DN_STATUS_OFFLINE; @@ -499,7 +499,7 @@ static bool bnMontiorDropping() { if (dnodeIsMasterEp(pDnode->dnodeEp)) continue; if (mnodeGetDnodesNum() <= 1) continue; - mLInfo("dnode:%d, set to removing state for it offline:%d seconds", pDnode->dnodeId, + mLInfo("dnode:%d, set to removing state for it offline:%" PRId64 " seconds", pDnode->dnodeId, tsAccessSquence - pDnode->lastAccess); pDnode->status = TAOS_DN_STATUS_DROPPING; @@ -574,8 +574,8 @@ void bnCheckStatus() { if (pDnode->status != TAOS_DN_STATUS_DROPPING && pDnode->status != TAOS_DN_STATUS_OFFLINE) { pDnode->status = TAOS_DN_STATUS_OFFLINE; pDnode->offlineReason = TAOS_DN_OFF_STATUS_MSG_TIMEOUT; - mInfo("dnode:%d, set to offline state, access seq:%d last seq:%d laststat:%d", pDnode->dnodeId, tsAccessSquence, - pDnode->lastAccess, pDnode->status); + mInfo("dnode:%d, set to offline state, access seq:%" PRId64 " last seq:%" PRId64 " laststat:%d", pDnode->dnodeId, + tsAccessSquence, pDnode->lastAccess, pDnode->status); bnSetVgroupOffline(pDnode); bnStartTimer(3000); } diff --git a/src/balance/src/bnThread.c b/src/balance/src/bnThread.c index d07591ecd55a9a10613cc61de3a77ea85e022bc2..f39b82f2c692135097946e605a538611470dd3bb 100644 --- a/src/balance/src/bnThread.c +++ b/src/balance/src/bnThread.c @@ -101,13 +101,13 @@ static void bnProcessTimer(void *handle, void *tmrId) { if (!sdbIsMaster()) return; if (tsBnThread.stop) return; - tsBnThread.timer = NULL; - tsAccessSquence++; + if (handle == NULL) { + tsBnThread.timer = NULL; + ++tsAccessSquence; - bnStartTimer(-1); - bnCheckStatus(); + bnStartTimer(-1); + bnCheckStatus(); - if (handle == NULL) { if (tsAccessSquence % tsBalanceInterval == 0) { mDebug("balance function is scheduled by timer"); bnPostSignal(); diff --git a/src/mnode/inc/mnodeDef.h b/src/mnode/inc/mnodeDef.h index e052f34a33b2a74dcd858721694225859f1581b8..c1f2ea7fd7aa11dcd74661412d9e37647e8f5bb6 100644 --- a/src/mnode/inc/mnodeDef.h +++ b/src/mnode/inc/mnodeDef.h @@ -48,9 +48,8 @@ typedef struct SDnodeObj { int32_t dnodeId; int32_t openVnodes; int64_t createdTime; - int32_t resever0; // from dnode status msg, config information + int64_t lastAccess; int32_t customScore; // config by user - uint32_t lastAccess; uint16_t numOfCores; // from dnode status msg uint16_t dnodePort; char dnodeFqdn[TSDB_FQDN_LEN]; diff --git a/src/mnode/inc/mnodeDnode.h b/src/mnode/inc/mnodeDnode.h index fa1995254e9598614cebfef57221b3ff4238b6f1..d357cd65b818b7680c04ad04cef384928ecc7b91 100644 --- a/src/mnode/inc/mnodeDnode.h +++ b/src/mnode/inc/mnodeDnode.h @@ -77,7 +77,7 @@ void * mnodeGetDnodeByEp(char *ep); void mnodeUpdateDnode(SDnodeObj *pDnode); int32_t mnodeDropDnode(SDnodeObj *pDnode, void *pMsg); -extern int32_t tsAccessSquence; +extern int64_t tsAccessSquence; #ifdef __cplusplus } diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index 8a5d24c474df34429cdd73938fcb71a6f6e72281..fb775d92d87390b7506ee29953c6f778b62148f3 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -39,8 +39,8 @@ #include "mnodePeer.h" #include "mnodeCluster.h" -int32_t tsAccessSquence = 0; -int64_t tsDnodeRid = -1; +int64_t tsAccessSquence = 0; +int64_t tsDnodeRid = -1; static void * tsDnodeSdb = NULL; static int32_t tsDnodeUpdateSize = 0; extern void * tsMnodeSdb; @@ -567,7 +567,7 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { mnodeGetClusterId()); return TSDB_CODE_MND_INVALID_CLUSTER_ID; } else { - mTrace("dnode:%d, status received, access times %d openVnodes:%d:%d", pDnode->dnodeId, pDnode->lastAccess, + mTrace("dnode:%d, status received, access times %" PRId64 " openVnodes:%d:%d", pDnode->dnodeId, pDnode->lastAccess, htons(pStatus->openVnodes), pDnode->openVnodes); } } @@ -629,9 +629,9 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { bnNotify(); } - if (!tsEnableBalance) { - int32_t numOfMnodes = mnodeGetMnodesNum(); - if (numOfMnodes < tsNumOfMnodes) bnNotify(); + int32_t numOfMnodes = mnodeGetMnodesNum(); + if (numOfMnodes < tsNumOfMnodes && numOfMnodes < mnodeGetOnlineDnodesNum()) { + bnNotify(); } if (openVnodes != pDnode->openVnodes) {