Repository navigation
Expire gateway requests exactly at their deadline - #4
Merged
Merged
Conversation
expire_pending compared now - started >= timeout. When now is exactly started + timeout, the subtraction can round just below the timeout (252.15820775 + 10 - 252.15820775 is 9.99999999999997), so a request was kept for one more expiry pass. test_lost_results_expire_and_free_capacity checks that boundary with the real perf_counter() start time, so it failed for about 1.3% of start times under 1,000 s, which is where a fresh CI runner's clock sits. It failed the macOS TSan job on main after PR #2. Compare now against started + timeout instead, and add a test that pins the start time from the failing run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GatewayState.expire_pendingcomparednow - started >= timeout. Whennowis exactlystarted + timeout, the subtraction can round just below the timeout, so the request was kept for one more expiry pass:test_lost_results_expire_and_free_capacitychecks that boundary using the realperf_counter()start time, so it fails for some clock values. Over a million random start times under 1,000 s (where a freshly booted CI runner's clock sits), the old check missed the deadline 1.26% of the time. It failed the macOS TSan job on main after PR #2 (run 44932944283), even though the same code had passed on the PR.Change
expire_pendingnow comparesnow >= started + timeout, so a request expires exactly at its deadline. Away from the boundary, behavior is unchanged; in production the comparison runs once a second against the real clock, so the difference was at most one extra pass.test_request_expires_exactly_at_its_deadlinepins the start time from the failing run. It fails on the old code and passes with the fix.Testing
pytest python/testsin the dev image: 11 passed (the new test failed before the fix).