github-vet / github-vet/rangeloop-pointer-findings
dfuse-io/dmesh: client/etcd/etcd.go; 26 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [dfuse-io/dmesh](https://www.github.com/dfuse-io/dmesh) at [client/etcd/etcd.go](https://github.com/dfuse-io/dmesh/blob/6a094bb91fca6300af74bf1a0a42abc734b92085/client/etcd/etcd.go#L308-L333)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.
> range-loop variable servicePrefix used in defer or goroutine at line 313
[Click here to see the code in its original context.](https://github.com/dfuse-io/dmesh/blob/6a094bb91fca6300af74bf1a0a42abc734b92085/client/etcd/etcd.go#L308-L333)
Click here to show the 26 line(s) of Go which triggered the analyzer.
```go
for _, servicePrefix := range d.watchServices {
zlog.Debug("Watch Update running now on service", zap.String("service", servicePrefix))
go func() {
initRev := d.initialRevision
zlog.Info("dmesh watching service", zap.String("service_prefix", servicePrefix), zap.Int64("initial_revision", initRev))
// FIXME: We'd need another `for` loop, so `Watch()` is
// restarted when it fails. Or does it need? Would it
// simply retry and continue from where it left off?!
for wresp := range d.client.Watch(d.ctx, servicePrefix, clientv3.WithPrefix(), clientv3.WithRev(initRev)) {
if wresp.Err() != nil {
zlog.Error("failed to track watching", zap.Error(wresp.Err()))
// TODO: make this KILL the whole system?! What,s the failure condition of `Watch.Err()` ?
time.Sleep(10 * time.Second)
continue
}
d.applyUpdates(wresp.Events)
initRev = wresp.Header.Revision
zlog.Debug("dmesh peers updated", zap.Int("peer_count", len(d.allPeers)))
}
}()
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 6a094bb91fca6300af74bf1a0a42abc734b92085
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.