Skip to content

Commit

Permalink
server/storage: update currentRev if scheduledCompact > currentRev
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Fu <fuweid89@gmail.com>
  • Loading branch information
fuweid committed Apr 18, 2024
1 parent 8b7b796 commit 3ed757f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions server/storage/mvcc/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,17 @@ func (s *store) restore() error {
}
}

// NOTE: Last compaction could delete all the related revisions but it
// didn't have chance to update it finished state. When revisions in
// [N, `scheduledCompact`] are tombstone, the `currentRev` will be less
// than scheduledCompact. The next following `compactLockfree` call
// will return ErrFutureRev. Since we force-commit scheduledCompact
// rev, it's trusted value. We should update `currentRev` to align with
// `scheduledCompact` just in case that the revision is decreased.
if scheduledCompact != 0 && s.currentRev < scheduledCompact {
s.currentRev = scheduledCompact
}

tx.RUnlock()

s.lg.Info("kvstore restored", zap.Int64("current-rev", s.currentRev))
Expand Down

0 comments on commit 3ed757f

Please sign in to comment.