[TD-993] add error code of "cluster not ready"
This commit is contained in:
parent
45ec0df68b
commit
12633aa291
|
@ -142,9 +142,14 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
|
|||
if (vnodes != pVgroup->numOfVnodes) {
|
||||
mDebug("vgId:%d, db:%s need vnodes:%d, but alloc:%d, free them", pVgroup->vgId, pVgroup->dbName,
|
||||
pVgroup->numOfVnodes, vnodes);
|
||||
balanceReleaseDnodeList();
|
||||
balanceReleaseDnodeList();
|
||||
balanceUnLock();
|
||||
return -1;
|
||||
|
||||
if (mnodeGetOnlineDnodesNum() == 0) {
|
||||
return TSDB_CODE_MND_NOT_READY;
|
||||
} else {
|
||||
return TSDB_CODE_MND_NO_ENOUGH_DNODES;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -179,7 +184,7 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
|
|||
|
||||
balanceReleaseDnodeList();
|
||||
balanceUnLock();
|
||||
return 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static bool balanceCheckVgroupReady(SVgObj *pVgroup, SVnodeGid *pRmVnode) {
|
||||
|
|
|
@ -132,6 +132,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_NOT_IN_DNODE, 0, 0x0338, "vgroup not
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE, 0, 0x0339, "vgroup already in dnode")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DNODE_NOT_FREE, 0, 0x033A, "dnode not avaliable")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CLUSTER_ID, 0, 0x033B, "cluster id not match")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_NOT_READY, 0, 0x033C, "cluster not ready")
|
||||
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_ACCT_ALREADY_EXIST, 0, 0x0340, "mnode accounts already exist")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_ACCT, 0, 0x0341, "mnode invalid account")
|
||||
|
|
|
@ -41,7 +41,7 @@ void mgmtMonitorDnodeModule();
|
|||
|
||||
int32_t mnodeGetDnodesNum();
|
||||
int32_t mnodeGetOnlinDnodesCpuCoreNum();
|
||||
int32_t mnodeGetOnlinDnodesNum();
|
||||
int32_t mnodeGetOnlineDnodesNum();
|
||||
void * mnodeGetNextDnode(void *pIter, SDnodeObj **pDnode);
|
||||
void mnodeIncDnodeRef(SDnodeObj *pDnode);
|
||||
void mnodeDecDnodeRef(SDnodeObj *pDnode);
|
||||
|
|
|
@ -206,7 +206,7 @@ int32_t mnodeGetOnlinDnodesCpuCoreNum() {
|
|||
return cpuCores;
|
||||
}
|
||||
|
||||
int32_t mnodeGetOnlinDnodesNum() {
|
||||
int32_t mnodeGetOnlineDnodesNum() {
|
||||
SDnodeObj *pDnode = NULL;
|
||||
void * pIter = NULL;
|
||||
int32_t onlineDnodes = 0;
|
||||
|
|
|
@ -270,7 +270,7 @@ static int32_t mnodeProcessHeartBeatMsg(SMnodeMsg *pMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
pHBRsp->onlineDnodes = htonl(mnodeGetOnlinDnodesNum());
|
||||
pHBRsp->onlineDnodes = htonl(mnodeGetOnlineDnodesNum());
|
||||
pHBRsp->totalDnodes = htonl(mnodeGetDnodesNum());
|
||||
mnodeGetMnodeEpSetForShell(&pHBRsp->epSet);
|
||||
|
||||
|
|
|
@ -434,11 +434,12 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi
|
|||
maxVgroupsPerDb = MAX(maxVgroupsPerDb, 2);
|
||||
}
|
||||
|
||||
int32_t code = TSDB_CODE_MND_NO_ENOUGH_DNODES;
|
||||
if (pDb->numOfVgroups < maxVgroupsPerDb) {
|
||||
mDebug("app:%p:%p, db:%s, try to create a new vgroup, numOfVgroups:%d maxVgroupsPerDb:%d", pMsg->rpcMsg.ahandle,
|
||||
pMsg, pDb->name, pDb->numOfVgroups, maxVgroupsPerDb);
|
||||
pthread_mutex_unlock(&pDb->mutex);
|
||||
int32_t code = mnodeCreateVgroup(pMsg);
|
||||
code = mnodeCreateVgroup(pMsg);
|
||||
if (code == TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||
return code;
|
||||
} else {
|
||||
|
@ -449,10 +450,10 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi
|
|||
SVgObj *pVgroup = pDb->vgList[0];
|
||||
if (pVgroup == NULL) {
|
||||
pthread_mutex_unlock(&pDb->mutex);
|
||||
return TSDB_CODE_MND_NO_ENOUGH_DNODES;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t code = mnodeAllocVgroupIdPool(pVgroup);
|
||||
code = mnodeAllocVgroupIdPool(pVgroup);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
pthread_mutex_unlock(&pDb->mutex);
|
||||
return code;
|
||||
|
@ -529,10 +530,12 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) {
|
|||
pVgroup->numOfVnodes = pDb->cfg.replications;
|
||||
pVgroup->createdTime = taosGetTimestampMs();
|
||||
pVgroup->accessState = TSDB_VN_ALL_ACCCESS;
|
||||
if (balanceAllocVnodes(pVgroup) != 0) {
|
||||
mError("db:%s, no enough dnode to alloc %d vnodes to vgroup", pDb->name, pVgroup->numOfVnodes);
|
||||
int32_t code = balanceAllocVnodes(pVgroup);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
mError("db:%s, no enough dnode to alloc %d vnodes to vgroup, reason:%s", pDb->name, pVgroup->numOfVnodes,
|
||||
tstrerror(code));
|
||||
free(pVgroup);
|
||||
return TSDB_CODE_MND_NO_ENOUGH_DNODES;
|
||||
return code;
|
||||
}
|
||||
|
||||
if (pMsg->pVgroup != NULL) {
|
||||
|
@ -551,7 +554,7 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) {
|
|||
.reqFp = mnodeCreateVgroupFp
|
||||
};
|
||||
|
||||
int32_t code = sdbInsertRow(&oper);
|
||||
code = sdbInsertRow(&oper);
|
||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||
pMsg->pVgroup = NULL;
|
||||
mnodeDestroyVgroup(pVgroup);
|
||||
|
|
Loading…
Reference in New Issue