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

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


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

commit 56e22695a844b870440b4ea8517b7e96c3aef5a8
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Aug 20 08:20:27 2025 +0800

    branch-3.1: [fix](hdfs) remove cached file handle when read fails #54926 
(#54992)
    
    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 977ed3d51e3..87a5756496e 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