kgo: fix handleListGroups race
Before, the same request was used for every broker. This meant that each
broker would call SetVersion and IsFlexible concurrently, which was a
data race.
Now, this copies the ListGroups request to each broker, so they each
have their own copy that they can modify.
@@ -1000,9 +1000,10 @@ func (cl *Client) handleListGroupsReq(ctx context.Context, req *kmsg.ListGroupsR
}
wg.Add(1)
numReqs++
+ myReq := *req
go func(br *broker) {
defer wg.Done()
- resp, err := br.waitResp(ctx, req)
+ resp, err := br.waitResp(ctx, &myReq)
respErrs <- respErr{resp, err}
}(br)
}
