litellm/tests/test_litellm/proxy/utils/prisma_and_spend
devin-ai-integration[bot] cba3dd5828
fix(proxy): retry deadlocks and requeue spend logs on any DB write error (#39883)
* fix(proxy): retry deadlocks and requeue spend logs on any DB write error

update_spend_logs dequeued the batch and only retried/requeued on transport
errors. A 40P01 deadlock surfaced as a plain prisma DataError and went through
poison-row isolation, which dropped every row it hit; every other DB error was
re-raised with the batch already gone from the queue.

Treat deadlocks as transient (retry, then requeue), keep them out of poison-row
isolation, and requeue the batch at the head of the queue on any other prisma
error so it lands once the DB is healthy.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(proxy): drop redundant docstrings and tighten test typing for spend-log requeue

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(proxy): assert deadlock retries from mock call history instead of mutable lists

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: yassin <yassin@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-05 11:41:56 -07:00
..
__init__.py test(proxy/utils): pin PrismaClient and spend-update behavior (#29488) 2026-06-02 17:45:28 -07:00
_harness_smoke_test.py test(proxy/utils): pin PrismaClient and spend-update behavior (#29488) 2026-06-02 17:45:28 -07:00
conftest.py fix(proxy): run SMTP send_email off the event loop with a connection timeout (#38473) 2026-08-29 16:05:57 -07:00
test_cache_user_row.py test(proxy/utils): pin PrismaClient and spend-update behavior (#29488) 2026-06-02 17:45:28 -07:00
test_config_param_cache.py test(proxy/utils): pin PrismaClient and spend-update behavior (#29488) 2026-06-02 17:45:28 -07:00
test_password_helpers.py test(proxy/utils): pin PrismaClient and spend-update behavior (#29488) 2026-06-02 17:45:28 -07:00
test_prisma_client_engine_watcher.py fix(proxy): recover Prisma DB reconnect loop when client is disconnected 2026-07-07 09:50:27 +03:00
test_prisma_client_get_data.py Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_decrease_anys_opus5_round2 2026-08-25 16:17:29 -07:00
test_prisma_client_health.py feat(proxy): add paginated GET /public/v1/model_hub (#38636) 2026-08-28 10:02:59 -07:00
test_prisma_client_lifecycle.py feat(proxy): authenticate to Azure Postgres with Microsoft Entra ID tokens 2026-08-20 11:50:16 -07:00
test_prisma_client_reconnect.py fix(health): honor allow_requests_on_db_unavailable in readiness probe (#37640) 2026-08-29 10:17:12 -07:00
test_prisma_client_writes.py fix(proxy): never log raw virtual keys in key insertion debug output (#33268) 2026-07-14 16:32:26 -07:00
test_proxy_update_spend.py fix(proxy): retry deadlocks and requeue spend logs on any DB write error (#39883) 2026-09-05 11:41:56 -07:00
test_send_email.py fix(proxy): run SMTP send_email off the event loop with a connection timeout (#38473) 2026-08-29 16:05:57 -07:00
test_spend_functions.py fix(responses): resolve previous_response_id for a just-written turn 2026-08-22 11:46:24 -07:00