Copilot commented on code in PR #65271:
URL: https://github.com/apache/doris/pull/65271#discussion_r3528557192


##########
be/src/util/async_io.h:
##########
@@ -79,6 +80,12 @@ class AsyncIO {
         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();

Review Comment:
   SCOPED_INIT_THREAD_CONTEXT() prevents thread_context() from FatalErroring on 
AsyncIO worker threads, but it initializes an *unattached* ThreadContext. That 
means query/load-specific behavior in fn() (e.g. workload-group IO throttling 
via LIMIT_*_SCAN_IO and per-task memory tracking) will still be skipped or 
charged to the orphan tracker because is_attach_task() is false.
   
   If AsyncIO tasks are expected to inherit the caller’s query/load context, 
consider propagating the caller ResourceContext into the worker and wrapping 
fn() with SCOPED_ATTACH_TASK(rc) (or attach_task/detach_task) when available so 
limits/tracking remain effective.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to