diff --git a/source/dnode/vnode/src/tsdb/tsdbCompact.c b/source/dnode/vnode/src/tsdb/tsdbCompact.c index fc7df98217cfebd8c7979c2e08167330d36bddee..1cd11a30395f2b6efbca6cff56f6c26bca75d492 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCompact.c +++ b/source/dnode/vnode/src/tsdb/tsdbCompact.c @@ -57,32 +57,6 @@ typedef struct { SBlockData sData; } STsdbCompactor; -static int32_t tsdbCommitCompact(STsdbCompactor *pCompactor) { - int32_t code = 0; - int32_t lino = 0; - - STsdb *pTsdb = pCompactor->pTsdb; - - code = tsdbFSPrepareCommit(pTsdb, &pCompactor->fs); - TSDB_CHECK_CODE(code, lino, _exit); - - taosThreadRwlockWrlock(&pTsdb->rwLock); - - code = tsdbFSCommit(pTsdb); - if (code) { - taosThreadRwlockUnlock(&pTsdb->rwLock); - TSDB_CHECK_CODE(code, lino, _exit); - } - - taosThreadRwlockUnlock(&pTsdb->rwLock); - -_exit: - if (code) { - tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); - } - return code; -} - static int32_t tsdbAbortCompact(STsdbCompactor *pCompactor) { int32_t code = 0; int32_t lino = 0; @@ -660,8 +634,31 @@ _exit: if (code) { tsdbAbortCompact(pCompactor); } else { - tsdbCommitCompact(pCompactor); + tsdbFSPrepareCommit(pTsdb, &pCompactor->fs); } tsdbEndCompact(pCompactor); return code; } + +int32_t tsdbCommitCompact(STsdb *pTsdb) { + int32_t code = 0; + int32_t lino = 0; + + taosThreadRwlockWrlock(&pTsdb->rwLock); + + code = tsdbFSCommit(pTsdb); + if (code) { + taosThreadRwlockUnlock(&pTsdb->rwLock); + TSDB_CHECK_CODE(code, lino, _exit); + } + + taosThreadRwlockUnlock(&pTsdb->rwLock); + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); + } else { + tsdbInfo("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__); + } + return code; +} diff --git a/source/dnode/vnode/src/vnd/vnodeCompact.c b/source/dnode/vnode/src/vnd/vnodeCompact.c index 16e39d75dce38d40940df3b4ebf886f972f2caaf..2b7abee99a01bafb7eb7ffd2a6c88978334e7b78 100644 --- a/source/dnode/vnode/src/vnd/vnodeCompact.c +++ b/source/dnode/vnode/src/vnd/vnodeCompact.c @@ -15,6 +15,8 @@ #include "vnd.h" +extern int32_t tsdbCommitCompact(STsdb *pTsdb); + static int32_t vnodeCompactTask(void *param) { int32_t code = 0; int32_t lino = 0; @@ -33,8 +35,11 @@ static int32_t vnodeCompactTask(void *param) { } else { snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path); } + vnodeCommitInfo(dir); + tsdbCommitCompact(pVnode->pTsdb); + _exit: tsem_post(&pInfo->pVnode->canCommit); taosMemoryFree(pInfo);