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

Fix Goroutine leaks in several packages #5066

Merged
merged 11 commits into from
Dec 30, 2023

Conversation

akagami-harsh
Copy link
Member

@akagami-harsh akagami-harsh commented Dec 30, 2023

Which problem is this PR solving?

  • fix gorourine leak in some packages

Description of the changes

How was this change tested?

  • go test

Checklist

Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
@akagami-harsh akagami-harsh requested a review from a team as a code owner December 30, 2023 17:26
@akagami-harsh
Copy link
Member Author

I've ignored goleak check for github.com/golang/glog.(*fileSink).flushDaemon in certain packages, as is couldn't find a fix for it

Copy link

codecov bot commented Dec 30, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (bdd43f7) 95.56% compared to head (e4a6b6a) 95.56%.
Report is 3 commits behind head on main.

Files Patch % Lines
pkg/testutils/leakcheck.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #5066    +/-   ##
========================================
  Coverage   95.56%   95.56%            
========================================
  Files         313      315     +2     
  Lines       18160    18323   +163     
========================================
+ Hits        17355    17511   +156     
- Misses        645      651     +6     
- Partials      160      161     +1     
Flag Coverage Δ
cassandra-3.x 25.60% <0.00%> (-0.01%) ⬇️
cassandra-4.x 25.60% <0.00%> (-0.01%) ⬇️
elasticsearch-5.x 19.86% <0.00%> (-0.03%) ⬇️
elasticsearch-6.x 19.88% <0.00%> (-0.01%) ⬇️
elasticsearch-7.x 20.00% <0.00%> (-0.03%) ⬇️
elasticsearch-8.x 20.10% <0.00%> (-0.01%) ⬇️
grpc-badger 19.50% <0.00%> (+<0.01%) ⬆️
kafka 14.10% <0.00%> (-13.41%) ⬇️
opensearch-1.x 20.00% <0.00%> (-0.03%) ⬇️
opensearch-2.x 20.01% <0.00%> (+<0.01%) ⬆️
unittests 93.25% <0.00%> (+0.02%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
// be stopped when the test finishes, leading to a detected but expected leak.
func IgnoreGlogFlushDaemonLeak() goleak.Option {
return goleak.IgnoreTopFunction("github.com/golang/glog.(*fileSink).flushDaemon")
}
Copy link
Member

Choose a reason for hiding this comment

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

add package_test invoking this function to appease code coverage

Copy link
Member

Choose a reason for hiding this comment

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

Also, I just realized, we could've done this differently by adding testutils.CheckGoroutineLeaks function that would be called from the rest of the codebase, instead of having two dependencies everywhere (goleak and testutils).

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, we can also do that.

Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
// IgnoreGlogFlushDaemonLeak returns a goleak.Option that ignores the flushDaemon function
// from the glog package that can cause false positives in leak detection.
// This is necessary because glog starts a goroutine in the background that may not
// be stopped when the test finishes, leading to a detected but expected leak.
Copy link
Member

Choose a reason for hiding this comment

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

great explanation!

Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
@yurishkuro yurishkuro added the changelog:test Change that's adding missing tests or correcting existing tests label Dec 30, 2023
Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
@yurishkuro yurishkuro merged commit 5c6348e into jaegertracing:main Dec 30, 2023
35 checks passed
@yurishkuro
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:test Change that's adding missing tests or correcting existing tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants