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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]