app/vminsert/netstorage: do not return error from storageNode.flushBufLocked when the buffer has been successfully re-routed to healthy nodes

This should reduce the number of false errors in the log and the number of falsely lost rows
This commit is contained in:
Aliaksandr Valialkin 2020-05-22 18:27:10 +03:00
parent 6edc33d9bb
commit 4bd3d4b148

View file

@ -57,7 +57,7 @@ func (sn *storageNode) push(buf []byte, rows int) error {
if err := sn.flushBufLocked(); err != nil {
// Failed to flush or re-route sn.buf to vmstorage nodes.
// The sn.buf is already dropped by flushBufLocked.
// Drop buf too, since there is litte sense in trying to rescue it.
// Drop buf too, since there is little sense in trying to rescue it.
rowsLostTotal.Add(rows)
return err
}
@ -99,15 +99,16 @@ func (sn *storageNode) flushBufLocked() error {
// Couldn't flush sn.buf to vmstorage. Mark sn as broken
// and try re-routing sn.buf to healthy vmstorage nodes.
sn.broken = true
if !addToReroutedBuf(sn.buf, sn.rows) {
// Preserve sn.buf when it cannot be sent to healthy nodes
// in the hope the error will disappear on the next call to flushBufLocked.
//
// This should fix https://github.com/VictoriaMetrics/VictoriaMetrics/issues/294 .
return err
if addToReroutedBuf(sn.buf, sn.rows) {
// Successfully re-routed data to healthy nodes.
sn.buf = sn.buf[:0]
sn.rows = 0
return nil
}
sn.buf = sn.buf[:0]
sn.rows = 0
// Preserve sn.buf when it cannot be sent to healthy nodes
// in the hope the error will disappear on the next call to flushBufLocked.
//
// This should fix https://github.com/VictoriaMetrics/VictoriaMetrics/issues/294 .
return err
}