fix: deadlock in loki.source.file when target is removed#3488
Merged
Conversation
kalleep
commented
May 2, 2025
| opts component.Options | ||
| metrics *metrics | ||
|
|
||
| updateMut sync.Mutex |
Contributor
Author
There was a problem hiding this comment.
This was only used in Update so we don't need it
wildum
approved these changes
May 2, 2025
36e110b to
6b44e0e
Compare
kalleep
added a commit
that referenced
this pull request
May 5, 2025
* Fix deadlock that can happen when stopping reader tasks Co-authored-by: William Dumont <william.dumont@grafana.com>
kalleep
added a commit
that referenced
this pull request
May 5, 2025
* fix: panic that happens when a target gets deleted when using decompression (#3475) * Fix panic caused that can happen when when file is removed for decompressor * Change to start readLine start and stops updatePositions * Add changelog * Fix mimir.rules.kubernetes panic on non-leader debug info retrieval (#3451) * Fix mimir.rules.kubernetes to only return eventProcessor state if it exists * fix: deadlock in loki.source.file when target is removed (#3488) * Fix deadlock that can happen when stopping reader tasks Co-authored-by: William Dumont <william.dumont@grafana.com> * fix: emit valid logfmt key (#3495) * Fix log keys to be valid for logfmt * Add changelog * Fix streams limit error check so that metrics are correctly labeled as `ReasonStreamLimited` (#3466) * fix: replace direct error string compare with isErrMaxStreamsLimitExceeded helper * update CHANGELOG * Make errMaxStreamsLimitExceeded an error type --------- Co-authored-by: Théo Brigitte <theo.brigitte@gmail.com> Co-authored-by: William Dumont <william.dumont@grafana.com> Co-authored-by: Marat Khvostov <marathvostov@gmail.com>
marctc
pushed a commit
that referenced
this pull request
May 7, 2025
* Fix deadlock that can happen when stopping reader tasks Co-authored-by: William Dumont <william.dumont@grafana.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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
PR Description
#3456 reports that some alloy nodes stopped sending logs. Alloy itself still produced some logs looking like this:
Trying to access
/api/v0/web/componentshangs and the profile shows that most go routines are parked. This is most likely symptoms of a deadlock.While going through the changes we have made to this component I noticed this.
So what happens is that when we are stopping tasks we wait for them to finish, that includes flushing any logs that have not been sent over the handler channel yet. Because nothing is reading from that channel when we are performing this update we get stuck waiting there indefinitely.
To fix this we need to keep on reading while we perform the update and stop that when we are done
Which issue(s) this PR fixes
fixes: #3456
fixes: #3472
Notes to the Reviewer
PR Checklist