File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed
main/scala/org/apache/spark
test/scala/org/apache/spark
sql/core/src/main/scala/org/apache/spark/sql Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -351,8 +351,12 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
351351 protected [spark] val localProperties = new InheritableThreadLocal [Properties ] {
352352 override protected def childValue (parent : Properties ): Properties = {
353353 // Note: make a clone such that changes in the parent properties aren't reflected in
354- // the those of the children threads, which has confusing semantics (SPARK-10564).
355- SerializationUtils .clone(parent).asInstanceOf [Properties ]
354+ // the those of the children threads, which has confusing semantics (SPARK-10563).
355+ if (conf.get(" spark.localProperties.clone" , " false" ).toBoolean) {
356+ SerializationUtils .clone(parent).asInstanceOf [Properties ]
357+ } else {
358+ new Properties (parent)
359+ }
356360 }
357361 override protected def initialValue (): Properties = new Properties ()
358362 }
Original file line number Diff line number Diff line change @@ -214,6 +214,7 @@ class ThreadingSuite extends SparkFunSuite with LocalSparkContext with Logging {
214214
215215 test(" mutation in parent local property does not affect child (SPARK-10563)" ) {
216216 sc = new SparkContext (" local" , " test" )
217+ sc.conf.set(" spark.localProperties.clone" , " true" )
217218 val originalTestValue : String = " original-value"
218219 var threadTestValue : String = null
219220 sc.setLocalProperty(" test" , originalTestValue)
Original file line number Diff line number Diff line change @@ -78,6 +78,12 @@ class SQLContext(@transient val sparkContext: SparkContext)
7878 sparkContext.addSparkListener(listener)
7979 sparkContext.ui.foreach(new SQLTab (this , _))
8080
81+ // Execution IDs go through SparkContext's local properties, which are not safe to use with
82+ // fork join pools by default. In particular, even after a child thread is spawned, if the
83+ // parent sets a property the value may be reflected in the child. This leads to undefined
84+ // consequences such as SPARK-10548, so we should just clone the properties instead to be safe.
85+ sparkContext.conf.set(" spark.localProperties.clone" , " true" )
86+
8187 /**
8288 * Set Spark SQL configuration properties.
8389 *
You can’t perform that action at this time.
0 commit comments