This repository was archived by the owner on Sep 30, 2024. It is now read-only.
fix/internal/memcmd: fix goroutine leak in linux observer#63206
Merged
ggilmore merged 1 commit intoJun 11, 2024
Merged
Conversation
Contributor
Author
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
f74052a to
a08dde7
Compare
Contributor
Author
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.


There was a goroutine leak in the Linux observation logic.
https://github.com/sourcegraph/sourcegraph/blob/add4baa455ef86d60b59f7c0182839a7bb2a9e18/internal/memcmd/observer_linux.go#L122-L141
In observe, it was possible for the goroutine that produces collection events on a channel to block forever. If we exit early from the function, it was still possible for the channel to be full (because the consumer exited early), which causes the producer goroutine to block forever since there is no room in the channel.
This PR fixes this issue by adding a
deferstatement that ensures that collection channel is drained before we exit - thus fixing the leak.Test plan
Added goroutine leak dector to linux tests - now see them pass.
Changelog
A goroutine leak in the experimental linux memory observation logic has been fixed.