{{ message }}
Draft PR: Configurable timeout_ms and num_retries in model_config#2908
Draft
Rahik-Sikder wants to merge 1 commit into
Draft
Draft PR: Configurable timeout_ms and num_retries in model_config#2908Rahik-Sikder wants to merge 1 commit into
timeout_ms and num_retries in model_config#2908Rahik-Sikder wants to merge 1 commit into
Conversation
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.

This is a partial implementation of #2839, covering per-field timeout and retry configuration. The fallback provider mechanism is left pending design clarification (see questions below).
Problem
When using an external embedding provider, Typesense's error handling behavior is entirely hardcoded: a 5-second CURL timeout and 2 retries, with no fallback. If a provider is unreliable, this results in slow requests (2 × 5s = 10s stall) with no way to fine tune or escape this behavior. The original issue also requests a fallback provider mechanism where if all retries against the primary fail, Typesense should attempt the request against a secondary provider. The original issue also references Plexus-style features such as provider cooldown and routing to the lowest-latency provider.
Proposed Solution
Expose
timeout_msandnum_retriesas optional fields inembed.model_config, allowing per-field overrides of the collection-level defaults. Fallback provider support is deferred pending design input (see open questions). As for the Plexus-like features, they currently seem out of scope but can be revisited once the fallback design is settled, possibly in a different PR.Changes
include/field.h— Addedfields::timeout_msandfields::num_retriesconstants.src/field.cpp— Validation injson_field_to_field():timeout_ms: optional, must be a positive integer (0is rejected - a zero-ms timeout would cause all calls to fail)num_retries: optional, must be a non-negative integer (0is valid - means one attempt, no retries)src/index.cpp— Inbatch_embed_fields(), field-level values are read frommodel_configand fall back to collection-level defaults when absent. Note:num_retriesis user-facing (additional attempts), whileembed_documentstakesnum_tries(total attempts), so+1is applied on read.test/collection_schema_change_test.cpp— Four tests covering: valid settings,timeout_ms: 0rejection,num_retries: 0acceptance, and invalid num_retries type rejection.Open Questions (Fallback Design)
Before implementing fallback providers, input on the following would be helpful:
Config structure — Should
model_configbe able to accept an array of provider objects so fallbacks are defined inline? Or would a dedicatedfallback_configfield be preferable?Stickiness / cooldown — If the primary provider fails and a fallback is used, should the fallback be sticky for a cooldown period before retrying the primary (requiring failure state to be tracked)? Or should the primary always be attempted first on each new document/request?
Happy to extend this once the design direction is confirmed.
PR Checklist