Skip to content

branch-4.1: [fix](be) Key the index lookup map by each surviving index in remove_index #66316 - #66393

Open
github-actions[bot] wants to merge 1 commit into
branch-4.1from
auto-pick-66316-branch-4.1
Open

branch-4.1: [fix](be) Key the index lookup map by each surviving index in remove_index #66316#66393
github-actions[bot] wants to merge 1 commit into
branch-4.1from
auto-pick-66316-branch-4.1

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Cherry-picked from #66316

…index (#66316)

### What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

`TabletSchema::remove_index` rebuilds the `(index_type, col_unique_id,
index_suffix) -> position` lookup map after dropping an entry. The loop
walks each surviving index, but builds every map key from
`_indexes.back()` instead of the entry being registered:

```cpp
for (size_t new_pos = 0; new_pos < _indexes.size(); ++new_pos) {
    const auto& index = _indexes[new_pos];
    ...
    IndexKey key = std::make_tuple(_indexes.back()->index_type(), col_uid,
                                   _indexes.back()->get_index_suffix());
    _col_id_suffix_to_index[key].push_back(new_pos);
}
```

So every survivor is filed under the LAST survivor's index type and
suffix. When the survivors are homogeneous -- e.g. several INVERTED
indexes with no suffix, which is what the existing coverage uses --
every
key is identical and the result is accidentally correct. When they
differ,
it is not: after dropping one of two INVERTED indexes on a table that
also
carries an NGRAM_BF index, the surviving INVERTED index is filed under
`(NGRAM_BF, col, "")`, and `inverted_indexs()` -- which looks up
`IndexType::INVERTED` -- no longer finds it. A surviving index then
becomes
invisible to callers that resolve indexes through this map, including
the
segment writer and index compaction, with no error reported. The same
applies to indexes that differ only in suffix (variant sub-column
indexes).

The fix keys each entry by its own `index_type()` /
`get_index_suffix()`.
This also makes `remove_index` consistent with the other three sites
that
populate the same map (`append_index`, `init_from_pb`, and the
column-append path): those iterate right after
`_indexes.emplace_back(...)`,
where `_indexes.back()` IS the entry being registered, so they are
correct
as written and are left unchanged.

The map is a runtime cache rebuilt from scratch by `init_from_pb`, so a
schema that round-trips through protobuf is unaffected; only an
in-memory
schema that keeps being used after `remove_index` sees the stale
mapping.
@github-actions
github-actions Bot requested a review from yiguolei as a code owner August 3, 2026 13:37
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@hello-stephen

Copy link
Copy Markdown
Contributor

run buildall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants