fix: add transport retries to hosted_api_client to handle SQLite lock contention#21118
Draft
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Draft
fix: add transport retries to hosted_api_client to handle SQLite lock contention#21118devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
… contention The hosted_api_client fixture connects to a server running in a subprocess that shares the same SQLite database as the test process. During parallel test execution, SQLite lock contention can cause the server to close the HTTP connection, resulting in httpx.ReadError on the client side. Add transport-level retries (retries=3) to the httpx client, which automatically retries on connection-level errors like ReadError by establishing a new connection. This only retries transport-level failures, not HTTP error responses, so it won't mask real test failures. This is a broader fix that addresses SQLite lock contention for all tests using hosted_api_client, rather than switching individual tests to ephemeral_client_with_lifespan. Co-authored-by: apk <apk@cognition.ai> Co-Authored-By: bot_apk <apk@cognition.ai>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Fixes intermittent
httpx.ReadErrorfailures in tests usinghosted_api_client, such astest_get_runs_in_queue_concurrency_limit_and_limit[1].Root cause: The
hosted_api_clientfixture connects to a uvicorn server running in a subprocess that shares the same SQLite database as the test process. During parallel test execution (pytest-xdist), SQLite lock contention (database is locked) can cause the server's error handler to close the HTTP connection before the response is fully sent, resulting inhttpx.ReadErroron the client side.Fix: Add
httpx.AsyncHTTPTransport(retries=3)to thehosted_api_clientfixture. This uses httpx's built-in transport retry mechanism, which retries only on connection-level errors (e.g.,ReadError,ConnectError) — not on HTTP error responses (4xx/5xx). On retry, httpx establishes a new connection, recovering from the broken one.This is a broader fix that addresses the issue for all tests using
hosted_api_clientrather than switching individual tests toephemeral_client_with_lifespan.Important review considerations
hosted_api_clientacross many test files. Transport retries should be safe since they only fire on connection-level failures, but worth considering if any tests intentionally validate connection behavior.Checklist
<link to issue>"mint.json.Link to Devin session: https://app.devin.ai/sessions/62533fe09ad943fa936cf77f7de1abcb
Requested by: bot_apk (apk@cognition.ai)