-
Notifications
You must be signed in to change notification settings - Fork 785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closing kafka Writer during WriteMessages causes a potential hang #1307
Labels
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Closing the kafka.Writer while attempting to write a message can cause the process to hang indefinitely. This issue is resolved by closing the writer again.
Kafka Version
To Reproduce
Expected Behavior
Expecting
kafka.Writer.Close()
not to hang.Observed Behavior
Hangs here: w.group.Wait()
*batchQueue.cond.Wait() waits for a broadcast signal, preventing the decrementing of the waitgroup counter. The signal would typically come from closing the writer here, but at that point, the
w.writers
map is still empty.Sequence of function calls leading to it:
Closing the writer again resolves the issue.
Additional Context
This issue happened in an application that creates writers with different transports, which are closed after a configurable period of inactivity. The transports are not reused, causing the related goroutines
(*connPool).discover
and(*conn).run
to also hang indefinitely.This is almost a non-issue in real scenarios unless the inactivity period is set to a very low duration. I can also work around it by closing the writer again if the previous close doesn't complete in time. However, I thought you might want to know about it regardless.
Thanks!
The text was updated successfully, but these errors were encountered: