[SPARK-52673][CONNECT][CLIENT] Add grpc RetryInfo handling to Spark Connect retry policies #51363
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.
What changes were proposed in this pull request?
Spark Connect Client has a set of retry policies that specify which errors coming from the Server can be retried.
This change adds the capability for the Spark Connect Client to use server-provided retry information according to the grpc standards: https://github.com/googleapis/googleapis/blob/master/google/rpc/error_details.proto#L91
The server can include
RetryInfo
gRPC message containingretry_delay
field in its error response. The Client will now useRetryInfo
message to classify the error as retriable and will useretry_delay
to calculate the next time to wait. This behavior is in line with the gRPC standard for client-server communication.The change is needed for two reasons:
retry_delay
field.RetryInfo
in the error message. The error message will be retried automatically by the client. No changes to the client-side retry policies are needed to retry the new error.Changes in detail
recognize_server_retry_delay
andmax_server_retry_delay
options forRetryPolicy
classes in Python and Scala clients.recognize_server_retry_delay=True
will takeRetryInfo.retry_delay
into account when calculating the next backoff.retry_delay
can override client'smax_backoff
retry_delay
is limited bymax_server_retry_delay
(10 minutes by default).max_backoff
.DefaultPolicy
hasrecognize_server_retry_delay=True
and will useretry_delay
in the backoff calculation.RetryInfo
as retryable.DefaultPolicy
now retries all errors withRetryInfo
. If we keep the existing behaviour, an error that is both has theRetryInfo
and is matched by a differentCustomPolicy
, would be retried both by theDefaultPolicy
and by theCustomPolicy
. This can lead to excessively long retry periods and complicates the planning of total retry times.test_client.py
to a newtest_client_retries.py
file. Same for scala.Why are the changes needed?
See above
Does this PR introduce any user-facing change?
RetryInfo
grpc message using the DefaultPolicy.How was this patch tested?
Old and new unit tests.
Was this patch authored or co-authored using generative AI tooling?
No