GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Bug] Negative available permits with consumer stuck · Issue #24418 · apache/pulsar

[Bug] Negative available permits with consumer stuck #24418

New issue
Copy link
New issue
Copy link
Closed
Closed
[Bug] Negative available permits with consumer stuck#24418
Copy link
Labels
type/bugThe PR fixed a bug or issue reported a bug

Description

@FlorentinDUBOIS
FlorentinDUBOIS
opened on Jun 16, 2025
Issue body actions

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 main branch.
  • 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

pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumersClassic.java

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

#24298

Are you willing to submit a PR?

  • I'm willing to submit a PR!
Reacted by Alexandre Burgoni and Allemand Sébastien
Reacted by kannar

Activity

  1. FlorentinDUBOIS
    added
    type/bugThe PR fixed a bug or issue reported a bug
    on Jun 16, 2025
  2. FlorentinDUBOIS commented on Sep 18, 2025

    @FlorentinDUBOIS
    FlorentinDUBOIS
    on Sep 18, 2025
    ContributorAuthor
    More actions

    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.

  3. FlorentinDUBOIS
    closed this as completedon Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugThe PR fixed a bug or issue reported a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.