[TBASE-1128]
This commit is contained in:
parent
87ab685471
commit
862e8ee00b
|
@ -142,7 +142,7 @@ int mgmtCheckDbParams(SCreateDbMsg *pCreate) {
|
||||||
if (pCreate->cacheNumOfBlocks.fraction < 0) pCreate->cacheNumOfBlocks.fraction = tsAverageCacheBlocks; //
|
if (pCreate->cacheNumOfBlocks.fraction < 0) pCreate->cacheNumOfBlocks.fraction = tsAverageCacheBlocks; //
|
||||||
//-1 for balance
|
//-1 for balance
|
||||||
|
|
||||||
if (pCreate->replications <= 0 || pCreate->replications > TSDB_REPLICA_MAX_NUM) {
|
if (pCreate->replications < 0 || pCreate->replications > TSDB_REPLICA_MAX_NUM) {
|
||||||
mTrace("invalid db option replications: %d", pCreate->replications);
|
mTrace("invalid db option replications: %d", pCreate->replications);
|
||||||
return TSDB_CODE_INVALID_OPTION;
|
return TSDB_CODE_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,10 @@ void mgmtCleanupBalance() {}
|
||||||
int mgmtAllocVnodes(SVgObj *pVgroup) {
|
int mgmtAllocVnodes(SVgObj *pVgroup) {
|
||||||
int selectedVnode = -1;
|
int selectedVnode = -1;
|
||||||
SDnodeObj *pDnode = &dnodeObj;
|
SDnodeObj *pDnode = &dnodeObj;
|
||||||
|
int lastAllocVode = pDnode->lastAllocVnode;
|
||||||
|
|
||||||
for (int i = 0; i < pDnode->numOfVnodes; i++) {
|
for (int i = 0; i < pDnode->numOfVnodes; i++) {
|
||||||
int vnode = (i + pDnode->lastAllocVnode) % pDnode->numOfVnodes;
|
int vnode = (i + lastAllocVode) % pDnode->numOfVnodes;
|
||||||
if (pDnode->vload[vnode].vgId == 0 && pDnode->vload[vnode].status == TSDB_VN_STATUS_OFFLINE) {
|
if (pDnode->vload[vnode].vgId == 0 && pDnode->vload[vnode].status == TSDB_VN_STATUS_OFFLINE) {
|
||||||
selectedVnode = vnode;
|
selectedVnode = vnode;
|
||||||
break;
|
break;
|
||||||
|
@ -39,8 +40,7 @@ int mgmtAllocVnodes(SVgObj *pVgroup) {
|
||||||
mError("vgroup:%d alloc vnode failed, free vnodes:%d", pVgroup->vgId, pDnode->numOfFreeVnodes);
|
mError("vgroup:%d alloc vnode failed, free vnodes:%d", pVgroup->vgId, pDnode->numOfFreeVnodes);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
mTrace("vgroup:%d allocate vnode:%d, last allocated vnode:%d", pVgroup->vgId, selectedVnode,
|
mTrace("vgroup:%d allocate vnode:%d, last allocated vnode:%d", pVgroup->vgId, selectedVnode, lastAllocVode);
|
||||||
pDnode->lastAllocVnode);
|
|
||||||
pVgroup->vnodeGid[0].vnode = selectedVnode;
|
pVgroup->vnodeGid[0].vnode = selectedVnode;
|
||||||
pDnode->lastAllocVnode = selectedVnode + 1;
|
pDnode->lastAllocVnode = selectedVnode + 1;
|
||||||
if (pDnode->lastAllocVnode >= pDnode->numOfVnodes) pDnode->lastAllocVnode = 0;
|
if (pDnode->lastAllocVnode >= pDnode->numOfVnodes) pDnode->lastAllocVnode = 0;
|
||||||
|
|
|
@ -37,7 +37,7 @@ int mgmtInitDnodes() {
|
||||||
dnodeObj.thandle = (void*)(1); //hack way
|
dnodeObj.thandle = (void*)(1); //hack way
|
||||||
if (dnodeObj.numOfVnodes == TSDB_INVALID_VNODE_NUM) {
|
if (dnodeObj.numOfVnodes == TSDB_INVALID_VNODE_NUM) {
|
||||||
mgmtSetDnodeMaxVnodes(&dnodeObj);
|
mgmtSetDnodeMaxVnodes(&dnodeObj);
|
||||||
mPrint("first access, set total vnodes:%d", dnodeObj.numOfVnodes);
|
mPrint("dnode first access, set total vnodes:%d", dnodeObj.numOfVnodes);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue