Github user vanzin commented on a diff in the pull request:
https://github.com/apache/spark/pull/6648#discussion_r31971618
--- Diff: core/src/main/scala/org/apache/spark/shuffle/ShuffleManager.scala
---
@@ -62,4 +88,31 @@ private[spark] trait ShuffleManager {
/** Shut down this ShuffleManager. */
def stop(): Unit
+
+ private[this] val shuffleToAttempts = new ConcurrentHashMap[Int,
ConcurrentHashMap[Int, Int]]()
+
+ /**
+ * Register a stage attempt for the given shuffle, so we can clean up
all attempts when
+ * the shuffle is unregistered
+ */
+ protected def addShuffleAttempt(shuffleId: Int, stageAttemptId: Int):
Unit = {
+ shuffleToAttempts.putIfAbsent(shuffleId, new ConcurrentHashMap[Int,
Int]())
+ shuffleToAttempts.get(shuffleId).putIfAbsent(stageAttemptId,
stageAttemptId)
--- End diff --
Wait, why is the value of the map a map itself, if you're basically using
it as a list? Maybe a `CopyOnWriteArraySet` or some other thread-safe
collection would be more appropriate?
Or maybe just a plain `HashSet`, and use
`shuffleToAttempts.get(shuffleId).synchronized` for thread-safety (since it
should be rare for this to be called by the same shuffle concurrently, right?).
---
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]