Repository navigation
test(pgbouncer): stop the never-listens replacement test flaking under CI load - #40830
Conversation
…r CI load The initial start() ran with ready_timeout_seconds=0.3, so the fake pooler had to be listening on both TCP and the unix socket within two 0.1s polls. On a loaded runner the interpreter takes longer than that to start, TCP is bound before the unix socket, and the timeout branch reports the port as served by another process. Give the start 2s and restore the port file as soon as the wrong-port replacement is up, so the next spawn reads the right port however the supervisor thread is scheduled Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 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:
|
|
|
Greptile SummaryThis PR stabilizes the PgBouncer replacement test under CI load
Confidence Score: 5/5The PR appears safe to merge because the timing change removes the CI race while preserving the test's regression coverage The fake pooler reads its configured port only at startup, and the existing assertions still require the wrong-port process to time out, terminate, and be replaced on the intended port
|
| Filename | Overview |
|---|---|
| tests/test_litellm/proxy/db/test_pgbouncer.py | Adjusts test-only readiness timing and port-file sequencing without weakening the replacement lifecycle checks |
Reviews (1): Last reviewed commit: "test(pgbouncer): stop the never-listens ..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
TLDR
Problem this solves:
test_a_replacement_that_never_listens_is_replaced_againfails on loaded CI runnersstart()only got 0.3s, effectively two 0.1s polls, to see the fake pooler listenHow it solves it:
User Flow
Before: a contributor's PR goes red on the proxy-infra unit shard for a change they did not make
test-unit / proxy-infrajob on their PRtests/test_litellm/proxy/db/test_pgbouncer.py::TestPgBouncerProcess::test_a_replacement_that_never_listens_is_replaced_againwithassert PgBouncerError(reason='127.0.0.1:34569 is served by another process, not the pgbouncer that was started') is NoneAfter: the same shard passes on the first attempt
test-unit / proxy-infrajob on their PRtests/test_litellm/proxy/db/test_pgbouncer.pypasses, the test takes about 2s longer than beforeRelevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
This PR only touches a unit test, so the proof is that test under the CPU contention that makes it fail in CI. Both runs below start 96 busy
python3 -c 'while True: pass'loops on an 8 core box (about 12x oversubscription, comparable to a 4 worker xdist shard on a small runner) and then run the base and PR versions of the test side by side in the same pytest invocation. The base version is copied to a sibling file so both can run in one processBefore (7057b2f)
test_pgbouncer_old_tmp.pyis the merge base version of the teststart()of the base test in a 40 iteration loop under the same load: 39 of 40 fail, 35 with "served by another process" and 4 with "did not start listening within 0s".start()took 0.33s to 0.37s, past the 0.3s budgetAfter (cf186cb)
test_pgbouncer.pyis this PR's version of the test1 passedin each of the three lines above is the PR version, run in the same process under the same load as the failing base versionstart()of the PR test in the same 40 iteration loop under the same load: 0 of 40 fail,start()took 0.35s median and 0.47s max against the 2s budgetuv run --no-sync pytest tests/test_litellm/proxy/db/test_pgbouncer.py -q -n 4->64 passed in 15.86sType
✅ Test
Caveats (if any)
Low
Final Attestation
Link to Devin session: https://app.devin.ai/sessions/df2cd953c2aa44ea86966af72381f8e1
Open in Devin Desktop: https://app.devin.ai/desktop/session/df2cd953c2aa44ea86966af72381f8e1?variant=devin
Requested by: @yassin-berriai