marekczajkowski opened a new issue, #23245: URL: https://github.com/apache/pulsar/issues/23245
### Search before asking - [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar. ### Read release policy - [X] I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker. ### Version OSX 14.3.1 (23D60), JDK 17, Pulsar 3.3.1 ### Minimal reproduce step When last message sent to topic has no value and such topic is compacted then subscription that reads this compacted topic has messages in backlog. Please check the junit Test below. It fails but it should pass just fine. @Test public void testCompactionWithEmptyValue() throws Exception { log.info("Starting test"); String topic = "persistent://my-property/use/my-ns/test1"; Producer<byte[]> producer = pulsarClient.newProducer() .topic(topic) .enableBatching(false) .messageRoutingMode(MessageRoutingMode.SinglePartition) .create(); pulsarClient.newConsumer().topic(topic).subscriptionName("sub1").readCompacted(true).subscribe().close(); producer.newMessage().key("withValue").value("data".getBytes()).send(); producer.newMessage().key("emptyValue").send(); admin.topics().triggerCompaction(topic); Awaitility.await().atMost(1, TimeUnit.MINUTES).untilAsserted(() -> Assert.assertEquals(admin.topics().compactionStatus(topic).status, Status.SUCCESS)); try (Consumer<byte[]> consumer = pulsarClient.newConsumer().topic(topic).subscriptionName("sub1") .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest) .subscriptionType(SubscriptionType.Exclusive) .readCompacted(true).subscribe()) { for (int i=0; i<2 ; i++) { Message<byte[]> m = consumer.receive(2, TimeUnit.SECONDS); if (m != null) { consumer.acknowledgeCumulative(m); } } Awaitility.await().untilAsserted(() -> Assert.assertEquals(admin.topics().getStats(topic).getSubscriptions().get("sub1").getMsgBacklog(), 0)); } } ### What did you expect to see? No message in backlog of the subscription that reads compacted topic. ### What did you see instead? Message backlog is not empty when subscription read compacted topic. ### Anything else? I verified this behavior on both running Pulsar and unit test. If you change second message `producer.newMessage().key("emptyValue").send()` to `producer.newMessage().key("emptyValue").value("data".getBytes()).send()` The test passes. The behavior should be the same regardless the presence of payload in last message on the topic. ### Are you willing to submit a PR? - [ ] I'm willing to submit a PR! -- 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]
