[litellm-agent] Staging → litellm_internal_staging (5/6/2026) - #27250
[litellm-agent] Staging → litellm_internal_staging (5/6/2026)#27250oss-pr-review-agent-shin[bot] wants to merge 2 commits into
Conversation
Iterate user/key/team/team_member/org/end_user/tag spend dicts in sorted order inside each Prisma transaction so concurrent pods acquire row locks in the same order, avoiding PostgreSQL deadlocks under load.
|
|
Greptile SummaryThis PR applies a consistent sorted iteration order to all spend-update transaction loops across the proxy's DB write layer, so concurrent pods acquire row locks in the same order and avoid PostgreSQL deadlocks. A parametrized mock test verifies the sorted order for all 8 spend buckets (user, key, team, team_member, org, end_user, tag, agent).
Confidence Score: 5/5This PR is safe to merge — it changes only iteration order within existing transactions, not the data written, and all paths are covered by mock tests. The change is a targeted, low-risk addition of sorted() to dictionary iteration in spend-flush loops. The sort is deterministic, doesn't alter the values written, and is backed by a comprehensive parametrized test suite. The composite-key sort assumption for team_member entries is correct given the fixed-length prefix format. No new DB paths, no API changes, and no real network calls in the tests. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/db/db_spend_update_writer.py | Adds sorted() to 5 spend-update transaction loops (user, key, team, team_member, org) and the shared _update_entity_spend_in_db helper to enforce a consistent row-lock acquisition order and prevent cross-pod PostgreSQL deadlocks. |
| litellm/proxy/utils.py | Applies the same sorted() fix to the end_user spend loop in ProxyUpdateSpend.update_end_user_spend, completing deadlock prevention coverage across all spend buckets. |
| tests/test_litellm/proxy/db/test_db_spend_update_writer.py | Adds a parametrized mock-only test covering all 8 spend buckets to assert that _commit_spend_updates_to_db iterates each bucket in sorted order; no real network calls are made. |
Reviews (1): Last reviewed commit: "Merge PR #27221 into agent staging branc..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
🤖 litellm-agent: Merged into staging branch Triage Summary Merge Confidence: 5/5 ✅ READY All checks green. Greptile 5/5, no blocking pattern findings, CircleCI passed. |
Automated staging PR created by litellm-agent.
This branch collects PRs approved by the agent on 5/6/2026.