You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/04/25 17:43:40 UTC

[GitHub] [rocketmq] dugenkui03 commented on pull request #4097: [ISSUE #4096]Read consistent service state

dugenkui03 commented on PR #4097:
URL: https://github.com/apache/rocketmq/pull/4097#issuecomment-1108858642

   > They are not shared objects, If there is a thread-safety problem, it is probably the wrong way to use it.
   
   Thanks for your review. I convert this pr to draft and I think I need more information discuss in https://github.com/apache/rocketmq/issues/3066.
   
   #### In Chinese
   感谢你的review,我暂时将这个PR设置为 draft。
   
   其实我理解这是个很简单的问题,即这些类对`serviceState`的可见性和线程安全性作出了什么承诺、即获取这些类对象的代码是否需要额外的同步策略才能够访问到最新的和有效的`serviceState`值。
   
   基于这些类中的`#start()`和`#shutdown()` 方法都有对`serviceState`的 check-then-action 操作,而且加了锁,所以我认为这些类对该状态的访问是承诺了线程安全性、即不加锁也能读取到最新的**有效值**。
   
   但是当前保证`serviceState`可见性和对其进行 check-then-action 操作的同步策略似乎有些冲突:加锁已经可以保证可见性了、无需volatile。我先去了解你之前跟我说的https://github.com/apache/rocketmq/issues/3066 中讨论
   


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org