diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index 9f80b4e6acb483207d771cbbf1245ca568ec48d9..15e6d5920fa26ce7267bee45f58c997bbc8398d8 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -421,7 +421,7 @@ bool tsdbNoProblem(STsdbRepo* pRepo); // unit of walSize: MB int tsdbCheckWal(STsdbRepo *pRepo, uint32_t walSize); -int tsdbGetNumOfWaitCommit(STsdbRepo *pRepo, int *nNum); +int tsdbGetValOfWaitCommit(STsdbRepo *pRepo, int *nVal); #ifdef __cplusplus } diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 10cfacca57a543886c85f52a6c2ea9c4a911de6e..da68cb63919cb9767c97009e662346b1c8f44cac 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -199,8 +199,8 @@ int tsdbCheckCommit(STsdbRepo *pRepo) { return 0; } -int tsdbGetNumOfWaitCommit(STsdbRepo *pRepo, int *nNum) { - if (sem_getvalue(&pRepo->readyToCommit, nNum) != 0) { +int tsdbGetValOfWaitCommit(STsdbRepo *pRepo, int *nVal) { + if (sem_getvalue(&pRepo->readyToCommit, nVal) != 0) { tsdbError("vgId:%d failed to sem_getvalue of readyToCommit", REPO_ID(pRepo)); return -1; } diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 0b6064474a925474390c71f4c09ce0052ff33a2f..efbdfed80ec276a77647eefefe12a1a38e16df70 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -169,14 +169,14 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR } static int32_t vnodeCheckWal(SVnodeObj *pVnode) { - // no need to check wal size to trigger commit if: - // 1) vnode in committing state; - // 2) other instance wait to commit; - int nWaitCommit = 0; - if (tsdbGetNumOfWaitCommit(pVnode->tsdb, &nWaitCommit) != 0) { + int nVal = 0; + if (tsdbGetValOfWaitCommit(pVnode->tsdb, &nVal) != 0) { return -1; } - if ((nWaitCommit > 0) && (pVnode->isCommiting == 0)) { + // no need to check wal size to trigger commit if: + // 1) have instances waiting to commit; + // or 2) vnode in committing state; + if ((nVal > 0) && (pVnode->isCommiting == 0)) { return tsdbCheckWal(pVnode->tsdb, walGetFSize(pVnode->wal) >> 20); } return 0;