Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Retry handling for streamed request bodies #852

Merged
merged 3 commits into from
Nov 8, 2024
Merged

Conversation

jbelkins
Copy link
Contributor

@jbelkins jbelkins commented Nov 8, 2024

Description of changes

This change ensures that retry is only used when a request body is reusable, and that the request body is prepared for reuse if needed.

  • When a request body is a seekable stream, rewind the stream to the beginning before retrying. Do not retry if rewind is not successful.
  • When a request body is a non-seekable stream, do not attempt to retry; fail the request immediately instead.
  • Non-streamed request bodies (i.e. in-memory Data and empty bodies) are always retryable.

Additionally, unit tests are added to Orchestrator to verify correct retry behavior.

Scope

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jbelkins jbelkins marked this pull request as ready for review November 8, 2024 17:56
@@ -167,20 +168,22 @@ class OrchestratorTests: XCTestCase {
}

class TraceExecuteRequest: ExecuteRequest {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior of this type is unchanged; I added a variable to allow for counting of retry attempts that is separate from the original allowed count.

@@ -1315,4 +1318,43 @@ class OrchestratorTests: XCTestCase {
}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RetryBackoffStrategy below always sets a retry delay of 0 so the retry tests can proceed without waiting for any retry delay. This prevents the first test below from taking 0.5-2 seconds to finish.

Copy link
Collaborator

@dayaffe dayaffe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jbelkins jbelkins merged commit abd012b into main Nov 8, 2024
31 checks passed
@jbelkins jbelkins deleted the jbe/stream_retry_fix branch November 8, 2024 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants