Repository navigation
Description
Search before reporting
- I searched in the issues and found nothing similar.
Read release policy
- 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.
User environment
- We are using latest commit on
mainbranch. - We are running on Exherbo OS, (a fork of Gentoo)
- We are running on
openjdk version "21.0.5" 2024-10-15 LTS, OpenJDK Runtime Environment Temurin-21.0.5+11 (build 21.0.5+11-LTS), OpenJDK 64-Bit Server VM Temurin-21.0.5+11 (build 21.0.5+11-LTS, mixed mode, sharing) - We are using the pulsar-rs driver provided by streamnative, the latest commit.
- We are running on Exherbo OS, (a fork of Gentoo)
Issue Description
Hello @sijie,
We got this issue on our public cluster in production using the version on master branch at this time with commit (1b7e4a7) and using pulsar-rs as driver for producers and consumers (streamnative/pulsar-rs@5b476d6).
We got in a state where consumers where unable to consume messages as the availablePermits field goes negative in the context of consumers are reading batching messages.
We first think that the issue came from the pulsar-rs driver as we had issues with it, but we already had this issue particularly, fix here streamnative/pulsar-rs@ba58c9c.
So, we dig in closer and goes through the source code of the broker and find something interesting there that may explain what is on going.
// ❯ pulsarctl topics stats <tenant>/<namespace>/<topic> -p
{
"msgRateIn": 8186.440912942124,
"msgRateOut": 11296.304120122804,
"msgThroughputIn": 1386137.2051409963,
"msgThroughputOut": 1908363.7662075842,
"averageMsgSize": 169.3795312743928,
"storageSize": 33094246359,
"publishers": [
...
],
"subscriptions": {
"<subscription>": {
"blockedSubscriptionOnUnackedMsgs": false,
"isReplicated": false,
"lastConsumedFlowTimestamp": 0,
"lastConsumedTimestamp": 0,
"lastAckedTimestamp": 0,
"msgRateOut": 3109.896609295402,
"msgThroughputOut": 522242.73325029423,
"msgRateRedeliver": 0,
"msgRateExpired": 0,
"msgBacklog": 26933368,
"msgBacklogNoDelayed": 26933368,
"msgDelayed": 0,
"unackedMessages": 0,
"type": "Failover",
"activeConsumerName": "",
"consumers": [
{
"blockedConsumerOnUnackedMsgs": false,
"availablePermits": -271, // negative available permits which seems to be always inferior to our producer batch size, here producer batch size is 1024
"unackedMessages": 5271, // unacked messages is always consumer batch size minus negative available permits.
"msgRateOut": 0,
"msgThroughputOut": 0,
"msgRateRedeliver": 0,
"consumerName": "",
"metadata": null
},
...
]
}
},
"replication": {},
"deduplicationStatus": "",
"metadata": {
"partitions": 12
},
"partitions": {}
}
What we found out is that counter is updated at https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java#L422 and its able to go under zero.
It is only updated when receiving a SendFlow messages coming from the consumers located at
Line 300 in 7702bde
| public synchronized void readMoreEntries() { |
As we are consuming in batch mode, sometimes the consumer got stuck with the case above of the
unackedMessages is equals to the batchSize of the consumer less the availablePermits.
We are not sure of what happens and would like a bit of help here, but from what I understand, there is a way of the availablePermits is unable to recover from the negative value?
Error messages
Reproducing the issue
The condition when we see the bug is on a subscription on partitioned topic with 12 partitions taking 10k messages/s continuously, with producer that send batch messages of 1024 messages and consumers that have a batch size at 5k messages. It happens in fail over, shared and key-shared subscription type.
Additional information
Are you willing to submit a PR?
- I'm willing to submit a PR!
Activity
FlorentinDUBOIS commentedon Sep 18, 2025
We found out that the issue involved a pulsar proxy which was lost in garbage collection and do not answering correctly which lead to a blocking state. Rebooting the pulsar proxy solve this issue.