Skip to content
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

DefaultRegistryServer#handlePublish(...)并发问题 #108

Open
anyoptional opened this issue Sep 26, 2021 · 2 comments
Open

DefaultRegistryServer#handlePublish(...)并发问题 #108

anyoptional opened this issue Sep 26, 2021 · 2 comments

Comments

@anyoptional
Copy link

Your question

DefaultRegistryServer#handlePublish(...)方法中提到putIfAbsent和config.newVersion()需要是原子操作, 所以需要加锁。按照我的理解,if (config.getConfig().putIfAbsent(meta.getAddress(), meta) == null) 这一步已经是原子操作了,相应地保证了 config.newVersion() 不会被执行多次,是不是这里不需要加锁呢?

Your scenes

Describe your use scenes (why need this feature)

Your advice

Describe the advice or solution you'd like

Environment

  • Jupiter version: Jupiter 1.3.1
  • JVM version (e.g. java -version): java 8
  • OS version (e.g. uname -a): Windows
  • Maven version: 3.6.0
  • IDE version: IDEA 2021
@fengjiachun
Copy link
Owner

你好,看了下,代码有点久远不太想的起来当时的意图,不过你说的应该是对的,不需要加锁
可能有一点影响: version 是 config 粒度的,会导致 version 和原来的行为有差别

@anyoptional
Copy link
Author

你好,看了下,代码有点久远不太想的起来当时的意图,不过你说的应该是对的,不需要加锁
可能有一点影响: version 是 config 粒度的,会导致 version 和原来的行为有差别

因为目前只看了代码库中注册中心部分,RPC还没来得及看,理解得可能比较片面。感谢解答。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants