github-vet / github-vet/rangeloop-pointer-findings
couchbase/indexing: secondary/indexer/indexer.go; 45 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/indexer.go](https://github.com/couchbase/indexing/blob/c10c28f1e61017748dd0e6c083b2f887ca1faabc/secondary/indexer/indexer.go#L6130-L6174)
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.
> function call which takes a reference to index at line 6169 may start a goroutine
[Click here to see the code in its original context.](https://github.com/couchbase/indexing/blob/c10c28f1e61017748dd0e6c083b2f887ca1faabc/secondary/indexer/indexer.go#L6130-L6174)
Click here to show the 45 line(s) of Go which triggered the analyzer.
```go
for instId, index := range idx.indexInstMap {
if index.Stream == common.MAINT_STREAM &&
index.State != common.INDEX_STATE_DELETED {
//ignore proxy instances as rebalancer will clean those up
if common.IsPartitioned(index.Defn.PartitionScheme) && index.RealInstId != 0 {
continue
}
anyPartnNonNil := false
anyPartnNil := false
if partnMap, ok := idx.indexPartnMap[instId]; ok {
for _, partnInst := range partnMap {
sc := partnInst.Sc
//there is only one slice for now
slice := sc.GetSliceById(0)
infos, err := slice.GetSnapshots()
// TODO: Proper error handling if possible
if err != nil {
panic("Unable read snapinfo -" + err.Error())
}
s := NewSnapshotInfoContainer(infos)
latestSnapInfo := s.GetLatest()
if latestSnapInfo != nil {
anyPartnNonNil = true
} else {
anyPartnNil = true
}
}
}
//if all partns are nil
if anyPartnNil && !anyPartnNonNil {
idx.resetSingleIndexOnRollback(&index, nil)
idx.indexInstMap[instId] = index
updatedInsts = append(updatedInsts, index)
}
}
}
```
Click here to show extra information the analyzer produced.
```
The following graphviz dot graph describes paths through the callgraph that could lead to a function calling a goroutine:
digraph G {
"(resetSingleIndexOnRollback, 2)" -> {}
}
```
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.