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

    https://github.com/apache/spark/pull/10705#discussion_r53719624
  
    --- Diff: core/src/main/scala/org/apache/spark/CacheManager.scala ---
    @@ -58,7 +67,9 @@ private[spark] class CacheManager(blockManager: 
BlockManager) extends Logging {
             // If another thread already holds the lock, wait for it to finish 
return its results
             val storedValues = acquireLockForPartition[T](key)
             if (storedValues.isDefined) {
    -          return new InterruptibleIterator[T](context, storedValues.get)
    +          val iter =
    +            CompletionIterator[T, Iterator[T]](storedValues.get, 
blockManager.releaseLock(key))
    --- End diff --
    
    This is mainly a note to self and other reviewers: I spent a long time 
wrapping my head around `blockManager.get` and I think I finally got it. The 
confusing part was that `get` sometimes acquires the lock but sometimes 
doesn't, so in all places where we call `get` we must likewise sometimes 
release the lock later.
    
    In `CacheManager`, we do this by checking whether the read method is 
network. If it is, then we read the block from a remote host so we don't have 
to release any locks. Otherwise, we read it locally (whether from memory or 
from disk) so we do have to release the lock.
    
    In this line, however, we assume another thread in the same JVM has 
computed the values for us, so there is no way we got the block's values over 
the network, so we don't need to do the network check as we did elsewhere.
    
    @JoshRosen is that correct?


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