-
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
Race condition in PersistentTopic#addReplicationCluster #12723
Comments
I found another interesting thing is that in org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap, if we call Not the same behavior in java.util.concurrent.ConcurrentHashMap, a key with null value will be dismissed. |
I am working on a fix. |
…ster (apache#12729) ### Motivation See apache#12723 ### Modifications Add a method org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap#removeNullValue to remove null value in a thread safe way.
…ster (apache#12729) See apache#12723 Add a method org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap#removeNullValue to remove null value in a thread safe way. (cherry picked from commit a3fe00e) (cherry picked from commit 230e1ac)
…ster (apache#12729) ### Motivation See apache#12723 ### Modifications Add a method org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap#removeNullValue to remove null value in a thread safe way.
Describe the bug
In class
org.apache.pulsar.broker.service.persistent.PersistentTopic
, we have fieldreplicators
of class ConcurrentOpenHashMap. There is a race condiftion in method addReplicationCluster.It's clear that there is a race condition if multi threads would run in this code. For example
Thread A is just about to execute
replicators.remove
, Thread B inserts a non-null PersistentReplicator. Then thread A will delete the PersistentReplicator which thread B just created.And there is no other thread safe measures applied to these code.
Expected behavior
It should be thead safe.
Screenshots
Not applicable.
Desktop (please complete the following information):
Additional context
Nop
The text was updated successfully, but these errors were encountered: