rangadi opened a new pull request, #42460: URL: https://github.com/apache/spark/pull/42460
### What changes were proposed in this pull request? This terminates Python worker created for `foreachBatch` when the streaming query terminate. All of the tracking is done inside connect server (inside `StreamingForeachBatchHelper`). How this works: * (A) The helper class returns a cleaner (an `AutoCloseable`) to connect server when foreachBatch function is set up (happens before starting the query). * (B) If the query fails to start, server directly invokes the cleaner. * (C) If the query starts up, the server registers the cleaner with `streamingRunnerCleanerCache` in the `SessionHolder`. * (D) The cache keeps a mapping of query to cleaner. * It registers a streaming listener (only once per session), which invokes the cleaner when a query terminates. * There is also finally cleanup when SessionHolder expires. ### Why are the changes needed? This ensures Python process created for a streaming query is properly terminated when a query terminates. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - Unit tests are added for `CleanerCache` - Existing unit tests for foreachBatch. - Manual test to verify python process is terminated (How ca we test this in a unit test?) -- 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]
