Repository navigation
[Issue 833] Fix the availablePermits leak that could cause consumer stuck. - #835
Conversation
zzzming
left a comment
There was a problem hiding this comment.
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? |
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()