-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
time: Ticker.Reset(0) deadlocks #49315
Comments
cc @rsc |
Change https://golang.org/cl/361074 mentions this issue: |
I suspect panicking will be too invasive of a change. I'm sure there's plenty of code in the wild that does some math to compute a duration for Reset and isn't careful about whether it's <= 0 when what the caller would instead want is "right away". |
But if we make it tick as fast as possible when period is 0. This change is invasive, too. |
Oh, sorry, I read this too quickly about being about Timer.Reset. |
I sent the CL above to fix this bug by adding a check. If duration <= 0, it will panic. If it is the right way to fix it, could anyone review it continue and submit? |
When there's network issues (thanks vodafone), chunks can fail to fetch. When this happens our calculation to reset the timer based on fetched data returns 0, which deadlocks the ticker (golang/go#49315). As this will panic in future releases as well, reset the ticker to 5 seconds when this occurs. This should stop hammering things when network issues occur too. Exponential backoff would be nice, but y'know. Also upgrade to go 1.18rc while here, because why not.
When there's network issues (thanks vodafone), chunks can fail to fetch. When this happens our calculation to reset the timer based on fetched data returns 0, which deadlocks the ticker (golang/go#49315). As this will panic in future releases as well, reset the ticker to 5 seconds when this occurs. This should stop hammering things when network issues occur too. Exponential backoff would be nice, but y'know. Also upgrade to go 1.18rc while here, because why not. Fixes #5
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/weOQpA3YuFD
What did you expect to see?
Either:
Reset
call for setting duration to zero (this will panic intime.NewTicker
, but does not intime.Reset
)What did you see instead?
The ticker fires exactly one more tick, then stops - the example deadlocks because nothing is running anymore.
For any Duration >0 the ticker does not stop ticking after one tick.
The text was updated successfully, but these errors were encountered: