Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promtail: handling tight loop in journal follow logic #4066

Merged

Conversation

dannykopping
Copy link
Contributor

What this PR does / why we need it:
While following the systemd journal, if an EBADMSG error is thrown (or indeed anything else besides for sdjournal.ErrExpired or io.EOF), then we will enter into a tight loop and consume all available CPU.

This PR handles EBADMSG which can occur in a corrupt journal file, and additionally adds a 100ms sleep in the loop to prevent runaway CPU usage.

Which issue(s) this PR fixes:
Partially addresses #4053

Special notes for your reviewer:

Checklist

  • Documentation added
  • Tests updated

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Danny Kopping added 3 commits July 28, 2021 15:21
@dannykopping dannykopping merged commit a3414a5 into grafana:main Jul 28, 2021
@dannykopping dannykopping deleted the dannykopping/fix-journal-tight-loop branch July 28, 2021 15:01
dannykopping pushed a commit that referenced this pull request Apr 3, 2023
**What this PR does / why we need it**:
Since PR #4066 two messages are logged for the errors `ErrExpired` and
`EOF`, whereas nothing has been logged beforehand.

As `ErrExpired` is returned by the `JournalReader` after sending a
message to the `until` channel to signal a normal stop, this should not
be logged as an error.
grafanabot pushed a commit that referenced this pull request May 5, 2023
**What this PR does / why we need it**:
Since PR #4066 two messages are logged for the errors `ErrExpired` and
`EOF`, whereas nothing has been logged beforehand.

As `ErrExpired` is returned by the `JournalReader` after sending a
message to the `until` channel to signal a normal stop, this should not
be logged as an error.

(cherry picked from commit 46af2cd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants