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

[SPARK-44193][CONNECT] Implement GRPC exceptions interception for conversion #41743

Closed
wants to merge 3 commits into from

Conversation

heyihong
Copy link
Contributor

@heyihong heyihong commented Jun 26, 2023

What changes were proposed in this pull request?

This PR adds GrpcStub and GrpcExceptionConverter utilities to the Spark Connect Scala Client so that the client can intercept the GRPC Exceptions and convert them to Spark related exceptions. The change converts all GRPC RuntimeStatusException to SparkException as a starting point.

Why are the changes needed?

Intercept GRPC Exceptions in Spark Connect Scala Client and convert them to Spark related exceptions for making exceptions more compatible with the existing behaviors

Does this PR introduce any user-facing change?

No

How was this patch tested?

Existing tests

@heyihong heyihong changed the title [SPARK-42554][CONNECT] Implement GRPC exceptions interception [SPARK-42554][CONNECT] Implement GRPC exceptions interception for conversion Jun 26, 2023
Copy link
Contributor

@juliuszsompolski juliuszsompolski left a comment

Choose a reason for hiding this comment

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

TMLG (To me it looks good.)

Copy link
Contributor

@grundprinzip grundprinzip left a comment

Choose a reason for hiding this comment

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

Please change the name.

@juliuszsompolski
Copy link
Contributor

juliuszsompolski commented Jul 4, 2023

Followup:
I noticed that ArtifactManager uses GRPC stubs directly, and it also needs the non-blocking stub.
Do we need error conversion for addArtifacts as well? Even if not, if we want to make this generic for adding similar wrappers, do we want to add a CustomSparkConnectNonBlockingStub as well (that hopefully could reuse GrpcExceptionConverter? Should functions be added to SparkConnectClient to be used by ArtifactManager instead of it using stubs directly?

cc also @dillitz

@heyihong
Copy link
Contributor Author

heyihong commented Jul 4, 2023

Followup: I noticed that ArtifactManager uses GRPC stubs directly, and it also needs the non-blocking stub. Do we need error conversion for addArtifacts as well? Even if not, if we want to make this generic for adding similar wrappers, do we want to add a CustomSparkConnectNonBlockingStub as well (that hopefully could reuse GrpcExceptionConverter? Should functions be added to SparkConnectClient to be used by ArtifactManager instead of it using stubs directly?

cc also @dillitz

Yes, that's a good point. It would be nice to have similar (ideally the same) wrappers for both blocking and non-blocking stubs in ArtifactManager.

@juliuszsompolski
Copy link
Contributor

It would be nice to have similar (ideally the same) wrappers for both blocking and non-blocking stubs in ArtifactManager.

I'd be in favor of also adding functions to SparkConnectClient that the ArtifactManager, so that every RPC goes through SparkConnectClient.

@HyukjinKwon
Copy link
Member

Merged to master.

@heyihong heyihong changed the title [SPARK-42554][CONNECT] Implement GRPC exceptions interception for conversion [SPARK-44193][CONNECT] Implement GRPC exceptions interception for conversion Jul 5, 2023
HyukjinKwon pushed a commit that referenced this pull request Jul 7, 2023
…k Connect

### What changes were proposed in this pull request?
This PR introduces a configurable retry mechanism for the Scala `SparkConnectClient`.
Parameters for the exponential backoff and a filter for exceptions to retry are passed to the client via the existing (extended) `Configuration` class. By default, only RuntimeStatusException: Unavailable triggers a retry - this mirrors the default retry behavior in the Python client.

One might want to move the retry logic into the GRPC stub that will potentially be introduced [here](#41743).

### Why are the changes needed?
There are a few existing exceptions that one might want to handle with a retry.
For example, this would allow one to not exit with an exception when executing a command while the cluster is still starting.

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Tests included.

Closes #41829 from dillitz/spark-44275-retries.

Authored-by: Robert Dillitz <robert.dillitz@databricks.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
ragnarok56 pushed a commit to ragnarok56/spark that referenced this pull request Mar 2, 2024
…version

### What changes were proposed in this pull request?

This PR adds GrpcStub and GrpcExceptionConverter utilities to the Spark Connect Scala Client so that  the client can intercept the GRPC Exceptions and convert them to Spark related exceptions. The change converts all GRPC RuntimeStatusException to SparkException as a starting point.

### Why are the changes needed?

Intercept GRPC Exceptions in Spark Connect Scala Client and convert them to Spark related exceptions for making exceptions more compatible with the existing behaviors

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

Existing tests

Closes apache#41743 from heyihong/SPARK-42554.

Authored-by: Yihong He <yihong.he@databricks.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
ragnarok56 pushed a commit to ragnarok56/spark that referenced this pull request Mar 2, 2024
…k Connect

### What changes were proposed in this pull request?
This PR introduces a configurable retry mechanism for the Scala `SparkConnectClient`.
Parameters for the exponential backoff and a filter for exceptions to retry are passed to the client via the existing (extended) `Configuration` class. By default, only RuntimeStatusException: Unavailable triggers a retry - this mirrors the default retry behavior in the Python client.

One might want to move the retry logic into the GRPC stub that will potentially be introduced [here](apache#41743).

### Why are the changes needed?
There are a few existing exceptions that one might want to handle with a retry.
For example, this would allow one to not exit with an exception when executing a command while the cluster is still starting.

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Tests included.

Closes apache#41829 from dillitz/spark-44275-retries.

Authored-by: Robert Dillitz <robert.dillitz@databricks.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants