From 1fa5d02b9482bce37917215452a819943fc4a64b Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 27 Feb 2023 18:20:09 +0800 Subject: [PATCH] more code --- source/dnode/vnode/src/tsdb/tsdbCompact.c | 51 +++++++++++------------ source/dnode/vnode/src/vnd/vnodeCompact.c | 5 +++ 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCompact.c b/source/dnode/vnode/src/tsdb/tsdbCompact.c index fc7df98217..1cd11a3039 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 16e39d75dc..2b7abee99a 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); -- GitLab