DDtKey opened a new issue, #9317: URL: https://github.com/apache/arrow-datafusion/issues/9317
### Describe the bug I see a lot of cases of using `tokio::spawn` without wrapping `JoinHandle`s correctly. So if we stop execution (e.g `tokio::select!`) - we can find some tasks that are still alive. We can even see panic after canceling an execution (at least I did) Examples: - `demux_task`: [a function](https://github.com/apache/arrow-datafusion/blob/02c948d91b82f3e8988fafd12a072a476500c13d/datafusion/core/src/datasource/file_format/write/demux.rs#L73-L113) and then just [await on JoinHandle ](https://github.com/apache/arrow-datafusion/blob/02c948d91b82f3e8988fafd12a072a476500c13d/datafusion/core/src/datasource/file_format/arrow.rs#L298-L308) - parquet [spawn_rg_join_and_finalize_task](https://github.com/apache/arrow-datafusion/blob/02c948d91b82f3e8988fafd12a072a476500c13d/datafusion/core/src/datasource/file_format/parquet.rs#L822-L847) - parquet [spawn_column_parallel_row_group_writer](https://github.com/apache/arrow-datafusion/blob/02c948d91b82f3e8988fafd12a072a476500c13d/datafusion/core/src/datasource/file_format/parquet.rs#L778-L779) - orchestration [serialize_rb_stream_to_object_store](https://github.com/apache/arrow-datafusion/blob/02c948d91b82f3e8988fafd12a072a476500c13d/datafusion/core/src/datasource/file_format/write/orchestration.rs#L61-L65) ### To Reproduce Easiest way, is to create a long-running query which probably may even fail, and track the tokio tasks with tokio console after cancelling the execution. ### Expected behavior I believe execution should be cancel-safe, and I think we need to care more about spawned tasks. We already had such issues before, e.g: https://github.com/apache/arrow-datafusion/issues/5178 But I think even `AbortOnDropMany` doesn't solve all edge-cases, for example there are places when we do return `Vec<JoinHandle>` or just `JoinHandle` from an `async` function, but actually the execution can be canceled before wrapping into `AbortOnDropMany`. So I'd say https://github.com/apache/arrow-datafusion/issues/6513 is more relevant now, I guess even single task should be spawned with `JoinSet` ### Additional context How can we protect of introducing this? I think we have to pay attention to any `spawn` during review at least -- 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]
