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

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


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

commit 8251b44bbb7f3bddda7b82a72b1280b7823ff3ed
Author: Xin Liao <[email protected]>
AuthorDate: Tue Jul 7 15:11:06 2026 +0800

    [branch-4.0][fix](be) Init thread context on AsyncIO worker threads (#65271)
    
    Pick apache/doris#64846
---
 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 624686716db..51f72b0c1e7 100644
--- a/be/src/util/async_io.h
+++ b/be/src/util/async_io.h
@@ -21,6 +21,7 @@
 
 #include "io/fs/file_system.h"
 #include "olap/olap_define.h"
+#include "runtime/thread_context.h"
 #include "util/cpu_info.h"
 #include "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