Merge pull request #17831 from ahrtr/3.4_update_compact_log_bootstrap_20240421

[3.4] Update the compaction log when bootstrap and update compact's signature
This commit is contained in:
Benjamin Wang 2024-04-23 09:50:52 +01:00 committed by GitHub
commit 913a0805f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -276,7 +276,7 @@ func (s *store) updateCompactRev(rev int64) (<-chan struct{}, error) {
return nil, nil return nil, nil
} }
func (s *store) compact(trace *traceutil.Trace, rev int64) (<-chan struct{}, error) { func (s *store) compact(trace *traceutil.Trace, rev int64) <-chan struct{} {
ch := make(chan struct{}) ch := make(chan struct{})
var j = func(ctx context.Context) { var j = func(ctx context.Context) {
if ctx.Err() != nil { if ctx.Err() != nil {
@ -295,7 +295,7 @@ func (s *store) compact(trace *traceutil.Trace, rev int64) (<-chan struct{}, err
s.fifoSched.Schedule(j) s.fifoSched.Schedule(j)
trace.Step("schedule compaction") trace.Step("schedule compaction")
return ch, nil return ch
} }
func (s *store) compactLockfree(rev int64) (<-chan struct{}, error) { func (s *store) compactLockfree(rev int64) (<-chan struct{}, error) {
@ -304,7 +304,7 @@ func (s *store) compactLockfree(rev int64) (<-chan struct{}, error) {
return ch, err return ch, err
} }
return s.compact(traceutil.TODO(), rev) return s.compact(traceutil.TODO(), rev), nil
} }
func (s *store) Compact(trace *traceutil.Trace, rev int64) (<-chan struct{}, error) { func (s *store) Compact(trace *traceutil.Trace, rev int64) (<-chan struct{}, error) {
@ -318,7 +318,7 @@ func (s *store) Compact(trace *traceutil.Trace, rev int64) (<-chan struct{}, err
} }
s.mu.Unlock() s.mu.Unlock()
return s.compact(trace, rev) return s.compact(trace, rev), nil
} }
// DefaultIgnores is a map of keys to ignore in hash checking. // DefaultIgnores is a map of keys to ignore in hash checking.
@ -477,17 +477,28 @@ func (s *store) restore() error {
tx.Unlock() tx.Unlock()
if scheduledCompact != 0 { if scheduledCompact != 0 {
s.compactLockfree(scheduledCompact) if _, err := s.compactLockfree(scheduledCompact); err != nil {
if s.lg != nil {
if s.lg != nil { s.lg.Warn("compaction encountered error",
s.lg.Info( zap.String("meta-bucket-name", string(metaBucketName)),
"resume scheduled compaction", zap.String("meta-bucket-name-key", string(scheduledCompactKeyName)),
zap.String("meta-bucket-name", string(metaBucketName)), zap.Int64("scheduled-compact-revision", scheduledCompact),
zap.String("meta-bucket-name-key", string(scheduledCompactKeyName)), zap.Error(err),
zap.Int64("scheduled-compact-revision", scheduledCompact), )
) } else {
plog.Printf("compaction encountered error, scheduled-compact-revision: %d", scheduledCompact)
}
} else { } else {
plog.Printf("resume scheduled compaction at %d", scheduledCompact) if s.lg != nil {
s.lg.Info(
"resume scheduled compaction",
zap.String("meta-bucket-name", string(metaBucketName)),
zap.String("meta-bucket-name-key", string(scheduledCompactKeyName)),
zap.Int64("scheduled-compact-revision", scheduledCompact),
)
} else {
plog.Printf("resume scheduled compaction at %d", scheduledCompact)
}
} }
} }