This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 4171309b9b [Bug](scanner) fix core dump due to release ScannerContext 
too early #21946
4171309b9b is described below

commit 4171309b9bc2c83317f678ac8b236621a05229da
Author: Pxl <[email protected]>
AuthorDate: Wed Jul 19 00:53:23 2023 +0800

    [Bug](scanner) fix core dump due to release ScannerContext too early #21946
---
 be/src/vec/exec/scan/scanner_scheduler.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/be/src/vec/exec/scan/scanner_scheduler.cpp 
b/be/src/vec/exec/scan/scanner_scheduler.cpp
index e6bec4f9d9..cb829cfd5a 100644
--- a/be/src/vec/exec/scan/scanner_scheduler.cpp
+++ b/be/src/vec/exec/scan/scanner_scheduler.cpp
@@ -180,25 +180,26 @@ void ScannerScheduler::_schedule_scanners(ScannerContext* 
ctx) {
     watch.reset();
     watch.start();
     ctx->incr_num_ctx_scheduling(1);
+    size_t size = 0;
+    Defer defer {[&]() { ctx->update_num_running(size, -1); }};
+
     if (ctx->done()) {
-        ctx->update_num_running(0, -1);
         return;
     }
 
     std::list<VScannerSPtr> this_run;
     ctx->get_next_batch_of_scanners(&this_run);
-    if (this_run.empty()) {
+    size = this_run.size();
+    if (!size) {
         // There will be 2 cases when this_run is empty:
         // 1. The blocks queue reaches limit.
         //      The consumer will continue scheduling the ctx.
         // 2. All scanners are running.
         //      There running scanner will schedule the ctx after they are 
finished.
         // So here we just return to stop scheduling ctx.
-        ctx->update_num_running(0, -1);
         return;
     }
 
-    ctx->update_num_running(this_run.size(), -1);
     // Submit scanners to thread pool
     // TODO(cmy): How to handle this "nice"?
     int nice = 1;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to