You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2021/12/11 15:32:00 UTC

[GitHub] [rocketmq] XiaoyiPeng commented on pull request #3509: [ISSUE #2516]: Fix the value of sendThreadPoolQueueHeadWaitTimeMills is 0 most of the time

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: dev-unsubscribe@rocketmq.apache.org

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