-
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
[Issue 833] Fix the availablePermits leak that could cause consumer stuck. #835
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.
That's a good finding to fix the availablePermits leak.
Can we let dipatcher() to manage the availablePermits since most cases already covered by various signals in dispatcher()'s select cases. The benefits are 1) centralize one function to manage availablePermits 2) to avoid using Atomic or any synchronizing because avialablePermits can only updated one at a time.
To achieve that, can we have failure cases from MessageReceived() to send a signal to a new channel that dispatcher() listens to that will call your new function increasePermitsAndRequestMoreIfNeed()
There might be other cases leaking availablePermits. So in the future, those cases can send a sig to this new increasePermits channel.
What do you think? I think the statement management (i.e. availablePermits) should be done by dispatcher() instead of leaking all over the places then it forces to use synchronization (i.e. atomic) and better use of channel.
Hi @zzzming. I agree with you that handle the availablePermits in dispatcher().
You are right. Chunking also need to increase availablePermits when all the chunks haven't all arrived yet. So this is also a case where need to request more |
The modify for dispatcher has done. CC @zzzming By the way, what is the difference between pulsar-client-go/pulsar/consumer_partition.go Lines 933 to 944 in 68e4317
I think the code here is redundant. |
@Gleiphir2769
These two are very close terminologies. Ultimately, we need one counter to keep track the number of availablePermits. The requestPermits is just an intermediary variable hold the availablePermits value and send to the broker. The rest of PR looks good to me. @merlimat @michaeljmarshall @wolfstudy Can we merge this soon? |
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.
Nice work, LGTM +1
Fixes #833
Motivation
The availablePermits may leak when message is discarded. Please refer to #833 for details.
Modifications
discardCorruptedMessage
.Verifying this change
This change added tests and can be verified as follows:
pulsar/consumer_test.go:TestAvailablePermitsLeak()