Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10705#discussion_r53722796
  
    --- Diff: 
core/src/main/scala/org/apache/spark/broadcast/TorrentBroadcast.scala ---
    @@ -179,8 +198,13 @@ private[spark] class TorrentBroadcast[T: 
ClassTag](obj: T, id: Long)
                 blocks, SparkEnv.get.serializer, compressionCodec)
               // Store the merged copy in BlockManager so other tasks on this 
executor don't
               // need to re-fetch it.
    -          SparkEnv.get.blockManager.putSingle(
    -            broadcastId, obj, StorageLevel.MEMORY_AND_DISK, tellMaster = 
false)
    +          blockManager.putSingle(broadcastId, obj, 
StorageLevel.MEMORY_AND_DISK, tellMaster = false)
    +          Option(TaskContext.get()) match {
    +            case Some(taskContext) =>
    +              taskContext.addTaskCompletionListener(_ => 
blockManager.releaseLock(broadcastId))
    +            case None =>
    +              blockManager.releaseLock(broadcastId)
    --- End diff --
    
    This branch corresponds to a case where you call `putSingle` outside of the 
context of a task. If we don't release this lock here then the driver will 
never be able to delete its local copy of broadcast variables. We can't have 
`put()` automatically release locks because that's going to introduce race 
conditions in the `CacheManager` simplification patch.


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to