zhang-arvin opened a new pull request, #67056: URL: https://github.com/apache/doris/pull/67056
## Proposed changes Fix #66997: RScan_normal ThreadPool idle workers never shrink, OS threads accumulate beyond max_threads and eventually crash BE. ### Root Cause The `ThreadPool::dispatch_thread()` shrink logic was only checking the shrink condition (`queue empty && num_threads > min_threads`) when `std::condition_variable::wait_for()` returned `std::cv_status::timeout`. However, on some platforms (observed in Doris cloud deployments with compute-storage separation), `pthread_cond_timedwait` may return success (no_timeout) even when the timeout has expired. This causes idle workers to never check the shrink condition, re-enter the idle loop, and never exit. Over time, remote scan jobs (RScan_normal) create batches of ~80-110 workers per run that accumulate to 20k+ OS threads, exceeding cgroup pids.max and causing BE abort with 'Could not create thread (error 11)'. ### Fix Always check the shrink condition after `wait_for` returns, regardless of the `cv_status`. The queue-empty guard ensures workers woken for legitimate tasks will not exit prematurely. ### Changes - `be/src/util/threadpool.cpp`: Remove the `cv_status::timeout` guard around the shrink check, so idle workers always evaluate the shrink condition after `wait_for` returns. ## Types of changes - [x] Bugfix (non-breaking change which fixes an issue) ## Checklist - [x] I have created an issue and described the bug in detail - [x] I have performed a self-review of my code - [x] My changes generate no new warnings -- 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]
