Skip to content

KAFKA-2632: move fetchable check ahead in handleFetchResponse#295

Closed
guozhangwang wants to merge 3 commits into
apache:trunkfrom
guozhangwang:K2632
Closed

KAFKA-2632: move fetchable check ahead in handleFetchResponse#295
guozhangwang wants to merge 3 commits into
apache:trunkfrom
guozhangwang:K2632

Conversation

@guozhangwang

Copy link
Copy Markdown
Contributor

No description provided.

@ijuma

ijuma commented Oct 11, 2015

Copy link
Copy Markdown
Member

I take it that it's not easy to write a test that shows the issue?

@guozhangwang

Copy link
Copy Markdown
Contributor Author

It is a bit timing-dependent that you need to have an in-flight fetch request going on while calling pause(); this cannot be easily reproduced since consumer.poll() may trigger pollOnce() multiple times.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we still need this check. There may be a rebalance between the time a fetch response is handled and the time it is returned to the user.

@guozhangwang

Copy link
Copy Markdown
Contributor Author

Thanks @hachikuji , comments addressed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't it a little dangerous to assume that the fetch position in the returned record is still relevant? Suppose we have the following sequence:

  1. User calls poll() and we initiate a fetch.
  2. User calls commitSync() (or some other blocking operation) and the fetch returns.
  3. User calls seek() with a new offset.
  4. User calls poll() and now we've written over their seeked offset.

Maybe instead we should reset the fetched position to the consumed position?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@hachikuji I thought about this, but consumed() may return null for the first time so we cannot rely on that value either. Maybe we should just combine these two? I.e.:

If consumed() != null, set to consumed;
otherwise this MUST be the first fetch ever returned before any seek() was called, hence resetting to first offset should be safe.

@hachikuji

Copy link
Copy Markdown
Contributor

LGTM.

@gwenshap

Copy link
Copy Markdown
Contributor

LGTM

@asfgit asfgit closed this in d8c5750 Oct 14, 2015
@guozhangwang
guozhangwang deleted the K2632 branch October 7, 2016 21:46
wyuka pushed a commit to wyuka/kafka that referenced this pull request Mar 4, 2022
…ache#295)

TICKET = N/A
LI_DESCRIPTION =
The testResponseIncludesLeaderEpoch method has been flaky, and sometimes fails with
org.opentest4j.AssertionFailedError: expected: <(10,1)> but was: <(-1,-1)>
        at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:55)
        at org.junit.jupiter.api.AssertionUtils.failNotEqual(AssertionUtils.java:62)
        at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)
        at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:177)
        at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1124)
        at kafka.server.ListOffsetsRequestTest.testResponseIncludesLeaderEpoch(ListOffsetsRequestTest.scala:203)

This PR addresses the flakiness by adding repeated checks for the condition until it is satisfied.

EXIT_CRITERIA = N/A
wyuka pushed a commit to wyuka/kafka that referenced this pull request Mar 28, 2022
…ache#295)

TICKET = N/A
LI_DESCRIPTION =
The testResponseIncludesLeaderEpoch method has been flaky, and sometimes fails with
org.opentest4j.AssertionFailedError: expected: <(10,1)> but was: <(-1,-1)>
        at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:55)
        at org.junit.jupiter.api.AssertionUtils.failNotEqual(AssertionUtils.java:62)
        at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)
        at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:177)
        at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1124)
        at kafka.server.ListOffsetsRequestTest.testResponseIncludesLeaderEpoch(ListOffsetsRequestTest.scala:203)

This PR addresses the flakiness by adding repeated checks for the condition until it is satisfied.

EXIT_CRITERIA = N/A
wyuka pushed a commit to wyuka/kafka that referenced this pull request Jun 16, 2022
…ache#295)

TICKET = N/A
LI_DESCRIPTION =
The testResponseIncludesLeaderEpoch method has been flaky, and sometimes fails with
org.opentest4j.AssertionFailedError: expected: <(10,1)> but was: <(-1,-1)>
        at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:55)
        at org.junit.jupiter.api.AssertionUtils.failNotEqual(AssertionUtils.java:62)
        at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)
        at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:177)
        at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1124)
        at kafka.server.ListOffsetsRequestTest.testResponseIncludesLeaderEpoch(ListOffsetsRequestTest.scala:203)

This PR addresses the flakiness by adding repeated checks for the condition until it is satisfied.

EXIT_CRITERIA = N/A
davide-armand pushed a commit to aiven/kafka that referenced this pull request Dec 1, 2025
jeqo pushed a commit to aiven/kafka that referenced this pull request Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants