From cc67b631f6a481cfa228b13be19185d063ee65dc Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 18 Apr 2023 17:01:09 +0800 Subject: [PATCH] refactor: do some internal refactor. --- source/dnode/vnode/src/tq/tqRestore.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/dnode/vnode/src/tq/tqRestore.c b/source/dnode/vnode/src/tq/tqRestore.c index ab69a16ec9..f96573702d 100644 --- a/source/dnode/vnode/src/tq/tqRestore.c +++ b/source/dnode/vnode/src/tq/tqRestore.c @@ -29,18 +29,21 @@ int tqStreamTasksScanWal(STQ* pTq) { while (1) { int32_t scan = pMeta->walScan; tqDebug("vgId:%d continue check if data in wal are available, scan:%d", vgId, scan); + ASSERT(scan >= 1); // check all restore tasks - bool allFull = true; - streamTaskReplayWal(pTq->pStreamMeta, pTq->pOffsetStore, &allFull); + bool shouldIdle = true; + streamTaskReplayWal(pTq->pStreamMeta, pTq->pOffsetStore, &shouldIdle); int32_t times = 0; - if (allFull) { + if (shouldIdle) { taosWLockLatch(&pMeta->lock); pMeta->walScan -= 1; times = pMeta->walScan; + ASSERT(pMeta->walScan >= 0); + if (pMeta->walScan <= 0) { taosWUnLockLatch(&pMeta->lock); break; @@ -49,6 +52,7 @@ int tqStreamTasksScanWal(STQ* pTq) { taosWUnLockLatch(&pMeta->lock); tqDebug("vgId:%d scan wal for stream tasks for %d times", vgId, times); } else { + tqDebug("vgId:%d no idle, scan wal for stream tasks for %d times", vgId, pMeta->walScan); ASSERT(pMeta->walScan >= 1); } }