You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/02/25 16:14:52 UTC
[GitHub] [spark] Ngone51 commented on a change in pull request #31600: [SPARK-34482][SS] Correct the active SparkSession for StreamExecution.logicalPlan
Ngone51 commented on a change in pull request #31600:
URL: https://github.com/apache/spark/pull/31600#discussion_r582967118
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/StreamExecution.scala
##########
@@ -323,26 +323,28 @@ abstract class StreamExecution(
startLatch.countDown()
// While active, repeatedly attempt to run batches.
- SparkSession.setActiveSession(sparkSession)
-
- updateStatusMessage("Initializing sources")
- // force initialization of the logical plan so that the sources can be created
- logicalPlan
-
- // Adaptive execution can change num shuffle partitions, disallow
- sparkSessionForStream.conf.set(SQLConf.ADAPTIVE_EXECUTION_ENABLED.key, "false")
- // Disable cost-based join optimization as we do not want stateful operations to be rearranged
- sparkSessionForStream.conf.set(SQLConf.CBO_ENABLED.key, "false")
- offsetSeqMetadata = OffsetSeqMetadata(
- batchWatermarkMs = 0, batchTimestampMs = 0, sparkSessionForStream.conf)
-
- if (state.compareAndSet(INITIALIZING, ACTIVE)) {
- // Unblock `awaitInitialization`
- initializationLatch.countDown()
- runActivatedStream(sparkSessionForStream)
- updateStatusMessage("Stopped")
- } else {
- // `stop()` is already called. Let `finally` finish the cleanup.
+ sparkSessionForStream.withActive {
Review comment:
Using `withActive` to keep safe for the `StreamExecution` to avoid using the wrong active session.
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org