vagetablechicken opened a new issue #5102: URL: https://github.com/apache/incubator-doris/issues/5102
**Describe the bug** In OlapScanNode, the scanner threads is running in `state->exec_env()->thread_pool();`. So we can't control the scanner threads directly, and their destructions. When we close `OlapScanNode`, we only wait for `_transfer_thread`. https://github.com/apache/incubator-doris/blob/81c7c0360e61a6ad5ab4221f3a687d031f548e50/be/src/exec/olap_scan_node.cpp#L314 But we don't wait for the scanner threads, it has a risk: **scanner threads may be running and using the member vars of OlapScanNode, when the OlapScanNode has already destroyed.** **To Reproduce** To illustrate the risk, we can add a sleep before scanner threads exit. It's an unlikely scenario, just for simulation. https://github.com/apache/incubator-doris/blob/81c7c0360e61a6ad5ab4221f3a687d031f548e50/be/src/exec/olap_scan_node.cpp#L1354-L1361 For example: ``` // NOTICE: scanner thread live some more SleepFor(MonoDelta::FromSeconds(5)); _scan_batch_added_cv.notify_one(); ``` **Expected behavior** Maybe we can use `_running_thread` to be the last accessed member variable. And OlapScanNode should wait for `_running_thread==0`. ---------------------------------------------------------------- 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. 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