315157973 commented on pull request #9850:
URL: https://github.com/apache/pulsar/pull/9850#issuecomment-795165527


   > > Then there is no thread to modify it, it is "unmodifiable"
   > 
   > "safe publication" is also needed for objects that aren't modified. I 
guess there's an existing way [to achieve "safe 
publication"](https://shipilev.net/blog/2014/safe-public-construction/#_safe_publication)
 in that case?
   
   I understand that you are talking about the visibility of objects to other 
threads in Policies, just like double check locks.
   But this PR is just to fix the thread safety of objects in Policies, such as 
Set and Map. Even if the current HashMap is set to be concurrent, it will only 
solve the problem of concurrent operation of the Map.
   
   If we want to solve the problem of visibility, we can set all internal 
objects to volatile, but it doesn't make much sense. Now all the attributes in 
Policies are objects, and many of them are directly assigned. Does this kind of 
short-lived invisible have a great impact on us? 
   When the user uses the Get method, old data may be read. But writing to zk 
will not be affected. When the version is different, the new policy will be 
read again, then the policy will be modified again, and then written to ZK
   
   If it has a big impact, we can open another Issue to solve the visibility of 
all the objects in the Policy


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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to