fix: wait retry_interval_seconds between retries (#140) - #141
Open
jaideeppyne wants to merge 1 commit into
Open
Conversation
The httpx rewrite (v1.0.0) dropped the delay between retries that the requests-based client had. `_execute_request` recursed straight into the next attempt on a server error, so `retry_interval_seconds` was stored but never read. A node returning 503 or timing out received all attempts within milliseconds instead of being spaced out, and since each failed attempt marks the node unhealthy, every retry landed before the node had any chance to recover. Restore the wait in both the sync and async clients, sleeping only between attempts (num_retries < config.num_retries) so there is no needless delay before the final failure is raised. Also address the related config-key mismatch: `retry_interval_seconds` was read by Configuration but absent from ConfigDict (so the working key failed type checking), while the documented `interval_seconds` was in ConfigDict but never read. Add `retry_interval_seconds` to ConfigDict and honor both spellings, mirroring the earlier fix for `connection_timeout_seconds` (typesense#73). The async client is the unasync source of truth; add an asyncio->time token mapping so the generated sync client uses `time.sleep`. Adds regression tests for both the sync and async retry paths.
tharropoulos
left a comment
Contributor
There was a problem hiding this comment.
LGTM ![]()
CC: @kishorenc
Author
|
Gentle nudge, and no urgency. Thanks for the review @tharropoulos. @kishorenc, this is ready whenever it suits you. Happy to rebase or adjust anything if that would help. |
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 #140.
Since the v1.0.0
httpxrewrite, the client no longer waits between retries._execute_request(sync and async) recurses straight into the next attempt on a server error, soretry_interval_secondsis stored but never read. A node returning 503 or timing out receives every attempt within a few milliseconds instead of being spaced out — and because each failed attempt marks the node unhealthy, all retries land before the node has any chance to recover. The 0.21.0 client slept viatime.sleep(self.config.retry_interval_seconds).Changes
sync/api_call.pyandasync_/api_call.py, sleeping only between attempts (num_retries < config.num_retries) so there is no needless wait before the final failure is raised — this reproduces the "N+1 attempts / N gaps" behaviour the issue documents.retry_interval_secondsis read byConfigurationbut was missing fromConfigDict(so the working key failed type-checking), while the documentedinterval_secondswas inConfigDictbut read by nothing. Addretry_interval_secondstoConfigDictand honour both spellings — the same shape as theconnection_timeout_secondsfix in [bug] typesense.configuration.ConfigDict is missing parameter connection_timeout_seconds #73.asyncio → timetoken mapping inutils/run-unasync.pyso the generated sync client usestime.sleep.Tests
Adds
test_sleeps_retry_interval_between_retriesand its async counterpart, which assert the client waitsretry_interval_secondsbetween failed attempts. Both fail onmaster(no delay occurs) and pass with this change.