Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
09fcb3e
Pass sql/core releated cases
LuciferYang Sep 30, 2021
adc566d
SparkBuild.scala
LuciferYang Sep 30, 2021
70fc3bf
revert project/SparkBuild.scala
LuciferYang Sep 30, 2021
2b60264
add SparkBuild.sh
LuciferYang Sep 30, 2021
7e016b3
fix comments
LuciferYang Sep 30, 2021
44c566f
change SparkBuild
LuciferYang Sep 30, 2021
1761e74
fix utils
LuciferYang Sep 30, 2021
3b0f6ed
add commnets
LuciferYang Sep 30, 2021
0bb8df7
add commnets
LuciferYang Sep 30, 2021
0861c5d
add comments
LuciferYang Sep 30, 2021
86517e6
add comments
LuciferYang Sep 30, 2021
4981260
add commnet
LuciferYang Sep 30, 2021
32ac109
Merge branch 'upmaster' into SPARK-36796
LuciferYang Oct 11, 2021
4aa3643
resolve conflicts
LuciferYang Oct 11, 2021
cfe530f
revert
LuciferYang Oct 11, 2021
733a754
revert
LuciferYang Oct 11, 2021
f61215f
Merge branch 'upmaster' into SPARK-36796
LuciferYang Oct 11, 2021
e70e4cc
add IgnoreUnrecognizedVMOptions
LuciferYang Oct 11, 2021
8628ed6
refactor
LuciferYang Oct 11, 2021
4017630
revert
LuciferYang Oct 11, 2021
1abe44e
revert change of LauncherBackendSuite
LuciferYang Oct 11, 2021
2925783
refactor
LuciferYang Oct 11, 2021
0e4bba8
fix case
LuciferYang Oct 11, 2021
ad22526
remove unused mothod
LuciferYang Oct 11, 2021
1fb8fb1
remove JavaModuleUtils
LuciferYang Oct 11, 2021
fdd912e
change to use private
LuciferYang Oct 12, 2021
41e73fe
Merge branch 'upmaster' into SPARK-36796
LuciferYang Oct 12, 2021
67c041f
remove new conf
LuciferYang Oct 12, 2021
2e87bde
remove new conf
LuciferYang Oct 12, 2021
ee8b1b8
Merge branch 'upmaster' into SPARK-36796
LuciferYang Oct 13, 2021
bc4bad7
Merge branch 'upmaster' into SPARK-36796
LuciferYang Oct 13, 2021
40ab4a8
Merge branch 'upmaster' into SPARK-36796
LuciferYang Oct 14, 2021
5098d31
Merge branch 'upmaster' into SPARK-36796
LuciferYang Oct 18, 2021
e773fc4
remove HashSet
LuciferYang Oct 19, 2021
2dec62e
revert change of SQLQueryTestSuite
LuciferYang Oct 19, 2021
c7265c9
Merge branch 'upmaster' into SPARK-36796
LuciferYang Oct 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/src/main/scala/org/apache/spark/SparkContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ class SparkContext(config: SparkConf) extends Logging {
// This should be set as early as possible.
SparkContext.fillMissingMagicCommitterConfsIfNeeded(_conf)

JavaModuleUtils.supplementJava17ModuleOptsIfNeeded(_conf)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you have any better suggestions about supplement --add-opens configurations to spark.driver.extraJavaOptions and spark.executor.extraJavaOptions for test cases using local and local-cluster modes.

@dongjoon-hyun @wangyum

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This call may not be necessary. I'm testing it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, this is necessary for UTs in the core module


_driverLogger = DriverLogger(_conf)

val resourcesFileOpt = conf.get(DRIVER_RESOURCES_FILE)
Expand Down
84 changes: 84 additions & 0 deletions core/src/main/scala/org/apache/spark/util/JavaModuleUtils.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* 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.util

import scala.collection.mutable

import org.apache.commons.lang3.{JavaVersion, SystemUtils}

import org.apache.spark.SparkConf
import org.apache.spark.internal.config.{DRIVER_JAVA_OPTIONS, EXECUTOR_JAVA_OPTIONS, OptionalConfigEntry}

object JavaModuleUtils {

private val javaModuleOptions = Set("--add-opens java.base/java.nio=ALL-UNNAMED",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's use = instead of space like --add-opens=java.base/java.nio=ALL-UNNAMED.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok

"--add-opens java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens java.base/java.lang.invoke=ALL-UNNAMED",
"--add-opens java.base/java.nio=ALL-UNNAMED",
"--add-opens java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens java.base/java.lang.invoke=ALL-UNNAMED",
"--add-opens java.base/java.util=ALL-UNNAMED",
"--add-opens java.base/sun.security.action=ALL-UNNAMED",
"--add-opens java.base/sun.util.calendar=ALL-UNNAMED",
"--add-opens java.base/java.lang=ALL-UNNAMED",
"--add-opens java.base/sun.nio.cs=ALL-UNNAMED",
"--add-opens java.base/java.net=ALL-UNNAMED",
"--add-opens java.base/java.io=ALL-UNNAMED",
"--add-opens java.base/java.util.concurrent=ALL-UNNAMED",
"--add-exports java.base/jdk.internal.util.random=ALL-UNNAMED")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, @LuciferYang !

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

BTW, I didn't realized that we need --add-exports. Could you explain a little more about this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

--add-exports is useless for the current pr , already remove it.

But It is needed in modules mllib-local and mllib, some code in test like mock[java.util.Random] need this --add-exports


def isJavaVersionAtLeast17: Boolean = SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_17)

def defaultModuleOptions(): String = javaModuleOptions.mkString(" ", " ", " ")


def supplementJava17ModuleOptsIfNeeded(conf: SparkConf): Unit = {

def supplementModuleOpts(configEntry: OptionalConfigEntry[String]): Unit = {
val v = conf.get(configEntry) match {
case Some(opts) => JavaModuleUtils.defaultModuleOptions() + opts
case None => JavaModuleUtils.defaultModuleOptions()
}
conf.set(configEntry.key, v)
}

if (Utils.isTesting && isJavaVersionAtLeast17) {
supplementModuleOpts(DRIVER_JAVA_OPTIONS)
supplementModuleOpts(EXECUTOR_JAVA_OPTIONS)
}
}

def supplementJava17ModuleOptsIfNeeded(args: Seq[String]): Seq[String] = {

def supplementModuleOpts(buffer: mutable.Buffer[String], key: String): Unit = {
val index = buffer.indexWhere(_.startsWith(s"$key}="))
if (index != -1) {
buffer.update(index, buffer(index) + JavaModuleUtils.defaultModuleOptions())
} else {
buffer.prependAll(Seq("--conf", s"$key=${JavaModuleUtils.defaultModuleOptions()}"))
}
}

if (Utils.isTesting && isJavaVersionAtLeast17) {
val buffer = args.toBuffer
supplementModuleOpts(buffer, DRIVER_JAVA_OPTIONS.key)
supplementModuleOpts(buffer, EXECUTOR_JAVA_OPTIONS.key)
buffer.toSeq
} else args
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import org.scalatest.time.SpanSugar._

import org.apache.spark.ProcessTestUtils.ProcessOutputCapturer
import org.apache.spark.SparkFunSuite
import org.apache.spark.util.Utils
import org.apache.spark.util.{JavaModuleUtils, Utils}

trait SparkSubmitTestUtils extends SparkFunSuite with TimeLimits {

Expand All @@ -53,7 +53,9 @@ trait SparkSubmitTestUtils extends SparkFunSuite with TimeLimits {
} else {
new File(new File(sparkHome, "bin"), "spark-submit")
}
val commands = Seq(sparkSubmit.getCanonicalPath) ++ args

val commands = Seq(sparkSubmit.getCanonicalPath) ++
JavaModuleUtils.supplementJava17ModuleOptsIfNeeded(args)
val commandLine = commands.mkString("'", "' '", "'")

val builder = new ProcessBuilder(commands: _*).directory(new File(sparkHome))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.scalatest.matchers.should.Matchers._

import org.apache.spark._
import org.apache.spark.internal.config.UI.UI_ENABLED
import org.apache.spark.util.Utils
import org.apache.spark.util.{JavaModuleUtils, Utils}

class LauncherBackendSuite extends SparkFunSuite with Matchers {

Expand All @@ -46,15 +46,22 @@ class LauncherBackendSuite extends SparkFunSuite with Matchers {
private def testWithMaster(master: String): Unit = {
val env = new java.util.HashMap[String, String]()
env.put("SPARK_PRINT_LAUNCH_COMMAND", "1")
val handle = new SparkLauncher(env)
val launcher = new SparkLauncher(env)
.setSparkHome(sys.props("spark.test.home"))
.setConf(SparkLauncher.DRIVER_EXTRA_CLASSPATH, System.getProperty("java.class.path"))
.setConf(UI_ENABLED.key, "false")
.setConf(SparkLauncher.DRIVER_EXTRA_JAVA_OPTIONS, s"-Dtest.appender=console")
.setMaster(master)
.setAppResource(SparkLauncher.NO_RESOURCE)
.setMainClass(TestApp.getClass.getName().stripSuffix("$"))
.startApplication()

if(JavaModuleUtils.isJavaVersionAtLeast17) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rather than just add these in tests, can we ensure they get added for Java 17 in the non-test code paths? like ensure that these args are always added to the JVM command? that would go a long way to not disrupting users

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree with @LuciferYang (#34153 (comment) ).
@srowen , why don't we add these options -XX:+IgnoreUnrecognizedVMOptions --add-opens=java.base/java.nio=ALL-UNNAMED ... always for all JDKs at Apache Spark 3.3? We can remove them later.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agree. We can set it wherever possible.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And nit: space after if

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, @srowen .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If we agree to always add -XX:+IgnoreUnrecognizedVMOptions --add-opens=java.base/java.nio=ALL-UNNAMED ... options now, let me see if there is a better way

launcher.setConf(SparkLauncher.DRIVER_EXTRA_JAVA_OPTIONS,
s"${JavaModuleUtils.defaultModuleOptions()} -Dtest.appender=console")
} else {
launcher.setConf(SparkLauncher.DRIVER_EXTRA_JAVA_OPTIONS, s"-Dtest.appender=console")
}
val handle = launcher.startApplication()

try {
eventually(timeout(30.seconds), interval(100.milliseconds)) {
Expand Down
26 changes: 24 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@

<test.java.home>${java.home}</test.java.home>

<extraJavaTestArgs></extraJavaTestArgs>

<!-- Some UI tests require Chrome and Chrome driver installed so those tests are disabled by default. -->
<test.default.exclude.tags>org.apache.spark.tags.ChromeUITest</test.default.exclude.tags>
<test.exclude.tags></test.exclude.tags>
Expand Down Expand Up @@ -2686,7 +2688,7 @@
<include>**/*Suite.java</include>
</includes>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<argLine>-ea -Xmx4g -Xss4m -XX:MaxMetaspaceSize=2g -XX:ReservedCodeCacheSize=${CodeCacheSize} -Dio.netty.tryReflectionSetAccessible=true</argLine>
<argLine>-ea -Xmx4g -Xss4m -XX:MaxMetaspaceSize=2g -XX:ReservedCodeCacheSize=${CodeCacheSize} ${extraJavaTestArgs} -Dio.netty.tryReflectionSetAccessible=true</argLine>
<environmentVariables>
<!--
Setting SPARK_DIST_CLASSPATH is a simple way to make sure any child processes
Expand Down Expand Up @@ -2737,7 +2739,7 @@
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>SparkTestSuite.txt</filereports>
<argLine>-ea -Xmx4g -Xss4m -XX:MaxMetaspaceSize=2g -XX:ReservedCodeCacheSize=${CodeCacheSize} -Dio.netty.tryReflectionSetAccessible=true</argLine>
<argLine>-ea -Xmx5g -Xss4m -XX:MaxMetaspaceSize=2g -XX:ReservedCodeCacheSize=${CodeCacheSize} ${extraJavaTestArgs} -Dio.netty.tryReflectionSetAccessible=true</argLine>
Comment thread
LuciferYang marked this conversation as resolved.
Outdated
<stderr/>
<environmentVariables>
<!--
Expand Down Expand Up @@ -3431,6 +3433,26 @@

</profile>

<profile>
<id>jdk-17</id>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we make this active by default on Java 17? Does it cause any conflicts with other profiles currently?

      <activation>
        <jdk>[17,)</jdk>
      </activation>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think that helps - this just controls whether it's active when built with JDK 17. We're not building with 17 anytime soon

<properties>
<extraJavaTestArgs>
--add-opens java.base/java.nio=ALL-UNNAMED

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use --add-opens=java.base/java.nio=ALL-UNNAMED pattern.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dongjoon-hyun this profile already removed

--add-opens java.base/sun.nio.ch=ALL-UNNAMED
--add-opens java.base/java.lang.invoke=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/sun.security.action=ALL-UNNAMED
--add-opens java.base/sun.util.calendar=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
--add-opens java.base/sun.nio.cs=ALL-UNNAMED
--add-opens java.base/java.net=ALL-UNNAMED
--add-opens java.base/java.util.concurrent=ALL-UNNAMED
--add-exports java.base/jdk.internal.util.random=ALL-UNNAMED
</extraJavaTestArgs>
</properties>
</profile>

<!--
This is a profile to enable the use of the ASF snapshot and staging repositories
during a build. It is useful when testing against nightly or RC releases of dependencies.
Expand Down
2 changes: 1 addition & 1 deletion sql/catalyst/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<configuration>
<argLine>-ea -Xmx4g -Xss4m -XX:ReservedCodeCacheSize=${CodeCacheSize} -Dio.netty.tryReflectionSetAccessible=true</argLine>
<argLine>-ea -Xmx4g -Xss4m -XX:ReservedCodeCacheSize=${CodeCacheSize} ${extraJavaTestArgs} -Dio.netty.tryReflectionSetAccessible=true</argLine>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ private object DateTimeFormatterHelper {
// 2.4, the SimpleDateFormat uses Monday as the first day of week.
final val weekBasedLetters = Set('Y', 'W', 'w', 'u', 'e', 'c')
final val unsupportedLetters = Set('A', 'n', 'N', 'p')
final val unknownPatternLetters: Set[Char] = Set('B')
Comment thread
LuciferYang marked this conversation as resolved.
Outdated
// The quarter fields will also be parsed strangely, e.g. when the pattern contains `yMd` and can
// be directly resolved then the `q` do check for whether the month is valid, but if the date
// fields is incomplete, e.g. `yM`, the checking will be bypassed.
Expand Down Expand Up @@ -322,6 +323,9 @@ private object DateTimeFormatterHelper {
(isParsing && unsupportedLettersForParsing.contains(c))) {
throw new IllegalArgumentException(s"Illegal pattern character: $c")
}
for (c <- patternPart if unknownPatternLetters.contains(c)) {

@LuciferYang LuciferYang Sep 30, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dongjoon-hyun @wangyum the result of select date_format('2018-11-17 13:33:33.333', 'B') in datetime-formatting-invalid.sql with Java 8 is:

-- !query
select date_format('2018-11-17 13:33:33.333', 'B')
-- !query schema
struct<>
-- !query output
java.lang.IllegalArgumentException
Unknown pattern letter: B

With Java 17 the result is

- datetime-formatting-invalid.sql *** FAILED ***
  datetime-formatting-invalid.sql
  Expected "struct<[]>", but got "struct<[date_format(2018-11-17 13:33:33.333, B):string]>" Schema did not match for query #34
  select date_format('2018-11-17 13:33:33.333', 'B'): -- !query
  select date_format('2018-11-17 13:33:33.333', 'B')
  -- !query schema
  struct<date_format(2018-11-17 13:33:33.333, B):string>
  -- !query output
  in the afternoon (SQLQueryTestSuite.scala:469)

'B' is used to represent Pattern letters to output a day period in Java 17

*  Pattern  Count  Equivalent builder methods
     *  -------  -----  --------------------------
     *    B       1      appendDayPeriodText(TextStyle.SHORT)
     *    BBBB    4      appendDayPeriodText(TextStyle.FULL)
     *    BBBBB   5      appendDayPeriodText(TextStyle.NARROW)

Manual disabled it there for compatibility with Java 8 behavior.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

SGTM since the pattern is not documented/supported http://spark.apache.org/docs/latest/sql-ref-datetime-pattern.html

@dongjoon-hyun dongjoon-hyun Oct 5, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you make this a separate PR please, @LuciferYang ? We can merge that first before this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Could you make this a separate PR please, @LuciferYang ? We can merge that first before this.

OK

throw new IllegalArgumentException(s"Unknown pattern letter: $c")
}
for (style <- unsupportedPatternLengths if patternPart.contains(style)) {
throw new IllegalArgumentException(s"Too many pattern letters: ${style.head}")
}
Expand Down
2 changes: 1 addition & 1 deletion sql/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<configuration>
<argLine>-ea -Xmx4g -Xss4m -XX:ReservedCodeCacheSize=${CodeCacheSize} -Dio.netty.tryReflectionSetAccessible=true</argLine>
<argLine>-ea -Xmx4g -Xss4m -XX:ReservedCodeCacheSize=${CodeCacheSize} ${extraJavaTestArgs} -Dio.netty.tryReflectionSetAccessible=true</argLine>
</configuration>
</plugin>
<plugin>
Expand Down
Loading