-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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, runtime: zero duration timer takes 2 minutes to fire #44868
Comments
@gopherbot Please open backport to 1.16. This issue can cause timers to fire up to two minutes late. |
Backport issue(s) opened: #44869 (for 1.16). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Technically, 2 minutes is after at least 0 seconds. :> |
This is a bug in The logic behind This isn't quite true, as
P 0's
Since it doesn't affect correctness, I believe it would be sufficient to fix this problem by updating |
Alternatively, it may be cleaner to keep the expectation the |
Change https://golang.org/cl/300610 mentions this issue: |
Change https://golang.org/cl/300611 mentions this issue: |
The timerpMask optimization updates a mask of Ps (potentially) containing timers in pidleget / pidleput. For correctness, it depends on the assumption that new timers can only be added to a P's own heap. addtimer violates this assumption if it is preempted after computing pp. That G may then run on a different P, but adding a timer to the original P's heap. Avoid this by disabling preemption while pp is in use. Other uses of doaddtimer should be OK: * moveTimers: always moves to the current P's heap * modtimer, cleantimers, addAdjustedTimers, runtimer: does not add net new timers to the heap while locked For #44868 Fixes #44869 Change-Id: I4a5d080865e854931d0a3a09a51ca36879101d72 Reviewed-on: https://go-review.googlesource.com/c/go/+/300610 Trust: Michael Pratt <[email protected]> Run-TryBot: Michael Pratt <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Result: Go Bot <[email protected]> (cherry picked from commit aa26687) Reviewed-on: https://go-review.googlesource.com/c/go/+/300611
Change https://golang.org/cl/313129 mentions this issue: |
Change https://golang.org/cl/313130 mentions this issue: |
The timerpMask optimization updates a mask of Ps (potentially) containing timers in pidleget / pidleput. For correctness, it depends on the assumption that new timers can only be added to a P's own heap. addtimer violates this assumption if it is preempted after computing pp. That G may then run on a different P, but adding a timer to the original P's heap. Avoid this by disabling preemption while pp is in use. Other uses of doaddtimer should be OK: * moveTimers: always moves to the current P's heap * modtimer, cleantimers, addAdjustedTimers, runtimer: does not add net new timers to the heap while locked For #44868 Fixes #45731 Change-Id: I4a5d080865e854931d0a3a09a51ca36879101d72 Reviewed-on: https://go-review.googlesource.com/c/go/+/300610 Trust: Michael Pratt <[email protected]> Run-TryBot: Michael Pratt <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-on: https://go-review.googlesource.com/c/go/+/313129 Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
Very rarely, zero duration timers fail to fire for 2 minutes. This program will occassionally fail. e.g.,
This reproduces on 1.16 (linux-amd64, other platforms not tested), but not 1.15. Thus this is probably more fallout from http://golang.org/cl/232298.
Failure seems to consistently occur at 2 minutes, which is a strong indication that this is related to the 2 minute force GC period. Most likely the scheduler is completely missing the timer until forced GC kicks it awake again. That makes this distinct from #44343, where timer expiration is slower but never missed.
cc @ChrisHines @aclements @mknyszek
The text was updated successfully, but these errors were encountered: