Technoboy- commented on a change in pull request #11564:
URL: https://github.com/apache/pulsar/pull/11564#discussion_r689967293



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/compaction/TwoPhaseCompactor.java
##########
@@ -145,14 +149,17 @@ private void phaseOneLoop(RawReader reader,
                     Pair<String, Integer> keyAndSize = extractKeyAndSize(m);
                     if (keyAndSize != null) {
                         if (keyAndSize.getRight() > 0) {
-                            latestForKey.put(keyAndSize.getLeft(), id);
+                            MessageId old = 
latestForKey.put(keyAndSize.getLeft(), id);
+                            replaceMessage = old != null;
                         } else {
                             deletedMessage = true;
                             latestForKey.remove(keyAndSize.getLeft());
                         }
                     }
                 }
-
+                if (replaceMessage || deletedMessage) {
+                    mxBean.addCompactRemovedEvent(reader.getTopic());
+                }

Review comment:
       > Maybe the `replaceMessage` could be re-modified. For example, in a 
batch loop, at first, it could be true, when meeting a new key it will change 
to false.
   Yes, really, Thanks for the kindly review.
   
   
   




-- 
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-unsubscr...@pulsar.apache.org

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


Reply via email to