chia7712 commented on pull request #8657:
URL: https://github.com/apache/kafka/pull/8657#issuecomment-671749755


   > Both operations are done under the same group lock. If we relax the lock, 
it seems that the condition "all members have joined" may no longer be true 
when we get to DelayedJoin.onComplete() even though that condition was true 
during the DelayedJoin.tryCompleteJoin() check. It's not clear what we should 
do in that case.
   
   Your feedback always makes sense. 👍 
   
   It seems to me the approach has to address following issue.
   
   1. avoid conflicting (multiples) locks
   1. small change (don't introduce complicated mechanism)
   1. keep behavior compatibility (```hasAllMembersJoined``` and 
```onCompleteJoin``` should be included in same lock)
   
   I'd like to add an new method (default implementation is empty body) to 
```DelayedOperation```. The new method is almost  same to ```onComplete``` 
except for that it is executed without locking. Currently, only 
```DelayedJoin``` has to use it.
   
   ```scala
   
     def cleanup(): Unit = {}
   
     private[server] def maybeTryComplete(): Boolean = {
       lock.lock()
       if (try tryComplete() finally lock.unlock()) {
         cleanup()
         true
       } else false  
     }
   
     override def run(): Unit = {
       if (forceComplete()) {
         cleanup()
         onExpiration()
       }
     }
   ```
   


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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to