Skip to content

Commit

Permalink
kgo: add more context to opportunistic metadata loads while fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
twmb committed Jul 8, 2023
1 parent 9dae366 commit b45d663
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/kgo/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ func (s *source) fetch(consumerSession *consumerSession, doneFetch chan<- struct
}

var didBackoff bool
backoff := func() {
backoff := func(why interface{}) {
// We preemptively allow more fetches (since we are not buffering)
// and reset our session because of the error (who knows if kafka
// processed the request but the client failed to receive it).
Expand All @@ -633,7 +633,7 @@ func (s *source) fetch(consumerSession *consumerSession, doneFetch chan<- struct
s.session.reset()
didBackoff = true

s.cl.triggerUpdateMetadata(false, "opportunistic load during source backoff") // as good a time as any
s.cl.triggerUpdateMetadata(false, fmt.Sprintf("opportunistic load during source backoff: %v", why)) // as good a time as any
s.consecutiveFailures++
after := time.NewTimer(s.cl.cfg.retryBackoff(s.consecutiveFailures))
defer after.Stop()
Expand All @@ -652,7 +652,7 @@ func (s *source) fetch(consumerSession *consumerSession, doneFetch chan<- struct
// but that is fine; we may just re-request too early and fall into
// another backoff.
if err != nil {
backoff()
backoff(err)
return
}

Expand Down Expand Up @@ -774,7 +774,7 @@ func (s *source) fetch(consumerSession *consumerSession, doneFetch chan<- struct
// fetching from topics that were deleted. We want to back off
// a bit rather than spin-loop immediately re-requesting
// deleted topics.
backoff()
backoff("empty fetch response due to all partitions having retryable errors")
}
return
}
Expand Down

0 comments on commit b45d663

Please sign in to comment.