thetumbled commented on code in PR #22794:
URL: https://github.com/apache/pulsar/pull/22794#discussion_r1621814036
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -2678,8 +2676,7 @@ private void persistPositionMetaStore(long
cursorsLedgerId, PositionImpl positio
ManagedCursorInfo.Builder info = ManagedCursorInfo.newBuilder() //
.setCursorsLedgerId(cursorsLedgerId) //
.setMarkDeleteLedgerId(position.getLedgerId()) //
- .setMarkDeleteEntryId(position.getEntryId()) //
- .setLastActive(lastActive); //
+ .setMarkDeleteEntryId(position.getEntryId()); //
Review Comment:
Done, thanks for review.
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceTest.java:
##########
@@ -1313,6 +1314,67 @@ public void
testCheckInactiveSubscriptionsShouldNotDeleteCompactionCursor() thro
}
+ @Test
+ public void testCheckInactiveSubscriptionWhenNoMessageToAck() throws
Exception {
+ String namespace = "prop/testInactiveSubscriptionWhenNoMessageToAck";
+
+ try {
+ admin.namespaces().createNamespace(namespace);
+ } catch (PulsarAdminException.ConflictException e) {
+ // Ok.. (if test fails intermittently and namespace is already
created)
+ }
+ // set enable subscription expiration.
+ admin.namespaces().setSubscriptionExpirationTime(namespace, 1);
+
+ String topic = "persistent://" + namespace + "/my-topic";
+ Producer<byte[]> producer =
pulsarClient.newProducer().topic(topic).create();
+ producer.send("test".getBytes());
+ producer.close();
+
+ // create consumer to consume all messages
+ Consumer<byte[]> consumer =
pulsarClient.newConsumer().topic(topic).subscriptionName("sub1")
+
.subscriptionInitialPosition(SubscriptionInitialPosition.Earliest).subscribe();
+ consumer.acknowledge(consumer.receive());
+
+ Optional<Topic> topicOptional =
pulsar.getBrokerService().getTopic(topic, true).get();
+ assertTrue(topicOptional.isPresent());
+ PersistentTopic persistentTopic = (PersistentTopic)
topicOptional.get();
+
+ // wait for 1min, but consumer is still connected all the time.
+ // so subscription should not be deleted.
+ Thread.sleep(60000);
+ persistentTopic.checkInactiveSubscriptions();
Review Comment:
Good idea, updated.
--
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]