From adf1c3f29124ed15e2420c3e61a77441d0005757 Mon Sep 17 00:00:00 2001 From: Benjamin Wang Date: Sun, 21 Apr 2024 13:17:02 +0100 Subject: [PATCH] Update the compaction log when bootstrap and update compact's signature Actually the compact() never return an error, so remove the second return parameter. Signed-off-by: Benjamin Wang --- server/mvcc/kvstore.go | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/server/mvcc/kvstore.go b/server/mvcc/kvstore.go index e1f74760ed5..66e612b0a81 100644 --- a/server/mvcc/kvstore.go +++ b/server/mvcc/kvstore.go @@ -237,7 +237,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{}) var j = func(ctx context.Context) { if ctx.Err() != nil { @@ -262,7 +262,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) { @@ -272,7 +272,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) { @@ -287,7 +287,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() { @@ -408,15 +408,18 @@ 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.Stringer("meta-bucket-name", buckets.Meta), + zap.String("meta-bucket-name-key", string(scheduledCompactKeyName)), + zap.Int64("scheduled-compact-revision", scheduledCompact), + ) } - - s.lg.Info( - "resume scheduled compaction", - zap.Stringer("meta-bucket-name", buckets.Meta), - zap.String("meta-bucket-name-key", string(scheduledCompactKeyName)), - zap.Int64("scheduled-compact-revision", scheduledCompact), - ) } return nil