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:02 UTC

[I] [BUG] registry/etcdv3: dataListener.interestedURL slice race (no lock) between AddInterestedURL and DataChange [dubbo-go]

Aias00 opened a new issue, #3544:
URL: https://github.com/apache/dubbo-go/issues/3544

   ### Problem
   
   `registry/etcdv3.dataListener.interestedURL` is a plain `[]*common.URL` slice with no lock:
   
   ```go
   // registry/etcdv3/listener.go
   type dataListener struct {
       interestedURL []*common.URL
       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(...)
       }
   }
   ```
   
   `AddInterestedURL` is called from `DoSubscribe` (consumer subscribe path) while `DataChange` runs on the etcd watch goroutine (`ListenServiceEvent`). Concurrent `append` (which may reallocate the slice header) and `slices.ContainsFunc` (which reads the slice header/elements) is a data race. `go test -race` flags it.
   
   ### Current behavior
   
   Two near-simultaneous `DoSubscribe` calls, or a subscribe concurrent with an incoming etcd watch event, race on the `interestedURL` slice header → torn reads, missed event matching, or stale reads dropping events.
   
   ### Expected behavior
   
   `interestedURL` reads and writes must be guarded; `DataChange` must not hold the lock across the external `Process` callback.
   
   ### Suggested approach
   
   - Add a `sync.RWMutex` to `dataListener`.
   - `AddInterestedURL` takes the write lock.
   - `DataChange` does the `slices.ContainsFunc` check under `RLock`, releases it, then dispatches `Process` outside the lock.
   
   ### Acceptance criteria
   
   - [ ] `interestedURL` is accessed under the mutex in both `AddInterestedURL` and `DataChange`.
   - [ ] `DataChange` dispatches `Process` outside the lock.
   - [ ] A concurrency test (concurrent `AddInterestedURL` vs `DataChange`) passes under `-race`.
   


-- 
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.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: [I] [BUG] registry/etcdv3: dataListener.interestedURL slice race (no lock) between AddInterestedURL and DataChange [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl closed issue #3544: [BUG] registry/etcdv3: dataListener.interestedURL slice race (no lock) between AddInterestedURL and DataChange
URL: https://github.com/apache/dubbo-go/issues/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: [I] [BUG] registry/etcdv3: dataListener.interestedURL slice race (no lock) between AddInterestedURL and DataChange [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on issue #3544:
URL: https://github.com/apache/dubbo-go/issues/3544#issuecomment-5086258170

   not planned


-- 
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