You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/10/22 09:19:26 UTC
[GitHub] [rocketmq] codersfarm opened a new issue, #5380: countDownLatch.await in necessary in queryMessage
codersfarm opened a new issue, #5380:
URL: https://github.com/apache/rocketmq/issues/5380

In MQAdminImpl.class, queryMessage method, `CountDownLatch countDownLatch = new CountDownLatch(brokerAddrs.size());` the size is brokerAddrs.size(), and countDownLatch countDown finally. why need this method below `boolean ok = countDownLatch.await(timeoutMillis * 4, TimeUnit.MILLISECONDS);`
--
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: commits-unsubscribe@rocketmq.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] nowinkeyy commented on issue #5380: countDownLatch.await in necessary in queryMessage
Posted by GitBox <gi...@apache.org>.
nowinkeyy commented on issue #5380:
URL: https://github.com/apache/rocketmq/issues/5380#issuecomment-1287695804
The ```finally{}``` will executes whether or not it catches the exception, the method ```boolean ok = countDownLatch.await(timeoutMillis * 4, TimeUnit.MILLISECONDS);``` just used to block thread until countdownLatch goes to zero. If some broker failed, the countdownLatch cann't return to zero, the method ```await()``` will time out and the thread will log.warn.
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] codersfarm commented on issue #5380: countDownLatch.await in necessary in queryMessage
Posted by GitBox <gi...@apache.org>.
codersfarm commented on issue #5380:
URL: https://github.com/apache/rocketmq/issues/5380#issuecomment-1288281664
Thanks. Main thead is blocked by countDownLatch until sub thead complete. The countDownLatch will goes zero, countDownLatch.await(timeoutMillis * 4, TimeUnit.MILLISECONDS) execute immediately. The query this.mQClientFactory.getMQClientAPIImpl().queryMessage(addr, requestHeader, timeoutMillis * 3 is timeoutMillis * 3,and the countDownLatch.await is timeoutMillis * 4.
2022-10-24_090335
2022-10-24_090408
> Hi @codersfarm , IMO, I think the countDownLatch will goes zero whether the broker failed or not. And i think the purpose of this `await()` method is to wait for the for loop to complete so that the `queryResultList` results of querying all brokers can be retrieved. The `queryResultList` is incomplete without the `await()` method waiting for the completion of the for loop.
>
>  
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] nowinkeyy commented on issue #5380: countDownLatch.await in necessary in queryMessage
Posted by GitBox <gi...@apache.org>.
nowinkeyy commented on issue #5380:
URL: https://github.com/apache/rocketmq/issues/5380#issuecomment-1287988182
Hi @codersfarm ,
IMO, I think the countDownLatch will goes zero whether the broker failed or not. And i think the purpose of this ```await()``` method is to wait for the for loop to complete so that the ```queryResultList``` results of querying all brokers can be retrieved.
The ```queryResultList``` is incomplete without the ```await()``` method waiting for the completion of the for loop.


--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] codersfarm commented on issue #5380: countDownLatch.await in necessary in queryMessage
Posted by GitBox <gi...@apache.org>.
codersfarm commented on issue #5380:
URL: https://github.com/apache/rocketmq/issues/5380#issuecomment-1288280929
Thanks. Main thead is blocked by countDownLatch until sub thead complete. The countDownLatch will goes zero, `countDownLatch.await(timeoutMillis * 4, TimeUnit.MILLISECONDS)` execute immediately. The query `this.mQClientFactory.getMQClientAPIImpl().queryMessage(addr, requestHeader, timeoutMillis * 3` is `timeoutMillis * 3`,and the `countDownLatch.await` is `timeoutMillis * 4`.


--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] codersfarm commented on issue #5380: countDownLatch.await in necessary in queryMessage
Posted by GitBox <gi...@apache.org>.
codersfarm commented on issue #5380:
URL: https://github.com/apache/rocketmq/issues/5380#issuecomment-1288095767
Thanks
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] codersfarm commented on issue #5380: countDownLatch.await in necessary in queryMessage
Posted by GitBox <gi...@apache.org>.
codersfarm commented on issue #5380:
URL: https://github.com/apache/rocketmq/issues/5380#issuecomment-1287971054
The countDownLatch‘s size equals brokerAddrs.size(), `finally{}` is in for loop(loop size equals brokerAddrs.size()),when for loop executes the countDownLatch goes zero whether the broker failed or not. Is this right?
- if true, the method `boolean ok = countDownLatch.await(timeoutMillis * 4, TimeUnit.MILLISECONDS);` maybe no use.
- if false, even if the broker failed and countDownLatch>=1, the method will execute 24 seconds. for users query message by eByUniqKey
> The `finally{}` will executes whether or not it catches the exception, the method `boolean ok = countDownLatch.await(timeoutMillis * 4, TimeUnit.MILLISECONDS);` just used to block thread until countdownLatch goes to zero. If some broker failed, the countdownLatch cann't return to zero, the method `await()` will time out and the thread will log.warn.
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] codersfarm closed issue #5380: countDownLatch.await in necessary in queryMessage
Posted by GitBox <gi...@apache.org>.
codersfarm closed issue #5380: countDownLatch.await in necessary in queryMessage
URL: https://github.com/apache/rocketmq/issues/5380
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org