fix: improve model read retry logic for eventual consistency#22
Open
shin-bot-litellm wants to merge 1 commit intoBerriAI:mainfrom
Open
fix: improve model read retry logic for eventual consistency#22shin-bot-litellm wants to merge 1 commit intoBerriAI:mainfrom
shin-bot-litellm wants to merge 1 commit intoBerriAI:mainfrom
Conversation
Fixes BerriAI#16 - Model resource intermittently fails with 'Root object was present, but now absent' The issue occurs when creating multiple models in parallel due to eventual consistency in the LiteLLM database - the model is created successfully but the immediate read-back verification returns empty/nil. Changes: - Add isRetryableModelError() helper for flexible error pattern matching - Add 200ms initial delay before first read to allow database sync - Start with 500ms delay (was 1s) for faster first retry - Increase retry count from 5 to 8 (total max wait ~45s) - More robust error detection using pattern matching instead of exact string - Better logging for debugging eventual consistency issues The retry pattern now handles: - 'not found' error messages - 'Model id = X' patterns - 'model_not_found' sentinel values - Cleared resource IDs
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.
Summary
Fixes #16 -
litellm_modelresource intermittently fails with "Root object was present, but now absent" on createProblem
When creating multiple
litellm_modelresources in parallel, some randomly fail because:Root Cause
Database eventual consistency - the model is written but not immediately readable, especially under concurrent writes.
Solution
Improved the retry mechanism in
retryModelRead():isRetryableModelError()Error Patterns Now Handled
"not found"messages"Model id = X"patterns"model_not_found"sentinel valuesRetry Timeline
Testing
The fix addresses the intermittent failure by: