-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Broker] Make Persistent*DispatcherMultipleConsumers.readMoreEntries synchronized #10413
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
[Broker] Make Persistent*DispatcherMultipleConsumers.readMoreEntries synchronized #10413
Conversation
|
@eolivelli @devinbost @merlimat @codelipenghui @rdhabalia Please review this change that could be a solution to some concurrency issues in PersistentDispatcherMultipleConsumers and PersistentStreamingDispatcherMultipleConsumers classes. |
|
You know you've got my support, though I do wonder if there was a specific reason why it wasn't synchronized already. One of the others with a deeper knowledge of the architecture might have some insight there. |
|
After thinking about this, I noticed a few things.
So, I think it becomes a question of latency vs memory impact and whether more local locks should be used instead. |
merlimat
left a comment
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.
👍 Initially the readMoreEntries() was a private method and always called with sync already taken..
|
@devinbost this patch did not apply. See the related patch for branch 2.7 |
Motivation
There are concurrency issues in
PersistentDispatcherMultipleConsumersandPersistentStreamingDispatcherMultipleConsumersclasses. Some symptoms or previous fixes are #5311, #6054, #6255, #7266, #9789 .Currently
PersistentStreamingDispatcherMultipleConsumers.readMoreEntriesmethod isn't synchronized:pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentStreamingDispatcherMultipleConsumers.java
Lines 137 to 140 in f2d72c9
In one location the method is called within a synchronized block like this:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/InMemoryDelayedDeliveryTracker.java
Lines 191 to 205 in 31f8315
Another location where the
readEntriescall is explicitly wrapped in a synchronized blockpulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java
Lines 612 to 621 in 875262a
Synchronization is missing in this location (and a few other locations):
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
Lines 2439 to 2451 in a1cebdb
It seems that it would be more consistent to make the
readMoreEntriesmethod asynchronizedmethod.Modifications
readEntriesMethodinPersistentDispatcherMultipleConsumersandPersistentStreamingDispatcherMultipleConsumersclasses asynchronizedmethod.