diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index 51cd471a6b66526228b85be1c8dbc6f033d2515f..e0f30166c437c4d5005f2911417a28a3e3ae0be1 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -103,9 +103,6 @@ void cqClose(void *handle) { SCqContext *pContext = handle; if (handle == NULL) return; - taosTmrCleanUp(pContext->tmrCtrl); - pContext->tmrCtrl = NULL; - // stop all CQs cqStop(pContext); @@ -125,6 +122,9 @@ void cqClose(void *handle) { pthread_mutex_destroy(&pContext->mutex); + taosTmrCleanUp(pContext->tmrCtrl); + pContext->tmrCtrl = NULL; + cTrace("vgId:%d, CQ is closed", pContext->vgId); free(pContext); } diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index ffaab375a3bfc305cbedecae6df8881e28772aa2..e30164592dee23c1baf86c11f44daba2f3e4ab85 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -148,7 +148,7 @@ void tsdbCloseRepo(TSDB_REPO_T *repo, int toCommit) { STsdbRepo *pRepo = (STsdbRepo *)repo; int vgId = REPO_ID(pRepo); - tsdbStopStream(repo); + tsdbStopStream(pRepo); if (toCommit) { tsdbAsyncCommit(pRepo); @@ -1126,6 +1126,7 @@ static void tsdbStartStream(STsdbRepo *pRepo) { } } + static void tsdbStopStream(STsdbRepo *pRepo) { STsdbMeta *pMeta = pRepo->tsdbMeta; diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 98882e4c3ccb4c1d964f41137b438f74c193853f..249fb428e7781c2c88551116602bb80e584cbc95 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -340,6 +340,13 @@ void vnodeRelease(void *pVnodeRaw) { tsdbCloseRepo(pVnode->tsdb, 1); pVnode->tsdb = NULL; + // stop continuous query + if (pVnode->cq) { + void *cq = pVnode->cq; + pVnode->cq = NULL; + cqClose(cq); + } + if (pVnode->wal) walClose(pVnode->wal); pVnode->wal = NULL; @@ -511,13 +518,6 @@ static void vnodeCleanUp(SVnodeObj *pVnode) { syncStop(sync); } - // stop continuous query - if (pVnode->cq) { - void *cq = pVnode->cq; - pVnode->cq = NULL; - cqClose(cq); - } - vTrace("vgId:%d, vnode will cleanup, refCount:%d", pVnode->vgId, pVnode->refCount); // release local resources only after cutting off outside connections