From b1cc403da165864faf50c93e77098641e20ef77c Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 15 Oct 2020 18:23:28 +0800 Subject: [PATCH] TD-1725 --- src/balance/src/balance.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/balance/src/balance.c b/src/balance/src/balance.c index fc1853f3d8..3ae65674c8 100644 --- a/src/balance/src/balance.c +++ b/src/balance/src/balance.c @@ -126,6 +126,8 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) { balanceAccquireDnodeList(); + mDebug("db:%s, alloc %d vnodes to vgroup, dnodes total:%d, avail:%d", pVgroup->dbName, pVgroup->numOfVnodes, + mnodeGetDnodesNum(), tsBalanceDnodeListSize); for (int32_t i = 0; i < pVgroup->numOfVnodes; ++i) { for (; dnode < tsBalanceDnodeListSize; ++dnode) { SDnodeObj *pDnode = tsBalanceDnodeList[dnode]; @@ -135,17 +137,33 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) { pVnodeGid->pDnode = pDnode; dnode++; vnodes++; + mDebug("dnode:%d, is selected, vnodeIndex:%d", pDnode->dnodeId, i); break; + } else { + mDebug("dnode:%d, is not selected, status:%s vnodes:%d disk:%fGB role:%d", pDnode->dnodeId, + mnodeGetDnodeStatusStr(pDnode->status), pDnode->openVnodes, pDnode->diskAvailable, + pDnode->alternativeRole); } } } if (vnodes != pVgroup->numOfVnodes) { - mDebug("vgId:%d, db:%s need vnodes:%d, but alloc:%d, free them", pVgroup->vgId, pVgroup->dbName, - pVgroup->numOfVnodes, vnodes); balanceReleaseDnodeList(); balanceUnLock(); + mDebug("db:%s, need vnodes:%d, but alloc:%d", pVgroup->dbName, pVgroup->numOfVnodes, vnodes); + + void * pIter = NULL; + SDnodeObj *pDnode = NULL; + while (1) { + pIter = mnodeGetNextDnode(pIter, &pDnode); + if (pDnode == NULL) break; + mDebug("dnode:%d, status:%s vnodes:%d disk:%fGB role:%d", pDnode->dnodeId, mnodeGetDnodeStatusStr(pDnode->status), + pDnode->openVnodes, pDnode->diskAvailable, pDnode->alternativeRole); + mnodeDecDnodeRef(pDnode); + } + sdbFreeIter(pIter); + if (mnodeGetOnlineDnodesNum() == 0) { return TSDB_CODE_MND_NOT_READY; } else { -- GitLab