This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 9908fef374d10b3aad30d1668737782e0d1bdadd 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 da240fa644..aaa7e1e69c 100644 --- a/be/src/vec/exec/scan/scanner_scheduler.cpp +++ b/be/src/vec/exec/scan/scanner_scheduler.cpp @@ -159,25 +159,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]
