JkSelf commented on code in PR #52039:
URL: https://github.com/apache/spark/pull/52039#discussion_r2501562881
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/SQLExecution.scala:
##########
@@ -135,97 +135,110 @@ object SQLExecution extends Logging {
withSQLConfPropagated(sparkSession) {
sparkSession.artifactManager.withResources {
- withSessionTagsApplied(sparkSession) {
- var ex: Option[Throwable] = None
- var isExecutedPlanAvailable = false
- val startTime = System.nanoTime()
- val startEvent = SparkListenerSQLExecutionStart(
- executionId = executionId,
- rootExecutionId = Some(rootExecutionId),
- description = desc,
- details = callSite.longForm,
- physicalPlanDescription = "",
- sparkPlanInfo = SparkPlanInfo.EMPTY,
- time = System.currentTimeMillis(),
- modifiedConfigs = redactedConfigs,
- jobTags = sc.getJobTags(),
- jobGroupId =
Option(sc.getLocalProperty(SparkContext.SPARK_JOB_GROUP_ID))
- )
- try {
- body match {
- case Left(e) =>
- sc.listenerBus.post(startEvent)
+ synchronized {
Review Comment:
The value of `SPARK_JOB_TAGS` affects the job cancellation logic
[here](https://github.com/apache/spark/blob/9894abcca68aa9339a740c676d1656f24ca3cedc/core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala#L1258-L1262).
And the SQ method adds and removes job tags for each thread
[here](https://github.com/apache/spark/blob/9894abcca68aa9339a740c676d1656f24ca3cedc/sql/core/src/main/scala/org/apache/spark/sql/execution/SQLExecution.scala#L279C20-L287),
but when multiple threads share the same SparkContext, the value may be
overwritten or become inconsistent. Therefore, we introduce a lock here to
ensure thread-safe isolation of the tag values.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]