-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-49423][CONNECT][SQL] Consolidate Observation in sql/api #47921
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
Closed
Conversation
This file contains hidden or 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
hvanhovell
commented
Aug 28, 2024
| } | ||
| } | ||
| private[spark] def setMetricsAndNotify(metrics: Row): Boolean = { | ||
| val metricsMap = metrics.getValuesMap(metrics.schema.map(_.name)) |
Contributor
Author
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.
I am still wondering why this needed to be a map...
Contributor
Author
|
@xupefei can you take a look? |
HyukjinKwon
approved these changes
Aug 29, 2024
Contributor
Author
|
Merging to master |
gengliangwang
pushed a commit
that referenced
this pull request
Oct 20, 2025
### What changes were proposed in this pull request? This patch proposes a fix to a deadlock bug in `Observation`. It replaces `synchronized` locks with a promise to avoid deadlock happened between `get` and `onFinish` methods ### Why are the changes needed? `Observation` class has been evolved a few times during Spark 3.5 to Spark 4.0.0. Previously it uses locking mechanism (`synchronized`) between `get` and `onFinish` methods to coordinate metrics update and retrieval. But it has a potential deadlocking bug. If `get` is called before `ObservationListener` is triggered to call `onFinish`, `get` will forever be waiting for metrics because it locks the observation object by `synchronized` so later `onFinish` call is locked out from updating the metrics. This locking mechanism was replaced by a promise by #47921 that is a large refacroring on observation feature. But in the PR, I don’t see the deadlock bug was mentioned, and there is no bug fix PR proposed to earlier versions. So I think that the bug was not known and the fix is unintentional in Spark 4.0.0. The bug is still in Spark 3.5 branch. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? The deadlock bug was hit by customer and is tricky to reproducing by unit test. This patch should pass existing tests. ### Was this patch authored or co-authored using generative AI tooling? No Closes #52657 from viirya/fix_observation_deadlock. Authored-by: Liang-Chi Hsieh <viirya@gmail.com> Signed-off-by: Gengliang Wang <gengliang@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 PR moves Observation into sql/api. For classic I moved the wiring into the
observemethod itself, and the required listener is now part of theorg.apache.spark.sql.internalpackage. I have also take the liberty to get rid of most of the homegrown locking, and I have replaced it with a promise.Why are the changes needed?
We are creating a shared interface for the classic and connect Scala DataFrame API. This class is part of that API.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Existing tests.
Was this patch authored or co-authored using generative AI tooling?
No.