samra-h opened a new pull request, #58965:
URL: https://github.com/apache/spark/pull/58965

   ### Jira ticket
   https://issues.apache.org/jira/browse/SPARK-59613
   
   ### What changes were proposed in this pull request?
   This PR fixes intermittent 404 responses for /static/sql/* requests in the 
Spark History Server (SHS), which cause the SparkSQL tab's SQL -> ExecutionPage 
-> Plan Visualization to fail to render its graphs.
   The /static/sql Jetty static handler was previously registered only inside 
SQLTab's constructor:
   parent.addStaticHandler(SQLTab.STATIC_RESOURCE_DIR, "/static/sql")
   SQLTab is instantiated lazily, per-application, via 
SQLHistoryServerPlugin.setupUI — only when an application containing 
SQL/DataFrame executions is loaded into the SHS application cache. Its handler 
therefore shared the lifetime of a per-application SparkUI, which is cached and 
evicted by ApplicationCache.
   This change decouples the /static/sql handler from per-application SparkUI 
creation/eviction by registering it as part of the core SHS UI at startup 
(alongside the main /static handler wired up by HistoryServer), so the handler 
exists unconditionally for the lifetime of the server.
   
   
   ### Why are the changes needed?
   The SparkSQL ExecutionPage intermittently rendered no execution graphs, with 
browser network logs showing GET /static/sql returning 404.
   Because the /static/sql handler's lifetime was tied to whichever SparkUI 
happened to register it, evicting that application from ApplicationCache tore 
the handler down, and /static/sql/* requests began 404ing until another 
SQL-bearing application was loaded and re-registered it.
   This is significantly worse in multi-pod SHS deployments: each pod maintains 
its own independent ApplicationCache and its own set of dynamically-registered 
handlers. The core /static handler exists on every pod (registered at startup), 
but /static/sql only exists on a pod that currently has a SQL application 
loaded. A single browser page load fans out across pods — the ExecutionPage 
HTML may be served by a pod that has the handler, while the follow-up 
/static/sql/* asset request is routed to a different pod that never 
instantiated SQLTab, producing the seemingly random 404s. This also explains 
why manually opening the SQL tab once was only an unreliable, temporary 
workaround (it registered the handler on a single pod for a single eviction 
window).
   Registering the handler at startup ensures /static/sql is available on every 
pod for the server's entire lifetime, eliminating both the eviction-driven and 
routing-driven 404s.
   
   
   ### Does this PR introduce _any_ user-facing change?
   Yes — a bug fix. Previously, the SparkSQL ExecutionPage in the History 
Server intermittently failed to render execution graphs because /static/sql/* 
resources returned 404 (dependent on application-cache eviction, and pronounced 
in multi-pod deployments). After this change, the /static/sql resources are 
consistently served, so the SparkSQL execution graphs render reliably. There is 
no change to APIs, configuration, or output format.
   
   
   ### How was this patch tested?
   Manually verified against a live multi-pod SHS deployment (6 History Server 
pods behind the Service/load balancer).
   <img width="768" height="363" alt="Screenshot 2026-09-21 at 22 43 53" 
src="https://github.com/user-attachments/assets/86fd925c-3b12-47dd-b650-02be58136957";
 />
   
   #### Reproduction of the bug (before the fix):
   - Restarted the SHS pods.
   - Opened the SparkSQL plan visualization in the SHS UI — the execution graph 
failed to render.
   <img width="1281" height="321" alt="Screenshot 2026-09-21 at 22 38 17" 
src="https://github.com/user-attachments/assets/4f6a1cc4-a4db-4e32-bba3-693ef953f8e7";
 />
   
   - Checked each of the 6 pods individually for the /static/sql 
static-resource registration and found the handler was registered on only one 
pod.
   <img width="1028" height="577" alt="Screenshot 2026-09-21 at 22 08 27" 
src="https://github.com/user-attachments/assets/6bf89f6f-b7aa-415e-919d-8e0b6b43c784";
 />
   
   - Concluded the graph-rendering request was being routed by the load 
balancer to one of the "cold" pods that had never instantiated SQLTab and 
therefore had no /static/sql handler, resulting in the 404 and the missing 
graph.
   
   #### Verification (after the fix):
   - Restarted the SHS pods again.
   - Checked all 6 pods for the /static/sql static-resource registration — the 
resources were present on all 6 pods immediately on startup, without needing 
any SQL-bearing application to be loaded first.
   <img width="996" height="591" alt="Screenshot 2026-09-21 at 22 43 10" 
src="https://github.com/user-attachments/assets/423a418b-c1de-446e-98e5-829dca2f6ee3";
 />
   
   - Repeatedly opened the SparkSQL plan visualization in the SHS UI and was 
unable to reproduce the missing-graph bug — the execution graph rendered 
consistently regardless of which pod served the request.
   <img width="1277" height="781" alt="Screenshot 2026-09-21 at 22 44 38" 
src="https://github.com/user-attachments/assets/ea14ce47-5a45-4c55-86d1-bae1af402a8f";
 />
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   No
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to