chickenchickenlove commented on PR #21279:
URL: https://github.com/apache/kafka/pull/21279#issuecomment-3833222866

   > I also found a second race which can cause premature retries, where 
maybeRequestNextBlock reads a stale backoffDeadlineMs and then the in-flight 
request fails.
   
   @squah-confluent 
   Thanks a lot for the careful review and for pointing this out.  🙇‍♂️ 
   You’re right — there’s still another race here that I missed.
   
   If you’re okay with it, I can file an issue and follow up with a separate PR 
for this. If you were already planning to address it yourself, please let me 
know and I’ll hold off!
   
   Also, regarding the fix, I was thinking that reordering the operations as 
follows might address the issue, but we can discuss this further in the next PR.
   
   ```java
   private void maybeRequestNextBlock() {
       if (nextProducerIdBlock.get() != null) 
           return;
   
       if (!requestInFlight.compareAndSet(false, true)) 
           return;
   
       final long retryTimestamp = backoffDeadlineMs.get();
       final long now = time.milliseconds();
   
       if (retryTimestamp != NO_RETRY && now < retryTimestamp) {
           requestInFlight.set(false);
           return;
       }
   
       sendRequest();
   }
   ```


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