Fix potential nil pointer in commitlog rebase
Fix a possible nil pointer when rebasing new log segments that were
created while log cleaning ran without compaction.
@@ -661,8 +661,11 @@ func (l *commitLog) rebaseSegments(from, to []*segment, epochCache *leaderEpochC
to = append(to, from...)
// Rebase any leader epoch offsets also. We don't check the error returned
// here because Rebase can't return an error since epochCache is not
- // file-backed.
+ // file-backed. The epoch cache is nil if compaction didn't run, in which
+ // case skip this.
+ if epochCache != nil {
epochCache.Rebase(l.leaderEpochCache, from[0].BaseOffset) // nolint: errcheck
+ }
return to
}
