Repository navigation
Conversation
FakeClock.After sent its deadline into the channel at call time, so a receive returned before any Advance and every timeout a host selected on fired at once. After now registers a waiter, and Advance fires each one the clock reaches, earliest deadline first, sending that deadline. After(d) with d of zero or less still fires at once, as time.After does. durable's clock tests relied on the instant fire; they now advance the wrapped clock first. Closes #219. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
The deadline-order test only checked each waiter's value, so removing the sort or reversing the tie-break passed. A goroutine already blocked on several waiters does see the order, so the new test parks a receiver with synctest and asserts it wakes on the earliest deadline, and on the first armed when deadlines tie. The old test keeps its checks under a name that says what they cover. durable's clock tests now also check that After waits for the wrapped clock. The docs and changelog say that a receive with no Advance blocks, and that After(d <= 0) now sends the current instant. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
Say that only a negative d changed what After sends, that a waiter fires when the clock reaches its deadline, and that an unfired waiter stays registered until an Advance reaches it. Reflow the godoc and name the waiters in the order test's failure message. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
ACR on this PR (one AI reviewer per dimension)All seven dimensions are confirmed after two rounds. Round 1 had 2 distinct blockers across 7 reviewers, after merging duplicates. Both are fixed in
Round 2 re-ran correctness, missed-context and human-readability: 0 blockers. Its wording non-blockers are fixed in Disagreement, resolved: three reviewers (regression-safety, concurrency, replay) said the firing order can't be observed, because every channel is buffered. Correctness showed that it can: a goroutine already blocked on several channels gets the first one sent. I kept the order and tested it. A probe confirmed it in 2000 of 2000 runs. The alternative was to drop the sort and the promise. Ruled: keep the sort and the order promise. The sort adds about 0.8 µs per Not changed, recorded:
|
What this change does
FakeClock.Aftersent its deadline into the channel at call time, so a receive returned before anyAdvance. A test that selected onClock.After(a silence timeout, a reconnect grace) saw every timeout fire at once.Now
After(d)registers a waiter with its deadline, andAdvancefires every waiter the clock reaches, sending each its deadline.d:Afterfires at once with the current instant, astime.Afterdoes. A negativedused to send an instant in the past.Advance: a receive with noAdvancefar enough now blocks, and the changelog says so. In this repository onlydurable's two clock-seam tests relied on the old instant fire. They now check that the channel waits, then advance the wrapped clock.aftertransitions throughNowandTick, notAfter.Why
Host code that tests its timeouts with
FakeClockpassed or failed for the wrong reason.Relates to: closes #219
Tests:
Advanceover several waiters.testing/synctestsees, ties included, and concurrentAfterandAdvanceunder-race.main, the wait, non-positive and every-reached tests always fail. The order test fails in most runs: there both channels are ready at once, soselectpicks at random.Checklist
git commit -s) per the DCOtype: subject)mage checkpasses locally (lint + race tests + govulncheck):go vetand-racetests pass forstate,durableandcluster; lint and govulncheck run in CI