Skip to content

Commit

Permalink
client: fix loadCoordinators
Browse files Browse the repository at this point in the history
Once we receive an error, we want to keep the first error and cancel the
context so all other requests quit.

The conditional was backwards, so we never canceled the other requests
and we never saved the first error, which also meant we never returned
an error.
  • Loading branch information
twmb committed Apr 12, 2021
1 parent d4fe91d commit 56b8308
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/kgo/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ func (cl *Client) loadCoordinators(reload bool, typ int8, names ...string) (map[

var mu sync.Mutex
m := make(map[string]*broker)
var errQuit error
var firstErr error

var wg sync.WaitGroup
for _, name := range names {
Expand All @@ -836,8 +836,8 @@ func (cl *Client) loadCoordinators(reload bool, typ int8, names ...string) (map[
defer mu.Unlock()

if err != nil {
if errQuit != nil {
errQuit = err
if firstErr == nil {
firstErr = err
cancel()
}
return
Expand All @@ -847,7 +847,7 @@ func (cl *Client) loadCoordinators(reload bool, typ int8, names ...string) (map[
}
wg.Wait()

return m, errQuit
return m, firstErr
}

func (cl *Client) handleAdminReq(ctx context.Context, req kmsg.Request) ResponseShard {
Expand Down

0 comments on commit 56b8308

Please sign in to comment.