dataroaring commented on PR #61844:
URL: https://github.com/apache/doris/pull/61844#issuecomment-4259034271

   ## Addressing review feedback: seg_id positional indexing safety
   
   The concern about `SegmentLoader::load_segments()` producing a compacted 
vector when segments are skipped is valid and has been fixed in commit ef0a2ce.
   
   ### Problem
   
   When `ignore_not_found_segment` is true and a segment is NOT_FOUND/IO_ERROR, 
the segment is skipped with `continue`, producing a vector with `size() < 
num_segments()`. Two callers break:
   
   1. **`BaseTablet::lookup_row_key()`** — indexes `segments[id]` where `id` is 
a seg_id in `[0, num_segments-1]`. With skipped segments, this is an 
out-of-bounds access (undefined behavior in release, DCHECK failure in debug).
   
   2. **`check_segment_rows_consistency()`** — asserts `rows_from_footer.size() 
== rows_from_meta.size()`, which fails when segments are missing.
   
   ### Fix
   
   - **`lookup_row_key`**: When `segments.size() != num_segments`, fall back to 
`std::find_if` by segment ID (matching the existing safe pattern in 
`_get_segment_column_iterator`). The normal path (no missing segments) uses the 
fast positional index unchanged.
   
   - **`check_segment_rows_consistency`**: When `ignore_not_found_segment` is 
on and sizes differ, skip the check with an INFO log. We cannot meaningfully 
verify footer rows for missing segments, and the compacted indices don't align 
with meta indices.
   
   ### Other review items (lower priority)
   
   - **Config name**: `ignore_not_found_segment` also covers `IO_ERROR` — 
agreed the name is slightly misleading. Can rename in a follow-up if desired.
   - **Duplicated ignore+log logic**: Three files share the same pattern. Could 
extract a helper, but the pattern is simple enough that the duplication is 
tolerable.
   - **Unused `#include "common/config.h"` in `lazy_init_segment_iterator.h`**: 
Will remove in a follow-up.
   - **Test improvements** (RAII debug points, regression test for seg_id 
contract): Noted for follow-up.
   
   — ThinkOps 🤖


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to