GitHub user zsxwing opened a pull request:
https://github.com/apache/spark/pull/887
SPARK-1932: Fix race conditions in onReceiveCallback and cachedPeers
`var cachedPeers: Seq[BlockManagerId] = null` is used in `def
replicate(blockId: BlockId, data: ByteBuffer, level: StorageLevel)` without
proper protection.
There are two place will call `replicate(blockId, bytesAfterPut, level)`
*
https://github.com/apache/spark/blob/17f3075bc4aa8cbed165f7b367f70e84b1bc8db9/core/src/main/scala/org/apache/spark/storage/BlockManager.scala#L644
runs in `connectionManager.futureExecContext`
*
https://github.com/apache/spark/blob/17f3075bc4aa8cbed165f7b367f70e84b1bc8db9/core/src/main/scala/org/apache/spark/storage/BlockManager.scala#L752
`doPut` runs in `connectionManager.handleMessageExecutor`.
`org.apache.spark.storage.BlockManagerWorker` calls `blockManager.putBytes` in
`connectionManager.handleMessageExecutor`.
As they run in different `Executor`s, this is a race condition which may
cause the memory pointed by `cachedPeers` is not correct even if `cachedPeers
!= null`.
The race condition of `onReceiveCallback` is that it's set in
`BlockManagerWorker` but read in a different thread in
`ConnectionManager.handleMessageExecutor`.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/zsxwing/spark SPARK-1932
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/887.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #887
----
commit 524f69cf66473fe3cf0a38789140e6ee6ca57802
Author: zsxwing <[email protected]>
Date: 2014-05-26T17:04:03Z
SPARK-1932: Fix race conditions in onReceiveCallback and cachedPeers
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---