diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index f9d4b3d7bf..228aba2a5e 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 9345bdae2c..7dbf605405 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;