From 9e79fc27c80326e6a009b70f737c562337612483 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Fri, 11 Dec 2020 13:05:27 +0200 Subject: [PATCH] app/vminsert/netstorage: properly update `vm_rpc_rerouted_rows_processed_total` metric Previously this metric wasn't updated because of improper defer call. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/955 Thanks to @xemxx for spotting the bug. --- app/vminsert/netstorage/netstorage.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/vminsert/netstorage/netstorage.go b/app/vminsert/netstorage/netstorage.go index a7d952868..c0a5209c4 100644 --- a/app/vminsert/netstorage/netstorage.go +++ b/app/vminsert/netstorage/netstorage.go @@ -585,7 +585,9 @@ func getHealthyStorageNodesBlocking(stopCh <-chan struct{}) []*storageNode { func spreadReroutedBufToStorageNodesBlocking(stopCh <-chan struct{}, br *bufRows) { var mr storage.MetricRow rowsProcessed := 0 - defer reroutedRowsProcessed.Add(rowsProcessed) + defer func() { + reroutedRowsProcessed.Add(rowsProcessed) + }() sns := getHealthyStorageNodesBlocking(stopCh) if len(sns) == 0 {