Skip to content

KAFKA-20423: Fix flakiness of testWakeupWithFetchDataAvailable (More) - #23367

Open
chickenchickenlove wants to merge 1 commit into
apache:trunkfrom
chickenchickenlove:KAFKA-20423-more
Open

KAFKA-20423: Fix flakiness of testWakeupWithFetchDataAvailable (More)#23367
chickenchickenlove wants to merge 1 commit into
apache:trunkfrom
chickenchickenlove:KAFKA-20423-more

Conversation

@chickenchickenlove

Copy link
Copy Markdown
Contributor

The previous PR changed the test to wait until MockClient invokes the completion callback for the fetch response. However, this callback only registers a completion handler in pendingCompletion; it does not guarantee that the fetch data has already been added to the FetchBuffer.

As a result, the following race condition can still occur:

  1. The test worker finishes waiting for fetchResponseCompleted, then verifies the wakeup exception and the position.
  2. After the second consumer.poll(Duration.ZERO) has passed coordinator processing, the heartbeat thread removes the handler from pendingCompletion.
  3. If the heartbeat thread is descheduled before executing the handler, the test worker may observe both the completion queue and the FetchBuffer as empty and return an empty result.
  4. The heartbeat thread then resumes and adds the fetch data to the buffer.

This PR changes the wait condition to fetcher.hasAvailableFetches(), ensuring that fetch data that can actually be returned is present in the buffer before calling wakeup().

This removes the dependency of the subsequent poll's record verification on the timing of the heartbeat thread's completion processing.

@github-actions github-actions Bot added the triage PRs from the community label Sep 5, 2026
@chickenchickenlove chickenchickenlove changed the title KAFKA-20423: Fix flakiness of testWakeupWithFetchDataAvailable- #22364 KAFKA-20423: Fix flakiness of testWakeupWithFetchDataAvailable Sep 5, 2026
@github-actions github-actions Bot added consumer tests Test fixes (including flaky tests) clients small Small PRs labels Sep 5, 2026
@chickenchickenlove chickenchickenlove changed the title KAFKA-20423: Fix flakiness of testWakeupWithFetchDataAvailable KAFKA-20423: Fix flakiness of testWakeupWithFetchDataAvailable (More) Sep 5, 2026
@chickenchickenlove

Copy link
Copy Markdown
Contributor Author

@lianetm
Hi! Sorry for the delayed response. 🙇‍♂️
I've drafted a new PR to address the remaining flakiness in testWakeupWithFetchDataAvailable.
When you get a chance, could you take a look?

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

Labels

clients consumer small Small PRs tests Test fixes (including flaky tests) triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant