massakam commented on a change in pull request #10696:
URL: https://github.com/apache/pulsar/pull/10696#discussion_r638971507



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java
##########
@@ -248,7 +249,9 @@ public synchronized void readMoreEntries() {
                 // next entries as readCompletedEntries-callback was never 
called
                 if ((messagesToReplayNow.size() - deletedMessages.size()) == 
0) {
                     havePendingReplayRead = false;
-                    readMoreEntries();
+                    // We should not call readMoreEntries() recursively in the 
same thread
+                    // as there is a risk of StackOverflowError
+                    topic.getBrokerService().executor().execute(() -> 
readMoreEntries());

Review comment:
       @eolivelli Those are difficult questions...
   
   Even now, if the message dispatch rate reaches the threshold, another thread 
can execute `readMoreEntries()` recursively after a certain period of time, so 
it seems to me that this change doesn't break the behavior of the dispatcher. 
However, there is no clear evidence for it.
   
   If anyone has any knowledge, I would like to hear opinions.
   
   
https://github.com/apache/pulsar/blob/a6aed551026825ef2de6b1ac5916d17daf1af5c3/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java#L225
   
https://github.com/apache/pulsar/blob/a6aed551026825ef2de6b1ac5916d17daf1af5c3/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java#L275-L308




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to