Repository navigation
fix(proxy-extras): keep the post-migration sanity check from building the hand-built SpendLogs indexes - #44397
Merged
Merged
Conversation
… the hand-built SpendLogs indexes schema.prisma still declares the LiteLLM_SpendLogs (api_key, startTime) and (litellm_call_id) indexes while their migrations are now SELECT 1, so the v1 resolver's drift script recreated both with a blocking CREATE INDEX at boot. The drift script now drops those two statements before it is applied, matching filter_request_log_index_diff on main. The schema sync test exempts the two indexes Ported to rc/1.104.0 from stable/1.103.x (#44286), which is not on main: main carries filter_request_log_index_diff from #43948 instead, and its backport here was reverted in #44212. The key metadata recovery hunk is dropped because this line's test file has no Postgres-backed index fixture (cherry picked from commit 4d245e1)
Contributor
|
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:
SELECT 1CREATE INDEXHow it solves it:
CREATE INDEXstatementsUser Flow
Before: an operator on the legacy migration resolver upgrades and the boot locks LiteLLM_SpendLogs while it builds two indexes
USE_V2_MIGRATION_RESOLVER=false(or--use_legacy_migration_resolver)CREATE INDEX "LiteLLM_SpendLogs_litellm_call_id_idx"andCREATE INDEX "LiteLLM_SpendLogs_api_key_startTime_idx", blocking writes to the table until both finishAfter: the same boot leaves the table alone
USE_V2_MIGRATION_RESOLVER=falseCREATE INDEXon LiteLLM_SpendLogsRelevant issues
Ports #44286 from stable/1.103.x to rc/1.104.0 ahead of the next 1.104.0 release candidate
Pre-Submission checklist
Screenshots / Proof of Fix
Setup for every run: a fresh
postgres:16 -c log_statement=all, seeded withprisma migrate deployusing only the 159 migrations older than 20260823000000, then 5 rows inserted into LiteLLM_SpendLogs. The proxy's DB setup then boots against it:The default case drops
USE_V2_MIGRATION_RESOLVER=falseBefore (5aa0cd0)
Legacy resolver
Default (v2) resolver
INFO - Using v2 migration resolver, no sanity check runs(0 rows)CREATE INDEXon LiteLLM_SpendLogsAfter (5bb3b88)
Legacy resolver
(0 rows)CREATE INDEXon LiteLLM_SpendLogsDefault (v2) resolver
INFO - Using v2 migration resolver, no sanity check runs(0 rows)CREATE INDEXon LiteLLM_SpendLogsThe new
_resolve_all_migrationstests fail on the rc tip without the fix (test_hand_built_spend_logs_indexes_never_reach_the_database[False],[True]andtest_drift_of_only_hand_built_indexes_executes_nothing, all AssertionError) and pass with it.tests/unit/litellm_proxy_extras/test_litellm_proxy_extras_utils.py: 86 passedType
Bug Fix
Caveats (if any)
Medium
filter_request_log_index_diff(fix(proxy-extras): build the SpendLogs indexes in the migration job instead of in migrations #43948)--use_prisma_db_pushcan still create both indexes, since db push applies schema.prisma directly. Same as stable/1.103.xLow
test_key_metadata_recovery.pyhunk: this line's file has no Postgres-backed index fixturetest_db_schema_migration.pynow exempts the two indexes. It needs a live DB and was not run locallyFinal Attestation