Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions offset_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,11 @@ func (om *offsetManager) flushToBroker() {
return
}

// Care needs to be taken to unlock this. Don't want to defer the unlock as this would
// cause the lock to be held while waiting for the broker to reply.
broker.lock.Lock()
req := om.constructRequest()
if req == nil {
broker.lock.Unlock()
return
}
resp, rp, err := sendOffsetCommit(broker, req)
broker.lock.Unlock()

if err != nil {
om.handleError(err)
Expand All @@ -290,6 +285,10 @@ func (om *offsetManager) flushToBroker() {
func sendOffsetCommit(coordinator *Broker, req *OffsetCommitRequest) (*OffsetCommitResponse, *responsePromise, error) {
resp := new(OffsetCommitResponse)
responseHeaderVersion := resp.headerVersion()

coordinator.lock.Lock()
defer coordinator.lock.Unlock()

promise, err := coordinator.send(req, true, responseHeaderVersion)
if err != nil {
return nil, nil, err
Expand Down