[#2771] feat(spark): Support Spark 4.2 (#2772)
### What changes were proposed in this pull request?
Add a mutually-exclusive `spark4.2` Maven profile that builds the existing `client-spark/spark4` module against **Apache Spark 4.2.0**, mirroring the `spark4.1` profile added in #2751.
- **Root `pom.xml`**: new `spark4.2` profile — a structural clone of `spark4.1`, differing only in `spark.version=4.2.0`, `scala.version=2.13.18`, `netty.version=4.2.13.Final`, `jackson.version=2.21.2`, and the lz4 coordinate (`lz4.groupId` + `lz4.version`, see below).
- **`client-spark/spark4/pom.xml`**: `spark4.2` profile reuses the `src/main/java-spark4_1` compat source root (the 4.1 `Spark4Compat` shim).
- **`client-spark/extension/pom.xml`**: `spark4.2` profile reuses the `scala-jakarta` servlet source root.
- **`client-spark/extension` — `ShufflePage.scala`**: the Uniffle UI tab's collapsible sections use `onClick="collapseTable(...)"`, relying on a global `collapseTable()` that Spark 3.x/4.0/4.1 ship in `webui.js`. Spark 4.2 removed that function (its own pages moved to Bootstrap 5 `data-bs-toggle` collapse), so under `-Pspark4.2` the sections could not be expanded. Inline a fallback that defines a compatible `collapseTable` only when the host Spark didn't provide one — 3.x/4.0/4.1 keep Spark's implementation, 4.2 gets a working equivalent, reusing the `.collapsed` / `arrow-open|closed` CSS every Spark line still ships.
- **lz4**: introduce `${lz4.groupId}` (`org.lz4` by default, `at.yawk.lz4` under `spark4.2`) and `${lz4.version}` (`1.8.1` by default, `1.11.0` under `spark4.2`); the two integration-test modules declare `${lz4.groupId}:lz4-java`, and the `at.yawk.lz4` root-`dependencyManagement` entry is pinned to `${lz4.version}`. The default build and every non-`spark4.2` profile stay on `org.lz4:1.8.1` — the bump is scoped to `spark4.2` only.
- **CI**: `parallel.yml` gains a `spark4.2 / java 17` matrix entry; `sequential.yml` gains a `-Pspark4.2` step gated on `java-version == 17`.
No new Maven module. `client-spark/spark4-shaded` needs no relocation change (its bouncycastle/jctools relocations are already global); a comment was added there noting its lz4 exclusion must stay `org.lz4` — Maven matches exclusions on the as-declared coordinate, so parameterizing it would leak `at.yawk.lz4` into the shaded jar under `-Pspark4.2`.
### Why are the changes needed?
Fix: #2771
Users should be able to build and run Uniffle's Spark client against Spark 4.2.0 with full parity to the existing 4.1 support.
The three cross-major APIs called from `client-spark/spark4` are **byte-identical** between 4.1.1 and 4.2.0 (verified with `javap`), so no shim change is required:
| API | 4.1.1 | 4.2.0 |
|---|---|---|
| `MapStatus.apply(BlockManagerId, long[], long, long)` | 4-arg | identical |
| `ExternalSorter(…, RowBasedChecksum[])` ctor | 6-arg | identical |
| `WebUIPage.render(jakarta…HttpServletRequest)` | jakarta | identical |
Dependency notes:
- **jackson → 2.21.2 (required):** Spark 4.2.0 ships `jackson-module-scala_2.13` 2.21.2, which validates the classpath `jackson-databind` on registration and throws in `RDDOperationScope`'s static initializer if it is outside `[2.21.0, 2.22.0)`. Same class of failure the 4.1 work hit.
- **netty → 4.2.13.Final:** matches what Spark 4.2.0 was compiled/tested against (still Netty 4.2, same major as 4.1's 4.2.7, so #2751's `NioIoHandler`/refCnt handling still applies — no code change).
- **lz4 → at.yawk.lz4:1.11.0, scoped to spark4.2 (required):** Spark 4.2.0 bumped lz4 to 1.11.0 and calls `LZ4BlockInputStream.newBuilder()` (added in the 1.11 line); without it the integration tests fail at runtime with `NoSuchMethodError`. Because `org.lz4:1.8.1` is a relocation stub that Maven rewrites to `at.yawk.lz4:1.8.1`, a globally-managed `at.yawk.lz4:1.11.0` would silently bump lz4 across the whole reactor (server/client/coordinator/…), which is out of this PR's scope and would override the `org.lz4:1.8.1` pin from #2693 (CVE-2025-12183). The `${lz4.groupId}`/`${lz4.version}` properties confine the bump to the `spark4.2` profile; every other build stays on 1.8.1.
- hadoop / jetty / log4j / slf4j / commons-lang3 deltas are deferred; the profile keeps the 4.1 values.
### Does this PR introduce _any_ user-facing change?
No behavioral change to existing profiles. Adds a new opt-in `-Pspark4.2` build profile, and fixes the Uniffle Spark UI tab so its collapsible sections expand under Spark 4.2. Existing `-Pspark4` (4.0.2) and `-Pspark4.1` (4.1.1) are unchanged.
### How was this patch tested?
Verified locally on JDK 17 (Zulu 17.0.18):
1. `mvn clean install -Pspark4.2 -DskipTests` — compiles + shades against 4.2.0 (spark-core/sql/catalyst 4.2.0, scala 2.13.18, netty 4.2.13.Final, jackson 2.21.2, lz4 `at.yawk.lz4:1.11.0` resolved).
2. `mvn clean install -Pspark4.1 -DskipTests` + integration tests — 4.1.1 build and `AQERepartitionTest` / `MapSideCombineTest` still green (lz4 stays `org.lz4:1.8.1`); confirms no regression. Also confirmed the default build (no profile) and other spark profiles keep lz4 at 1.8.1.
3. `AQERepartitionTest`, `MapSideCombineTest` pass under `-Pspark4.2`.
4. `TransportFrameDecoderTest` (2 tests) passes on Netty 4.2.13 under `-Pspark4.2`.
5. `RepartitionWithLocalFileRssTest` (NOOP/ZSTD/**LZ4** codecs) passes under `-Pspark4.2` — exercises the lz4 runtime path.
6. `dev/scripts/checkshade.sh` on the spark4.2 shaded jar — "check success", 0 unshaded classes; bouncycastle/jctools relocated, no `net.jpountz` (lz4) leak.
7. **End-to-end on a real Spark 4.2.0 distribution** against a local Uniffle cluster (coordinator + shuffle server): a shuffle job runs through `RssShuffleManager`, and the Uniffle Spark UI tab renders and its collapsible sections (Build Info / Shuffle Server / Assignment / …) expand with no page JS errors.
CI runs the build + unit + integration tests via the new `spark4.2` matrix entry / `-Pspark4.2` step.Uniffle is a high performance, general purpose remote shuffle service for distributed computing engines. It provides the ability to push shuffle data into centralized storage service, changing the shuffle style from “local file pull-like style” to “remote block push-like style”. It brings in several advantages like supporting disaggregated storage deployment, super large shuffle jobs, and high elasticity. Currently it supports Apache Spark, Apache Hadoop MapReduce and Apache Tez.
Uniffle cluster consists of three components, a coordinator cluster, a shuffle server cluster and an optional remote storage (e.g., HDFS).
Coordinator will collect the status of shuffle servers and assign jobs based on some strategy.
Shuffle server will receive the shuffle data, merge them and write to storage.
Depending on different situations, Uniffle supports Memory & Local, Memory & Remote Storage(e.g., HDFS), Memory & Local & Remote Storage(recommendation for production environment).
The shuffle data is stored with index file and data file. Data file has all blocks for a specific partition and the index file has metadata for every block.
Currently supports Spark 2.3.x, Spark 2.4.x, Spark 3.0.x, Spark 3.1.x, Spark 3.2.x, Spark 3.3.x, Spark 3.4.x, Spark 3.5.x
Note: To support dynamic allocation, the patch(which is included in patch/spark folder) should be applied to Spark
Currently supports the MapReduce framework of Hadoop 2.8.5, Hadoop 3.2.1
note: currently Uniffle requires JDK 1.8 to build, adding later JDK support is on our roadmap.
Uniffle is built using Apache Maven. To build it, run:
./mvnw -DskipTests clean package
To fix code style issues, run:
./mvnw spotless:apply -Pspark3 -Pspark2 -Ptez -Pmr -Phadoop2.8 -Pdashboard
Build against profile Spark 2 (2.4.6)
./mvnw -DskipTests clean package -Pspark2
Build against profile Spark 3 (3.1.2)
./mvnw -DskipTests clean package -Pspark3
Build against Spark 3.2.x, Except 3.2.0
./mvnw -DskipTests clean package -Pspark3.2
Build against Spark 3.2.0
./mvnw -DskipTests clean package -Pspark3.2.0
Build against Hadoop MapReduce 2.8.5
./mvnw -DskipTests clean package -Pmr,hadoop2.8
Build against Hadoop MapReduce 3.2.1
./mvnw -DskipTests clean package -Pmr,hadoop3.2
Build against Tez 0.9.1
./mvnw -DskipTests clean package -Ptez
Build against Tez 0.9.1 and Hadoop 3.2.1
./mvnw -DskipTests clean package -Ptez,hadoop3.2
Build with dashboard
./mvnw -DskipTests clean package -Pdashboard
note: currently Uniffle build the project against Java 8. If you want to compile it against other Java versions, you can build the code with
-Dmaven.compiler.release=${release-version}.
To package the Uniffle, run:
./build_distribution.sh
Package against Spark 3.2.x, Except 3.2.0, run:
./build_distribution.sh --spark3-profile 'spark3.2'
Package against Spark 3.2.0, run:
./build_distribution.sh --spark3-profile 'spark3.2.0'
Package will build against Hadoop 2.8.5 in default. If you want to build package against Hadoop 3.2.1, run:
./build_distribution.sh --hadoop-profile 'hadoop3.2'
Package with hadoop jars, If you want to build package against Hadoop 3.2.1, run:
./build_distribution.sh --hadoop-profile 'hadoop3.2' -Phadoop-dependencies-included
rss-xxx.tgz will be generated for deployment
If you have packaged tgz with hadoop jars, the env of HADOOP_HOME is needn't specified in rss-env.sh.
JAVA_HOME=<java_home> HADOOP_HOME=<hadoop home> COORDINATOR_XMX_SIZE="16g" # You can set coordinator memory size by `XMX_SIZE` too, but it affects all components. # XMX_SIZE="16g"
rss.rpc.server.port 19999 rss.jetty.http.port 19998 rss.coordinator.server.heartbeat.timeout 30000 rss.coordinator.app.expired 60000 rss.coordinator.shuffle.nodes.max 5 # enable dynamicClientConf, and coordinator will be responsible for most of client conf rss.coordinator.dynamicClientConf.enabled true # config the path of client conf rss.coordinator.dynamicClientConf.path <RSS_HOME>/conf/dynamic_client.conf # config the path of excluded shuffle server rss.coordinator.exclude.nodes.file.path <RSS_HOME>/conf/exclude_nodes
# MEMORY_LOCALFILE_HDFS is recommended for production environment rss.storage.type MEMORY_LOCALFILE_HDFS # multiple remote storages are supported, and client will get assignment from coordinator rss.coordinator.remote.storage.path hdfs://cluster1/path,hdfs://cluster2/path rss.writer.require.memory.retryMax 1200 rss.client.retry.max 50 rss.client.send.check.timeout.ms 600000 rss.client.read.buffer.size 14m
bash RSS_HOME/bin/start-coordnator.sh
We recommend to use JDK 11+ if we want to have better performance when we deploy the shuffle server. Some benchmark tests among different JDK is as below: (using spark to write shuffle data with 20 executors. Single executor will total write 1G, and each time write 14M. Shuffle Server use GRPC to transfer data)
| Java version | ShuffleServer GC | Max pause time | ThroughOutput |
|---|---|---|---|
| 8 | G1 | 30s | 0.3 |
| 11 | G1 | 2.5s | 0.8 |
| 18 | G1 | 2.5s | 0.8 |
| 18 | ZGC | 0.2ms | 0.99997 |
Deploy Steps:
JAVA_HOME=<java_home> HADOOP_HOME=<hadoop home> SHUFFLE_SERVER_XMX_SIZE="80g" # You can set shuffle server memory size by `XMX_SIZE` too, but it affects all components. # XMX_SIZE="80g"
rss.rpc.server.port 19999 rss.jetty.http.port 19998 rss.rpc.executor.size 2000 # it should be configured the same as in coordinator rss.storage.type MEMORY_LOCALFILE_HDFS rss.coordinator.quorum <coordinatorIp1>:19999,<coordinatorIp2>:19999 # local storage path for shuffle server rss.storage.basePath /data1/rssdata,/data2/rssdata.... # it's better to config thread num according to local disk num rss.server.flush.thread.alive 5 rss.server.flush.localfile.threadPool.size 10 rss.server.flush.hadoop.threadPool.size 60 rss.server.buffer.capacity 40g rss.server.read.buffer.capacity 20g rss.server.heartbeat.interval 10000 rss.rpc.message.max.size 1073741824 rss.server.preAllocation.expired 120000 rss.server.commit.timeout 600000 rss.server.app.expired.withoutHeartbeat 120000 # note: the default value of rss.server.flush.cold.storage.threshold.size is 64m # there will be no data written to DFS if set it as 100g even rss.storage.type=MEMORY_LOCALFILE_HDFS # please set a proper value if DFS is used, e.g., 64m, 128m. rss.server.flush.cold.storage.threshold.size 100g
bash RSS_HOME/bin/start-shuffle-server.sh
Add client jar to Spark classpath, e.g., SPARK_HOME/jars/
The jar for Spark2 is located in <RSS_HOME>/jars/client/spark2/rss-client-spark2-shaded-${version}.jar
The jar for Spark3 is located in <RSS_HOME>/jars/client/spark3/rss-client-spark3-shaded-${version}.jar
Update Spark conf to enable Uniffle, e.g.,
# Uniffle transmits serialized shuffle data over network, therefore a serializer that supports relocation of # serialized object should be used. spark.serializer org.apache.spark.serializer.KryoSerializer # this could also be in the spark-defaults.conf spark.shuffle.manager org.apache.spark.shuffle.RssShuffleManager spark.rss.coordinator.quorum <coordinatorIp1>:19999,<coordinatorIp2>:19999 # Note: For Spark2, spark.sql.adaptive.enabled should be false because Spark2 doesn't support AQE.
To support spark dynamic allocation with Uniffle, spark code should be updated. There are 7 patches for spark (2.3.4/2.4.6/3.0.1/3.1.2/3.2.1/3.3.1/3.4.1) in patch/spark folder for reference.
After apply the patch and rebuild spark, add following configuration in spark conf to enable dynamic allocation:
spark.shuffle.service.enabled false spark.dynamicAllocation.enabled true
For spark3.5 or above just add one more configuration:
spark.shuffle.sort.io.plugin.class org.apache.spark.shuffle.RssShuffleDataIo
The jar for MapReduce is located in <RSS_HOME>/jars/client/mr/rss-client-mr-XXXXX-shaded.jar
Update MapReduce conf to enable Uniffle, e.g.,
-Dmapreduce.rss.coordinator.quorum=<coordinatorIp1>:19999,<coordinatorIp2>:19999 -Dyarn.app.mapreduce.am.command-opts=org.apache.hadoop.mapreduce.v2.app.RssMRAppMaster -Dmapreduce.job.map.output.collector.class=org.apache.hadoop.mapred.RssMapOutputCollector -Dmapreduce.job.reduce.shuffle.consumer.plugin.class=org.apache.hadoop.mapreduce.task.reduce.RssShuffle
Note that the RssMRAppMaster will automatically disable slow start (i.e., mapreduce.job.reduce.slowstart.completedmaps=1) and job recovery (i.e., yarn.app.mapreduce.am.job.recovery.enable=false)
In production mode, you can append client jar (rss-client-tez-XXXXX-shaded.jar) to package which is set by ‘tez.lib.uris’.
In development mode, you can append client jar (rss-client-tez-XXXXX-shaded.jar) to HADOOP_CLASSPATH.
| Property Name | Default | Description |
|---|---|---|
| tez.am.launch.cmd-opts | -XX:+PrintGCDetails -verbose:gc -XX:+PrintGCTimeStamps -XX:+UseNUMA -XX:+UseParallelGC org.apache.tez.dag.app.RssDAGAppMaster | enable remote shuffle service |
| tez.rss.coordinator.quorum | coordinatorIp1:19999,coordinatorIp2:19999 | coordinator address |
Note that the RssDAGAppMaster will automatically disable slow start (i.e., tez.shuffle-vertex-manager.min-src-fraction=1, tez.shuffle-vertex-manager.max-src-fraction=1).
We have provided an operator for deploying uniffle in kubernetes environments.
For details, see the following document:
The important configuration is listed as follows.
| Role | Link |
|---|---|
| coordinator | Uniffle Coordinator Guide |
| shuffle server | Uniffle Shuffle Server Guide |
| client | Uniffle Shuffle Client Guide |
The primary goals of the Uniffle Kerberos security are:
The following security configurations are introduced.
| Property Name | Default | Description |
|---|---|---|
| rss.security.hadoop.kerberos.enable | false | Whether enable access secured hadoop cluster |
| rss.security.hadoop.kerberos.krb5-conf.file | - | The file path of krb5.conf. And only when rss.security.hadoop.kerberos.enable is enabled, the option will be valid |
| rss.security.hadoop.kerberos.keytab.file | - | The kerberos keytab file path. And only when rss.security.hadoop.kerberos.enable is enabled, the option will be valid |
| rss.security.hadoop.kerberos.principal | - | The kerberos keytab principal. And only when rss.security.hadoop.kerberos.enable is enabled, the option will be valid |
| rss.security.hadoop.kerberos.relogin.interval.sec | 60 | The kerberos authentication relogin interval. unit: sec |
| rss.security.hadoop.kerberos.proxy.user.enable | true | Whether using proxy user for job user to access secured Hadoop cluster. |
We provide some benchmark tests for Uniffle. For details, you can see Uniffle 0.2.0 Benchmark, Uniffle 0.9.0 Benchmark.
Uniffle is under the Apache License Version 2.0. See the LICENSE file for details.
For more information about contributing issues or pull requests, see Uniffle Contributing Guide.