You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/08/23 11:43:17 UTC

[GitHub] [pulsar] mattisonchao commented on a diff in pull request #17237: [fix][broker] Fix dispatch the duplicated message with `Exclusive` mode.

mattisonchao commented on code in PR #17237:
URL: https://github.com/apache/pulsar/pull/17237#discussion_r952498972


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentStreamingDispatcherSingleActiveConsumer.java:
##########
@@ -175,14 +175,19 @@ public synchronized void internalReadEntryComplete(Entry entry, PendingReadEntry
     }
 
     @Override
-    protected void readMoreEntries(Consumer consumer) {
+    protected synchronized void readMoreEntries(Consumer consumer) {
         // consumer can be null when all consumers are disconnected from broker.
         // so skip reading more entries if currently there is no active consumer.
         if (null == consumer) {
             return;
         }
+        if (havePendingRead) {

Review Comment:
   Check status ahead of time to avoid logging incorrect information.



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java:
##########
@@ -354,17 +359,15 @@ protected void readMoreEntries(Consumer consumer) {
                 log.debug("[{}-{}] Schedule read of {} messages", name, consumer, messagesToRead);
             }
 
-            synchronized (this) {
-                havePendingRead = true;
-                if (consumer.readCompacted()) {
-                    topic.getCompactedTopic().asyncReadEntriesOrWait(cursor, messagesToRead, isFirstRead,
-                            this, consumer);
-                } else {
-                    ReadEntriesCtx readEntriesCtx =
-                            ReadEntriesCtx.create(consumer, consumer.getConsumerEpoch());
-                    cursor.asyncReadEntriesOrWait(messagesToRead,
-                            bytesToRead, this, readEntriesCtx, topic.getMaxReadPosition());
-                }
+            havePendingRead = true;

Review Comment:
   Move `synchronized` to the method, could you take a look?
   /cc @shibd 



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org