Github user squito commented on the pull request:

    https://github.com/apache/spark/pull/8923#issuecomment-153892468
  
    I spent a bit of time reproducing this.  It is actually rather tricky. (a) 
the shared dependency has to be a shared `ShuffleDependency`, but *not* a 
shared `RDD`, since the rdds are tracked in `visited: Set[RDD]`.  (b) you need 
one more stage after the end of the diamond, b/c `getShuffleMapStage` "unrolls" 
the loop one level, handling the final stage directly without passing it off to 
`getAncestorShuffleDependencies`.  (So its a diamond with a little tail ... a 
lollipop dependency?).  In any case, here is what I came up with.  On master 
this does produce an extra stage; with this fix here it avoids the duplication, 
and the SparkListenerJobStart does have the correct relationship between 
everything.  This is really just the repro, though, I didn't write the checks 
(just took a look with some printlns ...)
    
    ```scala
      test("shared shuffle stages with diamond dependencies", ActiveTag) {
        val rddA = new MyRDD(sc, 3, Nil).setName("rddA")
        val diamondInput = new ShuffleDependency(rddA, new HashPartitioner(2))
        val rddTop = new MyRDD(sc, 2, List(diamondInput)).setName("rddTop")
        val diamondTop = new ShuffleDependency(rddTop, new HashPartitioner(10))
        val rddBottom = new MyRDD(sc, 2, 
List(diamondInput)).setName("rddBottom")
        val diamondBottom = new ShuffleDependency(rddBottom, new 
HashPartitioner(10))
        val rddC = new MyRDD(sc, 2, List(diamondTop, 
diamondBottom)).setName("rddC")
        val lastDep = new ShuffleDependency(rddC, new HashPartitioner(3))
        val rddD = new MyRDD(sc, 3, List(lastDep)).setName("rddD")
        submit(rddD, Array(0, 1, 2))
    }
    ```


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