You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2023/04/07 08:40:07 UTC

[doris] branch master updated: [fix](file cache) Fix be core while use block/whole/sub file cache (#18440)

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

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new e3ff2e3d21 [fix](file cache) Fix be core while use block/whole/sub file cache (#18440)
e3ff2e3d21 is described below

commit e3ff2e3d211512e48ac710d692749dde46669da6
Author: zxealous <zh...@baidu.com>
AuthorDate: Fri Apr 7 16:39:59 2023 +0800

    [fix](file cache) Fix be core while use block/whole/sub file cache (#18440)
    
    BE will core dump while use whole/sub file cache.
    Call func CachedRemoteFileReader/WholeFileCache/SubFileCache::read_at_impl() did not pass IOContext when reading segment footer.
---
 be/src/io/cache/sub_file_cache.cpp        | 2 +-
 be/src/io/cache/whole_file_cache.cpp      | 3 +--
 be/src/olap/rowset/segment_v2/segment.cpp | 8 ++++++--
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/be/src/io/cache/sub_file_cache.cpp b/be/src/io/cache/sub_file_cache.cpp
index 3b3cb4110a..fc075bf490 100644
--- a/be/src/io/cache/sub_file_cache.cpp
+++ b/be/src/io/cache/sub_file_cache.cpp
@@ -51,7 +51,7 @@ SubFileCache::~SubFileCache() {}
 Status SubFileCache::read_at_impl(size_t offset, Slice result, size_t* bytes_read,
                                   const IOContext* io_ctx) {
     RETURN_IF_ERROR(_init());
-    if (io_ctx->reader_type != READER_QUERY) {
+    if (io_ctx != nullptr && io_ctx->reader_type != READER_QUERY) {
         return _remote_file_reader->read_at(offset, result, bytes_read, io_ctx);
     }
     std::vector<size_t> need_cache_offsets;
diff --git a/be/src/io/cache/whole_file_cache.cpp b/be/src/io/cache/whole_file_cache.cpp
index 5f4935cd16..ef24295e68 100644
--- a/be/src/io/cache/whole_file_cache.cpp
+++ b/be/src/io/cache/whole_file_cache.cpp
@@ -38,8 +38,7 @@ WholeFileCache::~WholeFileCache() {}
 
 Status WholeFileCache::read_at_impl(size_t offset, Slice result, size_t* bytes_read,
                                     const IOContext* io_ctx) {
-    DCHECK(io_ctx);
-    if (io_ctx->reader_type != READER_QUERY) {
+    if (io_ctx != nullptr && io_ctx->reader_type != READER_QUERY) {
         return _remote_file_reader->read_at(offset, result, bytes_read, io_ctx);
     }
     if (_cache_file_reader == nullptr) {
diff --git a/be/src/olap/rowset/segment_v2/segment.cpp b/be/src/olap/rowset/segment_v2/segment.cpp
index f59b716361..4a86e04a0f 100644
--- a/be/src/olap/rowset/segment_v2/segment.cpp
+++ b/be/src/olap/rowset/segment_v2/segment.cpp
@@ -148,7 +148,10 @@ Status Segment::_parse_footer() {
 
     uint8_t fixed_buf[12];
     size_t bytes_read = 0;
-    RETURN_IF_ERROR(_file_reader->read_at(file_size - 12, Slice(fixed_buf, 12), &bytes_read));
+    // Block / Whole / Sub file cache will use it while read segment footer
+    io::IOContext io_ctx;
+    RETURN_IF_ERROR(
+            _file_reader->read_at(file_size - 12, Slice(fixed_buf, 12), &bytes_read, &io_ctx));
     DCHECK_EQ(bytes_read, 12);
 
     // validate magic number
@@ -168,7 +171,8 @@ Status Segment::_parse_footer() {
 
     std::string footer_buf;
     footer_buf.resize(footer_length);
-    RETURN_IF_ERROR(_file_reader->read_at(file_size - 12 - footer_length, footer_buf, &bytes_read));
+    RETURN_IF_ERROR(_file_reader->read_at(file_size - 12 - footer_length, footer_buf, &bytes_read,
+                                          &io_ctx));
     DCHECK_EQ(bytes_read, footer_length);
 
     // validate footer PB's checksum


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org