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

   Previously, `isConsumed` was not volatile and `drain()` set `isConsumed = 
true` before the `position` was updated. In the window between `drain()` and 
the `position` update, the background thread could race in, observe 
**_isConsumed == true but read a stale position_**, leading to duplicate fetch 
requests with the old offset.
   
   This PR declares `isConsumed` as volatile and reorders the operations so 
that the subscription `position` is always updated before `drain()` sets 
`isConsumed = true,` ensuring the background thread always sees the `updated 
position` when it observes `isConsumed == true`.


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