Technoboy- commented on code in PR #16205:
URL: https://github.com/apache/pulsar/pull/16205#discussion_r905695053


##########
pulsar-broker/src/test/java/org/apache/pulsar/compaction/CompactionTest.java:
##########
@@ -1678,4 +1689,62 @@ public void testHealthCheckTopicNotCompacted() {
         producer1.close();
         producer2.close();
     }
+
+    @Test(timeOut = 60000)
+    public void testCompactionWithMarker() throws Exception {
+        String namespace = "my-property/use/my-ns";
+        final TopicName dest = TopicName.get(
+                BrokerTestUtil.newUniqueName("persistent://" + namespace + 
"/testWriteMarker"));
+        admin.topics().createNonPartitionedTopic(dest.toString());
+        @Cleanup
+        Consumer<byte[]> consumer = pulsarClient.newConsumer()
+                .topic(dest.toString())
+                .subscriptionName("test-compaction-sub")
+                .subscriptionType(SubscriptionType.Exclusive)
+                .readCompacted(true)
+                
.subscriptionInitialPosition(SubscriptionInitialPosition.Latest)
+                .subscribe();
+        Producer<byte[]> producer = pulsarClient.newProducer()
+                .topic(dest.toString())
+                .enableBatching(false)
+                .messageRoutingMode(MessageRoutingMode.SinglePartition)
+                .create();
+        producer.send("msg-1".getBytes(StandardCharsets.UTF_8));
+        Optional<Topic> topic = 
pulsar.getBrokerService().getTopic(dest.toString(), true).join();
+        Assert.assertTrue(topic.isPresent());
+        PersistentTopic persistentTopic = (PersistentTopic) topic.get();
+        Random random = new Random();
+        for (int i = 0; i < 100; i++) {
+            int rad = random.nextInt(3);
+            ByteBuf marker;
+            if (rad == 0) {
+                marker = Markers.newTxnCommitMarker(-1L, 0, i);
+            } else if (rad == 1) {
+                marker = Markers.newTxnAbortMarker(-1L, 0, i);
+            } else {
+                marker = 
Markers.newReplicatedSubscriptionsSnapshotRequest(UUID.randomUUID().toString(), 
"r1");
+            }
+            persistentTopic.getManagedLedger().asyncAddEntry(marker, new 
AsyncCallbacks.AddEntryCallback() {
+                @Override
+                public void addComplete(Position position, ByteBuf entryData, 
Object ctx) {
+                    //
+                }
+
+                @Override
+                public void addFailed(ManagedLedgerException exception, Object 
ctx) {
+                    //
+                }
+            }, null);
+            marker.release();

Review Comment:
   Ah, it will `retain` in `asyncAddEntry`, so it's ok here.



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java:
##########
@@ -234,6 +236,12 @@ && trackDelayedDelivery(entry.getLedgerId(), 
entry.getEntryId(), msgMetadata)) {
         return totalEntries;
     }
 
+    private void doAcknowledgeMessage(List<Position> positions, AckType 
ackType, Map<String, Long> properties) {

Review Comment:
   updated. Thanks for your 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: [email protected]

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

Reply via email to