Skip to content

Commit

Permalink
kgo: handle ErrBrokerTooOld in doInitProducerID
Browse files Browse the repository at this point in the history
The comment already referred to handling this, this commit completes the
logic.
  • Loading branch information
twmb committed Feb 11, 2021
1 parent da52309 commit f57fc76
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/kgo/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,13 @@ func (cl *Client) doInitProducerID(lastID int64, lastEpoch int16) (*producerID,

resp, err := req.RequestWith(cl.ctx, cl)
if err != nil {
// If our broker is too old, then well...
// If our broker is too old, or our client is pinned to an old
// version, then well...
//
// Note this is dependent on the first broker we hit;
// there are other areas in this client where we assume
// what we hit first is the default.
if err == ErrUnknownRequestKey {
// Note this is dependent on the first broker we hit; there are
// other areas in this client where we assume what we hit first
// is the default.
if err == ErrUnknownRequestKey || err == BrokerTooOld {
cl.cfg.logger.Log(LogLevelInfo, "unable to initialize a producer id because the broker is too old, continuing without a producer id")
return &producerID{-1, -1, nil}, true
}
Expand Down

0 comments on commit f57fc76

Please sign in to comment.