You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by lh...@apache.org on 2026/07/22 10:02:46 UTC
(pulsar) 11/15: [improve][broker] Skip system cursor when check inactive cursor. (#26149)
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-4.2
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 02b1b7e1f544f0c1a41e379294e09ec43429f89e
Author: Yan Zhao <ho...@apache.org>
AuthorDate: Thu Jul 16 11:53:05 2026 +0800
[improve][broker] Skip system cursor when check inactive cursor. (#26149)
(cherry picked from commit fe61afda2d5bf4cb2de019cca47ef78cd1e350f1)
---
.../apache/pulsar/broker/service/persistent/PersistentTopic.java | 2 +-
.../java/org/apache/pulsar/broker/service/PersistentTopicTest.java | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
index 80f4beb784b9..a1ea21c068a1 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
@@ -3540,7 +3540,7 @@ public class PersistentTopic extends AbstractTopic implements Topic, AddEntryCal
subscriptions.forEach((subName, sub) -> {
if (sub.dispatcher != null && sub.dispatcher.isConsumerConnected()
|| sub.isReplicated()
- || isCompactionSubscription(subName)) {
+ || isSystemCursor(subName)) {
return;
}
if (System.currentTimeMillis() - sub.cursor.getLastActive() > expirationTimeMillis) {
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicTest.java
index 6ce87968155b..62c30dd65356 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicTest.java
@@ -2069,6 +2069,7 @@ public class PersistentTopicTest extends MockedBookKeeperTestCase {
@Test
public void testCheckInactiveSubscriptions() throws Exception {
pulsarTestContext.getConfig().setSubscriptionExpirationTimeMinutes(5);
+ pulsarTestContext.getConfig().setAdditionalSystemCursorNames(Set.of("additionalSystemCursor"));
PersistentTopic topic = new PersistentTopic(successTopicName, ledgerMock, brokerService);
final var subscriptions = new ConcurrentHashMap<String, PersistentSubscription>();
@@ -2087,6 +2088,11 @@ public class PersistentTopicTest extends MockedBookKeeperTestCase {
spyWithClassAndConstructorArgsRecordingInvocations(PersistentSubscription.class, topic,
"nonDeletableSubscription2", cursorMock, true);
subscriptions.put(nonDeletableSubscription2.getName(), nonDeletableSubscription2);
+ // This subscription is an additional system cursor.
+ PersistentSubscription nonDeletableSubscription3 =
+ spyWithClassAndConstructorArgsRecordingInvocations(PersistentSubscription.class, topic,
+ "additionalSystemCursor", cursorMock, false);
+ subscriptions.put(nonDeletableSubscription3.getName(), nonDeletableSubscription3);
Field field = topic.getClass().getDeclaredField("subscriptions");
field.setAccessible(true);
@@ -2111,6 +2117,7 @@ public class PersistentTopicTest extends MockedBookKeeperTestCase {
verify(nonDeletableSubscription1, times(0)).delete();
verify(deletableSubscription1, times(1)).delete();
verify(nonDeletableSubscription2, times(0)).delete();
+ verify(nonDeletableSubscription3, times(0)).delete();
}
@Test