Repository navigation
[Issue 1384][consumer] Fix the default nack backoff policy - #1385
Merged
crossoverJie merged 2 commits intoJul 10, 2025
Merged
Conversation
Gilthoniel
commented
Jun 18, 2025
Gilthoniel
force-pushed
the
bugfix/default-nack-backoff
branch
from
July 9, 2025 06:22
f85b6c8 to
0c1d4ed
Compare
Contributor
Author
|
Rebase done to fix the previous issue on master. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR addresses an overflow issue in the default negative-acknowledgement backoff policy by capping the computed backoff to the configured maximum when the shift overflows.
- Change backoff calculation to detect overflow (resulting in zero) and assign max backoff
- Remove unreachable negative-count check
- Extend tests to cover large redelivery counts and overflow scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pulsar/negative_backoff_policy.go | Detect shift overflow, clamp backoff to maxNackTime |
| pulsar/negative_backoff_policy_test.go | Import math, add overflow test cases |
Comments suppressed due to low confidence (3)
pulsar/negative_backoff_policy_test.go:34
- math.MaxUint8 is not defined in the standard
mathpackage, causing a compile error. Use an explicit literal like255or define a constant (e.g.,const maxUint8 = ^uint8(0)) and cast touint32.
assert.Equal(t, 10*time.Minute, defaultNackBackoff.Next(math.MaxUint8))
pulsar/negative_backoff_policy_test.go:35
- math.MaxUint16 is not defined in the standard
mathpackage, causing a compile error. Use an explicit literal like65535or define a constant (e.g.,const maxUint16 = ^uint16(0)) and cast touint32.
assert.Equal(t, 10*time.Minute, defaultNackBackoff.Next(math.MaxUint16))
pulsar/negative_backoff_policy_test.go:36
- math.MaxUint32 is not defined in the standard
mathpackage, causing a compile error. Use^uint32(0)directly or define a constant formath.MaxUint32before use.
assert.Equal(t, 10*time.Minute, defaultNackBackoff.Next(math.MaxUint32))
Co-authored-by: Copilot <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1384
Motivation
Once the redelivery count is high enough, the backoff time overflows to zero causing immediate redelivery.
Modifications
Check for the overflow to assign the max backoff time in that case.
Verifying this change
This change is already covered by existing tests, such as:
TestDefaultNackBackoffPolicy_Nextwith failing cases added.Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation