litellm/tests/test_litellm/proxy/db
Yassin Kortam cbb64111fa
fix(proxy): keep serving reads from the read replica when the primary DB is down at startup (#31951)
* fix(proxy): keep serving reads from the read replica when the primary DB is down at startup

RoutingPrismaWrapper.connect() connected the writer first and let a writer
failure propagate, so a proxy that started during a primary outage ended up
with no Prisma client at all (startup swallows the error under
allow_requests_on_db_unavailable): DB-stored models never loaded and every
inference request failed with 400 Invalid model name, even with a healthy
DATABASE_URL_READ_REPLICA. Workers recycled via MAX_REQUESTS_BEFORE_RESTART
hit this mid-outage and stayed broken for the rest of the outage.

connect() now degrades on a writer-only failure: reads (key auth, DB-stored
model loads) are served by the reader, writes fail at call time, and the DB
health watchdog keeps retrying the writer reconnect, which clears the
degraded flag once the primary recovers. A full outage (both sides down)
still raises as before.

Resolves LIT-4159

* fix(proxy): clear degraded-writer flag when the reconnect probe finds the writer already healthy

The direct-reconnect path returns early when the writer probe succeeds
(engine already reconnected by another path, e.g. an IAM token refresh),
skipping recreate_prisma_client, which was the only runtime path clearing
_writer_unavailable. The stale flag made the watchdog fire reconnect
attempts against a healthy writer on every cooldown cycle until restart.
Clear the flag in the early-return branch and cover it with a regression
test that fails without the change
2026-07-04 12:45:09 -07:00
..
db_transaction_queue fix(pod_lock): release cron lock by matching async_set_cache JSON encoding (#30600) 2026-06-17 17:01:04 -07:00
mcp_server build(VLLM-Passthrough-with-loadbalancing-support-(enables-using-model-list-for-VLLM-/classify-endpoint)): Closes #11205 2025-05-31 09:00:04 -07:00
test_check_migration.py build: migrate packaging, CI, and Docker from Poetry to uv (#25007) 2026-04-09 11:46:23 -07:00
test_create_views.py [Fix] should_create_missing_views returns False for reltuples=0 (falsy zero bug) 2026-04-18 11:00:09 -07:00
test_db_spend_update_writer.py perf(spend): move cost-callback payload deepcopy off the request event loop (#31579) 2026-06-30 10:31:02 -07:00
test_db_url_settings.py chore: litellm oss staging (#30968) 2026-06-23 07:31:44 -07:00
test_exception_handler.py fix(proxy): isolate poison spend-log rows so one bad record can't drop the whole batch (#31705) 2026-06-30 12:21:14 -07:00
test_exception_handler_reconnect_retry.py fix(proxy): preserve original transport error if reconnect itself raises 2026-04-28 23:55:46 -07:00
test_prisma_client.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prisma_planned_engine_restart.py chore: litellm oss staging (#30745) 2026-06-18 13:55:35 -07:00
test_prisma_self_heal.py fix(proxy): keep serving reads from the read replica when the primary DB is down at startup (#31951) 2026-07-04 12:45:09 -07:00
test_rds_iam_token_expiry.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_routing_prisma_wrapper.py fix(proxy): keep serving reads from the read replica when the primary DB is down at startup (#31951) 2026-07-04 12:45:09 -07:00
test_tool_registry_writer.py fix(proxy): self-heal startup/reload prisma reads on engine disconnect (#28803) 2026-06-10 20:16:58 +02:00