-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix promtail deadlock #5170
Fix promtail deadlock #5170
Conversation
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
@@ -319,6 +319,10 @@ func (s *targetSyncer) sync(groups []*targetgroup.Group, targetEventHandler chan | |||
target.Stop() | |||
s.metrics.targetsActive.Add(-1.) | |||
delete(s.targets, key) | |||
|
|||
// close related file event watcher |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @slim-bean :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -319,6 +319,10 @@ func (s *targetSyncer) sync(groups []*targetgroup.Group, targetEventHandler chan | |||
target.Stop() | |||
s.metrics.targetsActive.Add(-1.) | |||
delete(s.targets, key) | |||
|
|||
// close related file event watcher | |||
close(s.fileEventWatchers[target.path]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be safe, should we check that this member exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a good idea, on the other hand, there went something wrong beforehand if the member does not exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah good idea !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the only place we don't iterate. Let's do it.
Signed-off-by: Christian Haudum <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What this PR does / why we need it:
This PR fixes a deadlock in Promtail which occurred when targets were removed from the target groups by the discovery manager.
The problem was that upon removal of a target it was removed from the targets list, but the correlating file event watcher channel was not removed from from the watchers list. This caused events to be sent to channels that were not read any more and therefore resulting in a deadlock.
Which issue(s) this PR fixes:
Fixes #5162
Special notes for your reviewer:
Checklist
CHANGELOG.md
about the changes.