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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: flush block #1104

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

Conversation

rfyiamcool
Copy link

@rfyiamcool rfyiamcool commented Oct 19, 2023

summary

When the producer's close method is executed, the runEventsLoop coroutine will exit. If producer.flush is executed at this time, there is a possibility of blocking.

If you close first and then flush, Flush() will block.

go func() {
      close() := func() {
            close(internalQueue)
            producer.Close()
      }
}()

go func() {
      for _, msg := range internalQueue {
          producer.Send(...)
      }
      producer.Flush() // block
}

Sometimes, we cannot control the order of concurrent execution. 馃榿

Signed-off-by: rfyiamcool <rfyiamcool@163.com>
Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch doesn't "fix" an issue if any because it's possible that the check passed first but the producer gets closed just after the check passed.

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.

None yet

2 participants