airborne12 opened a new pull request, #21553: URL: https://github.com/apache/doris/pull/21553
## Proposed changes Issue Number: close #xxx 1. `_group_local_scan_thread_pool->shutdown();` is called before `_task_group_local_scan_queue->close();`. This could cause problems as threads in the thread pool might still be trying to fetch tasks from the queue. When you shut down the thread pool, these threads might get interrupted while there are still unprocessed tasks in the queue. To avoid this, we should first close the queue and then shut down the thread pool. This way, threads in the thread pool will not try to fetch new tasks after the queue is closed, but instead finish their current tasks and then exit. 2. `_scheduler_pool->wait();` and `_local_scan_thread_pool->join();` are called, but for the other thread pools (`_remote_scan_thread_pool`, `_limited_scan_thread_pool`, `_group_local_scan_thread_pool`), no corresponding `wait` or `join` methods are called. This could result in threads in these thread pools still running after the `ScannerScheduler` object has been destroyed, which could lead to undefined behavior. We should ensure that all threads have exited before destroying the `ScannerScheduler` object. This PR first closes the task queue, then shuts down all the thread pools, and finally waits for all threads in the thread pools to exit. This ensures that all tasks are properly handled, all threads are properly exited, and avoids resource leaks and undefined behavior. ## Further comments If this is a relatively large or complex change, kick off the discussion at [d...@doris.apache.org](mailto:d...@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc... -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org