fix(inputs.tail): Prevent deadlock when closing and max undelivered lines hit (#15649)

This commit is contained in:
Joshua Powers 2024-07-24 08:24:34 -06:00 committed by GitHub
parent 5cb142e676
commit 6874f41739
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -370,6 +370,11 @@ func (t *Tail) receiver(parser telegraf.Parser, tailer *tail.Tail) {
select {
case <-t.ctx.Done():
return
// Tail is trying to close so drain the sem to allow the receiver
// to exit. This condition is hit when the tailer may have hit the
// maximum undelivered lines and is trying to close.
case <-tailer.Dying():
<-t.sem
case t.sem <- empty{}:
t.acc.AddTrackingMetricGroup(metrics)
}