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

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


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new c76d49722c1 branch-4.1: [fix](be) Init thread context on AsyncIO 
worker threads #64846 (#64970)
c76d49722c1 is described below

commit c76d49722c1efdb214066a91ecc11a22fa16b200
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Jun 30 14:05:30 2026 +0800

    branch-4.1: [fix](be) Init thread context on AsyncIO worker threads #64846 
(#64970)
    
    Cherry-picked from #64846
    
    Co-authored-by: Xin Liao <[email protected]>
---
 be/src/util/async_io.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/be/src/util/async_io.h b/be/src/util/async_io.h
index 485be4b79f0..57587164b35 100644
--- a/be/src/util/async_io.h
+++ b/be/src/util/async_io.h
@@ -20,6 +20,7 @@
 #include <bthread/bthread.h>
 
 #include "io/fs/file_system.h"
+#include "runtime/thread_context.h"
 #include "storage/olap_define.h"
 #include "util/cpu_info.h"
 #include "util/work_thread_pool.hpp"
@@ -79,6 +80,12 @@ public:
         PriorityThreadPool::Task task;
         task.priority = nice;
         task.work_function = [&] {
+            // The AsyncIO worker is a plain infra pthread that is not bound 
to any task,
+            // so it has no ThreadContext. fn() (e.g. a FILESYSTEM_M 
dispatched upload/read)
+            // may touch thread_context() (memory tracking, LIMIT_*_SCAN_IO, 
...), which would
+            // FatalError without a context. Initialize an (unattached) 
ThreadContext here,
+            // same pattern as StorageEngine background threads.
+            SCOPED_INIT_THREAD_CONTEXT();
             fn();
             std::unique_lock l(mutex);
             cv.notify_one();


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

Reply via email to