Skip to content

Negative acknowledgment not working anymore when value is set to 0 #2214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Chr3is opened this issue Apr 6, 2022 · 5 comments · Fixed by #2215
Closed

Negative acknowledgment not working anymore when value is set to 0 #2214

Chr3is opened this issue Apr 6, 2022 · 5 comments · Fixed by #2215

Comments

@Chr3is
Copy link

Chr3is commented Apr 6, 2022

Version: 2.8.4

Describe the bug

With following commit: a1a5d48#diff-49bc63455f16e2f0b1fe17ed1ec885135d494883d5a21a3da53d031098d09a33R2485
the behavior how the nack in the listener container is handled was changed. Allowed values for nack are >=0. However when setting the value to 0 you will end in an endless partition reseeking because the new introduced method pauseForNackSleep checks the nack value against > 0 and NOT against >= 0. Due to this behavior the nack value is never reset to -1.

To Reproduce
execute acknowledgment.nack(0);

Expected behavior
When setting the value to 0 an endless partition reseeking does not happen.

@garyrussell garyrussell self-assigned this Apr 6, 2022
@garyrussell garyrussell added this to the 3.0.0-M4 milestone Apr 6, 2022
garyrussell added a commit to garyrussell/spring-kafka that referenced this issue Apr 6, 2022
Resolves spring-projects#2214

Regression; manual nack with zero sleep went into a tight loop since
2.8.4.

Add a copy of the current test, with a zero sleep; also verify that
nacking the first and last records work.

**cherry-pick to 2.9.x, 2.8.x**
garyrussell added a commit to garyrussell/spring-kafka that referenced this issue Apr 6, 2022
Resolves spring-projects#2214

Regression; manual nack with zero sleep went into a tight loop since
2.8.4.

Add a copy of the current test, with a zero sleep; also verify that
nacking the first and last records work.

**cherry-pick to 2.9.x, 2.8.x**
artembilan pushed a commit that referenced this issue Apr 6, 2022
Resolves #2214

Regression; manual nack with zero sleep went into a tight loop since
2.8.4.

Add a copy of the current test, with a zero sleep; also verify that
nacking the first and last records work.

**cherry-pick to 2.9.x, 2.8.x**

* Remove unnecessary interceptor from new test.
artembilan pushed a commit that referenced this issue Apr 6, 2022
Resolves #2214

Regression; manual nack with zero sleep went into a tight loop since
2.8.4.

Add a copy of the current test, with a zero sleep; also verify that
nacking the first and last records work.

**cherry-pick to 2.9.x, 2.8.x**

* Remove unnecessary interceptor from new test.
artembilan pushed a commit that referenced this issue Apr 6, 2022
Resolves #2214

Regression; manual nack with zero sleep went into a tight loop since
2.8.4.

Add a copy of the current test, with a zero sleep; also verify that
nacking the first and last records work.

**cherry-pick to 2.9.x, 2.8.x**

* Remove unnecessary interceptor from new test.
@sta-szek
Copy link

sta-szek commented Apr 7, 2022

Hi @garyrussell , @artembilan
how can i check if i am affected? i also do nack(0) - for the very first event and i faced some infinitive loop issue.
we use:

% mvn dependency:tree | grep spring-kafka                                                   
[INFO] |  +- org.springframework.kafka:spring-kafka:jar:2.8.4:compile

is the issue solved / backported to 2.8.4 already?

--- edit
just check sources for 2.8.4 and looks like we are still affected -> i see old code. since which version it is fixed?
and next quesiton ,not sure if you can answer, would be when it will be in spring-boot?
and :) when the issue was introduced? i would like to switch back to "working" version to confirm my issue is exactly this, otherwise i continue investigations

@Chr3is
Copy link
Author

Chr3is commented Apr 7, 2022

@sta-szek this bug was introduced with be4b1bf which was part of the v2.8.4 release (https://github.com/spring-projects/spring-kafka/releases/tag/v2.8.4) - the last working version should be 2.8.3 therefore. You can also "fix this" problem in 2.8.4 by setting the nack value from 0 to 1.

@artembilan
Copy link
Member

This is going to be released as a fix in the next 2.8.5 on April 18th: https://calendar.spring.io/

@sta-szek
Copy link

sta-szek commented Apr 8, 2022

@sta-szek this bug was introduced with be4b1bf which was part of the v2.8.4 release (v2.8.4 (release)) - the last working version should be 2.8.3 therefore. You can also "fix this" problem in 2.8.4 by setting the nack value from 0 to 1.

hi, thanks! indeed.
i switched back to spring-kafka 2.8.3 and the issue gone

however, if i add some events to topic, to avoid nack(0) then in my case the issue still happens in 2.8.4, but its, how to say it, less invasive.

i mean, if i nack(0) then after 1h i have ~200k events repeated.
if i put any event and do nack(x) where x > 0, then i got ~15k events repeated after 1h.

i would be happy to test spring-kafka 2.8.5-SNAPSHOT before release, to make sure the problem is solved fully, how can i do it?

@tomazfernandes
Copy link
Contributor

You can use Spring SNAPSHOT versions by adding the snapshot repositories:

repositories {
    maven {
        url 'https://repo.spring.io/snapshot'
    }
}

dependencies {
    implementation 'org.springframework.kafka:spring-kafka:2.8.5-SNAPSHOT'
} 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment