diff --git a/src/mnode/src/mgmtDb.c b/src/mnode/src/mgmtDb.c index c6506a350a56357b4f21d5ea0fa4d38bc13c74c2..d8dfcbe213304ad4f19a441a7781b2ed98970679 100644 --- a/src/mnode/src/mgmtDb.c +++ b/src/mnode/src/mgmtDb.c @@ -811,20 +811,20 @@ static SDbCfg mgmtGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) { if (replications > 0 && replications != pDb->cfg.replications) { mTrace("db:%s, replications:%d change to %d", pDb->name, pDb->cfg.replications, replications); newCfg.replications = replications; - } - if (replications > mgmtGetDnodesNum()) { - mError("db:%s, no enough dnode to change replica:%d", pDb->name, replications); - terrno = TSDB_CODE_NO_ENOUGH_DNODES; - } + if (replications > mgmtGetDnodesNum()) { + mError("db:%s, no enough dnode to change replica:%d", pDb->name, replications); + terrno = TSDB_CODE_NO_ENOUGH_DNODES; + } - if (pDb->cfg.replications - replications >= 2) { - mError("db:%s, replica number can't change from 3 to 1", pDb->name, replications); - terrno = TSDB_CODE_INVALID_OPTION; + if (pDb->cfg.replications - replications >= 2) { + mError("db:%s, replica number can't change from 3 to 1", pDb->name, replications); + terrno = TSDB_CODE_INVALID_OPTION; + } } - - if (walLevel < TSDB_MIN_WAL_LEVEL || walLevel > TSDB_MAX_WAL_LEVEL) { - mError("db:%s, wal level should be between 0-2", pDb->name); + + if (walLevel > 0 && (walLevel < TSDB_MIN_WAL_LEVEL || walLevel > TSDB_MAX_WAL_LEVEL)) { + mError("db:%s, wal level %d should be between 0-2, origin:%d", pDb->name, walLevel, pDb->cfg.walLevel); terrno = TSDB_CODE_INVALID_OPTION; }