From d159a205dfe710d2345a9f6d7e9fac57a46ece11 Mon Sep 17 00:00:00 2001 From: kailixu Date: Sat, 4 Mar 2023 17:11:27 +0800 Subject: [PATCH] feat: support force assign --- src/mnode/src/mnodeVgroup.c | 6 +++++- src/util/inc/tidpool.h | 2 +- src/util/src/tidpool.c | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 3aa54b3493..6363725219 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 90bceb7890..f37d170188 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 170898fb22..fdb94aa048 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 { -- GitLab