diff --git a/app/vmselect/bufferedwriter/bufferedwriter.go b/app/vmselect/bufferedwriter/bufferedwriter.go index 609ea6550..985d98d6d 100644 --- a/app/vmselect/bufferedwriter/bufferedwriter.go +++ b/app/vmselect/bufferedwriter/bufferedwriter.go @@ -4,6 +4,7 @@ import ( "bufio" "fmt" "io" + "strings" "sync" ) @@ -59,7 +60,7 @@ func (bw *Writer) Write(p []byte) (int, error) { return 0, bw.err } n, err := bw.bw.Write(p) - if err != nil { + if err != nil && !isTrivialNetworkError(err) { bw.err = fmt.Errorf("cannot send %d bytes to client: %w", len(p), err) } return n, bw.err @@ -72,7 +73,7 @@ func (bw *Writer) Flush() error { if bw.err != nil { return bw.err } - if err := bw.bw.Flush(); err != nil { + if err := bw.bw.Flush(); err != nil && !isTrivialNetworkError(err) { bw.err = fmt.Errorf("cannot flush data to client: %w", err) } return bw.err @@ -84,3 +85,12 @@ func (bw *Writer) Error() error { defer bw.lock.Unlock() return bw.err } + +func isTrivialNetworkError(err error) bool { + // Suppress trivial network errors, which could occur at remote side. + s := err.Error() + if strings.Contains(s, "broken pipe") || strings.Contains(s, "reset by peer") { + return true + } + return false +} diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 3c37fe5d1..3d3c6c06f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -21,6 +21,7 @@ The following tip changes can be tested by building VictoriaMetrics components f * FEATURE: [vmalert](https://docs.victoriametrics.com/vmalert.html): improve compliance with [Prometheus Alert Generator Specification](https://github.com/prometheus/compliance/blob/main/alert_generator/specification.md). * FEATURE: [vmalert](https://docs.victoriametrics.com/vmalert.html): add `-rule.resendDelay` command-line flag, which specifies the minumum amount of time to wait before resending an alert to Alertmanager (e.g. this is equivalent to `-rules.alert.resend-delay` option from Prometheus. See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1665). * FEATURE: [vmauth](https://docs.victoriametrics.com/vmauth.html): transparently treat `Authorization: Token ...` request headers as `Authorization: Bearer ...` request headers. This allows sending requests to `vmauth` from InfluxDB clients. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1897). Thanks to @dcircelli for the pull request. +* FEATURE: do not log trivial network errors such as `broken pipe` and `connection reset by peer`. This error could occur when writing data to the client, which closes the connection to VictoriaMetrics due to request timeout or similar reason. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2334). * BUGFIX: [Graphite Render API](https://docs.victoriametrics.com/#graphite-render-api-usage): return an additional point after `until` timestamp in the same way as Graphite does. Previously VictoriaMetrics didn't return this point, which could result in missing last point on the graph. * BUGFIX: properly locate series with the given `name` and without the given `label` when using the `name{label=~"foo|"}` series selector. Previously such series could be skipped. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2255). Thanks to @jduncan0000 for discovering and fixing the issue.