JoshRosen commented on code in PR #37282:
URL: https://github.com/apache/spark/pull/37282#discussion_r929397395


##########
sql/core/src/main/scala/org/apache/spark/sql/util/QueryExecutionListener.scala:
##########
@@ -81,7 +83,10 @@ class ExecutionListenerManager private[sql](
     loadExtensions: Boolean)
   extends Logging {
 
-  private val listenerBus = new ExecutionListenerBus(this, session)
+  // SPARK-39864: lazily create the listener bus on the first register() call 
in order to
+  // avoid listener overheads when QueryExecutionListeners aren't used:
+  @GuardedBy("this")

Review Comment:
   I don't think there's a deadlock risk here (something that I always want to 
check whenever I'm adding synchronization to existing code).  
   
   The register(), unregister(), clear(), and listListeners() methods call 
`ListenerBus` methods and those methods are synchronized. However, I don't 
think they'll have circular waits because those methods are just updating 
ListenerBus data structures and aren't running code which could call back into 
ExecutionListenerManager.
   
   I'm a bit less sure about clone(), though.
   
   To play it safe, I'm going to see if I can remove the method-level 
`synchronized` and instead do something more surgical.



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

Reply via email to