From 73ac7b8dd6ace3b96c0e5882320eaa29fb810606 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 25 Sep 2019 10:33:58 +0300 Subject: [PATCH] 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 --- app/vminsert/netstorage/netstorage.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/vminsert/netstorage/netstorage.go b/app/vminsert/netstorage/netstorage.go index fe29367626..5a000530b8 100644 --- a/app/vminsert/netstorage/netstorage.go +++ b/app/vminsert/netstorage/netstorage.go @@ -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()