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

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


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 05aa6706e55 branch-3.0: [fix](hdfs) remove cached file handle when 
read fails #54926 (#54991)
05aa6706e55 is described below

commit 05aa6706e55269385cb58ae5bc65871d53d8d916
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Aug 20 11:05:29 2025 +0800

    branch-3.0: [fix](hdfs) remove cached file handle when read fails #54926 
(#54991)
    
    Cherry-picked from #54926
    
    Co-authored-by: Yongqiang YANG <[email protected]>
---
 be/src/io/fs/hdfs_file_reader.cpp | 17 +++++++++++++----
 be/src/io/fs/hdfs_file_reader.h   |  3 +++
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/be/src/io/fs/hdfs_file_reader.cpp 
b/be/src/io/fs/hdfs_file_reader.cpp
index d43cfae1c28..c331223984b 100644
--- a/be/src/io/fs/hdfs_file_reader.cpp
+++ b/be/src/io/fs/hdfs_file_reader.cpp
@@ -114,9 +114,18 @@ Status HdfsFileReader::close() {
     return Status::OK();
 }
 
-#ifdef USE_HADOOP_HDFS
 Status HdfsFileReader::read_at_impl(size_t offset, Slice result, size_t* 
bytes_read,
-                                    const IOContext* /*io_ctx*/) {
+                                    const IOContext* io_ctx) {
+    auto st = do_read_at_impl(offset, result, bytes_read, io_ctx);
+    if (!st.ok()) {
+        _accessor.destroy();
+    }
+    return st;
+}
+
+#ifdef USE_HADOOP_HDFS
+Status HdfsFileReader::do_read_at_impl(size_t offset, Slice result, size_t* 
bytes_read,
+                                       const IOContext* /*io_ctx*/) {
     if (closed()) [[unlikely]] {
         return Status::InternalError("read closed file: {}", _path.native());
     }
@@ -169,8 +178,8 @@ Status HdfsFileReader::read_at_impl(size_t offset, Slice 
result, size_t* bytes_r
 #else
 // The hedged read only support hdfsPread().
 // TODO: rethink here to see if there are some difference between hdfsPread() 
and hdfsRead()
-Status HdfsFileReader::read_at_impl(size_t offset, Slice result, size_t* 
bytes_read,
-                                    const IOContext* /*io_ctx*/) {
+Status HdfsFileReader::do_read_at_impl(size_t offset, Slice result, size_t* 
bytes_read,
+                                       const IOContext* /*io_ctx*/) {
     if (closed()) [[unlikely]] {
         return Status::InternalError("read closed file: ", _path.native());
     }
diff --git a/be/src/io/fs/hdfs_file_reader.h b/be/src/io/fs/hdfs_file_reader.h
index 8ccbe4ade88..8556eea0de6 100644
--- a/be/src/io/fs/hdfs_file_reader.h
+++ b/be/src/io/fs/hdfs_file_reader.h
@@ -63,6 +63,9 @@ protected:
 
     void _collect_profile_before_close() override;
 
+    Status do_read_at_impl(size_t offset, Slice result, size_t* bytes_read,
+                           const IOContext* io_ctx);
+
 private:
 #ifdef USE_HADOOP_HDFS
     struct HDFSProfile {


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

Reply via email to