You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(metadata): add concurrency safety for application-level metadata state (#3353) (#3367)
* feat(metadata): add internal RWMutex for MetadataInfo and fix json serialization (#3353)
Add sync.RWMutex to MetadataInfo struct with json:"-" / hessian:"-"
tags to skip serialization. All mutating methods (AddService, RemoveService,
AddSubscribeURL, RemoveSubscribeURL) acquire the write lock, and read
methods (GetExportedServiceURLs, GetSubscribedURLs, GetServices) acquire
the read lock. The new GetServices method returns a snapshot copy.
Signed-off-by: jieguo-coder <1193249232@qq.com>
* feat(metadata): add lock protection for global registry and instances (#3353)
Add sync.RWMutex to protect registryMetadataInfo in metadata.go and
instances in report_instance.go. Extract getMetadataReportUnsafe helper
to avoid reentrant RLock deadlock in GetMetadataReportByRegistry fallback.
Fix nacos report_test to use pointer to MetadataInfo for json.Marshal.
Signed-off-by: jieguo-coder <1193249232@qq.com>
* feat(metadata): fix concurrency safety in listener callbacks and external calls (#3353)
Add mutex locking to AddListenerAndNotify and RemoveListener to protect
shared fields listeners and serviceUrls. Replace direct access to
MetadataInfo.Services with safe GetServices method in OnEvent and
convertV2 to prevent unprotected map reads.
Signed-off-by: jieguo-coder <1193249232@qq.com>
* style: format import blocks using dubbo-go imports-formatter
Signed-off-by: jieguo-coder <1193249232@qq.com>
* style: format metadata.go and report_instance.go to pass CI
Signed-off-by: jieguo-coder <1193249232@qq.com>
* fix(metadata): resolve data races pointed out in code review
Signed-off-by: jieguo-coder <1193249232@qq.com>
* test: fix failing tests and improve unit test coverage
Signed-off-by: jieguo-coder <1193249232@qq.com>
* test: fix testifylint error by avoiding require in goroutines
Signed-off-by: jieguo-coder <1193249232@qq.com>
* fix(metadata): deep copy ServiceInfo to prevent write-on-read data race and reduce lock granularity in report creation
Signed-off-by: jieguo-coder <1193249232@qq.com>
* chore: trigger CI re-run for codecov gpg issue
* refactor(metadata): implement no-lock helper to fix data race and avoid deadlocks in ReplaceExportedServices
Signed-off-by: jieguo-coder <1193249232@qq.com>
* test: fix compilation error in instance changed listener tests by adding missing registryId argument
Signed-off-by: jieguo-coder <1193249232@qq.com>
* fix(metadata): add RLock around global map lookup in RemoveService and RemoveSubscribeURL to prevent concurrent map read/write
Signed-off-by: jieguo-coder <1193249232@qq.com>
---------
Signed-off-by: jieguo-coder <1193249232@qq.com>
0 commit comments