github-vet / github-vet/rangeloop-pointer-findings
dgraph-io/dgraph: worker/groups.go; 22 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [dgraph-io/dgraph](https://www.github.com/dgraph-io/dgraph) at [worker/groups.go](https://github.com/dgraph-io/dgraph/blob/613531278666205ad0a7895cacdc971d5dafdd6a/worker/groups.go#L357-L378)
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 member used in defer or goroutine at line 363
[Click here to see the code in its original context.](https://github.com/dgraph-io/dgraph/blob/613531278666205ad0a7895cacdc971d5dafdd6a/worker/groups.go#L357-L378)
Click here to show the 22 line(s) of Go which triggered the analyzer.
```go
for _, member := range g.state.GetRemoved() {
// TODO: This leader check can be done once instead of repeatedly.
if member.GetGroupId() == g.Node.gid && g.Node.AmLeader() {
go func() {
// Don't try to remove a member if it's already marked as removed in
// the membership state and is not a current peer of the node.
_, isPeer := g.Node.Peer(member.GetId())
// isPeer should only be true if the rmeoved node is not the same as this node.
isPeer = isPeer && member.GetId() != g.Node.RaftContext.Id
for _, oldMember := range oldState.GetRemoved() {
if oldMember.GetId() == member.GetId() && !isPeer {
return
}
}
if err := g.Node.ProposePeerRemoval(g.Ctx(), member.GetId()); err != nil {
glog.Errorf("Error while proposing node removal: %+v", err)
}
}()
}
}
```
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: 613531278666205ad0a7895cacdc971d5dafdd6a
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.