apache / apache/pulsar

Topic stats "unackedMessages" not updated correctly for subscription and consumer

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

Description

**Describe the bug**
The "unackedMessages" stat is not updated correctly when getting topic stats via "pulsar-admin topics stats "

For example
```
{
"msgRateIn" : 0.0,
"msgThroughputIn" : 0.0,
"msgRateOut" : 23.73729424962721,
"msgThroughputOut" : 1343.9106512368942,
"bytesInCounter" : 226464,
"msgInCounter" : 4000,
"bytesOutCounter" : 226464,
"msgOutCounter" : 4000,
"averageMsgSize" : 0.0,
"msgChunkPublished" : false,
"storageSize" : 226464,
"backlogSize" : 226464,
"offloadedStorageSize" : 0,
"lastOffloadLedgerId" : 0,
"lastOffloadSuccessTimeStamp" : 0,
"lastOffloadFailureTimeStamp" : 0,
"publishers" : [ ],
"waitingPublishers" : 0,
"subscriptions" : {
"foo" : {
"msgRateOut" : 23.73729424962721,
"msgThroughputOut" : 1343.9106512368942,
"bytesOutCounter" : 226464,
"msgOutCounter" : 4000,
"msgRateRedeliver" : 0.0,
"chunkedMessageRate" : 0,
"msgBacklog" : 4000,
"backlogSize" : 226464,
"msgBacklogNoDelayed" : 4000,
"blockedSubscriptionOnUnackedMsgs" : false,
"msgDelayed" : 0,
"unackedMessages" : 0,
"type" : "Exclusive",
"activeConsumerName" : "4736f",
"msgRateExpired" : 0.0,
"totalMsgExpired" : 0,
"lastExpireTimestamp" : 0,
"lastConsumedFlowTimestamp" : 1631161834268,
"lastConsumedTimestamp" : 1631161834267,
"lastAckedTimestamp" : 0,
"lastMarkDeleteAdvancedTimestamp" : 0,
"consumers" : [ {
"msgRateOut" : 23.73729424962721,
"msgThroughputOut" : 1343.9106512368942,
"bytesOutCounter" : 226464,
"msgOutCounter" : 4000,
"msgRateRedeliver" : 0.0,
"chunkedMessageRate" : 0.0,
"consumerName" : "4736f",
"availablePermits" : 1000,
"unackedMessages" : 0,
"avgMessagesPerEntry" : 6,
"blockedConsumerOnUnackedMsgs" : false,
"lastAckedTimestamp" : 0,
"lastConsumedTimestamp" : 1631161834267,
"metadata" : { },
"address" : "/127.0.0.1:59606",
"connectedSince" : "2021-09-08T21:29:16.338-07:00",
"clientVersion" : "2.9.0-SNAPSHOT"
} ],
"isDurable" : true,
"isReplicated" : false,
"consumersAfterMarkDeletePosition" : { },
"nonContiguousDeletedMessagesRanges" : 0,
"nonContiguousDeletedMessagesRangesSerializedSize" : 0,
"durable" : true,
"replicated" : false
}
},
"replication" : { },
"deduplicationStatus" : "Disabled",
"nonContiguousDeletedMessagesRanges" : 0,
"nonContiguousDeletedMessagesRangesSerializedSize" : 0
}
```

**To Reproduce**
1. Start Pulsar standalone cluster
2. Create a consumer that reads from a topic but does not ack any messages
3. Start producing messages to the topic
4. Get stats of the topic.

**Expected behavior**

The "unackedMessages" stat is correctly displays the number of unacked messages for a subscription and consumer.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with a consumer that reads without acknowledging messages, then inspect the implementation behind `pulsar-admin topics stats `. Verify the subscription and consumer `unackedMessages` values against the messages read without acknowledgments; done means both stats report the correct count.

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.