BerriAI/litellm · error · RuntimeError
Database migration failed after 4 attempts (retry loop exhau
Error message
Database migration failed after 4 attempts (retry loop exhausted by timeouts or repeated idempotent-recovery continues). Check database connectivity, load, and _prisma_migrations ledger state.
What it means
Error "Database migration failed after 4 attempts (retry loop exhausted by timeouts or repeated idempotent-recovery continues). Check database connectivity, load, and _prisma_migrations ledger state." thrown in BerriAI/litellm.
Source
Thrown at litellm-proxy-extras/litellm_proxy_extras/utils.py:678
raise RuntimeError(
f"Failed to mark migration {name} as applied "
f"after idempotent recovery. Manual "
f"intervention may be required.\n\n"
f"Detail: {resolve_err}"
) from resolve_err
continue
raise RuntimeError(
"Database migration failed and cannot be auto-recovered. "
f"Manual intervention required.\n\nPrisma error:\n{stderr}"
) from e
raise RuntimeError(
"Database migration failed and cannot be auto-recovered. "
f"Manual intervention required.\n\nPrisma error:\n{stderr}"
) from e
raise RuntimeError(
"Database migration failed after 4 attempts (retry loop "
"exhausted by timeouts or repeated idempotent-recovery "
"continues). Check database connectivity, load, and "
"_prisma_migrations ledger state."
)
finally:
os.chdir(original_dir)
@staticmethod
def apply_replica_identity_full_if_requested() -> bool:
"""
Re-assert REPLICA IDENTITY FULL on LiteLLM's tables when the operator
opted in via LITELLM_SET_REPLICA_IDENTITY_FULL.
Prisma leaves new tables at the Postgres default, which logical
replication consumers reject, so the setting has to be re-applied after
every migration run rather than once by hand.
View on GitHub (pinned to 77b7c6c40c)
Solutions
- Check database connectivity and load; inspect the _prisma_migrations table for failed entries and resolve them with prisma migrate resolve before retrying.
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at litellm-proxy-extras/litellm_proxy_extras/utils.py:678 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/27f05c6a3c7794b5.
Report an issue: GitHub.