vanzin commented on a change in pull request #25951: [SPARK-28917][CORE] 
Synchronize access to RDD mutable state.
URL: https://github.com/apache/spark/pull/25951#discussion_r329227746
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
 ##########
 @@ -223,12 +236,12 @@ abstract class RDD[T: ClassTag](
   }
 
   /** Get the RDD's current storage level, or StorageLevel.NONE if none is 
set. */
-  def getStorageLevel: StorageLevel = storageLevel
+  def getStorageLevel: StorageLevel = stateLock.synchronized { storageLevel }
 
 Review comment:
   Synchronizing calls on simple getters always raises flags for me. Is this 
really safe?
   
   For example, in one of the places that calls this (`getOrCompute`): what 
happens if the storage level changes after this value is returned, but before 
the call to `blockManager.getOrElseUpdate` actually does its thing?

----------------------------------------------------------------
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