You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/11/10 16:07:04 UTC
[GitHub] [pulsar] AnonHxy opened a new pull request, #18418: [fix][broker] Fix ConcurrentModificationException on LocalBrokerData
AnonHxy opened a new pull request, #18418:
URL: https://github.com/apache/pulsar/pull/18418
Fixes https://github.com/apache/pulsar/issues/18417
### Motivation
Fixes https://github.com/apache/pulsar/issues/18417
### Modifications
Change `bundles` `lastBundleGains` `lastBundleLosses` from `HashSet` to `ConcurrentHashSet`, and remove the setter methods
### Verifying this change
- [x] Make sure that the change passes the CI checks.
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. Please attach the local preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR description, or else your PR might not get merged. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
### Matching PR in forked repository
PR in forked repository: <!-- ENTER URL HERE -->
<!--
After opening this PR, the build in apache/pulsar will fail and instructions will
be provided for opening a PR in the PR author's forked repository.
apache/pulsar pull requests should be first tested in your own fork since the
apache/pulsar CI based on GitHub Actions has constrained resources and quota.
GitHub Actions provides separate quota for pull requests that are executed in
a forked repository.
The tests will be run in the forked repository until all PR review comments have
been handled, the tests pass and the PR is approved by a reviewer.
-->
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] AnonHxy commented on pull request #18418: [fix][test] Fix ConcurrentModificationException in testConcurrentWriteBrokerData
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on PR #18418:
URL: https://github.com/apache/pulsar/pull/18418#issuecomment-1318139436
Updated. PTAL @poorbarcode
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] poorbarcode commented on pull request #18418: [fix][test] Fix ConcurrentModificationException in testConcurrentWriteBrokerData
Posted by GitBox <gi...@apache.org>.
poorbarcode commented on PR #18418:
URL: https://github.com/apache/pulsar/pull/18418#issuecomment-1319584478
> @AnonHxy
> Updated. PTAL @poorbarcode
Sorry, I've been so busy these days.
LGTM, 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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] AnonHxy commented on pull request #18418: [fix][broker] Fix ConcurrentModificationException in LocalBrokerData
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on PR #18418:
URL: https://github.com/apache/pulsar/pull/18418#issuecomment-1311233652
> In this for each block below: cleaning the collection, and creating new tasks to update the collection. I think this is the root cause of concurrent access.
It make sense to me.
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] AnonHxy commented on a diff in pull request #18418: [fix][broker] Fix ConcurrentModificationException in LocalBrokerData
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on code in PR #18418:
URL: https://github.com/apache/pulsar/pull/18418#discussion_r1019787659
##########
pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/LocalBrokerData.java:
##########
@@ -385,6 +379,7 @@ public Set<String> getBundles() {
return bundles;
}
+ @VisibleForTesting
Review Comment:
Great suggestion. I have updated the test cases using this method and removed this setter. PTAL @poorbarcode
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] AnonHxy commented on pull request #18418: [fix][broker] Fix ConcurrentModificationException in LocalBrokerData
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on PR #18418:
URL: https://github.com/apache/pulsar/pull/18418#issuecomment-1317984026
@poorbarcode do you have any other comments?:)
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] AnonHxy merged pull request #18418: [fix][test] Fix ConcurrentModificationException in testConcurrentWriteBrokerData
Posted by GitBox <gi...@apache.org>.
AnonHxy merged PR #18418:
URL: https://github.com/apache/pulsar/pull/18418
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] codecov-commenter commented on pull request #18418: [fix][test] Fix ConcurrentModificationException in testConcurrentWriteBrokerData
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #18418:
URL: https://github.com/apache/pulsar/pull/18418#issuecomment-1318153213
# [Codecov](https://codecov.io/gh/apache/pulsar/pull/18418?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 [#18418](https://codecov.io/gh/apache/pulsar/pull/18418?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e1ffdeb) into [master](https://codecov.io/gh/apache/pulsar/commit/27186a1ee9298802a12f1d42f9bba03d8f3eea77?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (27186a1) will **decrease** coverage by `8.80%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/pulsar/pull/18418?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #18418 +/- ##
============================================
- Coverage 45.61% 36.81% -8.81%
+ Complexity 10728 1949 -8779
============================================
Files 752 208 -544
Lines 72521 14426 -58095
Branches 7791 1582 -6209
============================================
- Hits 33083 5311 -27772
+ Misses 35769 8522 -27247
+ Partials 3669 593 -3076
```
| Flag | Coverage Δ | |
|---|---|---|
| unittests | `36.81% <ø> (-8.81%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pulsar/pull/18418?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...pache/pulsar/client/impl/schema/ByteBufSchema.java](https://codecov.io/gh/apache/pulsar/pull/18418/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-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL3NjaGVtYS9CeXRlQnVmU2NoZW1hLmphdmE=) | `68.75% <0.00%> (-31.25%)` | :arrow_down: |
| [...pulsar/client/impl/schema/LocalDateTimeSchema.java](https://codecov.io/gh/apache/pulsar/pull/18418/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-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL3NjaGVtYS9Mb2NhbERhdGVUaW1lU2NoZW1hLmphdmE=) | `76.92% <0.00%> (-23.08%)` | :arrow_down: |
| [...g/apache/pulsar/client/impl/schema/ByteSchema.java](https://codecov.io/gh/apache/pulsar/pull/18418/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-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL3NjaGVtYS9CeXRlU2NoZW1hLmphdmE=) | `50.00% <0.00%> (-19.24%)` | :arrow_down: |
| [...he/pulsar/client/impl/schema/ByteBufferSchema.java](https://codecov.io/gh/apache/pulsar/pull/18418/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-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL3NjaGVtYS9CeXRlQnVmZmVyU2NoZW1hLmphdmE=) | `43.33% <0.00%> (-16.67%)` | :arrow_down: |
| [...apache/pulsar/client/impl/schema/StringSchema.java](https://codecov.io/gh/apache/pulsar/pull/18418/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-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL3NjaGVtYS9TdHJpbmdTY2hlbWEuamF2YQ==) | `78.26% <0.00%> (-13.05%)` | :arrow_down: |
| [.../apache/pulsar/client/impl/schema/BytesSchema.java](https://codecov.io/gh/apache/pulsar/pull/18418/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-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL3NjaGVtYS9CeXRlc1NjaGVtYS5qYXZh) | `88.23% <0.00%> (-11.77%)` | :arrow_down: |
| [...g/apache/pulsar/client/impl/ConnectionHandler.java](https://codecov.io/gh/apache/pulsar/pull/18418/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-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL0Nvbm5lY3Rpb25IYW5kbGVyLmphdmE=) | `50.00% <0.00%> (-5.32%)` | :arrow_down: |
| [...he/pulsar/client/impl/MultiTopicsConsumerImpl.java](https://codecov.io/gh/apache/pulsar/pull/18418/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-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL011bHRpVG9waWNzQ29uc3VtZXJJbXBsLmphdmE=) | `22.26% <0.00%> (-0.70%)` | :arrow_down: |
| [...va/org/apache/pulsar/client/impl/ConsumerImpl.java](https://codecov.io/gh/apache/pulsar/pull/18418/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-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL0NvbnN1bWVySW1wbC5qYXZh) | `14.84% <0.00%> (-0.21%)` | :arrow_down: |
| [.../java/org/apache/pulsar/client/impl/ClientCnx.java](https://codecov.io/gh/apache/pulsar/pull/18418/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-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL0NsaWVudENueC5qYXZh) | `29.97% <0.00%> (-0.20%)` | :arrow_down: |
| ... and [558 more](https://codecov.io/gh/apache/pulsar/pull/18418/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) | |
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] poorbarcode commented on pull request #18418: [fix][broker] Fix ConcurrentModificationException in LocalBrokerData
Posted by GitBox <gi...@apache.org>.
poorbarcode commented on PR #18418:
URL: https://github.com/apache/pulsar/pull/18418#issuecomment-1318059846
Hi @AnonHxy
> It make sense to me. It seems that we could just remove the following from the test case, and keep others unchanged
```
LocalBrokerData data = loadManager.getLoadManager().updateLocalBrokerData();
data.cleanDeltas();
data.getBundles().clear();
```
> WDYT @poorbarcode
I don't know why `data.clear` should executed in this place (-_-)
> @poorbarcode do you have any other comments?:)
I think the concurrent operation was caused by the test case, so there is no need to change the collection to be thread-safe.
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] poorbarcode commented on a diff in pull request #18418: [fix][broker] Fix ConcurrentModificationException in LocalBrokerData
Posted by GitBox <gi...@apache.org>.
poorbarcode commented on code in PR #18418:
URL: https://github.com/apache/pulsar/pull/18418#discussion_r1019756547
##########
pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/LocalBrokerData.java:
##########
@@ -385,6 +379,7 @@ public Set<String> getBundles() {
return bundles;
}
+ @VisibleForTesting
Review Comment:
Should we remove this line?
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] nodece commented on a diff in pull request #18418: [fix][broker] Fix ConcurrentModificationException in LocalBrokerData
Posted by GitBox <gi...@apache.org>.
nodece commented on code in PR #18418:
URL: https://github.com/apache/pulsar/pull/18418#discussion_r1023483009
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedderTest.java:
##########
@@ -79,7 +78,7 @@ public void testBrokerNotReachThreshold() {
broker1.setDirectMemory(new ResourceUsage(5000, 100));
broker1.setBandwidthIn(new ResourceUsage(500, 1000));
broker1.setBandwidthOut(new ResourceUsage(500, 1000));
- broker1.setBundles(Sets.newHashSet("bundle-1"));
+ broker1.getBundles().add("bundle-1");
Review Comment:
Same above.
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedderTest.java:
##########
@@ -99,7 +98,7 @@ public void testBrokerWithSingleBundle() {
LocalBrokerData broker1 = new LocalBrokerData();
broker1.setBandwidthIn(new ResourceUsage(999, 1000));
broker1.setBandwidthOut(new ResourceUsage(999, 1000));
- broker1.setBundles(Sets.newHashSet("bundle-1"));
+ broker1.getBundles().add("bundle-1");
Review Comment:
Same above.
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] AnonHxy commented on pull request #18418: [fix][broker] Fix ConcurrentModificationException in LocalBrokerData
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on PR #18418:
URL: https://github.com/apache/pulsar/pull/18418#issuecomment-1311195729
> Normally, all three variables run in a lock block. I think the root cause is here:
>
> https://github.com/apache/pulsar/blob/da64346de46638aadcaec43fe530dfe9e8a97141/pulsar-broker/src/test/java/org/apache/pulsar/client/api/BrokerServiceLookupTest.java#L222-L223
It's interesting. The 'bundles' has clear before submitting to the thread pool, it maybe that other threads didn't see the clear action immediately?
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] AnonHxy commented on a diff in pull request #18418: [fix][broker] Fix ConcurrentModificationException in LocalBrokerData
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on code in PR #18418:
URL: https://github.com/apache/pulsar/pull/18418#discussion_r1023764243
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedderTest.java:
##########
@@ -69,7 +68,7 @@ public void testBrokerNotOverloaded() {
LocalBrokerData broker1 = new LocalBrokerData();
broker1.setBandwidthIn(new ResourceUsage(500, 1000));
broker1.setBandwidthOut(new ResourceUsage(500, 1000));
- broker1.setBundles(Sets.newHashSet("bundle-1"));
+ broker1.getBundles().add("bundle-1");
Review Comment:
Nice catch. Updated. PTAL @nodece
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] nodece commented on a diff in pull request #18418: [fix][broker] Fix ConcurrentModificationException in LocalBrokerData
Posted by GitBox <gi...@apache.org>.
nodece commented on code in PR #18418:
URL: https://github.com/apache/pulsar/pull/18418#discussion_r1023482907
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedderTest.java:
##########
@@ -69,7 +68,7 @@ public void testBrokerNotOverloaded() {
LocalBrokerData broker1 = new LocalBrokerData();
broker1.setBandwidthIn(new ResourceUsage(500, 1000));
broker1.setBandwidthOut(new ResourceUsage(500, 1000));
- broker1.setBundles(Sets.newHashSet("bundle-1"));
+ broker1.getBundles().add("bundle-1");
Review Comment:
It looks like you need to clear this bundle, and then add the `bundle-1`.
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedderTest.java:
##########
@@ -90,7 +89,7 @@ public void testBrokerWithSingleBundle() {
LocalBrokerData broker1 = new LocalBrokerData();
broker1.setBandwidthIn(new ResourceUsage(999, 1000));
broker1.setBandwidthOut(new ResourceUsage(999, 1000));
- broker1.setBundles(Sets.newHashSet("bundle-1"));
+ broker1.getBundles().add("bundle-1");
Review Comment:
Same above.
--
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@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org