提交 d159a205 编写于 作者: K kailixu

feat: support force assign

上级 a47de932
...@@ -472,7 +472,11 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi ...@@ -472,7 +472,11 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi
} }
*pSid = sid; // assignment *pSid = sid; // assignment
} else { } else {
int32_t code = taosAssignId(pVgroup->idPool, *pSid); bool forceAssign = false;
if (tsMetaSyncOption == 2) {
forceAssign = true;
}
int32_t code = taosAssignId(pVgroup->idPool, *pSid, forceAssign);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
mError("msg:%p, app:%p db:%s, failed to assign tid:%d in vgId:%d since %s", pMsg, pMsg->rpcMsg.ahandle, mError("msg:%p, app:%p db:%s, failed to assign tid:%d in vgId:%d since %s", pMsg, pMsg->rpcMsg.ahandle,
pDb->name, *pSid, pVgroup->vgId, tstrerror(code)); pDb->name, *pSid, pVgroup->vgId, tstrerror(code));
......
...@@ -28,7 +28,7 @@ int taosIdPoolMaxSize(void *handle); ...@@ -28,7 +28,7 @@ int taosIdPoolMaxSize(void *handle);
int taosAllocateId(void *handle); int taosAllocateId(void *handle);
int taosAssignId(void *handle, int id); int taosAssignId(void *handle, int id, bool force);
void taosFreeId(void *handle, int id); void taosFreeId(void *handle, int id);
......
...@@ -72,7 +72,7 @@ int taosAllocateId(void *handle) { ...@@ -72,7 +72,7 @@ int taosAllocateId(void *handle) {
return slot + 1; return slot + 1;
} }
int taosAssignId(void *handle, int id) { int taosAssignId(void *handle, int id, bool force) {
id_pool_t *pIdPool = handle; id_pool_t *pIdPool = handle;
if (handle == NULL) { if (handle == NULL) {
return TSDB_CODE_MND_APP_ERROR; return TSDB_CODE_MND_APP_ERROR;
...@@ -83,7 +83,7 @@ int taosAssignId(void *handle, int id) { ...@@ -83,7 +83,7 @@ int taosAssignId(void *handle, int id) {
if (pIdPool->numOfFree > 0) { if (pIdPool->numOfFree > 0) {
if (id > 0 && id < pIdPool->maxId) { if (id > 0 && id < pIdPool->maxId) {
if (false == pIdPool->freeList[id - 1]) { if (force || (false == pIdPool->freeList[id - 1])) {
pIdPool->freeList[id - 1] = true; pIdPool->freeList[id - 1] = true;
pIdPool->numOfFree--; pIdPool->numOfFree--;
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册