提交 ffd5513e 编写于 作者: M Minglei Jin

[TS-1223]<fix>(mnode): check vnode dnodes num when create db and alter

db replica
上级 db225ec3
......@@ -66,6 +66,7 @@ void mnodeCleanupDnodes();
int32_t mnodeGetDnodesNum();
int32_t mnodeGetOnlinDnodesCpuCoreNum();
int32_t mnodeGetVnodeDnodesNum();
int32_t mnodeGetOnlineDnodesNum();
void mnodeGetOnlineAndTotalDnodesNum(int32_t *onlineNum, int32_t *totalNum);
void * mnodeGetNextDnode(void *pIter, SDnodeObj **pDnode);
......
......@@ -339,8 +339,8 @@ static int32_t mnodeCheckDbCfg(SDbCfg *pCfg) {
return TSDB_CODE_MND_INVALID_DB_OPTION;
}
if (pCfg->replications > mnodeGetDnodesNum()) {
mError("no enough dnode to config replica: %d, #dnodes: %d", pCfg->replications, mnodeGetDnodesNum());
if (pCfg->replications > mnodeGetVnodeDnodesNum()) {
mError("no enough dnode to config replica: %d, #dnodes: %d", pCfg->replications, mnodeGetVnodeDnodesNum());
return TSDB_CODE_MND_INVALID_DB_OPTION;
}
......@@ -1057,7 +1057,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
terrno = TSDB_CODE_MND_INVALID_DB_OPTION;
}
if (replications > mnodeGetDnodesNum()) {
if (replications > mnodeGetVnodeDnodesNum()) {
mError("db:%s, no enough dnode to change replica:%d", pDb->name, replications);
terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES;
}
......
......@@ -271,6 +271,21 @@ int32_t mnodeGetOnlineDnodesNum() {
return onlineDnodes;
}
int32_t mnodeGetVnodeDnodesNum() {
SDnodeObj *pDnode = NULL;
void * pIter = NULL;
int32_t numOfDnodes = 0;
while (1) {
pIter = mnodeGetNextDnode(pIter, &pDnode);
if (pDnode == NULL) break;
if (pDnode->alternativeRole != TAOS_DN_ALTERNATIVE_ROLE_MNODE) numOfDnodes++;
mnodeDecDnodeRef(pDnode);
}
return numOfDnodes;
}
void mnodeGetOnlineAndTotalDnodesNum(int32_t *onlineNum, int32_t *totalNum) {
SDnodeObj *pDnode = NULL;
void * pIter = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册