Skip to content

Commit

Permalink
Merge pull request #604 from twmb/597
Browse files Browse the repository at this point in the history
kadm: do not reuse ApiVersions in many concurrent requests
  • Loading branch information
twmb authored Oct 22, 2023
2 parents 067ec8e + 1955938 commit d156322
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/kadm/acls.go
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ func (cl *Client) DescribeACLs(ctx context.Context, b *ACLBuilder) (DescribeACLs
)
defer cancel()
for i := range descs {
req := descs[i]
req := descs[i] // each req is unique per loop, we are not reusing req, this is safe
myIdx := i
wg.Add(1)
go func() {
Expand Down
7 changes: 3 additions & 4 deletions pkg/kadm/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,6 @@ func (cl *Client) ApiVersions(ctx context.Context) (BrokersApiVersions, error) {
return nil, err
}

req := kmsg.NewPtrApiVersionsRequest()
req.ClientSoftwareName = "kadm"
req.ClientSoftwareVersion = softwareVersion()

var mu sync.Mutex
var wg sync.WaitGroup
vs := make(BrokersApiVersions, len(m.Brokers))
Expand All @@ -256,6 +252,9 @@ func (cl *Client) ApiVersions(ctx context.Context) (BrokersApiVersions, error) {
wg.Add(1)
go func() {
defer wg.Done()
req := kmsg.NewPtrApiVersionsRequest()
req.ClientSoftwareName = "kadm"
req.ClientSoftwareVersion = softwareVersion()
v := BrokerApiVersions{NodeID: n, keyVersions: make(map[int16]minmax)}
v.raw, v.Err = req.RequestWith(ctx, cl.cl.Broker(int(n)))

Expand Down

0 comments on commit d156322

Please sign in to comment.