Skip to content

Commit

Permalink
kgo client.go: bugfix -1 leader epoch for a few minutes
Browse files Browse the repository at this point in the history
When the previous brokers map was split into brokers and seeds fields,
the supportsOffsetForLeaderEpoch was not updated to check seeds if no
brokers existed yet. This means that for the first metadata update, we
would store -1 for the leader epoch, and down the line when metadata
updated again, we would store the real leader epoch. The fallout is a
bit nebulous. I think this means we have a small window of time where we
would not validate data loss, but that's about it.
  • Loading branch information
twmb committed Aug 22, 2022
1 parent bc026a4 commit 9497cf3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/kgo/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,14 @@ func (cl *Client) supportsOffsetForLeaderEpoch() bool {
cl.brokersMu.RLock()
defer cl.brokersMu.RUnlock()

for _, b := range cl.brokers {
if v := b.loadVersions(); v != nil && v.versions[23] >= 2 {
return true
for _, brokers := range [][]*broker{
cl.brokers,
cl.seeds,
} {
for _, b := range brokers {
if v := b.loadVersions(); v != nil && v.versions[23] >= 2 {
return true
}
}
}
return false
Expand Down

0 comments on commit 9497cf3

Please sign in to comment.