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

   - Previous PR - https://github.com/apache/kafka/pull/22364/
   
   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.


-- 
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