diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 3aa54b3493927e3de01ff7581de09f698fb46c4a..6363725219070e27daa321a9166af23073e5d575 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -472,7 +472,11 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi } *pSid = sid; // assignment } 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) { 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)); diff --git a/src/util/inc/tidpool.h b/src/util/inc/tidpool.h index 90bceb7890afcd371f5ee98a823bee02d0864839..f37d170188918e8a2412ae07259e1a87018122c4 100644 --- a/src/util/inc/tidpool.h +++ b/src/util/inc/tidpool.h @@ -28,7 +28,7 @@ int taosIdPoolMaxSize(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); diff --git a/src/util/src/tidpool.c b/src/util/src/tidpool.c index 170898fb22e475cd8a59a24bfb9ea2e39322db24..fdb94aa04879fd101af7bee539a8d86a487fda36 100644 --- a/src/util/src/tidpool.c +++ b/src/util/src/tidpool.c @@ -72,7 +72,7 @@ int taosAllocateId(void *handle) { return slot + 1; } -int taosAssignId(void *handle, int id) { +int taosAssignId(void *handle, int id, bool force) { id_pool_t *pIdPool = handle; if (handle == NULL) { return TSDB_CODE_MND_APP_ERROR; @@ -83,7 +83,7 @@ int taosAssignId(void *handle, int id) { if (pIdPool->numOfFree > 0) { 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->numOfFree--; } else {