merlimat opened a new pull request #11764:
URL: https://github.com/apache/pulsar/pull/11764
### Motivation
Under certain conditions applications using the multi-topic consumers might
get the consumption stalled:
The conditions to reproduce the issue are:
* Messages are published in batches
* Consumer is subscribed to multiple topics, but only 1 topic has traffic
* Messages are published in batches (no repro if no batches)
* Receiver queue size == 1 (or small, in order to exercise race condition)
The problem is that there is race condition between 2 threads when we're
deciding to put one of the individual consumers in "paused" state, when the
shared queue is full.
What happens is that, just after we checked the conditions and we decide to
mark the consumer as paused, the application has emptied the shared queue
completely. From that point on, there is no re-attempt to check whether we need
to unblock that consumer.
### Modification
Instead of introducing a sync block (contended by many consumers), we just
double check the state of the shared queue after marking the consumer as
"paused". If the other thread has emptied the queue in the meantime, we'll be
guaranteed to unblock the consumer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]