github-vet / github-vet/rangeloop-pointer-findings
couchbase/indexing: secondary/indexer/cluster_manager_agent.go; 48 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [couchbase/indexing](https://www.github.com/couchbase/indexing) at [secondary/indexer/cluster_manager_agent.go](https://github.com/couchbase/indexing/blob/c10c28f1e61017748dd0e6c083b2f887ca1faabc/secondary/indexer/cluster_manager_agent.go#L198-L245)
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 index used in defer or goroutine at line 234
[Click here to see the code in its original context.](https://github.com/couchbase/indexing/blob/c10c28f1e61017748dd0e6c083b2f887ca1faabc/secondary/indexer/cluster_manager_agent.go#L198-L245)
Click here to show the 48 line(s) of Go which triggered the analyzer.
```go
for _, index := range indexList {
updatedState := common.INDEX_STATE_NIL
updatedStream := common.NIL_STREAM
updatedError := ""
updatedRState := common.REBAL_NIL
updatedPartitions := []uint64(nil)
updatedVersions := []int(nil)
updatedInstVersion := -1
if updatedFields.state {
updatedState = index.State
}
if updatedFields.stream {
updatedStream = index.Stream
}
if updatedFields.err {
updatedError = index.Error
}
if updatedFields.rstate {
updatedRState = index.RState
}
if updatedFields.partitions {
for _, partition := range index.Pc.GetAllPartitions() {
updatedPartitions = append(updatedPartitions, uint64(partition.GetPartitionId()))
updatedVersions = append(updatedVersions, int(partition.GetVersion()))
}
}
if updatedFields.version {
updatedInstVersion = index.Version
}
updatedBuildTs := index.BuildTs
var err error
if syncUpdate {
go func() {
err = c.mgr.UpdateIndexInstanceSync(index.Defn.Bucket, index.Defn.Scope, index.Defn.Collection,
index.Defn.DefnId, index.InstId, updatedState, updatedStream, updatedError, updatedBuildTs,
updatedRState, updatedPartitions, updatedVersions, updatedInstVersion)
respCh <- err
}()
} else {
err = c.mgr.UpdateIndexInstance(index.Defn.Bucket, index.Defn.Scope, index.Defn.Collection,
index.Defn.DefnId, index.InstId, updatedState, updatedStream, updatedError, updatedBuildTs,
updatedRState, updatedPartitions, updatedVersions, updatedInstVersion)
}
common.CrashOnError(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: c10c28f1e61017748dd0e6c083b2f887ca1faabc
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.