From fb9e62afe24cdab219a71cc7ad9fac229c82e362 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 9 Nov 2022 19:02:50 +0800 Subject: [PATCH] refactor(sync): if index less than wal.commitVer, do not truncate, otherwise it will print much log --- source/libs/sync/src/syncRaftLog.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index d3d69b288b..7b1158319e 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -301,6 +301,12 @@ static int32_t raftLogTruncate(struct SSyncLogStore* pLogStore, SyncIndex fromIn return 0; } + // need not truncate + SyncIndex walCommitVer = walGetCommittedVer(pWal); + if (fromIndex <= walCommitVer) { + return 0; + } + int32_t code = walRollback(pWal, fromIndex); if (code != 0) { int32_t err = terrno;