-
Notifications
You must be signed in to change notification settings - Fork 369
Fix: SendAsync callback was not invoked when producer is in reconnecting #1333
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR changes a critical part of the event loop. I'm concerned it might introduce risks if we don't manage concurrency properly.
I agree with @shibd : "the main purpose of sendAsync is to avoid waiting for the broker's response, not to skip all the logic." This async approach makes network requests asynchronous, similar to how it's implemented in the Java client, not fully asynchronous for all operations.
So, I think it would be easier if we accept this concept. SendAsync can wait until the runEventLoop processes it and pushes it into the pendingQueue or a batch, just like the Java client. Before entering the pendingQueue, SendAsync itself can check for timeouts and handle the callback. After entering the pendingQueue, failTimeoutMessages can manage the timeout.
I believe that performing timeout checks and callback handling before entering the In my opinion, this approach is essentially the same in nature as performing timeout checks after entering the Regarding your concerns about concurrency risks, I don't think there is any such risk. When a producer receives a Furthermore, even if we don't reconnect in a separate goroutine, the remaining changes in this PR are still necessary. This is because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue arises because the message is not added to the pending queue, preventing the timeout goroutine from triggering a timeout.
To resolve this, we can first add the message to the pending queue before sending it to the data channel.
Fixes #1332
Master Issue: #1332
Motivation
SendAsync() callback should be called to give a response to the user/application when the producer is busy in reconnecting.
Modifications
Run reconnecting in a seperate goroutine.
Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation