cloud-fan commented on a change in pull request #23539: [SPARK-26617][SQL] Cache manager locks URL: https://github.com/apache/spark/pull/23539#discussion_r249370269
########## File path: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala ########## @@ -136,19 +135,21 @@ class CacheManager extends Logging { spark: SparkSession, plan: LogicalPlan, cascade: Boolean, - blocking: Boolean): Unit = writeLock { - val shouldRemove: LogicalPlan => Boolean = - if (cascade) { - _.find(_.sameResult(plan)).isDefined - } else { - _.sameResult(plan) - } - val it = cachedData.iterator() - while (it.hasNext) { - val cd = it.next() - if (shouldRemove(cd.plan)) { - cd.cachedRepresentation.cacheBuilder.clearCache(blocking) - it.remove() + blocking: Boolean): Unit = { + writeLock { + val shouldRemove: LogicalPlan => Boolean = + if (cascade) { + _.find(_.sameResult(plan)).isDefined + } else { + _.sameResult(plan) + } + val it = cachedData.iterator() + while (it.hasNext) { + val cd = it.next() + if (shouldRemove(cd.plan)) { + cd.cachedRepresentation.cacheBuilder.clearCache(blocking) Review comment: I think it's safe. Once you remove the cache entry from `cachedData`, the cache entry will be invisible. Then we can safely do the `clearUncache` posthoc. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org