Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3544,7 +3544,7 @@ public void checkInactiveSubscriptions(long expirationTimeMillis) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2027,6 +2027,7 @@ public void addFailed(ManagedLedgerException exception, Object ctx) {

@Test
public void testCheckInactiveSubscriptions() throws Exception {
pulsarTestContext.getConfig().setAdditionalSystemCursorNames(Set.of("additionalSystemCursor"));
PersistentTopic topic = new PersistentTopic(successTopicName, ledgerMock, brokerService);

final var subscriptions = new ConcurrentHashMap<String, PersistentSubscription>();
Expand All @@ -2045,6 +2046,11 @@ public void testCheckInactiveSubscriptions() throws Exception {
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);
Expand All @@ -2071,6 +2077,7 @@ public void testCheckInactiveSubscriptions() throws Exception {
verify(nonDeletableSubscription1, times(0)).delete();
verify(deletableSubscription1, times(1)).delete();
verify(nonDeletableSubscription2, times(0)).delete();
verify(nonDeletableSubscription3, times(0)).delete();
}

@Test
Expand Down
Loading