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-47986][CONNECT][PYTHON] Unable to create a new session when the default session is closed by the server #46435

Closed
wants to merge 5 commits into from

Conversation

nija-at
Copy link
Contributor

@nija-at nija-at commented May 7, 2024

What changes were proposed in this pull request?

This is a follow-up to a previous improvement - 7d04d0f.

In some cases, particularly when running older versions of the Spark
cluster (3.5), the error actually manifests as a mismatch in the
observed server-side session id between calls.

With this fix, we also capture this case and ensure that this case is
also handled.

Further, we improve the implementation of getActiveSession()
and introduce a similar getDefaultSession() that accounts for
stopped sessions.
This ensures that all places where default or active session is used,
stopped sessions are considered neither default nor active.

Why are the changes needed?

Explained above.

Does this PR introduce any user-facing change?

Previously, when client encounters a session mismatch, a user
cannot create a new session. With this change, a user can
call getOrCreate() on the SparkSession builder and create a
new session.

How was this patch tested?

Attached unit tests.

Was this patch authored or co-authored using generative AI tooling?

No.

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

LGTM otherwise

@HyukjinKwon
Copy link
Member

Merged to master.

JacobZheng0927 pushed a commit to JacobZheng0927/spark that referenced this pull request May 11, 2024
…e default session is closed by the server

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

This is a follow-up to a previous improvement - 7d04d0f.

In some cases, particularly when running older versions of the Spark
cluster (3.5), the error actually manifests as a mismatch in the
observed server-side session id between calls.

With this fix, we also capture this case and ensure that this case is
also handled.

Further, we improve the implementation of `getActiveSession()`
and introduce a similar `getDefaultSession()` that accounts for
stopped sessions.
This ensures that all places where default or active session is used,
stopped sessions are considered neither default nor active.

### Why are the changes needed?

Explained above.

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

Previously, when client encounters a session mismatch, a user
cannot create a new session. With this change, a user can
call `getOrCreate()` on the SparkSession builder and create a
new session.

### How was this patch tested?

Attached unit tests.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#46435 from nija-at/session-expires-part2.

Lead-authored-by: Niranjan Jayakar <nija@databricks.com>
Co-authored-by: Hyukjin Kwon <gurwls223@gmail.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
2 participants