-
Notifications
You must be signed in to change notification settings - Fork 18k
time: timer reset sometimes ignored, causing delayed ticks #47762
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
Comments
Here's a reproduction in the Go playground, against 1.17. |
I think this may be related to #44343 as well. CC @prattmic @ChrisHines |
Cc @ianlancetaylor (for timers) |
Thanks for the test case. I think I found the problem. Sending a CL. |
@gopherbot Please open a backport to 1.16 and 1.17. This bug can cause timers to fail to fire. It appears to be new in recent 1.16 releases. |
Backport issue(s) opened: #47858 (for 1.16), #47859 (for 1.17). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Thanks for the nice test case. |
Change https://golang.org/cl/343882 mentions this issue: |
Not to nag, but is there a timeline for when the CL might be wrapped up ? I'd love to try out the fix. Thanks |
See the discussion at https://golang.org/cl/343882. |
Change https://golang.org/cl/350000 mentions this issue: |
Change https://golang.org/cl/350001 mentions this issue: |
I've tested with gotip and can confirm this fixes the problem as it originally manifested for us. |
…cessary When the adjustTimers function removed a timer it assumed it was sufficient to continue the heap traversal at that position. However, in some cases a timer will be moved to an earlier position in the heap. If that timer is timerModifiedEarlier, that can leave timerModifiedEarliest not correctly representing the earlier such timer. Fix the problem by restarting the heap traversal at the earliest changed position. For #47762 Fixes #47859 Change-Id: I152bbe62793ee40a680baf49967bcb89b1f94764 Reviewed-on: https://go-review.googlesource.com/c/go/+/343882 Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> (cherry picked from commit 2da3375) Reviewed-on: https://go-review.googlesource.com/c/go/+/350001
…cessary When the adjustTimers function removed a timer it assumed it was sufficient to continue the heap traversal at that position. However, in some cases a timer will be moved to an earlier position in the heap. If that timer is timerModifiedEarlier, that can leave timerModifiedEarliest not correctly representing the earlier such timer. Fix the problem by restarting the heap traversal at the earliest changed position. For #47762 Fixes #47858 Change-Id: I152bbe62793ee40a680baf49967bcb89b1f94764 Reviewed-on: https://go-review.googlesource.com/c/go/+/343882 Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> (cherry picked from commit 2da3375) Reviewed-on: https://go-review.googlesource.com/c/go/+/350000
What version of Go are you using (
go version
)?Go 1.16.7
I noticed the issue only with the 1.16.6 => 1.16.7 minor version bump, and cannot reproduce with 1.16.6.
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?
In rare circumstances, using Timer.Stop and Timer.Reset fails to cause a timer to properly deliver the expected tick on time.
The tick is eventually delivered, and experimentally it's roughly delivered according to previous Reset-and-then-Stop'd values.
I believe this is related to the timer-related fixes applied in the 1.16.7 point release discussed in issue #47329
I managed to distill down pseudo-random but deterministic test case. I only encounter a failure some of the time -- you'll want to use -count=10 for example, and should then observe delays.
What did you expect to see?
The test should complete quickly, since all timers are stopped before awaiting longer-duration time intervals,
and timer channels are only selected after being
Reset(0)
.What did you see instead?
The test frequently blocks for longer periods of time, on the order of a minute or two (and correlated to the long-duration time interval used).
The text was updated successfully, but these errors were encountered: