Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions be/src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,8 @@ DEFINE_mBool(enable_parquet_page_index, "true");

DEFINE_mBool(ignore_not_found_file_in_external_table, "true");

DEFINE_mBool(ignore_not_found_segment, "true");

DEFINE_mBool(enable_hdfs_mem_limiter, "true");

DEFINE_mInt16(topn_agg_limit_multiplier, "2");
Expand Down
5 changes: 5 additions & 0 deletions be/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,11 @@ DECLARE_mBool(enable_parquet_page_index);
// Default is true, if set to false, the not found file will result in query failure.
DECLARE_mBool(ignore_not_found_file_in_external_table);

// Whether to ignore IO errors (NOT_FOUND, EIO) when loading segment files in native olap tables.
// Default is true. When a segment file is missing or has IO errors,
// the query/load will skip the failing segment instead of reporting error to users.
DECLARE_mBool(ignore_not_found_segment);
Comment on lines +1707 to +1710
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new config name ignore_not_found_segment is misleading because the behavior (and comment) also includes IO_ERROR, not just missing segments. Since this is a newly introduced config, consider renaming it to something like ignore_segment_io_errors (or otherwise aligning the name strictly to NOT_FOUND-only behavior) to avoid operator confusion when toggling at runtime.

Suggested change
// Whether to ignore IO errors (NOT_FOUND, EIO) when loading segment files in native olap tables.
// Default is true. When a segment file is missing or has IO errors,
// the query/load will skip the failing segment instead of reporting error to users.
DECLARE_mBool(ignore_not_found_segment);
// Whether to ignore IO errors (NOT_FOUND, EIO) when loading segment files in native OLAP tables.
// Default is true. When a segment file is missing or has IO errors,
// the query/load will skip the failing segment instead of reporting error to users.
DECLARE_mBool(ignore_segment_io_errors);

Copilot uses AI. Check for mistakes.

DECLARE_mBool(enable_hdfs_mem_limiter);

// Define how many percent data in hashtable bigger than limit
Expand Down
16 changes: 15 additions & 1 deletion be/src/storage/rowset/beta_rowset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,15 @@ Status BetaRowset::load_segments(int64_t seg_id_begin, int64_t seg_id_end,
int64_t seg_id = seg_id_begin;
while (seg_id < seg_id_end) {
std::shared_ptr<segment_v2::Segment> segment;
RETURN_IF_ERROR(load_segment(seg_id, nullptr, &segment));
auto st = load_segment(seg_id, nullptr, &segment);
if ((st.is<ErrorCode::NOT_FOUND>() || st.is<ErrorCode::IO_ERROR>()) &&
config::ignore_not_found_segment) {
LOG(WARNING) << "segment io error, skip it. rowset_id=" << rowset_id()
<< ", seg_id=" << seg_id << ", status=" << st;
seg_id++;
continue;
}
RETURN_IF_ERROR(st);
segments->push_back(std::move(segment));
seg_id++;
}
Expand All @@ -260,6 +268,12 @@ Status BetaRowset::load_segments(int64_t seg_id_begin, int64_t seg_id_end,

Status BetaRowset::load_segment(int64_t seg_id, OlapReaderStatistics* stats,
segment_v2::SegmentSharedPtr* segment) {
DBUG_EXECUTE_IF("BetaRowset::load_segment.return_not_found", {
return Status::Error<ErrorCode::NOT_FOUND>("injected segment not found, seg_id={}", seg_id);
});
DBUG_EXECUTE_IF("BetaRowset::load_segment.return_io_error", {
return Status::Error<ErrorCode::IO_ERROR>("injected segment io error, seg_id={}", seg_id);
});
auto fs = _rowset_meta->fs();
if (!fs) {
return Status::Error<INIT_FAILED>("get fs failed");
Expand Down
13 changes: 11 additions & 2 deletions be/src/storage/segment/lazy_init_segment_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "storage/segment/lazy_init_segment_iterator.h"

#include "storage/rowset/beta_rowset.h"
#include "storage/segment/segment_loader.h"

namespace doris::segment_v2 {
Expand All @@ -40,8 +41,16 @@ Status LazyInitSegmentIterator::init(const StorageReadOptions& opts) {
std::shared_ptr<Segment> segment;
{
SegmentCacheHandle segment_cache_handle;
RETURN_IF_ERROR(SegmentLoader::instance()->load_segment(
_rowset, _segment_id, &segment_cache_handle, _should_use_cache, false, opts.stats));
auto st = SegmentLoader::instance()->load_segment(
_rowset, _segment_id, &segment_cache_handle, _should_use_cache, false, opts.stats);
if ((st.is<ErrorCode::NOT_FOUND>() || st.is<ErrorCode::IO_ERROR>()) &&
config::ignore_not_found_segment) {
LOG(WARNING) << "segment io error, skip it. rowset_id=" << _rowset->rowset_id()
<< ", seg_id=" << _segment_id << ", status=" << st;
// _inner_iterator remains nullptr, next_batch() will return EOF
return Status::OK();
}
RETURN_IF_ERROR(st);
Comment on lines +44 to +53
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ignore+log logic for segment load failures is now duplicated across SegmentLoader::load_segments, LazyInitSegmentIterator::init, and BetaRowset::load_segments. To avoid future drift (e.g., one path handling a new error code differently), consider extracting a small helper (e.g., should_ignore_segment_load_error(Status)) or a shared utility for the condition + standardized log message.

Copilot uses AI. Check for mistakes.
const auto& tmp_segments = segment_cache_handle.get_segments();
segment = tmp_segments[0];
}
Expand Down
7 changes: 6 additions & 1 deletion be/src/storage/segment/lazy_init_segment_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class LazyInitSegmentIterator : public RowwiseIterator {
Status next_batch(Block* block) override {
if (UNLIKELY(_need_lazy_init)) {
RETURN_IF_ERROR(init(_read_options));
DCHECK(_inner_iterator != nullptr);
}
if (_inner_iterator == nullptr) {
return Status::EndOfFile("segment not found, skipped");
}

return _inner_iterator->next_batch(block);
Expand All @@ -49,6 +51,9 @@ class LazyInitSegmentIterator : public RowwiseIterator {
const Schema& schema() const override { return *_schema; }

Status current_block_row_locations(std::vector<RowLocation>* locations) override {
if (_inner_iterator == nullptr) {
return Status::EndOfFile("no segment loaded");
}
return _inner_iterator->current_block_row_locations(locations);
}

Expand Down
11 changes: 9 additions & 2 deletions be/src/storage/segment/segment_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,15 @@ Status SegmentLoader::load_segments(const BetaRowsetSharedPtr& rowset,
return Status::OK();
}
for (int64_t i = 0; i < rowset->num_segments(); i++) {
RETURN_IF_ERROR(load_segment(rowset, i, cache_handle, use_cache, need_load_pk_index_and_bf,
index_load_stats));
auto st = load_segment(rowset, i, cache_handle, use_cache, need_load_pk_index_and_bf,
index_load_stats);
if ((st.is<ErrorCode::NOT_FOUND>() || st.is<ErrorCode::IO_ERROR>()) &&
config::ignore_not_found_segment) {
LOG(WARNING) << "segment io error, skip it. rowset_id=" << rowset->rowset_id()
<< ", seg_id=" << i << ", status=" << st;
continue;
}
RETURN_IF_ERROR(st);
}
cache_handle->set_inited();
return Status::OK();
Expand Down
Loading
Loading