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

panxiaolei 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 b01fef51ed3 [refactor](scan) extract scanner profile update logic and 
update on eos (#60615)
b01fef51ed3 is described below

commit b01fef51ed385cb92520974059f1a5d6fe3c9efc
Author: Pxl <[email protected]>
AuthorDate: Wed Feb 11 15:40:31 2026 +0800

    [refactor](scan) extract scanner profile update logic and update on eos 
(#60615)
    
    Extract the scanner profile update logic into a lambda to improve code
    reusability. Ensure that the scanner profile is updated specifically
    when 'eos' is reached before marking the scanner for closure, which
    prevents missing the final counter updates.
---
 be/src/vec/exec/scan/scanner_scheduler.cpp | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/be/src/vec/exec/scan/scanner_scheduler.cpp 
b/be/src/vec/exec/scan/scanner_scheduler.cpp
index 0d0f1db1f98..cb021e419e6 100644
--- a/be/src/vec/exec/scan/scanner_scheduler.cpp
+++ b/be/src/vec/exec/scan/scanner_scheduler.cpp
@@ -156,17 +156,22 @@ void 
ScannerScheduler::_scanner_scan(std::shared_ptr<ScannerContext> ctx,
     max_run_time_watch.start();
     scanner->update_wait_worker_timer();
     scanner->start_scan_cpu_timer();
-    Defer defer_scanner(
-            [&] { // WorkloadGroup Policy will check cputime realtime, so that 
should update the counter
-                // as soon as possible, could not update it on close.
-                if (scanner->has_prepared()) {
-                    // Counter update need prepare successfully, or it maybe 
core. For example, olap scanner
-                    // will open tablet reader during prepare, if not prepare 
successfully, tablet reader == nullptr.
-                    scanner->update_scan_cpu_timer();
-                    scanner->update_realtime_counters();
-                    scanner->start_wait_worker_timer();
-                }
-            });
+
+    // Counter update need prepare successfully, or it maybe core. For 
example, olap scanner
+    // will open tablet reader during prepare, if not prepare successfully, 
tablet reader == nullptr.
+    bool need_update_profile = scanner->has_prepared();
+    auto update_scanner_profile = [&]() {
+        if (need_update_profile) {
+            scanner->update_scan_cpu_timer();
+            scanner->update_realtime_counters();
+            need_update_profile = false;
+        }
+    };
+    Defer defer_scanner([&] {
+        // WorkloadGroup Policy will check cputime realtime, so that should 
update the counter
+        // as soon as possible, could not update it on close.
+        update_scanner_profile();
+    });
     Status status = Status::OK();
     bool eos = false;
     ASSIGN_STATUS_IF_CATCH_EXCEPTION(
@@ -325,6 +330,9 @@ void 
ScannerScheduler::_scanner_scan(std::shared_ptr<ScannerContext> ctx,
     }
 
     if (eos) {
+        // If eos, scanner will call _collect_profile_before_close to update 
profile,
+        // so we need update_scanner_profile here
+        update_scanner_profile();
         scanner->mark_to_need_to_close();
     }
     scan_task->set_eos(eos);


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

Reply via email to