Repository navigation
feat(metadata): add concurrency safety for application-level metadata state (#3353) #3367
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
Merged
Alanxtl
merged 17 commits into
apache:develop
from
jieguo-coder:fix/issue-3353-metadata-concurrency
Jun 25, 2026
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ef8cee4
feat(metadata): add internal RWMutex for MetadataInfo and fix json se…
jieguo-coder 605d0b2
feat(metadata): add lock protection for global registry and instances…
jieguo-coder abf50a7
feat(metadata): fix concurrency safety in listener callbacks and exte…
jieguo-coder 8bc0aaa
style: format import blocks using dubbo-go imports-formatter
jieguo-coder ea83f92
style: format metadata.go and report_instance.go to pass CI
jieguo-coder 0048c16
fix(metadata): resolve data races pointed out in code review
jieguo-coder e65f694
test: fix failing tests and improve unit test coverage
jieguo-coder a7bad03
test: fix testifylint error by avoiding require in goroutines
jieguo-coder 3cf2c5a
fix(metadata): deep copy ServiceInfo to prevent write-on-read data ra…
jieguo-coder 9bf63a0
chore: trigger CI re-run for codecov gpg issue
jieguo-coder 21cedcc
chore: resolve merge conflicts with develop and fix code formatting
jieguo-coder 1bd679e
refactor(metadata): implement no-lock helper to fix data race and avo…
jieguo-coder c77d53a
chore: resolve merge conflict with #3369, integrating deterministic f…
jieguo-coder f8d3248
test: fix compilation error in instance changed listener tests by add…
jieguo-coder d3f571d
fix(metadata): add RLock around global map lookup in RemoveService an…
jieguo-coder 3bf11e4
chore: resolve merge conflicts with #3370, keeping DeepCopy for concu…
jieguo-coder 11cc932
chore: resolve test file conflict by keeping both listener and cache …
jieguo-coder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor(metadata): implement no-lock helper to fix data race and avo…
…id deadlocks in ReplaceExportedServices Signed-off-by: jieguo-coder <1193249232@qq.com>
- Loading branch information
commit 1bd679e52bf944d44e7e0a4686ee80e08a95a692
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[P1] 这里仍然绕过
MetadataInfo.mu直接重置Services和exportedServiceURLs。本 PR 已经让AddService、RemoveService、GetServices、GetExportedServiceURLs通过同一个 mutex 保护这些字段,但ReplaceExportedServices由service_discovery_registry.go调用时会无锁写 map;如果同时有 metadata 读取或实例变更处理在调用GetServices/GetExportedServiceURLs,仍然可能触发 data race 或读到半重建状态。这里需要在函数入口持有写锁,并避免在持锁后直接调用会再次加锁的AddService,可以拆出一个内部 no-lock helper 来复用写入逻辑。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.
好的,我现在使用了内部无锁辅助模式重构逻辑,并提取
addServiceWithoutLock来处理核心映射更新。现在,ReplaceExportedServices在入口获取info.mu.Lock()一次,并在循环中安全地重用辅助函数。