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