Open kevinburke opened 7 years ago
Fascinating. 🍿!
I like how the test in https://github.com/aristanetworks/goarista/commit/46272bfb1c042fc2825d312fe33d494e9d13dd6b looks to be probabilistic, I guess you'd have to actually mess with the system time or do some horrendous mocking to pull off a deterministic test though.
And interesting that this conversation flared up again because Cloudflare had some downtime due to it. In general though, absent an admin messing with the system time, are time leaping and DST type of events the main places where this would cause a problem?
(I'm using this library: https://godoc.org/github.com/aristanetworks/goarista/monotime)
(In the grand scheme of things I doubt this matters much since I'm pretty confident the system can tolerate a negative time measurement. But it's good to do the right thing)
I wrote more about it here https://kev.inburke.com/kevin/leap-seconds/
A monotonic clock is probably coming in Go 1.9 https://github.com/golang/go/issues/12914
🙌 that's awesome
Occasionally the duration reported by calling
a := time.Now(); b := time.Now(); c := b.Since(a)
can be negative, since Go does not use a monotonic clock source fortime.Now()
calls. This affected production code after the leap second yesterday. This is being discussed at e.g. https://github.com/golang/go/issues/12914 but it might be good to consider switching to something like https://godoc.org/github.com/davecheney/junk/clock in the meantime.I'm still researching this issue.