Repository navigation
fix(proxy-extras): only spend a migrate-deploy attempt when a pass made no progress - #39506
Merged
mateo-berri merged 2 commits intoSep 3, 2026
Conversation
…de no progress The v2 migration resolver gave `prisma migrate deploy` four attempts, and every recovery path ended in a bare `continue`, so each one burned an attempt. A database first brought up with `--use_prisma_db_push` has a full schema and no migrations ledger, so the baseline spent attempt one and the first three migrations whose objects already existed spent the rest. The proxy then exited before binding its port, and that database could never be moved onto the resolver. The retry budget now counts only attempts that got nowhere. Creating the baseline, and each migration newly marked applied, leaves the budget alone, so a push-created database works through its pre-existing objects one pass at a time. Timeouts, deadlock rollbacks, advisory-lock waits, and a repeat of a recovery that already ran still spend an attempt, so a run that stops making progress gives up exactly as before.
Contributor
Greptile SummaryThis PR changes migration retry accounting so successful recovery progress does not consume the no-progress attempt budget
Confidence Score: 5/5The PR appears safe to merge No blocking failure remains
|
| Filename | Overview |
|---|---|
| litellm-proxy-extras/litellm_proxy_extras/utils.py | Refactors migration failure recovery and charges retry attempts only when a deploy pass makes no progress |
| tests/litellm-proxy-extras/test_litellm_proxy_extras_utils.py | Adds focused retry-accounting tests covering progressive and non-progressing migration recovery paths |
Reviews (2): Last reviewed commit: "refactor(proxy-extras): pull the migrate..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…o a budget helper _setup_database_v2 decided the next attempt budget inline in eight branches, each rebinding budget before continuing. The branches now live in _budget_after_deploy_failure, which returns the budget the next pass runs under, and the two identical idempotent-recovery blocks share _mark_migration_applied. The loop backs off whenever a pass spent an attempt, which is the same set of paths that slept before.
Contributor
Author
Contributor
Author
|
bugbot run |
Contributor
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 8572544. Configure here.
mateo-berri
enabled auto-merge
September 3, 2026 07:31
tin-berri
approved these changes
Sep 3, 2026
mateo-berri
merged commit Sep 3, 2026
45495e1
into
litellm_internal_staging
117 of 122 checks passed
mateo-berri
deleted the
litellm_fix_v2_migration_resolver_attempt_accounting
branch
September 3, 2026 15:36
This was referenced Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Problem this solves:
--use_prisma_db_pushdatabase can never boot under--use_v2_migration_resolverHow it solves it:
User Flow
Before: an operator who first brought their database up with
--use_prisma_db_pushcannot switch that same database to--use_v2_migration_resolver, and the proxy never starts--use_prisma_db_pushagainst an empty Postgres, and it servesPOST https://litellm-domain/v1/chat/completionsnormally--use_v2_migration_resolverinsteadSchema exists but no migrations ledger — creating baseline, then threeSQL hit idempotent error — marking applied and retryinglinesDatabase migration cannot proceed. Database migration failed after 4 attemptsand the process exitsGET https://litellm-domain/health/readinessnever answers because the port was never bound, and every request their apps send fails to connectAfter: the same restart works through the objects the push already created and the proxy comes up
--use_prisma_db_pushagainst an empty Postgres, and it servesPOST https://litellm-domain/v1/chat/completionsnormally--use_v2_migration_resolverinsteadSQL hit idempotent error — marking applied and retryingin turn instead of stopping at the fourthGET https://litellm-domain/health/readinessreturns 200 with{"status":"healthy","db":"connected"}, andPOST https://litellm-domain/v1/chat/completionsserves normally againRelevant issues
Linear ticket
Resolves LIT-6802
Type
🐛 Bug Fix
Caveats (if any)
Medium
Low
attempt Nin the logs now counts no-progress attempts, not passesPre-Submission checklist
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Screenshots / Proof of Fix
Both legs run against the same Postgres 16 container, and each leg starts from a database that was just brought up by
--use_prisma_db_pushand then dropped and recreated so the second boot sees exactly the push-created state.Shared setup:
Both legs are preceded by the same push boot, which is what creates the schema without a ledger:
Before (ff17e8b)
curl -s -m 20 -w '\nHTTP %{http_code}\n' http://127.0.0.1:45881/health/readinessAfter (8572544)
curl -s -m 20 -w '\nHTTP %{http_code}\n' http://127.0.0.1:45881/health/readinessgpt-5-minicompletion through the recovered database:0_initbaseline), where the Before leg stopped at 92:Final Attestation