fix(inputs.tail): Fix data race when cleaning up unused tailers#17613
Merged
mstrandboge merged 5 commits intoSep 12, 2025
Conversation
Remove Tell() call during tailer cleanup to avoid race condition with the tail library's internal file reopening goroutine. The race occurred when Tell() tried to read the file handle while the tail library was concurrently modifying it during reopen(). This fix prioritizes stability by not saving offsets for files that no longer match glob patterns, as these are typically rotated logs that won't return with the same name. Fixes influxdata#17571
srebhan
reviewed
Sep 10, 2025
Member
srebhan
left a comment
There was a problem hiding this comment.
Thanks @skartikey! One question in the code...
… preserve offsets Stop the tailer before calling Tell() during cleanup to eliminate the race condition while still preserving file offsets for state persistence. This ensures that files temporarily removed from glob patterns can resume from the correct position if they return.
srebhan
reviewed
Sep 10, 2025
Member
srebhan
left a comment
There was a problem hiding this comment.
Thanks for the update @skartikey! Looks good to me, just some style comments...
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
Contributor
|
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
mstrandboge
approved these changes
Sep 12, 2025
srebhan
added a commit
that referenced
this pull request
Sep 29, 2025
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com> (cherry picked from commit 2586690)
skartikey
added a commit
to skartikey/telegraf
that referenced
this pull request
Sep 30, 2025
…uxdata#17613) Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a critical data race condition in the tail input plugin that was blocking multiple dependency updates due to increased detection frequency with testify v1.11.x.
The race condition occurred in
cleanupUnusedTailers()between:Tell()to get the current file offsetreopen()which modifies the file handleSolution
Removed the
Tell()call during cleanup of tailers for files that no longer match glob patterns. This is a safe trade-off because:app.log→app.log.1) that won't return with the same nameChecklist
Related issues
resolves #17571