Skip to content

Commit

Permalink
server/mvcc: should update currentRev in revMu
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 24, 2024
1 parent c06b17b commit 0af22ab
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions server/mvcc/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,17 @@ func (s *store) restore() error {
if s.currentRev < s.compactMainRev {
s.currentRev = s.compactMainRev
}

// 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
}
s.revMu.Unlock()
}

Expand All @@ -402,17 +413,6 @@ 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.Unlock()

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

0 comments on commit 0af22ab

Please sign in to comment.