You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "Aias00 (via GitHub)" <gi...@apache.org> on 2026/07/26 17:18:31 UTC
[PR] fix(registry/etcdv3): guard dataListener.interestedURL with RWMutex [dubbo-go]
Aias00 opened a new pull request, #3545:
URL: https://github.com/apache/dubbo-go/pull/3545
## What
`dataListener.interestedURL` was a plain slice with no lock; `AddInterestedURL` appends from the `DoSubscribe` path while `DataChange` reads it (`slices.ContainsFunc`) on the etcd watch goroutine, racing the slice header.
## Why
```go
// registry/etcdv3/listener.go (before)
type dataListener struct {
interestedURL []*common.URL // no lock
listener config_center.ConfigurationListener
}
func (l *dataListener) AddInterestedURL(url *common.URL) {
l.interestedURL = append(l.interestedURL, url) // DoSubscribe path
}
func (l *dataListener) DataChange(eventType remoting.Event) bool {
...
if slices.ContainsFunc(l.interestedURL, serviceURL.URLEqual) { // etcd watch goroutine
l.listener.Process(...)
}
}
```
Two near-simultaneous `DoSubscribe` calls, or a subscribe concurrent with an incoming etcd watch event, race on the slice header → torn reads, missed event matching. `go test -race` flags it.
## Fix
Add a `sync.RWMutex` to `dataListener`. `AddInterestedURL` takes the write lock; `DataChange` does the `ContainsFunc` check under `RLock`, releases it, then dispatches `Process` outside the lock.
## Tests
Added `Test_dataListener_ConcurrentAddAndDataChange`: 100 rounds of concurrent `AddInterestedURL` vs `DataChange`, passing under `-race`. `registry/etcdv3` passes under `-race`.
Fixes #3544
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix(registry/etcdv3): guard dataListener.interestedURL with RWMutex [dubbo-go]
Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 closed pull request #3545: fix(registry/etcdv3): guard dataListener.interestedURL with RWMutex
URL: https://github.com/apache/dubbo-go/pull/3545
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix(registry/etcdv3): guard dataListener.interestedURL with RWMutex [dubbo-go]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #3545:
URL: https://github.com/apache/dubbo-go/pull/3545#issuecomment-5084574087
## [Codecov](https://app.codecov.io/gh/apache/dubbo-go/pull/3545?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 55.32%. Comparing base ([`60d1c2a`](https://app.codecov.io/gh/apache/dubbo-go/commit/60d1c2a949f0ee0da4be3fe09fb79d295491e040?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`86d0f7e`](https://app.codecov.io/gh/apache/dubbo-go/commit/86d0f7edb47efb3dc53ce91600df3a6f458cebe4?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 875 commits behind head on develop.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## develop #3545 +/- ##
===========================================
+ Coverage 46.76% 55.32% +8.55%
===========================================
Files 295 462 +167
Lines 17172 36002 +18830
===========================================
+ Hits 8031 19918 +11887
- Misses 8287 14527 +6240
- Partials 854 1557 +703
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/dubbo-go/pull/3545?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix(registry/etcdv3): guard dataListener.interestedURL with RWMutex [dubbo-go]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #3545:
URL: https://github.com/apache/dubbo-go/pull/3545#issuecomment-5084562074
## [](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3545) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3545&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3545&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3545&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3545&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3545&metric=new_duplicated_lines_density&view=list)
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3545)
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org