XiaoyiPeng commented on pull request #3509:
URL: https://github.com/apache/rocketmq/pull/3509#issuecomment-991684075


   > This commit cause critical problem. we should rollback it. And I sugguest 
review PR #3540 again.
   > 
   
   Thanks for your review. @areyouok , @RongtongJin 
   
    I know the reason. This is a potential **Lock Ordering Deadlock** caused by 
`putLock` and `takeLock` of `LinkedBlockingQueue`
   
   The method `offer()` will grab the `LinkedBlockingQueue#putLock` and method 
`remove()` will grab the `LinkedBlockingQueue#takeLock` .
   
    Meanwhile,  in this PR, stream  operation of `LinkedBlockingQueue` will  
invoking `LinkedBlockingQueue#fullyLock()` method in 
`LinkedBlockingQueue$LBQSpliterator#tryAdvance()` as shown below: 
    
   ```java
    public boolean tryAdvance(Consumer<? super E> action) {
               if (action == null) throw new NullPointerException();
               final LinkedBlockingQueue<E> q = this.queue;
               if (!exhausted) {
                   E e = null;
                   q.fullyLock();
                   try {
                       if (current == null)
                           current = q.head.next;
                       while (current != null) {
                           e = current.item;
                           current = current.next;
                           if (e != null)
                               break;
                       }
                   } finally {
                       q.fullyUnlock();
                   }
                   if (current == null)
                       exhausted = true;
                   if (e != null) {
                       action.accept(e);
                       return true;
                   }
               }
               return false;
           }
   ```
   
   I will fix it!


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