Area: Deployment Issues
Sub-Area: Spark Integration Memory Management
Applies to: OSS + Cloud
Issue
When you use the DataHub Spark agent (acryl-spark-lineage) with job coalescing on, a Spark application with many SQL operations can run the driver out of memory. The driver is killed while the application shuts down and the agent emits lineage.
You Might Be Asking
- Why do my Spark jobs process data successfully but the driver gets killed at the end?
- How can I reduce driver memory pressure from the DataHub Spark agent?
- What is the difference between coalesced and non-coalesced lineage emission?
Cause
The agent's event emitter converts each non-streaming Spark event into a DatahubJob object and keeps it in an in-memory list. It does this whether or not coalescing is on.
-
Coalescing on: the emitter merges all stored jobs into one DataJob and builds the MCPs from it. This runs when the application ends (
onApplicationEnd), or periodically when periodic emission is enabled. Merging many jobs at the end uses driver memory. - Coalescing off: the emitter emits each event's MCPs right away.
The agent has no setting to cap the number of retained jobs or to bound emitter memory.
Solution
Option 1: Turn off coalescing
Set the coalescing key to false. The key is coalesce_jobs. Do not add a .enabled suffix.
spark.datahub.coalesce_jobs=false
DataHub then emits MCPs per event as they happen. It no longer merges all jobs into one DataJob at application end. This changes your lineage model: you no longer get one merged DataJob for the whole application. The agent still keeps each job in its in-memory list, so this setting may not remove all memory growth.
Option 2: Increase driver memory
If you need coalesced emission, give the driver more memory. Use a real size:
spark.driver.memory=8g
Pick a size that fits your workload and container limit.
Check what the agent emits
To see the lineage payload without sending it to DataHub, emit to a file:
spark.datahub.emitter=file
spark.datahub.file.filename=/path/to/lineage-output
To watch memory pressure, turn on GC logging on the driver. On JDK 9 or later:
spark.driver.extraJavaOptions=-Xlog:gc*=info:file=/path/to/gc.log:time,level,tags
On Java 8, use -XX:+PrintGCDetails -Xloggc:/path/to/gc.log instead. Java 8 does not accept -Xlog.
To confirm the shutdown step ran, enable debug logging on the driver and look for the agent's Application end called message.
Confirm your setup
Every Spark setup needs spark.jars.packages set to io.acryl:acryl-spark-lineage_2.12:<version> (or _2.13 for Scala 2.13) and spark.extraListeners set to datahub.spark.DatahubSparkListener. Use spark.datahub.rest.server to point at your DataHub server.
Related Documentation
Tags: spark, lineage, oom, memory, driver, coalescing, acryl-spark-lineage, scale, kubernetes, deployment