From 2993bd61b03b1f3c7e57fa209f9b6742a824145e Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 8 Jan 2021 11:47:31 +0800 Subject: [PATCH] TD-2640 --- src/vnode/src/vnodeStatus.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/vnode/src/vnodeStatus.c b/src/vnode/src/vnodeStatus.c index 0bff062f09..ce7ddd11b5 100644 --- a/src/vnode/src/vnodeStatus.c +++ b/src/vnode/src/vnodeStatus.c @@ -56,7 +56,7 @@ static bool vnodeSetClosingStatusImp(SVnodeObj* pVnode) { bool set = false; pthread_mutex_lock(&pVnode->statusMutex); - if (pVnode->status == TAOS_VN_STATUS_READY) { + if (pVnode->status == TAOS_VN_STATUS_READY || pVnode->status == TAOS_VN_STATUS_INIT) { pVnode->status = TAOS_VN_STATUS_CLOSING; set = true; } else { @@ -68,13 +68,10 @@ static bool vnodeSetClosingStatusImp(SVnodeObj* pVnode) { } bool vnodeSetClosingStatus(SVnodeObj* pVnode) { - if (!vnodeInInitStatus(pVnode)) { - // it may be in updating or reset state, then it shall wait - int32_t i = 0; - while (!vnodeSetClosingStatusImp(pVnode)) { - if (++i % 1000 == 0) { - sched_yield(); - } + int32_t i = 0; + while (!vnodeSetClosingStatusImp(pVnode)) { + if (++i % 1000 == 0) { + sched_yield(); } } @@ -96,11 +93,11 @@ bool vnodeSetUpdatingStatus(SVnodeObj* pVnode) { return set; } -bool vnodeSetResetStatus(SVnodeObj* pVnode) { +static bool vnodeSetResetStatusImp(SVnodeObj* pVnode) { bool set = false; pthread_mutex_lock(&pVnode->statusMutex); - if (pVnode->status != TAOS_VN_STATUS_CLOSING && pVnode->status != TAOS_VN_STATUS_INIT) { + if (pVnode->status == TAOS_VN_STATUS_READY || pVnode->status == TAOS_VN_STATUS_INIT) { pVnode->status = TAOS_VN_STATUS_RESET; set = true; } else { @@ -111,6 +108,17 @@ bool vnodeSetResetStatus(SVnodeObj* pVnode) { return set; } +bool vnodeSetResetStatus(SVnodeObj* pVnode) { + int32_t i = 0; + while (!vnodeSetResetStatusImp(pVnode)) { + if (++i % 1000 == 0) { + sched_yield(); + } + } + + return true; +} + bool vnodeInInitStatus(SVnodeObj* pVnode) { bool in = false; pthread_mutex_lock(&pVnode->statusMutex); -- GitLab