Skip to content

Commit

Permalink
Merge pull request etcd-io#17792 from ahrtr/update_compact_log_bootst…
Browse files Browse the repository at this point in the history
…rap_20240415

Update the compaction log when bootstrap and update compact's signature
  • Loading branch information
ahrtr authored Apr 21, 2024
2 parents 2674f94 + a54098d commit 6cbaa1f
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions server/storage/mvcc/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (s *store) checkPrevCompactionCompleted() bool {
return scheduledCompact == finishedCompact && scheduledCompactFound == finishedCompactFound
}

func (s *store) compact(trace *traceutil.Trace, rev, prevCompactRev int64, prevCompactionCompleted bool) (<-chan struct{}, error) {
func (s *store) compact(trace *traceutil.Trace, rev, prevCompactRev int64, prevCompactionCompleted bool) <-chan struct{} {
ch := make(chan struct{})
j := schedule.NewJob("kvstore_compact", func(ctx context.Context) {
if ctx.Err() != nil {
Expand All @@ -251,7 +251,7 @@ func (s *store) compact(trace *traceutil.Trace, rev, prevCompactRev int64, prevC

s.fifoSched.Schedule(j)
trace.Step("schedule compaction")
return ch, nil
return ch
}

func (s *store) compactLockfree(rev int64) (<-chan struct{}, error) {
Expand All @@ -261,7 +261,7 @@ func (s *store) compactLockfree(rev int64) (<-chan struct{}, error) {
return ch, err
}

return s.compact(traceutil.TODO(), rev, prevCompactRev, prevCompactionCompleted)
return s.compact(traceutil.TODO(), rev, prevCompactRev, prevCompactionCompleted), nil
}

func (s *store) Compact(trace *traceutil.Trace, rev int64) (<-chan struct{}, error) {
Expand All @@ -275,7 +275,7 @@ func (s *store) Compact(trace *traceutil.Trace, rev int64) (<-chan struct{}, err
}
s.mu.Unlock()

return s.compact(trace, rev, prevCompactRev, prevCompactionCompleted)
return s.compact(trace, rev, prevCompactRev, prevCompactionCompleted), nil
}

func (s *store) Commit() {
Expand Down Expand Up @@ -394,13 +394,16 @@ func (s *store) restore() error {

if scheduledCompact != 0 {
if _, err := s.compactLockfree(scheduledCompact); err != nil {
s.lg.Warn("compaction encountered error", zap.Error(err))
s.lg.Warn("compaction encountered error",
zap.Int64("scheduled-compact-revision", scheduledCompact),
zap.Error(err),
)
} else {
s.lg.Info(
"resume scheduled compaction",
zap.Int64("scheduled-compact-revision", scheduledCompact),
)
}

s.lg.Info(
"resume scheduled compaction",
zap.Int64("scheduled-compact-revision", scheduledCompact),
)
}

return nil
Expand Down

0 comments on commit 6cbaa1f

Please sign in to comment.