Repository navigation
Unwedge Backend CI: one deadlocked test, and a timer that names the next one - #9515
Merged
Merged
Conversation
…ext one test_codex_proof_rollback_leaves_a_concurrent_save_alone drove two update_provider_config calls at the same provider concurrently, with the first parked inside a stubbed remember_catalog_account until the second one finished. serialize_provider_config holds a per-provider asyncio.Lock across the whole handler, so the second call could never start, and the await that would have released the first sat behind it. The event loop then had nothing to run and no timer to wake it, and the test never returned. Backend CI has been red on main since that test landed. The step timings say the suite was never the problem: the last green run finished "Backend tests" in 393s, and the first red run reached 95% of the same suite in 5m30s and then emitted nothing for the remaining 37 minutes before the job cap fired. The interleaved write now goes at providers_db directly. That is the shape the rollback actually defends against, since the route lock already forbids a second concurrent save on the same provider, and the assertions are unchanged: reverting _restore_metadata to restore the whole pre-request snapshot still fails the test. The parked handshake is now an Event the stub sets rather than a hundred turns of asyncio.sleep(0) and a read of Event._waiters. Backend CI also gets pytest-timeout and --timeout=330 on its pytest steps. A job cap reports "cancelled" and names nothing, which is what let this sit for forty hours; a per-test cap fails the test by name in minutes. 330s is 4x the slowest real test in the suite, test_the_newest_revision_survives_a_tied_run_LONGER_than_the_cap at 82.5s, with 76s and 25s next below it.
…ls.py needs A second break on main, which the hang above was hiding: the job never reached the summary, so these two never reported. #9411 added _is_imatrix_path to the import block at the top of routes/models.py and to _dir_has_downloaded_model, without telling the two tests that stand in for that module. test_export_absolute_paths builds a ModuleType for utils.models.model_config and gets ImportError at the import block; test_recommended_folders_has_model AST-extracts the real function into a namespace it assembles by hand and gets NameError when the function runs. The extracted-function test takes the real helper, the way it already takes the real is_appledouble_metadata: importing utils.models.model_config costs 0.14s and pulls in neither torch nor transformers, and a stub would let the exclusion that function depends on regress unnoticed. The ModuleType double gets a lambda beside its siblings, since export path discovery is what that file tests.
Member
Author
|
@codex review |
1 similar comment
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This was referenced Aug 22, 2026
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.
Backend CI has been red on
mainfor about forty hours and it blocks every open PR. One test deadlocks. The suite itself is fine.The boundary
(Python 3.13)jobBackend testsstepb4240405dcaa0b7925746ad086dSeventeen seconds separate the last green run from the first red one, and exactly one commit sits in the gap:
caa0b7925, "Studio: offer only the Codex models the ChatGPT plan can actually reach" (#9302).What the measurement showed
A hanging test, not a suite that outgrew the wall, and not the dependency install.
The red job's own log settles it.
Install backend test dependencies (CPU only)took 75s. pytest started at 00:01:32, finished collection at 00:02:43, and reached 95% of the suite at 00:08:05. Then it printed nothing at all for the remaining 37 minutes, until the job cap fired and the runner reported the word "cancelled".Reproduced locally on the runner's shape (
-n 4, same ignores and deselections), with a per-test timer added so a hang names itself:b4240405dlast greencaa0b7925first redThe 11m53s is 6m23s of real work plus one test sitting on a 330s timer. #9302 added 54 tests and no measurable time. The suite does its work in six and a half minutes against a 45 minute cap, so there is nothing here to split, parallelise further, or raise the limit for.
Where the fault is
The test, not the product code.
test_codex_proof_rollback_leaves_a_concurrent_save_alonestarts oneupdate_provider_configon a provider, parks it inside a stubbedremember_catalog_accounton anasyncio.Event, and then awaits a secondupdate_provider_configon the same provider before setting that event.serialize_provider_configwraps that handler in a per-providerasyncio.Lockheld for the whole call, and has since #9234, well before #9302:So the second call cannot start while the first holds the lock, and the
gate.set()that would release the first sits behind the second. The loop has no runnable task and no timer, parks inselectors.poll(None), and stays there. Confirmed directly: two coroutines throughprovider_config_guard("provider-x"), the first parked, and the second never runs.I checked the retry path in
openai_codex_client.pytoo, since it was the standing suspicion. It is sound and is not involved:_MAX_TRANSIENT_RETRIESis 2, the backoff is2**attempt,_retry_delay_secondsclamps an upstreamretry-afterto 60s, and_retry_pausere-checks the cancel event every 100ms. Worst case is bounded and cancellable, and no test in the file drives a retryable status anyway.The fix
The interleaved write now goes at
providers_db.update_providerdirectly. That is what_restore_metadataactually defends against, since the route lock already forbids a second concurrent save on the same provider, and it is reachable by any other writer. Every assertion is unchanged, and the test still catches the bug it exists for: reverting_restore_metadatato restore the whole pre-request snapshot fails it in 1.24s.The parked handshake is now an
Eventthe stub sets, awaited withasyncio.wait_for(..., timeout = 10), instead of a hundred turns ofasyncio.sleep(0)polling the privategate._waiters.The guard
pytest-timeoutwas not a dependency anywhere in the repo. Backend CI now installs it and passes--timeout=330to its pytest steps.A
timeout-minutesjob cap names nothing. That is the reason this cost forty hours rather than one CI round: three separate PRs each carried a red(Python 3.13)at 45m14s, 45m15s and 45m16s, all reading "cancelled", which looks like a concurrency cancel and says nothing about which test is at fault. A per-test cap fails the test by name in the summary. The job cap stays as the backstop for a wedge the per-test timer cannot see, such as one during collection.330s is taken off the measured distribution rather than picked for looking tidy. The slowest legitimate test in this suite is
test_conversation_archive.py::test_the_newest_revision_survives_a_tied_run_LONGER_than_the_capat 82.5s under-n 4(75.4s serially), with 76s and 25s next below it, so the cap is 4x the worst real test and nothing in the suite is within reach of it.repo-cpu-testsis deliberately left alone: I have no local measurement of its per-test distribution, and putting an unmeasured cap on a job that is currently green is how you trade one red for another.