Repository navigation
Time only the cancellation in the indexing execution-timeout test - #608
Closed
suguanYang wants to merge 1 commit into
Closed
suguanYang wants to merge 1 commit into
suguanYang wants to merge 1 commit into
Conversation
The test bounded the whole IndexingWorker.run() at budget + 0.32 s. Most of that run is blocking psycopg2 work before and after the native wait, which the cooperative gevent timer cannot interrupt and is not meant to. Locally the run takes 0.13-0.21 s; on CI runners it reached 0.55-0.72 s on unrelated branches, with the whole stall landing before the failure transition, so the bound failed without saying anything about cancellation. Record when the blocked native wait starts and ends, and assert that it ends within 0.1 s of the deadline (or of entering the wait, when the SQL before it already used the budget). Settlement after cancellation must finish within its own settlement budget, and the native call must not be replayed. Assertion messages report each phase so a future failure shows where the time went. With the deadline's Timeout disabled the test still fails: the native wait ends at +1.63 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Superseded by #610, which fixed the same execution-timeout test on main. |
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.
Summary
test_execution_timeout_stops_native_wait_and_returns_without_replaybounded the wholeIndexingWorker.run()atbudget + 0.32 s. CI runs on unrelated branches measured 0.55–0.72 s (47285454677, 46694073445, 47292243180). Captured logs show a single ~0.6 s stall before the failure transition, after which refund, webhook event and the "Indexing failed" log take only 10–15 ms.Most of that region is blocking psycopg2 work before and after the native wait. The cooperative gevent timer cannot interrupt it and is not meant to. The test now times the cancellation itself:
If the SQL before the native wait already used up the budget, the wait must end as soon as it starts. Assertion messages print each phase (
native wait started +…, ended +…, run returned +…), so a future CI failure shows where the time went.Investigation, in a Linux container (Python 3.12, Postgres 15):
clear_application_modules()re-importsshared.*before every test, so compiled-statement caches start empty each time.Evidence
assert (155.570 - 154.887) < ((0.08 + 0.32) + 0)andassert (185.249 - 184.531) < 0.40, both on unrelated branches.After: 20/20 passes, each in a fresh process (cold), in a fresh container. The whole file passes 17/18. The other failure is
test_native_connection_failure_consumes_one_terminal_execution, which is untouched. It fails the same way before this change in that container's drifted venv ('pending' == 'failed') and passes on CI.Timeout(None, …), temporary): the test still fails:AssertionError: budget 0.080s; native wait started +0.031s, ended +1.633s; run returned +1.701sCaveat: local runs used Python 3.12 and a venv reused from a worker image with a few locked packages patched in. CI uses 3.11.
Merge Danger
Door: two-way
Test-only change; revert restores the old bound.
Blast Radius: one-test
Only this contract test's assertions change. Slow settlement on CI is now allowed up to the 2 s settlement budget instead of 0.32 s. That is deliberate: settlement speed is not what this test is about.
🤖 Generated with Claude Code