-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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
Conversation
This file contains 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
HyukjinKwon
reviewed
May 8, 2024
HyukjinKwon
approved these changes
May 8, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise
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>
HyukjinKwon
pushed a commit
that referenced
this pull request
Jun 19, 2024
… the default session is closed by the server ### What changes were proposed in this pull request? This is a Scala port of #46221 and #46435. A client is unaware of a server restart or the server having closed the client until it receives an error. However, at this point, the client in unable to create a new session to the same connect endpoint, since the stale session is still recorded as the active and default session. With this change, when the server communicates that the session has changed via a GRPC error, the session and the respective client are marked as stale, thereby allowing a new default connection can be created via the session builder. 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. ### Why are the changes needed? Being unable to use getOrCreate() after an error is unacceptable and should be fixed. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? ./build/sbt testOnly *SparkSessionE2ESuite ### Was this patch authored or co-authored using generative AI tooling? No Closes #47008 from changgyoopark-db/SPARK-47986. Authored-by: Changgyoo Park <changgyoo.park@databricks.com> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
attilapiros
pushed a commit
to attilapiros/spark
that referenced
this pull request
Oct 4, 2024
… the default session is closed by the server ### What changes were proposed in this pull request? This is a Scala port of apache#46221 and apache#46435. A client is unaware of a server restart or the server having closed the client until it receives an error. However, at this point, the client in unable to create a new session to the same connect endpoint, since the stale session is still recorded as the active and default session. With this change, when the server communicates that the session has changed via a GRPC error, the session and the respective client are marked as stale, thereby allowing a new default connection can be created via the session builder. 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. ### Why are the changes needed? Being unable to use getOrCreate() after an error is unacceptable and should be fixed. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? ./build/sbt testOnly *SparkSessionE2ESuite ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47008 from changgyoopark-db/SPARK-47986. Authored-by: Changgyoo Park <changgyoo.park@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
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?
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 forstopped 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 anew session.
How was this patch tested?
Attached unit tests.
Was this patch authored or co-authored using generative AI tooling?
No.