Skip to content

Commit d22ca40

Browse files
authored
[-] make lastError sends in flush() non-blocking, closes #1212 (#1265)
1 parent 1d85e8e commit d22ca40

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

internal/sinks/postgres.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,10 @@ func (pgw *PostgresWriter) flush(msgs []metrics.MeasurementEnvelope) {
422422
}
423423
pgw.forceRecreatePartitions = false
424424
if err != nil {
425-
pgw.lastError <- err
425+
select {
426+
case pgw.lastError <- err:
427+
default:
428+
}
426429
}
427430

428431
var rowsBatched, n int64
@@ -446,7 +449,10 @@ func (pgw *PostgresWriter) flush(msgs []metrics.MeasurementEnvelope) {
446449
logger.WithField("rows", rowsBatched).WithField("elapsed", diff).Info("measurements written")
447450
return
448451
}
449-
pgw.lastError <- err
452+
select {
453+
case pgw.lastError <- err:
454+
default:
455+
}
450456
}
451457

452458
func (pgw *PostgresWriter) EnsureMetricTimescale(pgPartBounds map[string]ExistingPartitionInfo) (err error) {

0 commit comments

Comments
 (0)