Skip to content
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

Fix: Closing kafka Writer during WriteMessages causes a potential hang #1307 #1312

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iamgoroot
Copy link

@iamgoroot iamgoroot commented Jul 23, 2024

Fixes issue #1307 with closing Writer while WriteMessages() is ongoing

#1307

Cause of the issue:

  • Close takes the lock and goes through writers created in batchMessages closing them in a loop
  • Close hangs in wait while ongoing messages are processed
  • meanwhile in WriteMessages there's only one check for writer being closed. If WriteMessages is past that check while closing - new writers are created that will not be released in Close since it's already in a wait

Solution:
WriteMessages should fail with error in case the writer is closed upon acquiring mutex second time and before creating new writers (or map of writers) that won't be closed.

@iamgoroot iamgoroot marked this pull request as draft July 23, 2024 23:16
@iamgoroot iamgoroot marked this pull request as ready for review July 24, 2024 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant