app/vminsert/netstorage: capture the first error instead of the last error when sending data to vmstorage

The first error has more chances to point to the real root cause of the issue.
This commit is contained in:
Aliaksandr Valialkin 2020-05-22 17:49:04 +03:00
parent be7253c084
commit 6edc33d9bb

View file

@ -153,14 +153,14 @@ func (ctx *InsertCtx) FlushBufs() error {
resultCh <- br.pushTo(sn)
}(br, storageNodes[i])
}
var lastErr error
var firstErr error
for i := 0; i < resultChLen; i++ {
err := <-resultCh
if err != nil {
lastErr = err
if err != nil && firstErr == nil {
firstErr = err
}
}
return lastErr
return firstErr
}
// GetStorageNodeIdx returns storage node index for the given at and labels.