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

Return buffers to pool on network errors or queue overflow #2609

Merged
merged 1 commit into from
Oct 30, 2020

Conversation

chlunde
Copy link
Contributor

@chlunde chlunde commented Oct 30, 2020

Use of sync.Pool requires a .Put for every .Get.
On success, the downstream ThriftProcessor invoked .Put via .DataRecd
but in error cases there seems to be a leak.

Which problem is this PR solving?

I think I found a leak when reviewing this code for deadlock-related issues.

Short description of the changes

Free memory in error cases.

Use of sync.Pool requires a .Put for every .Get.
On success, the downstream ThriftProcessor invoked .Put via .DataRecd
but in error cases there seems to be a leak.

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>
@chlunde chlunde requested a review from a team as a code owner October 30, 2020 20:01
@mergify mergify bot requested a review from jpkrohling October 30, 2020 20:01
@codecov
Copy link

codecov bot commented Oct 30, 2020

Codecov Report

Merging #2609 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2609      +/-   ##
==========================================
- Coverage   95.07%   95.06%   -0.01%     
==========================================
  Files         209      209              
  Lines        9366     9368       +2     
==========================================
+ Hits         8905     8906       +1     
- Misses        385      386       +1     
  Partials       76       76              
Impacted Files Coverage Δ
cmd/agent/app/servers/tbuffered_server.go 100.00% <100.00%> (ø)
plugin/storage/integration/integration.go 77.34% <0.00%> (-0.56%) ⬇️

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 ec03a2d...8b7b6df. Read the comment docs.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

It's not a memory leak, the buffers would be gc-ed, but it doesn't hurt to put them back in error paths.

@yurishkuro yurishkuro changed the title Prevent memory leak in on dropped packets or network errors Return buffers to pool on network errors or queue overflow Oct 30, 2020
@yurishkuro yurishkuro merged commit be49a63 into jaegertracing:master Oct 30, 2020
@yurishkuro
Copy link
Member

Thanks!

@chlunde
Copy link
Contributor Author

chlunde commented Oct 30, 2020

Oh, sorry, I hate that the commit comment I made was incorrect 😭 For some reason I always assumed sync.Pool retained a reference to the objects, allocated as an array or similar..

@yurishkuro
Copy link
Member

no worries, I changed the commit message during merge

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.

3 participants