[ 
https://issues.apache.org/jira/browse/SPARK-62372?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

L. C. Hsieh updated SPARK-62372:
--------------------------------
          Component/s: Connect
    Affects Version/s: 4.0.5
                       4.1.4
                       4.2.1
                       4.5.0
                       4.3.0
                       4.4.0
                           (was: 5.0.0)

> Allow adding or removing a streaming query listener from a listener callback 
> in Spark Connect
> ---------------------------------------------------------------------------------------------
>
>                 Key: SPARK-62372
>                 URL: https://issues.apache.org/jira/browse/SPARK-62372
>             Project: Spark
>          Issue Type: Bug
>          Components: Connect, PySpark
>    Affects Versions: 4.3.0, 4.2.1, 4.0.5, 4.1.4, 4.4.0, 4.5.0
>            Reporter: L. C. Hsieh
>            Priority: Major
>
> In the Python Spark Connect client, StreamingQueryListenerBus.post_to_all 
> holds the non-reentrant _bus_lock while it runs the listener callbacks. A 
> callback that calls spark.streams.removeListener(...) or 
> spark.streams.addListener(...) blocks the event handling thread on _bus_lock 
> forever. After that, no more listener events are delivered, and the next 
> addListener/removeListener call on any thread hangs too. If the callback 
> removes the last listener, remove() would also try to join the handler thread 
> from itself. Releasing the lock during dispatch alone is not enough: remove() 
> may hold _thread_lock while joining the handler thread, so a callback that 
> takes _thread_lock would deadlock.
> Classic PySpark supports both: the JVM ListenerBus posts each event over a 
> snapshot of its listeners, so a listener can remove itself or add another one 
> from its callback.
> The fix dispatches each event over a snapshot of the listeners, without 
> holding _bus_lock. When a callback adds or removes a listener, the bus is 
> updated in place. After the event is posted, a separate thread starts or 
> stops the event handling thread (and the server side listener) to match the 
> bus.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to