-
Notifications
You must be signed in to change notification settings - Fork 29.2k
[SPARK-56448][CONNECT] Fix NPE on Spark Connect client restart due to ammonite compile cache #55720
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
+77
−0
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
72 changes: 72 additions & 0 deletions
72
...ect/client/jvm/src/test/scala/org/apache/spark/sql/application/AmmoniteReplE2ESuite.scala
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.spark.sql.application | ||
|
|
||
| import java.util.concurrent.TimeUnit | ||
|
|
||
| import scala.collection.mutable.ArrayBuffer | ||
| import scala.sys.process.BasicIO | ||
|
|
||
| import org.apache.spark.sql.connect.test.{ConnectFunSuite, RemoteSparkSession} | ||
| import org.apache.spark.tags.AmmoniteTest | ||
|
|
||
| @AmmoniteTest | ||
| class AmmoniteReplE2ESuite extends ConnectFunSuite with RemoteSparkSession { | ||
|
|
||
| private def runSparkShell(): (Int, String, String) = { | ||
| val sparkHome = sys.props.getOrElse( | ||
| "spark.test.home", | ||
| sys.env.getOrElse("SPARK_HOME", fail("spark.test.home or SPARK_HOME not set"))) | ||
| val command = Seq(s"$sparkHome/bin/spark-shell", "--remote", s"sc://localhost:$serverPort") | ||
|
|
||
| val process = new ProcessBuilder(command: _*).start() | ||
| // Close stdin immediately so shell exits on EOF | ||
| process.getOutputStream.close() | ||
|
|
||
| val stdout = new ArrayBuffer[String]() | ||
| val stderr = new ArrayBuffer[String]() | ||
| val stdoutThread = new Thread() { | ||
| setDaemon(true) | ||
| override def run(): Unit = BasicIO.processFully(stdout += _)(process.getInputStream) | ||
| } | ||
| val stderrThread = new Thread() { | ||
| setDaemon(true) | ||
| override def run(): Unit = BasicIO.processFully(stderr += _)(process.getErrorStream) | ||
| } | ||
| stdoutThread.start() | ||
| stderrThread.start() | ||
|
|
||
| val exited = process.waitFor(60, TimeUnit.SECONDS) | ||
| if (!exited) { | ||
| process.destroyForcibly() | ||
| fail("spark-shell did not exit within 60 seconds") | ||
| } | ||
| stdoutThread.join(10000) | ||
| stderrThread.join(10000) | ||
| (process.exitValue(), stdout.mkString("\n"), stderr.mkString("\n")) | ||
| } | ||
|
|
||
| test("SPARK-56448: restarting spark-shell --remote does not throw NPE") { | ||
| // First invocation | ||
| val (exit1, _, stderr1) = runSparkShell() | ||
| assert(exit1 == 0, s"First spark-shell failed (exit=$exit1): $stderr1") | ||
|
|
||
| // Second invocation -- without the fix, this would NPE from stale Ammonite cache | ||
| val (exit2, _, stderr2) = runSparkShell() | ||
| assert(exit2 == 0, s"Second spark-shell failed (exit=$exit2): $stderr2") | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
This test case seems to introduce a flakiness. I didn't dig much, but have you observed the following failures in your CIs, @yadavay-amzn and @attilapiros ?
cc @peter-toth
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.
@dongjoon-hyun Thanks for taking a look. We haven't seen this specific Arrow/Netty failure in our CI runs.
The CI failures we saw were always the
OracleIntegrationSuiteDocker test.The test launches spark-shell --remote as a subprocess, so it's sensitive to the JDK environment the CI runner uses. Would it help to add a retry or mark this test as flaky?
I'll also investigate the Arrow/Netty root cause by running the test locally to see if the CI flaky behavior is reproducible locally.
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.
Ran the
AmmoniteReplE2ESuitetest 10 times locally on current master (JDK 17) and its passing consistently. So the flakiness seems specific to the CI run.The error (
ExceptionInInitializerErrorin Arrow'sDefaultAllocationManagerFactory/ Netty'sPooledByteBufAllocatorL) looks like a JDK/Arrow memory allocator incompatibility which may be JDK version sensitive. The test itself just launches spark-shell --remote as a subprocess and it doesn't do anything Arrow/Netty-specific.@dongjoon-hyun / @peter-toth Could you share which JDK vendor/version and CI environment produced the failure? Or a link to the CI job if you have it? I can deep dive to figure out the issue and try repro with same setup.
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.
Thank you for confirming, @yadavay-amzn . For my cases, the failures are consistently observed with Java 25 +
UBI 10combination.