github-vet / github-vet/rangeloop-pointer-findings
youzan/nsq: consistence/nsqlookup_coord_api.go; 16 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [youzan/nsq](https://www.github.com/youzan/nsq) at [consistence/nsqlookup_coord_api.go](https://github.com/youzan/nsq/blob/18884a6505fb6ab8cfe9d496f3d3e2081e26d201/consistence/nsqlookup_coord_api.go#L128-L143)
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 topicInfo at line 135 may start a goroutine
[Click here to see the code in its original context.](https://github.com/youzan/nsq/blob/18884a6505fb6ab8cfe9d496f3d3e2081e26d201/consistence/nsqlookup_coord_api.go#L128-L143)
Click here to show the 16 line(s) of Go which triggered the analyzer.
```go
for _, topicInfo := range topics {
retry := 0
for retry < 3 {
retry++
leaderSession, err := nlcoord.leadership.GetTopicLeaderSession(topicInfo.Name, topicInfo.Partition)
if err != nil {
coordLog.Infof("failed to get topic %v leader session: %v", topicInfo.GetTopicDesp(), err)
nlcoord.notifyISRTopicMetaInfo(&topicInfo)
nlcoord.notifyAcquireTopicLeader(&topicInfo)
time.Sleep(time.Millisecond * 100)
} else {
nlcoord.notifyTopicLeaderSession(&topicInfo, leaderSession, "")
break
}
}
}
```
Click here to show extra information the analyzer produced.
```
The following paths through the callgraph could lead to a goroutine:
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (updateTopicLeaderSession, 3)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (notifyTopicsToSingleNsqdForReload, 2) -> (notifySingleNsqdForTopicReload, 2) -> (sendTopicLeaderSessionToNsqd, 5)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (watchTopics, 0)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (DeleteExistingChannel, 1) -> (CloseExistingChannel, 2)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (doCheckTopics, 5) -> (handleRemoveCatchupNodes, 1)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (NewChannel, 14)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (notifyAllNsqdsForTopicReload, 1) -> (notifyTopicLeaderSession, 3) -> (sendTopicLeaderSessionToNsqd, 5)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (notifyAllNsqdsForTopicReload, 1) -> (notifyTopicLeaderSession, 3) -> (sendTopicLeaderSessionToNsqd, 5) -> (doNotifyToSingleNsqdNode, 2) -> (resetJoinISRState, 3)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (IOLoop, 1) -> (RemoveAllByPeerId, 1)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (processInFlightQueue, 1) -> (peekAndReqDelayedMessages, 2)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (exit, 1) -> (GetQueueReadEnd, 0) -> (internalGetQueueReadEnd, 0)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (NewFlumeClient, 1)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (processRemovingNodes, 3) -> (handleRemoveTopicNodeOrMoveLeader, 4)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (NewFlumeClient, 1) -> (writeLoop, 0) -> (Printf, 3)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (IOLoop, 1) -> (RemoveAllByPeerId, 1) -> (Write, 3) -> (RemoveTopicProducer, 3)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (IOLoop, 1) -> (RemoveAllByPeerId, 1) -> (Write, 3) -> (RemoveTopicProducer, 3) -> (IsMatch, 3) -> (IsAllowed, 2) -> (HasPermission, 1)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (DisableConsume, 1)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (CloseExistingChannel, 2)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (WatchNsqdNodes, 2)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (notifyAllNsqdsForTopicReload, 1)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (doCheckTopics, 5) -> (handleRemoveCatchupNodes, 1) -> (UpdateTopicNodeInfo, 4)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (rebalanceTopNTopicsByLoad, 4) -> (addToCatchupAndWaitISRReady, 8) -> (tryMoveTopicPartition, 7)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (balanceTopicLeaderBetweenNodes, 7) -> (GetSortedTopicWriteLevel, 1) -> (GetTopicLoadFactor, 1)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (IOLoop, 1)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (doCheckTopics, 5)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (notifyTopicsToSingleNsqdForReload, 2) -> (notifySingleNsqdForTopicReload, 2)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (notifyAllNsqdsForTopicReload, 1) -> (notifyTopicLeaderSession, 3)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (notifyTopicsToSingleNsqdForReload, 2) -> (notifySingleNsqdForTopicReload, 2) -> (sendTopicLeaderSessionToNsqd, 5) -> (initJoinStateAndWait, 3)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (doCheckTopics, 5) -> (handleRemoveCatchupNodes, 1) -> (UpdateTopicNodeInfo, 4) -> (getRebalancedMultiTopicPartitionsFromNameList, 4) -> (resetJoinISRState, 3)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (notifyTopicsToSingleNsqdForReload, 2) -> (notifySingleNsqdForTopicReload, 2) -> (sendTopicLeaderSessionToNsqd, 5) -> (initJoinStateAndWait, 3) -> (waitForFinalSyncedISR, 4) -> (resetJoinISRState, 3)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (updateTopicLeaderSession, 3) -> (syncToNewLeader, 3)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (rebalanceMultiPartTopic, 1) -> (balanceTopicToExpectedISR, 4) -> (handleRemoveTopicNodeOrMoveLeader, 4)
(notifyISRTopicMetaInfo, 1) -> (sendTopicInfoToNsqd, 3) -> (acquireRpcClient, 1) -> (JoinHostPort, 2) -> (Start, 0) -> (persistLoop, 0) -> (persistMetadata, 1) -> (Write, 1) -> (IOLoop, 1) -> (RemoveAllByPeerId, 1) -> (Write, 3) -> (RemoveTopicProducer, 3) -> (IsMatch, 3) -> (IsAllowed, 2) -> (HasPermission, 1) -> (GETV1, 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: 18884a6505fb6ab8cfe9d496f3d3e2081e26d201
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.