diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index f9d4b3d7bf974bb8e6ca5cbb7c2021e137e32fd5..228aba2a5e57cc362ffb3af54a81093328e047b5 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -294,6 +294,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf #define TSDB_CQ_SQL_SIZE 1024 #define TSDB_MIN_VNODES 64 #define TSDB_MAX_VNODES 2048 +#define TSDB_MIN_VNODES_PER_DB 2 +#define TSDB_MAX_VNODES_PER_DB 16 #define TSDB_DNODE_ROLE_ANY 0 #define TSDB_DNODE_ROLE_MGMT 1 diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 9345bdae2c30e67129ac43bb817db3e8a9a93403..7dbf605405f1dc393c46be871651f0dab57c8f16 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -434,7 +434,8 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi int maxVgroupsPerDb = tsMaxVgroupsPerDb; if (maxVgroupsPerDb <= 0) { maxVgroupsPerDb = mnodeGetOnlinDnodesCpuCoreNum(); - maxVgroupsPerDb = MAX(maxVgroupsPerDb, 2); + maxVgroupsPerDb = MAX(maxVgroupsPerDb, TSDB_MIN_VNODES_PER_DB); + maxVgroupsPerDb = MIN(maxVgroupsPerDb, TSDB_MAX_VNODES_PER_DB); } int32_t code = TSDB_CODE_MND_NO_ENOUGH_DNODES;