app/vmagent: properly flush big blocks of data

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/741

Thanks to @IceRain00 for the investigation and initial attempt to fix the issue
at https://github.com/VictoriaMetrics/VictoriaMetrics/pull/742
This commit is contained in:
Aliaksandr Valialkin 2020-09-03 12:08:14 +03:00
parent de216bab41
commit a3cdef6b06

View File

@ -126,9 +126,9 @@ func (wr *writeRequest) push(src []prompbmarshal.TimeSeries) {
tssDst := wr.tss tssDst := wr.tss
for i := range src { for i := range src {
tssDst = append(tssDst, prompbmarshal.TimeSeries{}) tssDst = append(tssDst, prompbmarshal.TimeSeries{})
dst := &tssDst[len(tssDst)-1] wr.copyTimeSeries(&tssDst[len(tssDst)-1], &src[i])
wr.copyTimeSeries(dst, &src[i]) if len(tssDst) >= maxRowsPerBlock {
if len(wr.tss) >= maxRowsPerBlock { wr.tss = tssDst
wr.flush() wr.flush()
tssDst = wr.tss tssDst = wr.tss
} }