sunchao commented on code in PR #45052:
URL: https://github.com/apache/spark/pull/45052#discussion_r1501060613
##########
core/src/main/scala/org/apache/spark/storage/BlockManager.scala:
##########
@@ -177,15 +177,17 @@ private[spark] class HostLocalDirManager(
* Manager running on every node (driver and executors) which provides
interfaces for putting and
* retrieving blocks both locally and remotely into various stores (memory,
disk, and off-heap).
*
- * Note that [[initialize()]] must be called before the BlockManager is usable.
+ * Note that [[initialize()]] must be called before the BlockManager is
usable. Also, the
+ * `memoryManager` is initialized at a later stage after DriverPlugin is
loaded, to allow the
+ * plugin to overwrite memory configurations.
*/
private[spark] class BlockManager(
val executorId: String,
rpcEnv: RpcEnv,
val master: BlockManagerMaster,
val serializerManager: SerializerManager,
val conf: SparkConf,
- memoryManager: MemoryManager,
+ var memoryManager: MemoryManager,
Review Comment:
My suspicion is that after:
```scala
_env.initializeMemoryManager(SparkContext.numDriverCores(master, conf))
```
in `SparkContext`, `SparkEnv.set` is called by a different thread, which
updates the current `SparkEnv` to be a new instance without a `_memoryManager`
initialized. Later on when the `maxOnHeapMemory` is called in
`BlockManager.initialize`, it calls:
```scala
private lazy val _memoryManager =
Option(_memoryManager).getOrElse(SparkEnv.get.memoryManager)
```
which will call `SparkEnv.get.memoryManager`. Since the active `SparkEnv`
instance is updated, the `memoryManager` now is null.
I don't know how this would happen though, since it seems `SparkEnv` should
be a singleton within a single JVM. Somehow I wasn't not able to reproduce this
locally.
--
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]