Skip to content

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 <[email protected]>
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.

2 participants