DaveDeCaprio commented on a change in pull request #23539: [SPARK-26617][SQL]
Cache manager locks
URL: https://github.com/apache/spark/pull/23539#discussion_r249288930
##########
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 wasn't 100% sure on this change whether the clearCache call was safe to
make while the item was still in the cache. However, if it isn't, I'm not sure
this implementation reduces the amount of locking.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]