Fix driver crash on Spark 4.2 (Jetty 12 EE10 relocation) - #82
Open
menishmueli wants to merge 1 commit into
Open
Conversation
Spark 4.2 upgraded to Jetty 12, which relocated the shaded servlet classes
into the EE10 package:
Spark 3.x / 4.0 / 4.1 : org.sparkproject.jetty.servlet.ServletContextHandler
Spark 4.2 : org.sparkproject.jetty.ee10.servlet.ServletContextHandler
DataflintJettyUtils.getClassForName probed only
org.sparkproject.jetty.servlet.* and org.eclipse.jetty.servlet.*, so on 4.2
both lookups miss. This is not a degraded-UI failure: the exception propagates
out of SparkDataflintDriverPlugin.registerMetrics and SparkContext
initialization fails, so the whole Spark application dies at startup.
java.lang.ClassNotFoundException: org.eclipse.jetty.servlet.ServletContextHandler
at org.apache.spark.dataflint.api.DataflintJettyUtils$.getClassForName$1(DataflintJettyUtils.scala:26)
at org.apache.spark.dataflint.api.DataflintJettyUtils$.createStaticHandler(DataflintJettyUtils.scala:30)
at org.apache.spark.dataflint.api.Spark4PageFactory.addStaticHandler(Spark4PageFactory.scala:45)
at org.apache.spark.dataflint.DataflintSparkUICommonInstaller.loadUI(DataflintSparkUICommonLoader.scala:119)
at io.dataflint.spark.SparkDataflintDriverPlugin.registerMetrics(SparkDataflintPlugin.scala:27)
Probe the EE10 packages first and fall back to the older ones, so a single
build keeps working across Spark 3.x, 4.0, 4.1 and 4.2. Everything downstream
is reflective (setInitParameter, setContextPath, addServlet) and those methods
all exist on the EE10 ServletContextHandler, so no other change is required.
Failure now reports every package that was tried instead of surfacing the last
ClassNotFoundException.
Also adds an example_4_2_0 project mirroring example_4_0_1, which doubles as a
regression test: before this change it cannot start a SparkSession at all.
Verified on Apache Spark 4.2.0 (local mode, Java 17, Scala 2.13):
- driver starts and the plugin registers
- a DataFlint tab appears in the Spark UI nav
- GET /dataflint/ returns 200
- GET /dataflint/applicationinfo/json/ returns real application data
Known follow-up, NOT addressed here: with the backend healthy on 4.2 the web
UI still renders only a loading spinner and issues no XHR. That reproduces with
the published 0.9.9 static assets too, so it is independent of this fix.
|
|
Contributor
|
@menishmueli this looks like it's working - are there any plans to release this soon? |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
DataFlint does not work on Apache Spark 4.2 — and it fails hard: the exception
propagates out of
SparkDataflintDriverPlugin.registerMetrics, soSparkContextinitialization fails and the entire Spark application dies atstartup. It is not a degraded-UI failure.
Spark 4.2 upgraded to Jetty 12, which relocated the shaded servlet classes into
the EE10 package:
org.sparkproject.jetty.servlet.ServletContextHandlerorg.sparkproject.jetty.ee10.servlet.ServletContextHandlerDataflintJettyUtils.getClassForNameprobes onlyorg.sparkproject.jetty.servlet.*and thenorg.eclipse.jetty.servlet.*, so on4.2 both lookups miss.
Affects both published artifacts —
io.dataflint:spark_2.13:0.9.9andio.dataflint:dataflint-spark4_2.13:0.9.9.Fix
Probe the EE10 packages first and fall back to the older names, so one build
keeps working across 3.x, 4.0, 4.1 and 4.2.
Everything downstream is reflective (
setInitParameter,setContextPath,addServlet) and all of those methods exist on the EE10ServletContextHandler, so no other change was needed. On failure the error nowlists every package tried instead of surfacing the last
ClassNotFoundException.Also adds
example_4_2_0, mirroringexample_4_0_1. It doubles as a regressiontest: without this change it cannot start a
SparkSessionat all.Verification
Apache Spark 4.2.0, local mode, Java 17 (Corretto), Scala 2.13:
GET /dataflint/→ 200GET /dataflint/applicationinfo/json/→ 200 with real data:{ "info": { "id": "local-1787212371032", "name": "Spark 4.2 - What's New", "attempts": [ { "appSparkVersion": "4.2.0", ... } ] }, "environmentInfo": { "driverXmxBytes": 8589934592 } }sqlmetrics/cachedstorageJSON endpoints respondsbt example_4_2_0/compilesucceedsafter the EE10 ones
Exercised against a real workload (~90 SQL executions: Arrow UDFs, multi
COUNT(DISTINCT), Datasketches,nearestByJoin, Delta MERGE).Known follow-up — NOT fixed here
With the backend healthy on 4.2, the web UI still renders only a loading
spinner:
#rootcontains only aMuiCircularProgressfetch('/dataflint/applicationinfo/json/')from that same page returns 200with data
Reproduced with the published 0.9.9 static assets (hybrid jar: official 0.9.9
contents with only
DataflintJettyUtilsswapped), so it is independent of thischange. Since the app never issues a first request it looks like a bootstrap /
runtime-config step rather than an API incompatibility.
Two smaller observations while debugging:
/dataflint/status,/alerts,/summary,/config,/resources) return 404 — the static handler has no SPA fallback.asset-manifest 2.json,dataflint-favicon 2.ico,dataflint-logo 2.png.Happy to open separate issues for those.
🤖 Generated with Claude Code