Skip to content

Conversation

@LuciferYang
Copy link
Contributor

@LuciferYang LuciferYang commented Sep 30, 2021

What changes were proposed in this pull request?

In order to pass the UTs related to sql/core and dependent modules, this pr mainly does the following change:

  • Add a new property named extraJavaTestArgs to pom.xml, It includes all --add-opens configurations required for UTs with Java 17 and It also include -XX:+IgnoreUnrecognizedVMOptions to compatible with Java 8.
  • Add a new helper class named JavaModuleOptions to place constant and methods related to --add-opens
  • --add-opens options and -XX:+IgnoreUnrecognizedVMOptions is added by default when SparkSubmitCommandBuilder builds the submit command, this can help local-cluster related UTs pass and help users reduce the cost of using java 17
  • --add-opens options and -XX:+IgnoreUnrecognizedVMOptions is supplemented to spark.driver.extraJavaOptions and spark.executor.extraJavaOptions when init SparkContext, this also can help UTs pass and help users reduce the cost of using java 17

Why are the changes needed?

Pass Spark UTs with JDK 17

Does this PR introduce any user-facing change?

No

How was this patch tested?

  • Pass the Jenkins or GitHub Action
  • Manual test mvn clean install -pl sql/core -am with Java 17, only select format_string('%0$s', 'Hello') in postgreSQL/text.sql failed due to the different behavior of Java 8 and Java 17

@LuciferYang LuciferYang changed the title [SPARK-36796][BUILD][CORE][SQL] Pass all sql/core and dependent modules UTs with JDK 17 [WIP][SPARK-36796][BUILD][CORE][SQL] Pass all sql/core and dependent modules UTs with JDK 17 Sep 30, 2021
@LuciferYang LuciferYang marked this pull request as draft September 30, 2021 04:09
@SparkQA
Copy link

SparkQA commented Sep 30, 2021

Test build #143745 has finished for PR 34153 at commit 09fcb3e.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Sep 30, 2021

Kubernetes integration test unable to build dist.

exiting with code: 1
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48256/

@SparkQA
Copy link

SparkQA commented Sep 30, 2021

Test build #143746 has finished for PR 34153 at commit adc566d.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@LuciferYang LuciferYang changed the title [WIP][SPARK-36796][BUILD][CORE][SQL] Pass all sql/core and dependent modules UTs with JDK 17 [WIP][SPARK-36796][BUILD][CORE][SQL] Pass all sql/core and dependent modules UTs with JDK 17 and Maven Sep 30, 2021
@SparkQA
Copy link

SparkQA commented Sep 30, 2021

Kubernetes integration test unable to build dist.

exiting with code: 1
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48257/

@SparkQA
Copy link

SparkQA commented Sep 30, 2021

Test build #143747 has finished for PR 34153 at commit 70fc3bf.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

"--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
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
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
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

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

Instead of adding jdk-17 profile, you can add like the following always. Last time, I learned that --add-opens= do the tricks on the JIRA you mentioned your idea.

-XX:+IgnoreUnrecognizedVMOptions --add-opens=java.base/java.nio=ALL-UNNAMED ...


object JavaModuleUtils {

private val javaModuleOptions = Set("--add-opens java.base/java.nio=ALL-UNNAMED",
Copy link
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
Contributor Author

Choose a reason for hiding this comment

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

ok

@SparkQA
Copy link

SparkQA commented Sep 30, 2021

Kubernetes integration test unable to build dist.

exiting with code: 1
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48258/

@SparkQA
Copy link

SparkQA commented Sep 30, 2021

Test build #143748 has finished for PR 34153 at commit 2b60264.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Sep 30, 2021

Kubernetes integration test unable to build dist.

exiting with code: 1
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48259/

@SparkQA
Copy link

SparkQA commented Sep 30, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48262/

@SparkQA
Copy link

SparkQA commented Sep 30, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48265/

@LuciferYang LuciferYang changed the title [WIP][SPARK-36796][BUILD][CORE][SQL] Pass all sql/core and dependent modules UTs with JDK 17 and Maven [WIP][SPARK-36796][BUILD][CORE][SQL] Pass all sql/core and dependent modules UTs use Maven with JDK 17 Sep 30, 2021
@LuciferYang LuciferYang changed the title [SPARK-36796][BUILD][CORE][SQL] Pass all sql/core and dependent modules UTs use Maven with JDK 17 [SPARK-36796][BUILD][CORE][SQL] Pass all sql/core and dependent modules UTs with JDK 17 Oct 19, 2021
@LuciferYang LuciferYang changed the title [SPARK-36796][BUILD][CORE][SQL] Pass all sql/core and dependent modules UTs with JDK 17 [SPARK-36796][BUILD][CORE][SQL] Pass all sql/core and dependent modules UTs with JDK 17 except one case in postgreSQL/text.sql Oct 19, 2021
@LuciferYang
Copy link
Contributor Author

Do we need to wait on a resolution to the date difference here or treat it separately? would it mean we don't have to change the expected output?

I created a new Jira SPARK-37013 and #34153 try to fix the different string format behavior between Java 8 and Java 17, the relevant code has been removed from this pr.

At present, this pr only adds the default --add-opens options and -XX:+IgnoreUnrecognizedVMOptions where needed, and passed UTs except select format_string('%0$s', 'Hello') in postgreSQL/text.sql

@LuciferYang
Copy link
Contributor Author

If this pr is merged, we can continue to verify other modules

@SparkQA
Copy link

SparkQA commented Oct 19, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48857/

@SparkQA
Copy link

SparkQA commented Oct 19, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48858/

@SparkQA
Copy link

SparkQA commented Oct 19, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48858/

@SparkQA
Copy link

SparkQA commented Oct 19, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48857/

@SparkQA
Copy link

SparkQA commented Oct 19, 2021

Test build #144383 has finished for PR 34153 at commit e773fc4.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Oct 19, 2021

Test build #144384 has finished for PR 34153 at commit 2dec62e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Oct 19, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48871/

@SparkQA
Copy link

SparkQA commented Oct 19, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48871/

@SparkQA
Copy link

SparkQA commented Oct 19, 2021

Test build #144396 has finished for PR 34153 at commit c7265c9.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • trait ExtractValue extends Expression with NullIntolerant

@srowen srowen closed this in 3849340 Oct 19, 2021
@srowen
Copy link
Member

srowen commented Oct 19, 2021

Merged to master

@dongjoon-hyun
Copy link
Member

Thank you so much, @LuciferYang and @srowen and all!

@LuciferYang
Copy link
Contributor Author

thanks all ~

dongjoon-hyun added a commit that referenced this pull request Sep 18, 2023
…s` to drivers

### What changes were proposed in this pull request?

This PR aims to make `StandaloneRestServer` add `JavaModuleOptions` to drivers by default.

### Why are the changes needed?

Since Apache Spark 3.3.0 (SPARK-36796, #34153), `SparkContext` adds `JavaModuleOptions` by default.

We had better add `JavaModuleOptions` when `StandaloneRestServer` receives submissions via REST API, too. Otherwise, it fails like the following if the users don't set it manually.

**SUBMISSION**
```bash
$ SPARK_MASTER_OPTS="-Dspark.master.rest.enabled=true" sbin/start-master.sh
$ curl -s -k -XPOST http://yourserver:6066/v1/submissions/create \
    --header "Content-Type:application/json;charset=UTF-8" \
    --data '{
      "appResource": "",
      "sparkProperties": {
        "spark.master": "local[2]",
        "spark.app.name": "Test 1",
        "spark.submit.deployMode": "cluster",
        "spark.jars": "/Users/dongjoon/APACHE/spark-release/spark-3.5.0-bin-hadoop3/examples/jars/spark-examples_2.12-3.5.0.jar"
      },
      "clientSparkVersion": "",
      "mainClass": "org.apache.spark.examples.SparkPi",
      "environmentVariables": {},
      "action": "CreateSubmissionRequest",
      "appArgs": []
    }'
```

**DRIVER `stderr` LOG**
```
Exception in thread "main" java.lang.reflect.InvocationTargetException
...
at org.apache.spark.deploy.worker.DriverWrapper.main(DriverWrapper.scala)
Caused by: java.lang.IllegalAccessError: class org.apache.spark.storage.StorageUtils$
(in unnamed module 0x6d7a93c9) cannot access class sun.nio.ch.DirectBuffer
(in module java.base) because module java.base does not export sun.nio.ch
to unnamed module 0x6d7a93c9
```

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass the CIs with the newly added test case.

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

No.

Closes #42975 from dongjoon-hyun/SPARK-45197.

Authored-by: Dongjoon Hyun <dhyun@apple.com>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
viirya pushed a commit to viirya/spark-1 that referenced this pull request Oct 19, 2023
…s` to drivers

### What changes were proposed in this pull request?

This PR aims to make `StandaloneRestServer` add `JavaModuleOptions` to drivers by default.

### Why are the changes needed?

Since Apache Spark 3.3.0 (SPARK-36796, apache#34153), `SparkContext` adds `JavaModuleOptions` by default.

We had better add `JavaModuleOptions` when `StandaloneRestServer` receives submissions via REST API, too. Otherwise, it fails like the following if the users don't set it manually.

**SUBMISSION**
```bash
$ SPARK_MASTER_OPTS="-Dspark.master.rest.enabled=true" sbin/start-master.sh
$ curl -s -k -XPOST http://yourserver:6066/v1/submissions/create \
    --header "Content-Type:application/json;charset=UTF-8" \
    --data '{
      "appResource": "",
      "sparkProperties": {
        "spark.master": "local[2]",
        "spark.app.name": "Test 1",
        "spark.submit.deployMode": "cluster",
        "spark.jars": "/Users/dongjoon/APACHE/spark-release/spark-3.5.0-bin-hadoop3/examples/jars/spark-examples_2.12-3.5.0.jar"
      },
      "clientSparkVersion": "",
      "mainClass": "org.apache.spark.examples.SparkPi",
      "environmentVariables": {},
      "action": "CreateSubmissionRequest",
      "appArgs": []
    }'
```

**DRIVER `stderr` LOG**
```
Exception in thread "main" java.lang.reflect.InvocationTargetException
...
at org.apache.spark.deploy.worker.DriverWrapper.main(DriverWrapper.scala)
Caused by: java.lang.IllegalAccessError: class org.apache.spark.storage.StorageUtils$
(in unnamed module 0x6d7a93c9) cannot access class sun.nio.ch.DirectBuffer
(in module java.base) because module java.base does not export sun.nio.ch
to unnamed module 0x6d7a93c9
```

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass the CIs with the newly added test case.

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

No.

Closes apache#42975 from dongjoon-hyun/SPARK-45197.

Authored-by: Dongjoon Hyun <dhyun@apple.com>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
@LuciferYang LuciferYang deleted the SPARK-36796 branch October 22, 2023 07:43
@lachen-rms
Copy link

lachen-rms commented Sep 10, 2024

Hi guys, is there today a spark version that fully supports java17, im trying to run locally a project that uses spark an java 17, scala version 2.12.15, spark 3.3.4 and is failing because trying to access internal java APIs.

It works when adding:

--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/sun.nio.cs=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens java.base/sun.security.action=ALL-UNNAMED --add-opens java.base/sun.util.calendar=ALL-UNNAMED --add-opens java.security.jgss/sun.security.krb5=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED

@srowen
Copy link
Member

srowen commented Sep 10, 2024

(This isn't the place for general questions, but:)
Yes Java 17 has been supported for a while. You have to open access to internal packages.

@lachen-rms
Copy link

Hi @srowen thanks for replying, will stick into that. Have a good day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants