Copilot commented on code in PR #64846:
URL: https://github.com/apache/doris/pull/64846#discussion_r3473013312
##########
be/src/io/fs/s3_file_system.cpp:
##########
@@ -321,6 +321,12 @@ Status S3FileSystem::rename_impl(const Path& orig_name,
const Path& new_name) {
}
Status S3FileSystem::upload_impl(const Path& local_file, const Path&
remote_file) {
+ // When called from a bthread, FILESYSTEM_M dispatches upload_impl to an
AsyncIO
+ // worker pthread that has no attached task. Reading the local file below
goes through
+ // LocalFileReader::read_at_impl -> LIMIT_LOCAL_SCAN_IO, which
unconditionally touches
+ // thread_context() and would FatalError without a ThreadContext. Attach a
task here,
+ // mirroring batch_upload_impl, so the local read has a valid context.
+ SCOPED_ATTACH_TASK(ExecEnv::GetInstance()->s3_file_buffer_tracker());
Review Comment:
SCOPED_ATTACH_TASK unconditionally attaches a new task and *detaches it at
scope exit* (AttachTask::~AttachTask calls thread_context()->detach_task()).
Because FILESYSTEM_M runs upload_impl inline when bthread_self()==0,
upload_impl can execute on a thread that already has an attached query/load
task; in that case this call will overwrite the existing ResourceContext and
then detach it on return, breaking the caller’s thread context / memory
tracking (and will DCHECK in debug builds due to duplicate attach_task). Please
only attach when the current thread has no attached task, while still ensuring
a ThreadContext exists for the LocalFileReader path.
--
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]