From b9ccb24aa7fd2d0ed368cb361bef9ceffd6436a8 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Wed, 30 Jun 2021 16:44:35 +0800 Subject: [PATCH] [TD-4593]: fix vnode cannnot close while syncing --- src/dnode/src/dnodeVMgmt.c | 2 +- src/dnode/src/dnodeVRead.c | 2 +- src/dnode/src/dnodeVWrite.c | 2 +- src/inc/vnode.h | 1 + src/vnode/inc/vnodeInt.h | 2 ++ 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dnode/src/dnodeVMgmt.c b/src/dnode/src/dnodeVMgmt.c index 66c94bf675..41e48411ac 100644 --- a/src/dnode/src/dnodeVMgmt.c +++ b/src/dnode/src/dnodeVMgmt.c @@ -169,7 +169,7 @@ static int32_t dnodeProcessCreateVnodeMsg(SRpcMsg *rpcMsg) { static int32_t dnodeProcessAlterVnodeMsg(SRpcMsg *rpcMsg) { SAlterVnodeMsg *pAlter = dnodeParseVnodeMsg(rpcMsg); - void *pVnode = vnodeAcquire(pAlter->cfg.vgId); + void *pVnode = vnodeAcquireNotClose(pAlter->cfg.vgId); if (pVnode != NULL) { dDebug("vgId:%d, alter vnode msg is received", pAlter->cfg.vgId); int32_t code = vnodeAlter(pVnode, pAlter); diff --git a/src/dnode/src/dnodeVRead.c b/src/dnode/src/dnodeVRead.c index ea738661ce..41016d7b99 100644 --- a/src/dnode/src/dnodeVRead.c +++ b/src/dnode/src/dnodeVRead.c @@ -63,7 +63,7 @@ void dnodeDispatchToVReadQueue(SRpcMsg *pMsg) { pHead->contLen = htonl(pHead->contLen); assert(pHead->contLen > 0); - void *pVnode = vnodeAcquire(pHead->vgId); + void *pVnode = vnodeAcquireNotClose(pHead->vgId); if (pVnode != NULL) { code = vnodeWriteToRQueue(pVnode, pCont, pHead->contLen, TAOS_QTYPE_RPC, pMsg); if (code == TSDB_CODE_SUCCESS) queuedMsgNum++; diff --git a/src/dnode/src/dnodeVWrite.c b/src/dnode/src/dnodeVWrite.c index 26084a52eb..bbf257ff95 100644 --- a/src/dnode/src/dnodeVWrite.c +++ b/src/dnode/src/dnodeVWrite.c @@ -85,7 +85,7 @@ void dnodeDispatchToVWriteQueue(SRpcMsg *pRpcMsg) { pMsg->vgId = htonl(pMsg->vgId); pMsg->contLen = htonl(pMsg->contLen); - void *pVnode = vnodeAcquire(pMsg->vgId); + void *pVnode = vnodeAcquireNotClose(pMsg->vgId); if (pVnode == NULL) { code = TSDB_CODE_VND_INVALID_VGROUP_ID; } else { diff --git a/src/inc/vnode.h b/src/inc/vnode.h index 39bd2f46c3..576acb624a 100644 --- a/src/inc/vnode.h +++ b/src/inc/vnode.h @@ -68,6 +68,7 @@ int32_t vnodeInitMgmt(); void vnodeCleanupMgmt(); void* vnodeAcquire(int32_t vgId); void vnodeRelease(void *pVnode); +void* vnodeAcquireNotClose(int32_t vgId); void* vnodeGetWal(void *pVnode); int32_t vnodeGetVnodeList(int32_t vnodeList[], int32_t *numOfVnodes); void vnodeBuildStatusMsg(void *pStatus); diff --git a/src/vnode/inc/vnodeInt.h b/src/vnode/inc/vnodeInt.h index d770a38e37..ef05cf4a40 100644 --- a/src/vnode/inc/vnodeInt.h +++ b/src/vnode/inc/vnodeInt.h @@ -41,6 +41,8 @@ typedef struct { int32_t queuedWMsg; int32_t queuedRMsg; int32_t flowctrlLevel; + int8_t preClose; // drop and close switch + int8_t reserved[3]; int64_t sequence; // for topic int8_t status; int8_t role; -- GitLab