提交 ae9c5616 编写于 作者: M Minglei Jin

[TD-4826]<fix>: no extra sleep if no message in vwqueue

上级 27712464
...@@ -93,7 +93,7 @@ int32_t vnodeCreate(SCreateVnodeMsg *pVnodeCfg) { ...@@ -93,7 +93,7 @@ int32_t vnodeCreate(SCreateVnodeMsg *pVnodeCfg) {
} }
int32_t vnodeSync(int32_t vgId) { int32_t vnodeSync(int32_t vgId) {
SVnodeObj *pVnode = vnodeAcquire(vgId); SVnodeObj *pVnode = vnodeAcquireNotClose(vgId);
if (pVnode == NULL) { if (pVnode == NULL) {
vDebug("vgId:%d, failed to sync, vnode not find", vgId); vDebug("vgId:%d, failed to sync, vnode not find", vgId);
return TSDB_CODE_VND_INVALID_VGROUP_ID; return TSDB_CODE_VND_INVALID_VGROUP_ID;
...@@ -115,7 +115,7 @@ int32_t vnodeSync(int32_t vgId) { ...@@ -115,7 +115,7 @@ int32_t vnodeSync(int32_t vgId) {
} }
int32_t vnodeDrop(int32_t vgId) { int32_t vnodeDrop(int32_t vgId) {
SVnodeObj *pVnode = vnodeAcquire(vgId); SVnodeObj *pVnode = vnodeAcquireNotClose(vgId);
if (pVnode == NULL) { if (pVnode == NULL) {
vDebug("vgId:%d, failed to drop, vnode not find", vgId); vDebug("vgId:%d, failed to drop, vnode not find", vgId);
return TSDB_CODE_VND_INVALID_VGROUP_ID; return TSDB_CODE_VND_INVALID_VGROUP_ID;
...@@ -390,15 +390,16 @@ int32_t vnodeOpen(int32_t vgId) { ...@@ -390,15 +390,16 @@ int32_t vnodeOpen(int32_t vgId) {
} }
int32_t vnodeClose(int32_t vgId) { int32_t vnodeClose(int32_t vgId) {
SVnodeObj *pVnode = vnodeAcquire(vgId); SVnodeObj *pVnode = vnodeAcquireNotClose(vgId);
if (pVnode == NULL) return 0; if (pVnode == NULL) return 0;
if (pVnode->dropped) { if (pVnode->dropped) {
vnodeRelease(pVnode); vnodeRelease(pVnode);
return 0; return 0;
} }
pVnode->preClose = 1;
vDebug("vgId:%d, vnode will be closed, pVnode:%p", pVnode->vgId, pVnode); vDebug("vgId:%d, vnode will be closed, pVnode:%p", pVnode->vgId, pVnode);
vnodeRemoveFromHash(pVnode);
vnodeRelease(pVnode); vnodeRelease(pVnode);
vnodeCleanUp(pVnode); vnodeCleanUp(pVnode);
......
...@@ -125,6 +125,18 @@ void vnodeRelease(void *vparam) { ...@@ -125,6 +125,18 @@ void vnodeRelease(void *vparam) {
} }
} }
void *vnodeAcquireNotClose(int32_t vgId) {
SVnodeObj *pVnode = vnodeAcquire(vgId);
if (pVnode != NULL && pVnode->preClose == 1) {
vnodeRelease(pVnode);
terrno = TSDB_CODE_VND_INVALID_VGROUP_ID;
vDebug("vgId:%d, not exist, pre closing", vgId);
return NULL;
}
return pVnode;
}
static void vnodeBuildVloadMsg(SVnodeObj *pVnode, SStatusMsg *pStatus) { static void vnodeBuildVloadMsg(SVnodeObj *pVnode, SStatusMsg *pStatus) {
int64_t totalStorage = 0; int64_t totalStorage = 0;
int64_t compStorage = 0; int64_t compStorage = 0;
...@@ -187,7 +199,7 @@ void vnodeBuildStatusMsg(void *param) { ...@@ -187,7 +199,7 @@ void vnodeBuildStatusMsg(void *param) {
void vnodeSetAccess(SVgroupAccess *pAccess, int32_t numOfVnodes) { void vnodeSetAccess(SVgroupAccess *pAccess, int32_t numOfVnodes) {
for (int32_t i = 0; i < numOfVnodes; ++i) { for (int32_t i = 0; i < numOfVnodes; ++i) {
pAccess[i].vgId = htonl(pAccess[i].vgId); pAccess[i].vgId = htonl(pAccess[i].vgId);
SVnodeObj *pVnode = vnodeAcquire(pAccess[i].vgId); SVnodeObj *pVnode = vnodeAcquireNotClose(pAccess[i].vgId);
if (pVnode != NULL) { if (pVnode != NULL) {
pVnode->accessState = pAccess[i].accessState; pVnode->accessState = pAccess[i].accessState;
if (pVnode->accessState != TSDB_VN_ALL_ACCCESS) { if (pVnode->accessState != TSDB_VN_ALL_ACCCESS) {
......
...@@ -396,10 +396,13 @@ static int32_t vnodePerformFlowCtrl(SVWriteMsg *pWrite) { ...@@ -396,10 +396,13 @@ static int32_t vnodePerformFlowCtrl(SVWriteMsg *pWrite) {
} }
void vnodeWaitWriteCompleted(SVnodeObj *pVnode) { void vnodeWaitWriteCompleted(SVnodeObj *pVnode) {
int32_t extraSleep = 0;
while (pVnode->queuedWMsg > 0) { while (pVnode->queuedWMsg > 0) {
vTrace("vgId:%d, queued wmsg num:%d", pVnode->vgId, pVnode->queuedWMsg); vTrace("vgId:%d, queued wmsg num:%d", pVnode->vgId, pVnode->queuedWMsg);
taosMsleep(10); taosMsleep(10);
extraSleep = 1;
} }
if (extraSleep)
taosMsleep(900); taosMsleep(900);
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册