diff --git a/src/inc/vnode.h b/src/inc/vnode.h index d25953ec686da8519e88ee1840001e254f9d628c..845cfb250a090459a8003ad47de42d64f886d4fa 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 d2c603dd82b6a6343bbc448f5c6d82a00eeb1556..74cfbf1e731fd67c47f7375198a8353740429060 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 d4c2f87062cfb3bff51db0fd16d2038df0e4a4be..29aeaf2b1f3573abaa34a400873dac1eb628a195 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 fb27da4be5aee46f11941cfd6fe47d871c06adf0..973df7c5a10f2ba84a77718602c8ffddd4b14134 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 e2b502a3a486f0f231990758aa7174daada800dc..6b9b8ca4fd5a5c42028936e48b53f45ffa811903 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