Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/1083#discussion_r13781786
--- Diff: core/src/main/scala/org/apache/spark/CacheManager.scala ---
@@ -46,79 +46,27 @@ private[spark] class CacheManager(blockManager:
BlockManager) extends Logging {
new InterruptibleIterator(context,
values.asInstanceOf[Iterator[T]])
case None =>
- // Mark the split as loading (unless someone else marks it first)
- loading.synchronized {
- if (loading.contains(key)) {
- logInfo(s"Another thread is loading $key, waiting for it to
finish...")
- while (loading.contains(key)) {
- try {
- loading.wait()
- } catch {
- case e: Exception =>
- logWarning(s"Got an exception while waiting for another
thread to load $key", e)
- }
- }
- logInfo(s"Finished waiting for $key")
- /* See whether someone else has successfully loaded it. The
main way this would fail
- * is for the RDD-level cache eviction policy if someone else
has loaded the same RDD
- * partition but we didn't want to make space for it. However,
that case is unlikely
- * because it's unlikely that two threads would work on the
same RDD partition. One
- * downside of the current code is that threads wait serially
if this does happen. */
- blockManager.get(key) match {
- case Some(values) =>
- return new InterruptibleIterator(context,
values.asInstanceOf[Iterator[T]])
- case None =>
- logInfo(s"Whoever was loading $key failed; we'll try it
ourselves")
- loading.add(key)
- }
- } else {
- loading.add(key)
- }
+ // Acquire a lock for loading this partition
+ // If another thread already holds the lock, wait for it to finish
return its results
+ acquireLockForPartition(key).foreach { values =>
--- End diff --
Ok
---
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.
---