-
Notifications
You must be signed in to change notification settings - Fork 4
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
Close leaked response bodies #43
Conversation
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
mutex.Lock() | ||
defer mutex.Unlock() | ||
|
||
if resURL != "" { |
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.
Kinda seems like moving maybeUnmarshalRespInto
into this closure would make everything much easier to think about. (That and an errgroup would be much better suited than a multierrgroup but I'll pick one hill to die on here...)
var succeeded atomic.Bool
// ...
defer myRes.Body.Close()
if !succeeded.CompareAndSwap(false, true) {
// Someone else beat us.
return nil
}
// Unmarshal the successful call.
return maybeUnmarshalRespInto(method, resURL, res, into)
// ... Out of closure
if succeeded.Load() {
// Success or error un unmarshal
}
return grp.Errs()
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.
Whoops, meant to hit approve.
@chrisseto @gene-redpanda @RafalKorepta can y'all re-review with the janky test I added with a global response tracker in our tests to ensure we're actually closing connections? I couldn't get the |
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, nice testing solution!
@@ -69,6 +69,10 @@ type ( | |||
NopAuth struct{} | |||
) | |||
|
|||
// responseWrapper functions as a testing mechanism for ensuring |
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.
You could also consider adding an Opt
that allows setting the transport (line 190 in admin.go) and wrap this up in a transport wrapper. Then we'd catch any leaks that might be stemming from pester or a misuse there of.
This alone is a huge improvement though!
In latest rpadmin the go routine leak was fixed. redpanda-data/common-go#43
In latest rpadmin the go routine leak was fixed. redpanda-data/common-go#43
In latest rpadmin the go routine leak was fixed. redpanda-data/common-go#43
In latest rpadmin the go routine leak was fixed. redpanda-data/common-go#43
In latest rpadmin the go routine leak was fixed. redpanda-data/common-go#43
In latest rpadmin the go routine leak was fixed. redpanda-data/common-go#43
In latest rpadmin the go routine leak was fixed. redpanda-data/common-go#43
This ensures that we close all response bodies (or documents when they should be closed, but aren't). Working on some tests/validations, but throwing this up here for some eyes.