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

Make buffered channel to avoid goroutines leak in groupbytraceprocessor #1505

Merged
merged 3 commits into from
Nov 9, 2020

Conversation

pkositsyn
Copy link
Contributor

Description: Fixing a bug - goroutines leak

Link to tracking Issue: #1504

@pkositsyn pkositsyn requested a review from a team November 6, 2020 03:19
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 6, 2020

CLA Check
The committers are authorized under a signed CLA.

  • ✅ Kositsyn Pavel (a0de46b992eb1bfe0304be345b76fcb731686d82, dcba408995977843cf13db50e5469bf5fa5c32b6)

@codecov
Copy link

codecov bot commented Nov 6, 2020

Codecov Report

Merging #1505 (8705bd0) into master (422a647) will increase coverage by 1.33%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1505      +/-   ##
==========================================
+ Coverage   87.59%   88.93%   +1.33%     
==========================================
  Files         345      346       +1     
  Lines       16975    17057      +82     
==========================================
+ Hits        14870    15170     +300     
+ Misses       1648     1420     -228     
- Partials      457      467      +10     
Flag Coverage Δ
integration 70.87% <ø> (?)
unit 87.59% <85.71%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
processor/groupbytraceprocessor/event.go 95.96% <85.71%> (-0.65%) ⬇️
internal/common/testing/container/container.go 73.68% <0.00%> (ø)
receiver/jmxreceiver/receiver.go 94.73% <0.00%> (+10.52%) ⬆️
receiver/dockerstatsreceiver/docker.go 92.30% <0.00%> (+39.05%) ⬆️
receiver/dockerstatsreceiver/receiver.go 96.82% <0.00%> (+49.20%) ⬆️
receiver/jmxreceiver/subprocess/subprocess.go 96.52% <0.00%> (+73.61%) ⬆️
receiver/redisreceiver/receiver.go 87.50% <0.00%> (+87.50%) ⬆️
receiver/redisreceiver/client.go 100.00% <0.00%> (+100.00%) ⬆️
receiver/redisreceiver/factory.go 100.00% <0.00%> (+100.00%) ⬆️
...eceiver/jmxreceiver/subprocess/subprocess_linux.go 100.00% <0.00%> (+100.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 422a647...8705bd0. Read the comment docs.

Copy link
Member

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Is it possible to get a unit test for this?

processor/groupbytraceprocessor/event.go Show resolved Hide resolved
@pkositsyn
Copy link
Contributor Author

I cannot imagine test, which wouldn't use runtime.NumGoroutines() and accordingly would be 100% stable. I can do a test, which passes with a very big probability, if it worths this

@jpkrohling
Copy link
Member

I know we have a PR on Jaeger making use of goleak, but I have no idea how it works yet. Could you take a look and see if it's something that would be worth using here?

jaegertracing/jaeger#2606

Comment on lines 1 to 32
# /bin/bash
# Run this script only from current directory!

go test -c -o tests
for test in $(go test -list . | grep -E "^(Test|Example)");
do ./tests -test.run "^$test\$" &>/dev/null || echo "$test failed";
done
rm tests
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Took this script from goleak repo. It is extremely convenient to find leaky test. But still, do we need it here and should I copy the license?

Copy link
Member

Choose a reason for hiding this comment

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

How accurate is it? Would it have reliably found this leak? If we are copying the code, it should come with the same license header.

Copy link
Member

Choose a reason for hiding this comment

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

That said, would you be able to make it work with all other modules in the repo? Would be a good addition to the repo itself, I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generally, as I understood it just compares goroutines running before all tests and after all tests in a module. Now the tests fail with unbuffered channel, so it's really helpful here (also helped to find minor leak in shutdown). I am curious about stability of this method and there is a good point in discussion in Jaeger repo that, unfortunately, the main test must be put in every package manually. From my perspective, it can be helpful in components that use goroutines for servers or async processing. And don't see any point to use it otherwise

Well, the script is copied not entirely, but I admit that we have to put the license

Copy link
Member

Choose a reason for hiding this comment

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

I think I would prefer to leave it out for now from this PR. Instead, would you open an issue so that we can discuss a better, broader solution? Perhaps there's a linter out there that we can make use of?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed

@pkositsyn
Copy link
Contributor Author

Seems like I messed up with CLA. Should I make another PR?

processor/groupbytraceprocessor/go.sum Outdated Show resolved Hide resolved
Copy link
Member

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

LGTM.

@pkositsyn
Copy link
Contributor Author

Close in order to fix CLA in new PR #1532

@bogdandrutu bogdandrutu closed this Nov 9, 2020
@bogdandrutu bogdandrutu reopened this Nov 9, 2020
@bogdandrutu bogdandrutu merged commit 648e110 into open-telemetry:master Nov 9, 2020
@pkositsyn pkositsyn deleted the groupbytrace_leak branch November 9, 2020 14:35
dyladan referenced this pull request in dynatrace-oss-contrib/opentelemetry-collector-contrib Jan 29, 2021
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
ljmsc referenced this pull request in ljmsc/opentelemetry-collector-contrib Feb 21, 2022
* Update README master branch URL to main

* Remove master branch from workflow triggers

The master branch has been renamed to main.

* Add changes to CHANGELOG

* Rename other projects default branch

All of OpenTelemetry is moving to rename `master` to `main`, this
updates all other URLs for those projects.

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants