malinjawi opened a new pull request, #13752: URL: https://github.com/apache/gluten/pull/13752
Fixes #11446. On Spark 4.x, `SparkContext` publishes `SparkEnv` before it creates the memory manager, and `BlockManager` reads its memory manager lazily from `SparkEnv`. `GlobalOffHeapMemoryTarget` forced `blockManager.memoryStore` on every borrow and repay. If a repay lands in that window, the new `BlockManager` caches a null memory manager and the `SparkContext` fails in `BlockManager.initialize`. One way this happens is the Finalizer thread freeing an off-heap broadcast buffer (`UnsafeByteArray.finalize()`) left by an earlier session. That's the suite abort seen in CI. This skips the `BlockManager` and the accounting while the memory manager doesn't exist yet. Spark 3.x is unchanged, because there the memory manager exists before `SparkEnv` is published. The new `GlobalOffHeapMemoryEnvInitSuite` releases global off-heap memory from a driver plugin, which runs inside that window. It fails with the CI NPE on Spark 4.0 and 4.1 without the fix, and passes with it on 4.0, 4.1 and 3.5. I also reproduced the abort locally by running `VeloxTPCHV1BhjOffheapSuite` and then `VeloxOrcDataTypeValidationSuite` in one JVM and forcing GC in the window: both runs aborted without the fix, and all three runs passed with it. Generated-by: Claude Code (claude-opus-5-5) -- 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]
