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/12/16 06:27:38 UTC

[GitHub] [rocketmq] xiaoyifang opened a new pull request, #5713: [ISSUE #5710] optimize ServiceThread's waitForRunning logic

xiaoyifang opened a new pull request, #5713:
URL: https://github.com/apache/rocketmq/pull/5713

   replace CountDownLatch2 with Condition
   
   
   **Make sure set the target branch to `develop`**
   
   ## What is the purpose of the change
   
   fix #5710 
   
   ## Brief changelog
   
   XX
   
   ## Verifying this change
   
   XXXX
   
   Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
   
   - [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue. 
   - [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/rocketmq/tree/master/test).
   - [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test`  to make sure integration-test pass.
   - [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
   


-- 
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] xiaoyifang commented on pull request #5713: [ISSUE #5710] optimize ServiceThread's waitForRunning logic

Posted by GitBox <gi...@apache.org>.
xiaoyifang commented on PR #5713:
URL: https://github.com/apache/rocketmq/pull/5713#issuecomment-1358717527

   In the future edition , 
   I think `hasNotified` can be removed and use `isStop` instead. these two variables share some common senarios.
   
   pesudocode:
   `
   if(!isStop){
   await(N,millionseconds)
   }
   `
   
    This can be in a new PR.


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


Re: [PR] [ISSUE #5710] optimize ServiceThread's waitForRunning logic [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #5713:
URL: https://github.com/apache/rocketmq/pull/5713#issuecomment-1868394318

   This PR was closed because it has been inactive for 3 days since being marked as stale.


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


Re: [PR] [ISSUE #5710] optimize ServiceThread's waitForRunning logic [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #5713: [ISSUE #5710] optimize ServiceThread's waitForRunning logic
URL: https://github.com/apache/rocketmq/pull/5713


-- 
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] xiaoyifang commented on a diff in pull request #5713: [ISSUE #5710] optimize ServiceThread's waitForRunning logic

Posted by GitBox <gi...@apache.org>.
xiaoyifang commented on code in PR #5713:
URL: https://github.com/apache/rocketmq/pull/5713#discussion_r1052778499


##########
common/src/main/java/org/apache/rocketmq/common/ServiceThread.java:
##########
@@ -133,13 +149,17 @@ protected void waitForRunning(long interval) {
         }
 
         //entry to wait
-        waitPoint.reset();
-
+        lock.lock();
         try {
-            waitPoint.await(interval, TimeUnit.MILLISECONDS);
+            if (!hasNotified.get())
+            {
+                //ignore return value
+                waitPoint.await(interval, TimeUnit.MILLISECONDS);
+            }
         } catch (InterruptedException e) {
             log.error("Interrupted", e);
         } finally {
+            lock.unlock();

Review Comment:
   After carefully thinking ,I think you may be right.
   fixed.



-- 
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] fuyou001 commented on a diff in pull request #5713: [ISSUE #5710] optimize ServiceThread's waitForRunning logic

Posted by GitBox <gi...@apache.org>.
fuyou001 commented on code in PR #5713:
URL: https://github.com/apache/rocketmq/pull/5713#discussion_r1051948958


##########
common/src/main/java/org/apache/rocketmq/common/ServiceThread.java:
##########
@@ -133,13 +149,17 @@ protected void waitForRunning(long interval) {
         }
 
         //entry to wait
-        waitPoint.reset();
-
+        lock.lock();
         try {
-            waitPoint.await(interval, TimeUnit.MILLISECONDS);
+            if (!hasNotified.get())
+            {
+                //ignore return value
+                waitPoint.await(interval, TimeUnit.MILLISECONDS);
+            }
         } catch (InterruptedException e) {
             log.error("Interrupted", e);
         } finally {
+            lock.unlock();

Review Comment:
    hasNotified.set(false); 
   lock.unlock();
   
   if first unlock,may be miss a wait 
            



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


Re: [PR] [ISSUE #5710] optimize ServiceThread's waitForRunning logic [rocketmq]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #5713:
URL: https://github.com/apache/rocketmq/pull/5713#issuecomment-1865298700

   This PR is stale because it has been open for 365 days with no activity. It will be closed in 3 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this PR.


-- 
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] codecov-commenter commented on pull request #5713: [ISSUE #5710] optimize ServiceThread's waitForRunning logic

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #5713:
URL: https://github.com/apache/rocketmq/pull/5713#issuecomment-1354296809

   # [Codecov](https://codecov.io/gh/apache/rocketmq/pull/5713?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#5713](https://codecov.io/gh/apache/rocketmq/pull/5713?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a0b6337) into [develop](https://codecov.io/gh/apache/rocketmq/commit/aa7a442505ac012d1bc61b89bf10c41646a15005?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (aa7a442) will **increase** coverage by `0.09%`.
   > The diff coverage is `85.71%`.
   
   > :exclamation: Current head a0b6337 differs from pull request most recent head c326c0f. Consider uploading reports for the commit c326c0f to get more accurate results
   
   ```diff
   @@              Coverage Diff              @@
   ##             develop    #5713      +/-   ##
   =============================================
   + Coverage      42.35%   42.44%   +0.09%     
   - Complexity      8192     8205      +13     
   =============================================
     Files           1060     1059       -1     
     Lines          73108    73086      -22     
     Branches        9586     9582       -4     
   =============================================
   + Hits           30962    31023      +61     
   + Misses         38234    38147      -87     
   - Partials        3912     3916       +4     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/rocketmq/pull/5713?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...main/java/org/apache/rocketmq/store/CommitLog.java](https://codecov.io/gh/apache/rocketmq/pull/5713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL0NvbW1pdExvZy5qYXZh) | `65.30% <0.00%> (-0.11%)` | :arrow_down: |
   | [...java/org/apache/rocketmq/common/ServiceThread.java](https://codecov.io/gh/apache/rocketmq/pull/5713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb21tb24vU2VydmljZVRocmVhZC5qYXZh) | `82.27% <92.30%> (+0.33%)` | :arrow_up: |
   | [...tmq/remoting/protocol/body/ConsumerConnection.java](https://codecov.io/gh/apache/rocketmq/pull/5713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cmVtb3Rpbmcvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3JlbW90aW5nL3Byb3RvY29sL2JvZHkvQ29uc3VtZXJDb25uZWN0aW9uLmphdmE=) | `95.83% <0.00%> (-4.17%)` | :arrow_down: |
   | [...controller/impl/DefaultBrokerHeartbeatManager.java](https://codecov.io/gh/apache/rocketmq/pull/5713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcm9ja2V0bXEvY29udHJvbGxlci9pbXBsL0RlZmF1bHRCcm9rZXJIZWFydGJlYXRNYW5hZ2VyLmphdmE=) | `74.41% <0.00%> (-3.49%)` | :arrow_down: |
   | [...rocketmq/common/message/MessageClientIDSetter.java](https://codecov.io/gh/apache/rocketmq/pull/5713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb21tb24vbWVzc2FnZS9NZXNzYWdlQ2xpZW50SURTZXR0ZXIuamF2YQ==) | `71.42% <0.00%> (-2.39%)` | :arrow_down: |
   | [...che/rocketmq/container/BrokerContainerStartup.java](https://codecov.io/gh/apache/rocketmq/pull/5713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29udGFpbmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb250YWluZXIvQnJva2VyQ29udGFpbmVyU3RhcnR1cC5qYXZh) | `53.94% <0.00%> (-2.20%)` | :arrow_down: |
   | [...ache/rocketmq/proxy/common/ReceiptHandleGroup.java](https://codecov.io/gh/apache/rocketmq/pull/5713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3Byb3h5L2NvbW1vbi9SZWNlaXB0SGFuZGxlR3JvdXAuamF2YQ==) | `65.30% <0.00%> (-2.05%)` | :arrow_down: |
   | [...apache/rocketmq/store/ha/GroupTransferService.java](https://codecov.io/gh/apache/rocketmq/pull/5713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL2hhL0dyb3VwVHJhbnNmZXJTZXJ2aWNlLmphdmE=) | `92.30% <0.00%> (-1.29%)` | :arrow_down: |
   | [.../apache/rocketmq/store/ha/DefaultHAConnection.java](https://codecov.io/gh/apache/rocketmq/pull/5713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL2hhL0RlZmF1bHRIQUNvbm5lY3Rpb24uamF2YQ==) | `65.86% <0.00%> (-1.21%)` | :arrow_down: |
   | [...tmq/namesrv/processor/DefaultRequestProcessor.java](https://codecov.io/gh/apache/rocketmq/pull/5713/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bmFtZXNydi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcm9ja2V0bXEvbmFtZXNydi9wcm9jZXNzb3IvRGVmYXVsdFJlcXVlc3RQcm9jZXNzb3IuamF2YQ==) | `59.00% <0.00%> (-1.11%)` | :arrow_down: |
   | ... and [25 more](https://codecov.io/gh/apache/rocketmq/pull/5713/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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] xiaoyifang commented on a diff in pull request #5713: [ISSUE #5710] optimize ServiceThread's waitForRunning logic

Posted by GitBox <gi...@apache.org>.
xiaoyifang commented on code in PR #5713:
URL: https://github.com/apache/rocketmq/pull/5713#discussion_r1052014487


##########
common/src/main/java/org/apache/rocketmq/common/ServiceThread.java:
##########
@@ -133,13 +149,17 @@ protected void waitForRunning(long interval) {
         }
 
         //entry to wait
-        waitPoint.reset();
-
+        lock.lock();
         try {
-            waitPoint.await(interval, TimeUnit.MILLISECONDS);
+            if (!hasNotified.get())
+            {
+                //ignore return value
+                waitPoint.await(interval, TimeUnit.MILLISECONDS);
+            }
         } catch (InterruptedException e) {
             log.error("Interrupted", e);
         } finally {
+            lock.unlock();

Review Comment:
   can you show me a more detailed execution order.
   
   should this line `if (!hasNotified.get())` be enough?
   



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