chickenchickenlove opened a new pull request, #22364:
URL: https://github.com/apache/kafka/pull/22364

   ### Description
   
   I didn't reproduce it in my local. 
   This PR is based on the specific assumptions and fix non-deterministic path 
caused by it.
   
   1. The foreground test thread puts the fetch response into 
`MockClient.responses` via `respondFrom(...)`.
   2. The heartbeat thread enters `MockClient.poll()` first.
   3. The heartbeat thread removes the fetch response from the queue by calling 
`responses.poll()`.
   4. However, it gets descheduled before calling `response.onComplete()`.
   5. The foreground thread calls `client.poll(0, ...)`, but since the response 
queue is empty, it completes nothing and returns.
   6. `consumer.wakeup()` is called.
   7. The first `consumer.poll(Duration.ZERO)` immediately throws 
`WakeupException` from `maybeTriggerWakeup()`.
   8. `consumer.position(tp0)` already has a valid position of 0, so it returns 
0 directly without performing a network poll.
   9. The next `consumer.poll(Duration.ZERO)` also returns empty because the 
response is not yet in `pendingCompletion` and not in the `FetchBuffer` either.
   10. After that, the heartbeat thread wakes up and calls 
`response.onComplete()`, but by then the assertion has already 
   failed.
   
   Although I didn't reproduce it in my local, this scenario make sense to me. 
   Given this, this PR applies the change, and I plan to monitor the CI trend 
afterward to confirm whether the flakiness is resolved.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to