Fixed deadlock in key-shared dispatcher
@@ -403,14 +403,20 @@ public class PersistentStickyKeyDispatcherMultipleConsumers extends PersistentDi
}
@Override
- public synchronized void markDeletePositionMoveForward() {
+ public void markDeletePositionMoveForward() {
+ // Execute the notification in different thread to avoid a mutex chain here
+ // from the delete operation that was completed
+ topic.getBrokerService().getTopicOrderedExecutor().execute(() -> {
+ synchronized (PersistentStickyKeyDispatcherMultipleConsumers.this) {
if (recentlyJoinedConsumers != null && !recentlyJoinedConsumers.isEmpty()
&& removeConsumersFromRecentJoinedConsumers()) {
- // After we process acks, we need to check whether the mark-delete position was advanced and we can finally
- // read more messages. It's safe to call readMoreEntries() multiple times.
+ // After we process acks, we need to check whether the mark-delete position was advanced and we
+ // can finally read more messages. It's safe to call readMoreEntries() multiple times.
readMoreEntries();
}
}
+ });
+ }
private boolean removeConsumersFromRecentJoinedConsumers() {
Iterator<Map.Entry<Consumer, PositionImpl>> itr = recentlyJoinedConsumers.entrySet().iterator();
