-
Notifications
You must be signed in to change notification settings - Fork 151
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 maxRetries
and maxSleep
configurable in goleak
#93
Comments
Can you provide some more context on where you'd like to adjust the max retries/sleep behaviour? Is there a reason that the current defaults don't work well. Rather than exposing the underlying values as-is, would it be better to expose a single value for total maximum timeout (or perhaps use a context)? |
Make goleak options more flexible to adapt to users' variety scenarios Signed-off-by: Kante Yin <[email protected]> fix #93 --------- Signed-off-by: Kante Yin <[email protected]> Co-authored-by: Sung Yoon Whang <[email protected]> Co-authored-by: Abhinav Gupta <[email protected]>
The problem is the detecting duration of time is not long enough. also see https://github.com/kubernetes/kubernetes/pull/115456/files#r1097270472 Yes, agree that implementation leak is not something smells good, I'm ok with exposing a single value like So can we just remove the |
Any suggestion @prashantv ? |
One possible option re: @prashantv's point here: Instead of exposing two parameters "maxRetries" and "maxSleep", perhaps we can expose a single RetryPolicy type/option? Strawman: type RetryPolicy interface {
Attempt(num int) (delay time.Duration, ok bool)
} Takes the attempt number, reports the sleep duration for that, or false if we shouldn't retry anymore. The default retry policy will look something like this, that wouldn't be exported -- at least initially: type defaultRetryPolicy struct {
maxRetries int
maxSleep time.Duration
}
func (p *defaultRetryPolicy) Attempt(i int) (time.Duration, bool) {
if i >= o.maxRetries {
return 0, false
}
d := time.Duration(int(time.Microsecond) << uint(i))
if d > o.maxSleep {
d = o.maxSleep
}
return d, true
} @prashantv @sywhang WDYT? meta: We should probably re-open this issue if we're still discussing this. |
But this wouldn't solve my problem, isn't it? What I want is increasing the retry attempts or retry timeout. |
reopened the issue. @abhinav I think that's probably a good strawman to begin with. @kerthcet would it not? If we exposed a |
Ah, got the idea, users can implement their own interface to determine whether to retry or not, it should work. One question, does it really make sense to set the retry attempts, how to determine the explicitly value?And yes, I used to expose these two values for I didn't want to change a lot of the package, I should reconsider this again at that moment. :( |
I like the general idea of a retry policy, though I think the most common use is going to be bumping the timeout, so having a default option to bump the timeout seems useful (and internally it determines how many attempts, sleep per-attempt, etc). Couple of thoughts on the
|
I also came here looking for a way to control the It seem like most other people on this thread would like to extend the timeout to give go routines more time to join before considering it an issue. In my case I was trying to fix a bug where a go routine was leaking for a long time but eventually joins. Before fixing the bug I tried to write a failing unit test that verifies the go routine has joined by using From my point of view a go routine leaking even a few hundred milliseconds is still a logic error as there should be some code that waits for the go routine to property join. |
This is for flexibility and users can adjust to their own scenarios. Or do we have any other concerns?
/assign
The text was updated successfully, but these errors were encountered: