-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix][broker]Fix ConcurrentModificationException when ModularLoadManagerImpl start #16953
[fix][broker]Fix ConcurrentModificationException when ModularLoadManagerImpl start #16953
Conversation
/pulsarbot run-failure-checks |
@@ -197,7 +197,7 @@ public class ModularLoadManagerImpl implements ModularLoadManager { | |||
private long unloadBundleCount = 0; | |||
|
|||
private final Lock lock = new ReentrantLock(); | |||
private Set<String> knownBrokers = new HashSet<>(); | |||
private Set<String> knownBrokers = ConcurrentHashMap.newKeySet(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can move this line below to method start
and add some code comments, this could solves the concurrency problem.
Line 249 in 7650612
pulsar.getLocalMetadataStore().registerListener(this::handleDataNotification); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleDataNotification
also has other actions, so we'd better keep it in init
method I think @poorbarcode
@poorbarcode Could you do the final review? |
OK. Approved |
…apache#16953) (cherry picked from commit b516ed9)
…apache#16953) (cherry picked from commit b516ed9)
Fixes #16952
Motivation
ModularLoadManagerImpl#knownBrokers
can be modified in multi-thread throughModularLoadManagerImpl#updateAll
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java
Lines 282 to 292 in 5c09d53
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java
Lines 938 to 970 in 5c09d53
Modifications
ModularLoadManagerImpl#knownBrokers
toConcurrentHashMap.newKeySet()
Verifying this change
Documentation
Check the box below or label this PR directly.
Need to update docs?
doc-required
(Your PR needs to update docs and you will update later)
doc-not-needed
(Please explain why)
doc
(Your PR contains doc changes)
doc-complete
(Docs have been already added)