-
Notifications
You must be signed in to change notification settings - Fork 664
Monotonic timestamps #2618
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
Monotonic timestamps #2618
Conversation
gefjon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes look good, and I like your approach. Thanks for splitting into separate commits; that made review super easy!
I would like to see a test, though it may be manual or a smoketest at your discretion. I would write a module with a reducer that re-schedules itself on a very small delay (a zero delay, perhaps?) while decrementing a counter so that it runs a large number of times, and at each run asserts that its new timestamp is >= the previous one, panicking and breaking the loop if not. You should make sure to observe this failing at least once on master, and then run a loop, say, twice that length on this PR branch and see it succeed.
023205a to
5096079
Compare
|
Alright, added a test. I couldn't get the issue to reproduce naturally, but calling |
|
I also can't get the issue to repro naturally on master. I tried pretty hard, too: I changed the test to run 100000 iterations, set the delay to 0, and still didn't see an out-of-order run. Makes me wonder what was going on with the reporter's setup, that they apparently saw multiple anomalies of several seconds. I'm not sure there's much value in having the test checked in, in that case; I think a test with a 100% rate of false negatives is either useless or worse than useless. The manual test where you set the system clock is enough to convince me to merge this. Remove the new smoketest, then I'll approve. Thanks! |
5096079 to
8d685af
Compare
|
Yeah, I'm wondering if it's a windows-specific issue or something like that. At the very least it's a their-machine-specific issue. |
They used the Linux names for |
Description of Changes
Fixes for timestamps, so that a reducer that happens after another is observed to have a later timestamp. Specifically:
ctx.timestampwill be at least the timestamp the reducer was scheduled for.now + delay, clampnowso it is at least the timestamp of the start of the current reducer run.The first commit is pulled out from the second, to make it clearer what the actual logic change is.
Expected complexity level and risk
2 - timing stuff is intricate and this could mess with assumptions people have made about the way it works, but I'm pretty confident this is strictly a strong guarantee.
Testing
ctx.timestampand set back the system clock during the run.