fix: retry transient failures in jina (TEI) and ollama embedding providers - #125
Merged
Merged
Conversation
…iders The self-hosted jina (TEI) and ollama providers had no retry at all — a single transient 5xx or connection reset aborted the file's embedding, and the pipeline then skipped the file, leaving its index entries stale. Extract the 429 backoff, batch loop and malformed-response check that were duplicated near-verbatim across voyage, openai and jina_api into a shared server/embeddings/http_batch.py, and route all five providers through it. The shared helper also retries 5xx and transport/timeout errors, which no provider did before. Closes #71 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Closes #71.
Problem
server/embeddings/jina.py(self-hosted TEI) andserver/embeddings/ollama.pyhad no retry at all — a single transient 5xx or connection reset aborted the file's embedding.server/indexer/pipeline.py:252-254catches that, logs, andcontinues, so the file keeps its stale index entries until a later run.Meanwhile the 429 backoff + batch loop + malformed-response check was duplicated near-verbatim across
voyage.py,openai.pyandjina_api.py. None of those retried 5xx or transport errors either — only 429.Change
New
server/embeddings/http_batch.py:post_with_retry()— retries 429 (honouringRetry-After), 5xx, andhttpxtransport/timeout errors on the shared[10, 20, 30, 40]schedule, thenraise_for_status().embed_in_batches()— owns the chunk loop and the vector-count check, parameterized by a per-providermake_body/extract.All five providers now route through it. Each keeps its own batch size (32 self-hosted, 128 hosted), request shape, and dimension resolution — those are genuinely per-provider. Net −60 lines across the providers.
Tests
tests/embeddings/test_http_batch.py— 12 cases: backoff sequence,Retry-Afterprecedence, 5xx retry + exhaustion, transport-error retry + exhaustion, 4xx not retried, chunking, empty input, length mismatch.test_jina.pyandtest_ollama.py— new coverage, this is the actual fix.🤖 Generated with Claude Code