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-51691][CORE][TESTS] SerializationDebugger should swallow exception when try to find the reason of serialization problem #50489

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

summaryzb
Copy link
Contributor

@summaryzb summaryzb commented Apr 2, 2025

What changes were proposed in this pull request?

Catch SparkRuntimeException when deep into serialization exception stack during unit test.

Why are the changes needed?

Present a clearer serialization exception stack hierarchy during test, toString implementation of TreeNode may throw exception since SQLConf.get check. It is helpful for debug the real problem

Does this PR introduce any user-facing change?

Yes, but it only take effect in unit test.
User will see the direct serialization exception and the reference chain beyond the root cause.
Before this pr, user will get confuse when unrelated exception is shown

WARN org.apache.spark.serializer.SerializationDebugger: Exception in serialization debugger
org.apache.spark.SparkRuntimeException: Cannot get SQLConf inside scheduler event loop thread.
    at org.apache.spark.sql.errors.QueryExecutionErrors$.cannotGetSQLConfInSchedulerEventLoopThreadError(QueryExecutionErrors.scala:2002)
    at org.apache.spark.sql.internal.SQLConf$.get(SQLConf.scala:225)
    at org.apache.spark.sql.execution.ScalarSubquery.toString(subquery.scala:69)
    at java.lang.String.valueOf(String.java:2994)
    at scala.collection.mutable.StringBuilder.append(StringBuilder.scala:203)
    at scala.collection.immutable.Stream.addString(Stream.scala:701)
    at scala.collection.TraversableOnce.mkString(TraversableOnce.scala:377)
org.apache.spark.SparkException: Job aborted due to stage failure: Task not serializable: java.io.NotSerializableException: 
org.apache.spark.SimpleFutureAction

After this pr

org.apache.spark.SparkException: Job aborted due to stage failure: Task not serializable: java.io.NotSerializableException: org.apache.spark.SimpleFutureAction
Serialization stack:
	- object not serializable (class: org.apache.spark.SimpleFutureAction, value: org.apache.spark.SimpleFutureAction@4050649d)
	- writeObject data (class: java.util.concurrent.ConcurrentHashMap)
	- object (class java.util.concurrent.ConcurrentHashMap)
	....(not shown)

How was this patch tested?

Pass GitHub Actions

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

No

…en try to find the reason of serialization problem
@github-actions github-actions bot added the CORE label Apr 2, 2025
} catch {
case _: SparkRuntimeException => "cannot print object"
}
val elem = s"object (class ${s.getClass.getName}, $str)"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to add a new test case? Or which existing test case covers this scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add test SPARK-51691 improveException swallow underlying exception to cover this scenario

Copy link
Contributor

Choose a reason for hiding this comment

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

can we just add a branch like case s: Object with java.io.Serializable if Utils.isTesting =>

@summaryzb summaryzb requested a review from LuciferYang April 5, 2025 06:37
@@ -205,6 +214,12 @@ class SerializableClass1 extends Serializable

class SerializableClass2(val objectField: Object) extends Serializable

class SerializableClassWithStringException(val objectField: Object) extends Serializable {
override def toString: String = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This simulate the behavior of toString implementation of TreeNode, since SQLConf.get may throw exception

Copy link
Contributor

Choose a reason for hiding this comment

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

} else if (Utils.isTesting) {
throw QueryExecutionErrors.cannotGetSQLConfInSchedulerEventLoopThreadError()

So is this an issue that can only occur during testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it only throw exception in during test

@LuciferYang
Copy link
Contributor

@summaryzb Could you update the description of the pr to clarify that the changes in this PR are intended to present a clearer exception stack hierarchy in the tests? (Is my understanding correct?)
Additionally, I think it would be appropriate to add the [TESTS] tag to the PR title.

@summaryzb summaryzb changed the title [SPARK-51691][CORE] SerializationDebugger should swallow exception when try to find the reason of serialization problem [SPARK-51691][CORE][TESTS] SerializationDebugger should swallow exception when try to find the reason of serialization problem Apr 8, 2025
@summaryzb
Copy link
Contributor Author

Update the title and description to clarify that this is a unit test issue

Copy link
Contributor

@LuciferYang LuciferYang left a comment

Choose a reason for hiding this comment

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

+1, LGTM
Let's wait for another 48 hours, If no one has any other comments, I will merge it.

@the-sakthi
Copy link
Member

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants