Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow timer callbacks to participate in WriteFences.
This is a carefully considered change motivated by Tinytest, which fires timers from a method and then waits for them before returning. Because the timer callbacks didn't have a WriteFence, we had a race condition a while back where the test client would quiesce before all the results came in, which I fixed by giving Tinytest its own timer functions that kept the environment, including the WriteFence. I want to tear these special timer functions out now, since they are necessary (before this commit) for very obscure reasons. The race condition is hard to reproduce and is affected by Mongo latency, the order of the unit tests, etc. (I reproduced it semi-stably to test this commit, and it was tricky.) The change is to give timer callbacks the WriteFence and allow them to add writes before or after the fence fires. Writes that they get in before the fence is armed are included in the fence, and writes made after the fence fires still succeed (the fence is "retired" and doesn't complain that it has already fired). In practice, this means that methods that care about the writes happening as part of the method, like Tinytest's run method, can wait for them, and methods that don't care to wait will just return and let the writes trickle down the pipe later (as they could before). In a discussion with Geoff a few weeks ago, he said fences in general should still complain about late writes unless they are put in a special mode, so there is now a retire() method.
- Loading branch information