acelyc111 commented on a change in pull request #5111:
URL: https://github.com/apache/incubator-doris/pull/5111#discussion_r548944879



##########
File path: be/src/exec/olap_scan_node.cpp
##########
@@ -1250,12 +1250,25 @@ void OlapScanNode::transfer_thread(RuntimeState* state) 
{
 
     state->resource_pool()->release_thread_token(true);
     VLOG(1) << "TransferThread finish.";
-    std::unique_lock<std::mutex> l(_row_batches_lock);
-    _transfer_done = true;
+    {
+        std::unique_lock<std::mutex> l(_row_batches_lock);
+        _transfer_done = true;
+    }
     _row_batch_added_cv.notify_all();
+
+    std::unique_lock<std::mutex> l(_scan_batches_lock);
+    while (_running_thread != 0) {
+        l.unlock();
+        SleepFor(MonoDelta::FromMilliseconds(5));
+        l.lock();

Review comment:
       Is it elegant to use sleep to do multithread sync? why not use a cv to 
wait here, and nofity after _running_thread--?




----------------------------------------------------------------
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

Reply via email to