You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix a rare panic during consumer group rebalance (#791)
* Fix a rare panic during consumer group rebalance
Currently, there is a sync.WaitGroup that is used for process accounting
with go routines started by Generation.Start. It is used when a
generation is ending to ensure that all of the Start-ed functions exit
before the next generation can start. There is an edge case that can
cause panic as written up in #786 due to unsafe use of the WaitGroup.
Basically, it is possible that close() is already in process and is
waiting on WaitGroup.Wait() when Start() comes in and calls
WaitGroup.Add(1).
The contract of Start() is that the provided function is to be run.
Code in the wild may depend on this behavior, so it's not an option to
return from Start() without runing the provided function.
Accordingly, this PR updates the code to coordinate between close() and
Start() such that the panic case is no longer possible while preserving
the existing contract. It uses channels and a mutex in order to create
two cases: the normal case where the generation is alive and the edge
case where the generation has already ended.
* Update consumergroup.go
Co-authored-by: Achille <[email protected]>
Co-authored-by: Achille <[email protected]>
0 commit comments