DaveDeCaprio commented on a change in pull request #24028: [SPARK-26917][SQL] 
Further reduce locks in CacheManager
URL: https://github.com/apache/spark/pull/24028#discussion_r265142809
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala
 ##########
 @@ -72,12 +71,12 @@ class CacheManager extends Logging {
 
   /** Clears all cached tables. */
   def clearCache(): Unit = writeLock {
-    
cachedData.asScala.foreach(_.cachedRepresentation.cacheBuilder.clearCache())
-    cachedData.clear()
+    cachedData.foreach(_.cachedRepresentation.cacheBuilder.clearCache())
+    cachedData = IndexedSeq[CachedData]()
   }
 
   /** Checks if the cache is empty. */
-  def isEmpty: Boolean = readLock {
 
 Review comment:
   I made this change, but while doing that I realized there was an issue with 
the earlier change to the "partition" function.  See comment below
   
      val (plansToUncache, remainingPlans) = cachedData.partition(cd => 
shouldRemove(cd.plan))
      // If a new plan is cached by a different thread at this point, it will 
be in the cachedData object,
      //  but not in plansToUncache or remainingPlans.  So the next line will 
remove it.
       writeLock {
         cachedData = remainingPlans
       }
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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]

Reply via email to