zhiqiang-hhhh commented on code in PR #40493:
URL: https://github.com/apache/doris/pull/40493#discussion_r1824373036


##########
be/src/io/fs/buffered_reader.cpp:
##########
@@ -415,10 +415,36 @@ void PrefetchBuffer::reset_offset(size_t offset) {
     } else {
         _exceed = false;
     }
+
+    // The "io_ctx" in the input parameter belongs to the upper caller.
+    // Because PrefetchBuffer actually runs in another thread,
+    // its life cycle may be different from that of the caller.
+    // Therefore, before submitting PrefetchBuffer to the thread pool,
+    // we need to copy io_ctx to _owned_io_ctx to ensure that
+    // the life cycle of IOContext is consistent with that of PrefetchBuffer.
+    // _update_and_reset_io_context(io_ctx);
     _prefetch_status = 
ExecEnv::GetInstance()->buffered_reader_prefetch_thread_pool()->submit_func(
             [buffer_ptr = shared_from_this()]() { 
buffer_ptr->prefetch_buffer(); });
 }
 
+void PrefetchBuffer::_update_and_reset_io_context(const IOContext* io_ctx) {
+    if (io_ctx) {
+        // If file_cache_stats is set in the input parameter,
+        // first need to update the last statistics in _owned_cache_stats
+        // to the file_cache_stats in the input parameter.
+        // Then reset _owned_cache_stats
+        if (io_ctx->file_cache_stats) {

Review Comment:
   potential data race ?



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