fix(kafka): Read from beginning if no committed offset (#14865)

pull/14837/head^2
benclive 6 months ago committed by GitHub
parent ec95ed1d05
commit 1b6da11ee2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      pkg/kafka/partition/reader.go

@ -103,6 +103,10 @@ func (p *Reader) start(ctx context.Context) error {
// We manage our commits manually, so we must fetch the last offset for our consumer group to find out where to read from.
lastCommittedOffset := p.fetchLastCommittedOffset(ctx)
if lastCommittedOffset == kafkaEndOffset {
level.Warn(p.logger).Log("msg", "no committed offset found for partition, starting from the beginning", "partition", p.partitionID, "consumer_group", p.consumerGroup)
lastCommittedOffset = kafkaStartOffset // If we haven't committed any offsets yet, we start reading from the beginning.
}
if lastCommittedOffset > 0 {
lastCommittedOffset++ // We want to begin to read from the next offset, but only if we've previously committed an offset.
}

Loading…
Cancel
Save