apache / apache/pulsar

[Bug] unacked message count is zero when using exclusive subscription.

Open
#24,159 3 comments 0 reactions 0 assignees View on GitHub
type/bug
Dominant language
Java
Stars
15.3k
Forks
3.8k
Avg merge
1d 14h
Merged PRs (30d)
160

Description

### 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

Pulsar: master

### Minimal reproduce step

```java
@Test
public void testUnackedMessages() throws Exception {
String topicName = "testUnackedMessages";
String subscriptionName = "my-sub";
String serviceUrl = "pulsar://localhost:6650";

@Cleanup PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(serviceUrl).build();

@Cleanup Consumer consumer =
pulsarClient.newConsumer().topic(topicName).subscriptionName(subscriptionName)
.subscriptionType(SubscriptionType.Exclusive).messageListener((c, message) -> {
// noop
}).subscribe();

@Cleanup Producer producer = pulsarClient.newProducer().topic(topicName).create();
producer.send("1".getBytes());

TopicStats stats = admin.topics().getStats(topicName);
assertThat(stats.getSubscriptions().get(subscriptionName).getUnackedMessages()).isNotEqualTo(0);
}
```

### What did you expect to see?

unackedMessages is not equal to 0.

### What did you see instead?

unackedMessages is equal to 0.

### Anything else?

_No response_

### Are you willing to submit a PR?

- [x] I'm willing to submit a PR!

Contributor guide

Open the contributing guide

Research direction

Start by running the Java reproduction in the issue and inspect the TopicStats subscription entry for an exclusive subscription. Trace how unackedMessages is calculated and reported for this case; the work is done when the provided assertion observes a nonzero count without breaking other subscription types.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.