coderzc commented on code in PR #23495:
URL: https://github.com/apache/pulsar/pull/23495#discussion_r1830329658


##########
pulsar-broker/src/main/java/org/apache/pulsar/compaction/CompactedTopicUtils.java:
##########
@@ -88,15 +92,27 @@ public static void 
asyncReadCompactedEntries(TopicCompactionService topicCompact
                             return;
                         }
 
+                        List<Entry> unAckedEntries = new ArrayList<>();
                         long entriesSize = 0;
-                        for (Entry entry : entries) {
-                            entriesSize += entry.getLength();
+                        if (COMPACTION_CURSOR_NAME.equals(cursor.getName())) {
+                            for (Entry entry : entries) {
+                                entriesSize += entry.getLength();
+                            }
+                            unAckedEntries = entries;
+                        } else {
+                            for (Entry entry : entries) {
+                                Position position = entry.getPosition();
+                                if 
(!cursor.isMessageIndividualDeleted(position)) {
+                                    unAckedEntries.add(entry);
+                                    entriesSize += entry.getLength();
+                                }
+                            }
                         }
-                        cursor.updateReadStats(entries.size(), entriesSize);
+                        cursor.updateReadStats(unAckedEntries.size(), 
entriesSize);
 
                         Entry lastEntry = entries.get(entries.size() - 1);
                         cursor.seek(lastEntry.getPosition().getNext(), true);
-                        callback.readEntriesComplete(entries, readEntriesCtx);
+                        callback.readEntriesComplete(unAckedEntries, 
readEntriesCtx);

Review Comment:
   @summeriiii I think for the compacted topic, we cannot use individual 
acknowledgment, otherwise the entry will not be deleted because the messages 
deleted by compact will never be acknowledged. so I suggest using 
`acknowledgeCumulative` acknowledge message for compacted topic.
   
   



-- 
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: [email protected]

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

Reply via email to