From ad4cb9f3cad42818ea39b1551a658d82bc069773 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sun, 16 Feb 2020 15:51:11 +0200 Subject: [PATCH] lib/storage: prevent from clobbering nin-nil lastError in Storage.add --- lib/storage/storage.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/storage/storage.go b/lib/storage/storage.go index db2f4f5fb..bb9cb562c 100644 --- a/lib/storage/storage.go +++ b/lib/storage/storage.go @@ -1038,8 +1038,8 @@ func (s *Storage) add(rows []rawRow, mrs []MetricRow, precisionBits uint8) ([]ra if err := s.tb.AddRows(rows); err != nil { lastError = fmt.Errorf("cannot add rows to table: %s", err) } - if err := s.updatePerDateData(rows, lastError); err != nil { - lastError = err + if err := s.updatePerDateData(rows, lastError); err != nil lastError == nil { + lastError = fmt.Errorf("cannot update per-date data: %s", err) } if lastError != nil { return rows, fmt.Errorf("error occurred during rows addition: %s", lastError)