提交 899f9089 编写于 作者: S Shengliang Guan

TD-2640

上级 e987cd8c
...@@ -416,15 +416,12 @@ void vnodeDestroy(SVnodeObj *pVnode) { ...@@ -416,15 +416,12 @@ void vnodeDestroy(SVnodeObj *pVnode) {
} }
void vnodeCleanUp(SVnodeObj *pVnode) { void vnodeCleanUp(SVnodeObj *pVnode) {
if (!vnodeInInitStatus(pVnode)) { vDebug("vgId:%d, vnode will cleanup, refCount:%d pVnode:%p", pVnode->vgId, pVnode->refCount, pVnode);
// it may be in updateing or reset state, then it shall wait
int32_t i = 0; vnodeSetClosingStatus(pVnode);
while (!vnodeSetClosingStatus(pVnode)) {
if (++i % 1000 == 0) { // release local resources only after cutting off outside connections
sched_yield(); qQueryMgmtNotifyClosed(pVnode->qMgmt);
}
}
}
// stop replication module // stop replication module
if (pVnode->sync > 0) { if (pVnode->sync > 0) {
...@@ -433,10 +430,7 @@ void vnodeCleanUp(SVnodeObj *pVnode) { ...@@ -433,10 +430,7 @@ void vnodeCleanUp(SVnodeObj *pVnode) {
syncStop(sync); syncStop(sync);
} }
vDebug("vgId:%d, vnode will cleanup, refCount:%d pVnode:%p", pVnode->vgId, pVnode->refCount, pVnode); vDebug("vgId:%d, vnode is cleaned, refCount:%d pVnode:%p", pVnode->vgId, pVnode->refCount, pVnode);
// release local resources only after cutting off outside connections
qQueryMgmtNotifyClosed(pVnode->qMgmt);
vnodeRelease(pVnode); vnodeRelease(pVnode);
} }
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#include "taosmsg.h"
#include "query.h"
#include "vnodeStatus.h" #include "vnodeStatus.h"
char* vnodeStatus[] = { char* vnodeStatus[] = {
...@@ -44,11 +46,13 @@ bool vnodeSetReadyStatus(SVnodeObj* pVnode) { ...@@ -44,11 +46,13 @@ bool vnodeSetReadyStatus(SVnodeObj* pVnode) {
vDebug("vgId:%d, cannot set status:ready, old:%s", pVnode->vgId, vnodeStatus[pVnode->status]); vDebug("vgId:%d, cannot set status:ready, old:%s", pVnode->vgId, vnodeStatus[pVnode->status]);
} }
qQueryMgmtReOpen(pVnode->qMgmt);
pthread_mutex_unlock(&pVnode->statusMutex); pthread_mutex_unlock(&pVnode->statusMutex);
return set; return set;
} }
bool vnodeSetClosingStatus(SVnodeObj* pVnode) { static bool vnodeSetClosingStatusImp(SVnodeObj* pVnode) {
bool set = false; bool set = false;
pthread_mutex_lock(&pVnode->statusMutex); pthread_mutex_lock(&pVnode->statusMutex);
...@@ -63,6 +67,20 @@ bool vnodeSetClosingStatus(SVnodeObj* pVnode) { ...@@ -63,6 +67,20 @@ bool vnodeSetClosingStatus(SVnodeObj* pVnode) {
return set; return set;
} }
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();
}
}
}
return true;
}
bool vnodeSetUpdatingStatus(SVnodeObj* pVnode) { bool vnodeSetUpdatingStatus(SVnodeObj* pVnode) {
bool set = false; bool set = false;
pthread_mutex_lock(&pVnode->statusMutex); pthread_mutex_lock(&pVnode->statusMutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册