FB-1674: Kafka consumer stops reading messages from topic (#2222)

Added condition to first sort by topic, followed by partition and offset.
This commit is contained in:
rachithrr 2022-09-21 12:53:50 -05:00 committed by Christopher Lowenthal
parent a8709baa8e
commit 6c21910291

View file

@ -216,19 +216,23 @@ func (r *Record) Commit(ctx context.Context) error {
}
}
sort.Slice(section, func(i, j int) bool {
if section[i].Partition != section[j].Partition {
if *section[i].Topic != *section[j].Topic {
return *section[i].Topic < *section[j].Topic
} else if section[i].Partition != section[j].Partition {
return section[i].Partition < section[j].Partition
}
return section[i].Offset > section[j].Offset
})
p := int32(-1)
s := ""
r.src.highmarks = r.src.highmarks[:0]
// sort by increasing partition, decreasing offset
for _, x := range section {
if p != x.Partition {
if s != *x.Topic || p != x.Partition {
r.src.highmarks = append(r.src.highmarks, x)
}
s = *x.Topic
p = x.Partition
}
committedOffsets, err := r.src.CommitMessages(r.src.highmarks)