From 995682f044765bae848c24626fc598fae8a0fcf2 Mon Sep 17 00:00:00 2001 From: Jeff Tao Date: Wed, 15 Jul 2020 13:51:18 +0000 Subject: [PATCH] merge develop code --- src/inc/vnode.h | 5 ++--- src/vnode/inc/vnodeInt.h | 1 + src/vnode/src/vnodeMain.c | 7 ++++--- src/vnode/src/vnodeRead.c | 2 +- src/vnode/src/vnodeWrite.c | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/inc/vnode.h b/src/inc/vnode.h index d25953ec68..845cfb250a 100644 --- a/src/inc/vnode.h +++ b/src/inc/vnode.h @@ -22,11 +22,10 @@ extern "C" { typedef enum _VN_STATUS { TAOS_VN_STATUS_INIT, - TAOS_VN_STATUS_UPDATING, - TAOS_VN_STATUS_RESET, TAOS_VN_STATUS_READY, TAOS_VN_STATUS_CLOSING, - TAOS_VN_STATUS_DELETING, + TAOS_VN_STATUS_UPDATING, + TAOS_VN_STATUS_RESET, } EVnStatus; typedef struct { diff --git a/src/vnode/inc/vnodeInt.h b/src/vnode/inc/vnodeInt.h index d2c603dd82..74cfbf1e73 100644 --- a/src/vnode/inc/vnodeInt.h +++ b/src/vnode/inc/vnodeInt.h @@ -56,6 +56,7 @@ typedef struct { void *qMgmt; char *rootDir; tsem_t sem; + int8_t dropped; char db[TSDB_DB_NAME_LEN]; } SVnodeObj; diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index d4c2f87062..29aeaf2b1f 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -153,7 +153,7 @@ int32_t vnodeDrop(int32_t vgId) { SVnodeObj *pVnode = *ppVnode; vTrace("vgId:%d, vnode will be dropped, refCount:%d", pVnode->vgId, pVnode->refCount); - pVnode->status = TAOS_VN_STATUS_DELETING; + pVnode->dropped = 1; vnodeCleanUp(pVnode); return TSDB_CODE_SUCCESS; @@ -335,7 +335,6 @@ int32_t vnodeClose(int32_t vgId) { SVnodeObj *pVnode = *ppVnode; vDebug("vgId:%d, vnode will be closed", pVnode->vgId); - pVnode->status = TAOS_VN_STATUS_CLOSING; vnodeCleanUp(pVnode); return 0; @@ -381,7 +380,7 @@ void vnodeRelease(void *pVnodeRaw) { tfree(pVnode->rootDir); - if (pVnode->status == TAOS_VN_STATUS_DELETING) { + if (pVnode->dropped) { char rootDir[TSDB_FILENAME_LEN] = {0}; sprintf(rootDir, "%s/vnode%d", tsVnodeDir, vgId); taosMvDir(tsVnodeBakDir, rootDir); @@ -511,6 +510,8 @@ static void vnodeCleanUp(SVnodeObj *pVnode) { // remove from hash, so new messages wont be consumed taosHashRemove(tsDnodeVnodesHash, (const char *)&pVnode->vgId, sizeof(int32_t)); + pVnode->status = TSDB_VN_STATUS_CLOSING; + // stop replication module if (pVnode->sync) { syncStop(pVnode->sync); diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c index fb27da4be5..973df7c5a1 100644 --- a/src/vnode/src/vnodeRead.c +++ b/src/vnode/src/vnodeRead.c @@ -54,7 +54,7 @@ int32_t vnodeProcessRead(void *param, SReadMsg *pReadMsg) { // tsdb may be in reset state if (pVnode->tsdb == NULL) return TSDB_CODE_RPC_NOT_READY; - if (pVnode->status == TAOS_VN_STATUS_CLOSING || pVnode->status == TAOS_VN_STATUS_DELETING) + if (pVnode->status == TAOS_VN_STATUS_CLOSING) return TSDB_CODE_RPC_NOT_READY; // TODO: Later, let slave to support query diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index e2b502a3a4..6b9b8ca4fd 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -61,7 +61,7 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) { // tsdb may be in reset state if (pVnode->tsdb == NULL) return TSDB_CODE_RPC_NOT_READY; - if (pVnode->status == TAOS_VN_STATUS_CLOSING || pVnode->status == TAOS_VN_STATUS_DELETING) + if (pVnode->status == TAOS_VN_STATUS_CLOSING) return TSDB_CODE_RPC_NOT_READY; if (pHead->version == 0) { // from client or CQ -- GitLab