github-actions[bot] commented on code in PR #64846:
URL: https://github.com/apache/doris/pull/64846#discussion_r3475864070


##########
be/src/runtime/thread_context.h:
##########
@@ -294,6 +296,25 @@ static ThreadContext* thread_context() {
     throw Exception(Status::FatalError("{}", doris::NO_THREAD_CONTEXT_MSG));
 }
 
+// Same lookup as thread_context(), but returns nullptr instead of raising a
+// FatalError when the current thread has no ThreadContext. This is needed by
+// IO helpers (e.g. local/remote scan throttle) that may run on a raw pool
+// thread without SCOPED_ATTACH_TASK -- for example when a bthread upload is
+// dispatched to an AsyncIO worker pthread. Such threads simply have no
+// workload group to throttle against, so callers should treat nullptr as

Review Comment:
   This needs a focused BE test for the exact raw-thread path this helper is 
fixing. The existing `thread_context_test` runs under the BE test runner's 
main-thread `SCOPED_INIT_THREAD_CONTEXT()`, and I could not find any test 
reference to `thread_context_or_null`, `LIMIT_LOCAL_SCAN_IO`, or 
`LIMIT_REMOTE_SCAN_IO`. That leaves the reported `FILESYSTEM_M` / 
`AsyncIO::run_task` case unproved: a bthread filesystem call runs the upload on 
a raw pthread, then `LocalFileReader::read_at_impl` enters 
`LIMIT_LOCAL_SCAN_IO`, where this helper must return `nullptr` and skip 
throttling without raising `FatalError`. Please add a small BE unit test that 
invokes the helper or one of the throttle macros from a thread with no 
`SCOPED_INIT_THREAD_CONTEXT` / `SCOPED_ATTACH_TASK`, and keep an 
attached-context case so we know workload-group throttling still runs when a 
context is present.



-- 
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