lib/storage: prevent from clobbering nin-nil lastError in Storage.add

This commit is contained in:
Aliaksandr Valialkin 2020-02-16 15:51:11 +02:00
parent afecb34491
commit ad4cb9f3ca

View file

@ -1038,8 +1038,8 @@ func (s *Storage) add(rows []rawRow, mrs []MetricRow, precisionBits uint8) ([]ra
if err := s.tb.AddRows(rows); err != nil { if err := s.tb.AddRows(rows); err != nil {
lastError = fmt.Errorf("cannot add rows to table: %s", err) lastError = fmt.Errorf("cannot add rows to table: %s", err)
} }
if err := s.updatePerDateData(rows, lastError); err != nil { if err := s.updatePerDateData(rows, lastError); err != nil lastError == nil {
lastError = err lastError = fmt.Errorf("cannot update per-date data: %s", err)
} }
if lastError != nil { if lastError != nil {
return rows, fmt.Errorf("error occurred during rows addition: %s", lastError) return rows, fmt.Errorf("error occurred during rows addition: %s", lastError)