Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions be/src/io/fs/hdfs_file_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Status HdfsFileReader::read_at_impl(size_t offset, Slice result, size_t* bytes_r
const IOContext* io_ctx) {
auto st = do_read_at_impl(offset, result, bytes_read, io_ctx);
if (!st.ok()) {
_handle = nullptr;
_accessor.destroy();
}
return st;
Expand All @@ -131,6 +132,11 @@ Status HdfsFileReader::do_read_at_impl(size_t offset, Slice result, size_t* byte
return Status::InternalError("read closed file: {}", _path.native());
}

if (_handle == nullptr) [[unlikely]] {
return Status::InternalError("cached hdfs file handle has been destroyed: {}",
_path.native());
}

if (offset > _handle->file_size()) {
return Status::IOError("offset exceeds file size(offset: {}, file size: {}, path: {})",
offset, _handle->file_size(), _path.native());
Expand Down Expand Up @@ -245,6 +251,10 @@ Status HdfsFileReader::do_read_at_impl(size_t offset, Slice result, size_t* byte
void HdfsFileReader::_collect_profile_before_close() {
if (_profile != nullptr && is_hdfs(_fs_name)) {
#ifdef USE_HADOOP_HDFS
if (_handle == nullptr) [[unlikely]] {
return;
}

struct hdfsReadStatistics* hdfs_statistics = nullptr;
auto r = hdfsFileGetReadStatistics(_handle->file(), &hdfs_statistics);
if (r != 0) {
Expand Down
Loading