litellm/tests/litellm
tushar8408 85828da695
fix(proxy): stop IAM-refresh engine restart from cascading reconnects (#29176) (#30183)
An RDS IAM token refresh recreates the Prisma client, which SIGKILLs the
running query-engine and spawns a new one. That planned kill was
indistinguishable from a crash, and three reconnect paths used two
uncoordinated locks, so a single refresh triggered a cascade of engine
kill/respawn cycles:

  1. `_safe_refresh_token` (holds `_reconnection_lock`) -> recreate -> kill old
     engine, spawn new one.
  2. The engine-death watcher sees that kill, assumes a crash, and calls
     `attempt_db_reconnect(force=True)` (a different lock,
     `_db_reconnect_lock`) -> recreate again -> kills the fresh engine.
  3. In-flight queries failing during the swap are classified as transport
     errors and trigger their own `attempt_db_reconnect` -> recreate again.

Fix coordinates planned restarts across the wrapper and the watcher:

  - PrismaWrapper records the old engine PID in `_expected_engine_deaths`
    before killing it; all four watcher death-detectors (waitpid thread,
    pidfd, already-dead probe, os.kill poll) consume that PID and skip the
    reconnect instead of treating it as a crash.
  - `recreate_prisma_client` now serializes through `_reconnection_lock` and
    bumps a monotonic `_engine_generation`. Callers pass `expected_generation`
    as an optimistic-lock token, so racing/cascading recreates collapse into a
    single restart (losers no-op). This closes the two-lock gap.
  - The direct reconnect path probes the writer with SELECT 1 before
    recreating; a healthy connection (e.g. engine already replaced by a
    refresh) skips the recreate entirely.
  - `_safe_refresh_token` coalesces: it skips when the current token still has
    more than the refresh buffer of runway, so stacked triggers (proactive
    loop + __getattr__ fallback) don't each restart the engine. An
    `on_engine_replaced` hook re-arms the watcher on the new PID.

RoutingPrismaWrapper forwards `expected_generation` and skips recreating the
reader when the writer recreate was skipped.
2026-06-18 17:55:21 +05:30
..
a2a_protocol/providers/pydantic_ai_agents fix(a2a): forward agent_extra_headers through completion bridge (#28277) 2026-06-11 21:56:18 -07:00
integrations/helicone style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
litellm_core_utils test: create fresh ModelResponse per test to avoid shared mutable state 2026-03-03 14:54:11 -03:00
llms test(batches): move orphan tests into tests/test_litellm for CI coverage (#30510) 2026-06-16 10:20:59 -07:00
proxy fix(proxy): stop IAM-refresh engine restart from cascading reconnects (#29176) (#30183) 2026-06-18 17:55:21 +05:30
test_bedrock_extended_beta_models.py feat(bedrock): add support for 4 new beta models (#20974) 2026-02-13 18:32:12 +05:30
test_bedrock_nemotron_super.py Litellm ishaan april2 (#25113) 2026-04-04 12:31:49 -07:00
test_no_hardcoded_secrets.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_proxy_auth.py feat(sdk): add proxy_auth for auto OAuth2/JWT token management (#20238) 2026-02-02 22:04:08 -08:00
test_router_retry_backoff_headers.py fix(router): use current retry exception for retry backoff (#20725) 2026-02-10 22:44:25 -08:00
test_sambanova_model_metadata.py Add new chat model metadata (#27313) 2026-05-06 15:15:21 -07:00
test_stream_chunk_builder_images.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00