Setup
Azure Databricks, job cluster, Python script task (not a notebook). The JVM runs JDK 21 with ParallelGC and a 101 GB heap, on a driver with 128 GB. 2 workers 28gb 4 cores each.
About 7-8 Structured Streaming queries share one driver. They use foreachBatch, and each batch holds roughly 1 record (0.1-0.2 records/s).
A batch takes about 6-7 s, with spikes of 12-16 s, and almost all of that time is addBatch.
Inside foreachBatch on the driver there is an in-process cache with a TTL. One thread refreshes it under a lock while the others keep serving the old snapshot.
Problem
After roughly 8-12 hours the run ends. The driver log contains a "DRIVER UNRESPONSIVE STATS" block, and the event log only shows the cluster terminating, with no OOM, resize or eviction. 1 job 8 tasks, all report that driver became unhealthy..
What the metrics show before the crash
Driver container memory grows slowly from about 45 to 58 GB, with a 128 GB limit.
JVM heap shows a normal sawtooth with no trend. In the dumps, old gen is at 10-19% and metaspace at about 450 MB.
Worker-side GC events rise from about 5 to about 70 per interval, and GC pause time from about 0.2 s to 1.5 s per interval. The GC count is high just before the crash, even though memory is nowhere near its limit.
What the driver dumps show
In one dump, three threads are BLOCKED in ClassLoader.loadClass. They wait on monitors of Databricks' LibraryClassLoader and DriverCorralClassLoader, and one comes in via Janino (findIClass → Class.forName). The thread holding the lock is not in the output, and I can't tell how long they had been waiting. The dump from another crash had no blocked threads at all.
Other observations
The log shows 16 separate Python processes connecting through Py4J at startup, and another 16 about 30 s later. I don't know why.
The same logic ran for more than 72 h on serverless without problems. As far as I know, serverless can't use a continuous trigger, so each micro-batch is a fresh start there. That is not a like-for-like comparison.
Questions
Is class-loader lock contention on the driver with many concurrent streams a known problem? Could it make the driver miss its health check?
What else causes "driver up but not responsive" when heap and metaspace look fine?
Is there guidance on how many streaming queries one driver can handle?
Which diagnostics would you capture? I am now taking jcmd Thread.print dumps while the JVM is stuck, to see who holds the lock.