From 336429e14904e60ce05188c3b82988363c272da5 Mon Sep 17 00:00:00 2001 From: dmchen Date: Thu, 14 Nov 2024 16:01:28 +0800 Subject: [PATCH] fix/TD-32863-add-creating-hash-fix-review --- source/dnode/mgmt/mgmt_vnode/src/vmInt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index a81208c567..2ee607949d 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -63,14 +63,18 @@ int32_t vmAllocPrimaryDisk(SVnodeMgmt *pMgmt, int32_t vgId) { int32_t numOfVnodes = 0; SVnodeObj **ppVnodes = NULL; - code = vmGetAllVnodeListFromHashWithCreating(pMgmt, &numOfVnodes, &ppVnodes); + code = taosThreadMutexLock(&pMgmt->mutex); if (code != 0) { return code; } - code = taosThreadMutexLock(&pMgmt->mutex); + code = vmGetAllVnodeListFromHashWithCreating(pMgmt, &numOfVnodes, &ppVnodes); if (code != 0) { - goto _OVER; + int32_t r = taosThreadMutexUnlock(&pMgmt->mutex); + if (r != 0) { + dError("vgId:%d, failed to unlock mutex since %s", vgId, tstrerror(r)); + } + return code; } for (int32_t v = 0; v < numOfVnodes; v++) {