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 19, 2024
1 parent 08a8f8a commit 468a5ca
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 {
}
}

// If the latest revision was a tombstone revision and etcd just compacted
// it, but crashed right before persisting the FinishedCompactRevision,
// then it would lead to revision decreasing in bbolt db file. In such
// a scenario, we should adjust the current revision using the scheduled
// compact revision on bootstrap when etcd gets started again.
//
// See https://github.com/etcd-io/etcd/issues/17780#issuecomment-2061900231
if 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 468a5ca

Please sign in to comment.