-
Notifications
You must be signed in to change notification settings - Fork 344
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] Multiple calls to client.Close causes panic #1046
Conversation
This PR enables the 'close' method to be re-entrant. However, I'm not quite seeing the value in making the 'close' method re-entrant. Could you provide any scenarios or use cases where this would be necessary? |
This is just defensive programming, the consumer's close logic also has similar usage. pulsar-client-go/pulsar/consumer_multitopic.go Lines 256 to 270 in 5f8df27
|
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.
Generally looks good.
My concern can be that it may not be an idiom among the code. So if we change the flavor randomly it can introduce noise. But I think this direction is good to go.
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.
What if we cause the internal closes idempotent instead of hacky wrapping an Once
outer?
https://github.com/apache/pulsar/blob/a3bca685a4ef0916462228e035f77fdbf295653d/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java#L735-L739 I looked at the Java SDK's close logic, it uses an internal state to maintain the client state, and the |
I might add a scenario to this improvement. For example, our app may instantiate multiple instances that implement
In Go, we expect That is the opportunity that I've found out #1026. |
@tisonkun @Shoothzj Could you take a look at this? Does the explanation make sense to you? |
I believe this modification is feasible. Regardless of whether or not it supports reentrancy, and whether reentrancy supports concurrency, we can maintain consistent behavior across the entire code repository. |
Thanks for your contribution! |
Fixes #1026
Motivation
Multiple calls to
client.Close
causes panic.Modifications
Add
closeOnce sync.Once
Verifying this change
Does this pull request potentially affect one of the following parts:
Documentation