yiguolei opened a new pull request, #70906: URL: https://github.com/apache/doris/pull/70906
Backport of #70788 to `branch-4.1`, based on source head `c51dfbd5aeed1ce22427e38808291e05ed0832c8`. ### Background ANN indexes accelerate vector TopN and range predicates. Segments without index data can still evaluate these predicates by scanning their vectors. ANN and inverted indexes share the container reader, and legitimate empty containers can arise from small ANN segments or all-NULL VARIANT columns. ### What problem does this PR solve? Issue Number: None Related PR: #70788 PR Type: Enhancement Problem Summary: ANN loading currently converts every returned failure into brute-force fallback, hiding I/O and memory errors. Use explicit statuses so only a missing index permits fallback, and classify empty legacy containers as missing index data. Most added lines test this boundary and its callers. After upgrading, ANN queries expose other loading failures instead of silently scanning. ### Details - **Change map:** Production code +26/-32; tests +284/-30 across 14 files. Tests cover load-status propagation, both ANN consumers and empty containers using the existing branch-4.1 compound-directory interface. - **Before and after:** A single Status-returning `load_index` API replaces `try_load_index`. TopN and range fall back only for `INVERTED_INDEX_FILE_NOT_FOUND`. Empty V2/V3 containers now return that code rather than `INVERTED_INDEX_BYPASS`; missing internal Faiss files remain errors. - **Configs and defaults:** No new settings or default changes. Inverted predicates encountering empty containers now follow `enable_fallback_on_missing_inverted_index`, whose default remains true. - **Impact on existing users:** ANN loading failures other than missing indexes now fail the query. Inverted predicates with the fallback setting disabled now fail on empty containers too; the default still allows fallback. Empty-container diagnostics change from E-6004 to E-6003 while retaining `is empty`; downgrade logging changes from DEBUG to INFO. Persisted formats and SQL syntax are unchanged. - **Behavior change:** Missing and empty containers use the missing-index policy; unrelated loading failures remain visible. ### Testing - Builds, unit tests, regression tests and clang-tidy were not run for this backport, following the author's preference. Historical results in #70788 do not validate this branch. - Changed C++ lines were formatted and checked with clang-format 16; `git diff --check` passed. - Static self-review checked the release-branch interfaces, ANN TopN/range callers, compound-directory lifetime, and missing internal Faiss file handling. This is not runtime validation. - The new `AnnIndexLoadTest` cases cover init/open failures, cached failed loads, missing-only TopN/range fallback, a real empty V2 container, null readers and missing internal files for HNSW/IVF/IVF_ON_DISK. Existing empty-container, reader, index-builder and lifecycle/VARIANT expectations are updated. - The branch does not contain `build-support/check-build-hygiene.sh`; that gate was not run. ### Notes for Reviewers - Preserve branch-4.1's `IndexFileReader::open`, CLucene exception handling, `_compound_dir` ownership and existing Faiss load signature. Do not backport the ANN storage abstraction from #70270. - This branch already returns `INVERTED_INDEX_FILE_NOT_FOUND` for an absent logical index. It has no SNII status/interface, so the master-only SNII normalization and injected case are omitted. - Adapt fixtures to `Schema`, the two-argument `SegmentIterator` constructor, `_opts.stats`, `idx_to_cid` and `_need_read_data_indices`. - Omit the comment-only change to `ann_index_range_read_test.cpp`, which does not exist on branch-4.1 and depends on newer storage changes. - Removing the BE_TEST loading shortcut lets tests exercise the real loader. Search-only mocks explicitly model successful loading. Missing files inside an existing ANN index remain errors. - Empty-container regression assertions retain the distinction between existing empty files and absent files through the diagnostic message. ### Release note ANN queries fall back when index data is absent but now report other loading failures. Empty V2/V3 containers follow the missing-index policy, including the inverted-index fallback setting, and report diagnostic code E-6003. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: Yes (plan: document ANN missing-only fallback and empty-container interaction with enable_fallback_on_missing_inverted_index in apache/doris-website) - Pre-submission status: Partially verified: static inspection and changed-line formatting passed; this backport has not been compiled or tested, and clang-tidy has not run. ### AI Disclosure - Tool: Codex (GPT-6). - Generated: Backport conflict resolution, release-branch test adaptations, static self-review and this description; implementation and original tests come from #70788. - Human review: The author directed preserving branch-4.1 interfaces and authorized adaptation and PR submission; extent of full code review not stated. -- 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]
