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 — [fix][client] Reschedule the negative ack timer when a nack is due earlier by sakshichitnis27 · Pull Request #27106 · apache/pulsar

Conversation

@sakshichitnis27

@sakshichitnis27 sakshichitnis27 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #27096

Motivation

NegativeAcksTracker.add() only schedules a redelivery timer when none is pending. With a negativeAckRedeliveryBackoff, a message that is nacked later can have a shorter backoff than the message that started the pending timer. It then waits for the later timer instead of being redelivered after its own backoff.

For example, with the default MultiplierRedeliveryBackoff, a message on its 6th redelivery has a 10 minute backoff. A first-time nack that arrives while that timer is pending should be redelivered after 10 seconds, but it is redelivered after about 10 minutes, together with the first message.

Modifications

  • Keep the deadline of the pending timeout. When a nack is due before it, cancel the pending timeout and schedule one for the new nack. Nacks due at the same time or later still share the pending timeout, so the grouping of nacks from PIP-393 is kept. triggerRedelivery already re-arms the timer for the earliest remaining nack after it runs.
  • triggerRedelivery returns early if its timeout is no longer the current one. This covers a task that was already running when its timeout was replaced, and a task that fires after close().
  • Added NegativeAcksTrackerTest.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Added NegativeAcksTrackerTest. One test nacks a message with a 1 hour backoff and then one with a 1 second backoff, and checks that the second one is redelivered within 5 seconds. It fails without the change. The other tests use a mock timer to check that an earlier nack replaces the pending timeout, that same or later nacks reuse it, and that a replaced timeout does not redeliver.
  • Ran ./gradlew :pulsar-client-original:test --tests NegativeAcksTrackerTest, the existing ConsumerImplTest and ConsumerBuilderImplTest, ./gradlew :pulsar-broker:test --tests org.apache.pulsar.client.impl.NegativeAcksTest and ./gradlew quickCheck locally.

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sakshichitnis27
[fix][client] Reschedule the negative ack timer when a nack is due ea…
08066be
…rlier

Assisted-by: Claude Code (claude-sonnet-5-5)
@sakshichitnis27
sakshichitnis27 marked this pull request as ready for review October 25, 2026 09:36
codelipenghui
codelipenghui reviewed Oct 26, 2026
View reviewed changes

@codelipenghui codelipenghui left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One non-blocking suggestion to strengthen the stale-timeout regression test.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-client/src/test/java/org/apache/pulsar/client/impl/NegativeAcksTrackerTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Denovo1998
Denovo1998 approved these changes Oct 27, 2026
View reviewed changes

@Denovo1998 Denovo1998 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks good to me. Tracking the pending timeout deadline and ignoring stale callbacks addresses the earlier-backoff scheduling issue while preserving the existing batching behavior.

I agree with the existing suggestion to strengthen the stale-timeout test by checking for extra scheduling, but I consider it non-blocking.

LGTM, pending CI verification.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@merlimat
merlimat merged commit 8592d33 into apache:master Oct 30, 2026
44 checks passed

Uh oh!

There was an error while loading. Please reload this page.

lhotari pushed a commit that referenced this pull request Nov 2, 2026
@sakshichitnis27 @lhotari
[fix][client] Reschedule the negative ack timer when a nack is due ea…
c782129
…rlier (#27106)

(cherry picked from commit 8592d33)
@lhotari lhotari added release/5.0.2 cherry-picked/branch-5.0 labels Nov 2, 2026
This was referenced Nov 21, 2026
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27680
Closed
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27681
Closed
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27684
Closed
@lhotari lhotari added cherry-picked/branch-4.2 release/4.2.6 cherry-picked/branch-4.0 release/4.0.15 labels Nov 21, 2026
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@sakshichitnis27 @lhotari
[fix][client] Reschedule the negative ack timer when a nack is due ea…
ba98667
…rlier (apache#27106)

(cherry picked from commit 8592d33)
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@sakshichitnis27 @lhotari
[fix][client] Reschedule the negative ack timer when a nack is due ea…
8fcd282
…rlier (apache#27106)

(cherry picked from commit 8592d33)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@codelipenghui codelipenghui codelipenghui left review comments
@Denovo1998 Denovo1998 Denovo1998 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cherry-picked/branch-4.0 cherry-picked/branch-4.2 cherry-picked/branch-5.0 release/4.0.15 release/4.2.6 release/5.0.2

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Bug][client] Negative ack with a redelivery backoff: a short-backoff nack waits for an earlier nack's longer timer

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@sakshichitnis27 @codelipenghui @Denovo1998 @merlimat @lhotari
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.