Repository navigation
Conversation
|
CI caught two suites I had not run: Both are updated to the offloaded shape, not loosened:
|
|
Thanks @singhharsh1708 — verified against head What I checked in Tests: the new One non-blocking note: under saturation the three Leaving a positive signal — a human maintainer can take the formal approval from here. 🤖 Automated review on behalf of the maintainers. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Fixes #15227: six synchronous gate checks in sync_local_files ran directly on the event loop, stalling other requests/websockets during the large-upload endpoint's long-lived requests. Now offloaded via the same executors already used by identical calls elsewhere in the file (critical_executor/db_executor) — no logic change, just moved off-loop. AST-guard regression test fails on revert (3/4). CI green.
Fixes #15227
sync_local_filesisasync def, so the six synchronous gates it called ran on the event loop and stalled every other request and WebSocket on the pod for the duration of each Firestore or Redis round trip. This is the large-upload endpoint, so those requests are long lived and overlap.Each call is now offloaded with the executor the same call already uses elsewhere in the tree, so nothing here is a new judgement:
get_hard_restriction_statuscritical_executorsync_local_files_v2, same fileis_daily_audio_ceiling_exceededdb_executorsync_local_files_v2, same filehas_transcription_creditscritical_executorsync_local_files_v2, same fileget_enforcement_stagedb_executorrouters/listen/runtime.pyviaListenPersistence.callis_dg_budget_exhausteddb_executorrouters/listen/runtime.pyviaListenPersistence.callrecord_usagedb_executoruser_usage_dbListenPersistence.callisrun_blocking(db_executor, ...), so the last three follow the pool the listen path already picked for them.No control flow changed: the same values are computed in the same order and the same branches are taken.
record_usagestays inside its existingtry.Tests:
backend/tests/unit/test_sync_local_files_async.py, an AST guard in the shape of the existingtest_tts_ratelimit_async.py. It asserts the handler is async, that none of the six is called directly, that each is offloaded through an awaitedrun_blocking(a bare call would be a coroutine that never runs, so the gate would silently stop being enforced), and that each uses the executor above.Verification:
With
routers/sync.pyreverted to its state on main and the test kept, 3 of the 4 fail and only thetest_handler_is_asynccontrol passes.Worth noting for the manifest:
scan_async_blockers.pyreports 0 both before and after this change. Itsmixed_await_sync_dbdetector resolvesdatabase.*names imported directly into the scanned file, and these six reach Firestore and Redis throughutils/wrappers, so it cannot see them. That is why this PR adds a file-local AST guard rather than extending the scanner, which would be a much wider change.Product invariants affected
none
Failure class (fixes)
Failure-Class: none
The nearest existing class is FC-loop-bound-resource-shared-process-wide, but its contract is about a resource bound to one event loop being reused from another, not about synchronous I/O running on the loop, so it did not look like an honest fit.
Line-Count-Exception: backend/routers/sync.py | 2101 -> 2103 | wrapping six gate calls in awaited run_blocking