app/vminsert/netstorage: make sure the conn exists before closing it in storageNode.closeBrokenConn

The conn can be missing or already closed during the call to storageNode.closeBrokenConn.
Prevent `nil pointer dereference` panic by verifying whether the conn is already closed.

Thanks to @CH-anhngo for reporting the issue.

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/189
This commit is contained in:
Aliaksandr Valialkin 2019-09-25 10:33:58 +03:00
parent c64fb91a43
commit 73ac7b8dd6

View file

@ -167,6 +167,9 @@ func (sn *storageNode) dial() error {
}
func (sn *storageNode) closeBrokenConn() {
if sn.bc == nil {
return
}
_ = sn.bc.Close()
sn.bc = nil
sn.connectionErrors.Inc()