csun5285 opened a new pull request, #71358:
URL: https://github.com/apache/doris/pull/71358
### What problem does this PR solve?
Issue Number: close #71271
Related PR: #33648 (reset secondary index IDs on restore), #45283 (added
restore_reset_index_id), #46104 (defaulted restore_reset_index_id to false),
#57074 (introduced _rename_index_ids)
PR Type: Bugfix
Problem Summary:
When a table has two or more inverted indexes on the same column, cloning
onto an existing replica overwrites the second index's `index_id` in cloned
rowset metadata with the first index's `index_id`. Queries or cumulative
compaction on that replica then fail with `[E-6001] Duplicate inverted index id
... in one field` (or abort on `DORIS_CHECK` in debug/ASAN builds). This PR
stops resetting secondary `Index.indexId`s during `RESTORE` (deprecating
`Config.restore_reset_index_id` as a no-op) and removes `_rename_index_ids` and
`TabletSchema::get_index` from BE and Cloud snapshot conversion; over 80% of
the diff is tests.
For example, after repairing a lagging replica on a table with `idx_icu`
(`1796268006580`) and `idx_bigram` (`1796268006581`) on column `txt`:
```sql
SELECT count(*) FROM test_multi_inverted_index_clone
WHERE txt MATCH_PHRASE '営業職' USING ANALYZER analyzer_71271_icu;
```
| Before the fix | With the fix |
|---|---|
| Cloned rowset has `[1796268006580, 1796268006580]`; query fails with
`[E-6001] Duplicate inverted index id 1796268006580 in one field` | Cloned
rowset keeps `[1796268006580, 1796268006581]`; query returns `60` |
### Details
- **Change map:** Production code is `+10 / -122` across 8 files; tests are
`+514 / -91` across 8 files plus `+31 / -0` in 1 generated `.out` file (98% of
added lines are tests).
1. FE restore metadata (`OlapTable.resetIdsForRestore`,
`Config.restore_reset_index_id`, `+6 / -20`): keep upstream secondary
`Index.indexId`s unchanged on `RESTORE` and mark `restore_reset_index_id`
`@Deprecated` no-op.
2. BE and Cloud snapshot conversion (`SnapshotManager`,
`CloudSnapshotMgr`, `TabletSchema`, `+4 / -102`): delete `_rename_index_ids`
and the single-index `TabletSchema::get_index` lookup.
- **Frequency:** Always, whenever `EngineCloneTask` or
`EngineStorageMigrationTask` converts rowsets onto an existing local tablet
with multiple same-type secondary indexes on one column.
- **Root cause:** #33648 reset secondary `Index.indexId`s in
`OlapTable.resetIdsForRestore()`, and #57074 worked around the resulting
restore mismatch when `restore_reset_index_id = true` by adding
`_rename_index_ids` in `SnapshotManager::convert_rowset_ids` and
`CloudSnapshotMgr::convert_rowsets`. `_rename_index_ids` called
`TabletSchema::get_index(col_unique_id, index_type, suffix_path)`, which
returns `_indexes[it->second[0]]` and collapses every inverted index on the
same column to the first index's `index_id`.
- **Why existing tests missed it:** Unit tests
(`SnapshotManagerTest.TestConvertRowsetIdsNormal`,
`CloudSnapshotMgrTest.TestConvertRowsets`, `TestRenameIndexIds`) placed at most
one index per type on a column and asserted that `index_id` was overwritten
(updated here). Regression: `clone_p0` has no multi-inverted-index-per-column
case, `inverted_index_p0` multi-analyzer suites never clone, and
`test_backup_restore_inverted_idx` / `test_validate_restore_inverted_idx` left
`restore_reset_index_id = "true"` in `finally` after #46104 flipped the default
to `false` (cleaned up here).
- **Fix:** Preserve secondary `Index.indexId`s in
`OlapTable.resetIdsForRestore()` and remove `_rename_index_ids` and
`TabletSchema::get_index`. Matching by index name in `_rename_index_ids`
instead would still leave `.idx` headers mismatched if `restore_reset_index_id`
were set and could miswire dropped-and-recreated indexes across schema changes.
- **Other paths and branches:** Shared-nothing clone, storage migration,
shared-nothing restore, and Cloud restore all called the removed
`_rename_index_ids` helpers and are fixed here; `SchemaChangeHandler` `ADD
INDEX` keeps its collision-skipping loop from #45283. `branch-4.0`,
`branch-4.1`, and `branch-4.2` carry #57074 (`8af45166949` via #58660) and have
the bug; `branch-3.1` does not have #57074.
- **Configs and defaults:** FE mutable master-only config
`restore_reset_index_id` (default `false`) is now `@Deprecated` and a runtime
no-op, retained so existing `fe.conf` files and `ccr-syncer` callers do not
fail on an unknown key.
### Testing
- New `inverted_index_p0/test_multi_inverted_index_clone.groovy`: fails on
baseline `441cd03013d` (`expected: <[1796268006580, 1796268006581]> but was:
<[1796268006580]>`; manual query aborts BE with `Duplicate inverted index id`),
and passes on a local 1 FE + 3 BE ASAN cluster with `MATCH_PHRASE` queries and
cumulative compaction.
- FE UT `OlapTableTest` (`22/22` passed locally) and BE/Cloud UTs
`SnapshotManagerTest`, `CloudSnapshotMgrTest`, `TabletSchemaTest` (`43/43`
passed locally).
- Updated `test_backup_restore_reset_index_id.groovy`,
`test_backup_restore_inverted_idx.groovy`, and
`test_validate_restore_inverted_idx.groovy`: not run locally (require S3
repository credentials); run in `p0` and `validate_restore` CI pipelines.
### Notes for Reviewers
- `test_backup_restore_reset_index_id.groovy` now asserts `RESTORE`
preserves `oldIndexId == newIndexId` across FE, tablet schema, and rowset
schema even when deprecated `restore_reset_index_id = true` is set, and checks
`MATCH_ANY` without fallback.
### Release note
Fix replica corruption (`Duplicate inverted index id ... in one field` on
queries and cumulative compaction) after cloning tablets with multiple inverted
indexes on the same column.
### Check List (For Author)
- Behavior changed: No
- Does this need documentation: No
- Pre-submission status: Partially verified: S3-backed backup_restore suites
(test_backup_restore_reset_index_id, test_backup_restore_inverted_idx,
test_validate_restore_inverted_idx) not run locally without S3 repository
credentials
### AI Disclosure
- Tool: Antigravity (Gemini)
- Generated: code, tests, this description
- Human review: not stated
- Prompts: Asked the agent to reproduce #71271 in an isolated multi-BE
docker worktree, trace the history of `_rename_index_ids` and
`restore_reset_index_id`, and implement the root-cause fix by never resetting
secondary index IDs on restore and removing snapshot index-ID rewriting.
<!-- Recommended: develop the change with the develop-with-evidence skill
and write this description with the doris-pr-description skill, both from
https://github.com/apache/doris-skills (the doris-skills submodule of this
repository). -->
### Background
<!-- How the feature or module this PR touches works today, in two to four
plain sentences, for a reviewer who doesn't know it. Link the user doc if there
is one. Leave the problem and the fix to Problem Summary. -->
### What problem does this PR solve?
<!-- Issue Number: "close #N" if this PR resolves the issue, "#N" if it only
relates to it, "None" if there is none. A Feature needs an issue. -->
<!-- Related PR: "#N (relation)" for each PR a reviewer should know about,
such as "#123 (introduced the bug)", separated by commas. Write "None" if no
related PR is known. -->
<!-- PR Type: Bugfix, Performance, Feature, Enhancement, Refactor, Test,
Build/CI/Chore, Revert, Release/Dependency, or Other. -->
Issue Number:
Related PR:
PR Type:
Problem Summary:
<!-- Two to five sentences: the problem or need and who is affected; the
approach in one sentence; when the diff is larger than that suggests, what else
it had to handle, or that most of it is tests; and what existing users see
after an upgrade. -->
### Details
<!--
For a diff of more than about 300 changed lines, start with "- **Change
map:**": how many lines are production code, tests, generated files, and docs,
then the code in parts, each with the problem it handles and its size.
Then answer each field of your PR type on its own line, as "- **Field:**
answer", in this order:
Bugfix: Frequency, Root cause, Why existing tests missed it, Fix, Other
paths and branches
Performance: Why it was slow, Optimization, Results, Applicability and cost
Feature: Scope, Design, Usage, Default behavior, Compatibility
Enhancement: Before and after, Configs and defaults, Impact on existing
users
Refactor: Moves vs. logic changes, Behavior change, Compatibility,
Performance impact, Rollback
Test, adding tests: Scenarios, What existing tests miss, Fails when broken
Test, fixing a test: Failure, Cause, Stability evidence
Build/CI/Chore: Affected, Developer and release impact, License and
third-party, Rollback
Revert: Why not fix forward, Original author notified, Follow-up
Release/Dependency: Versions, Upstream changes, Compatibility, Rollback
Other: Why Other
"None" is a valid answer when it is true. Don't restate the diff.
-->
### Testing
<!-- The tests, suites, or commands that ran, what each shows, and where it
ran (locally or in CI). For a fix, the test that fails before it and passes
after. -->
### Notes for Reviewers
<!-- Optional; delete this section if there is nothing to say. Why each
non-obvious edit was made, what you are unsure about, and where to start
reading if Details has no Change map. -->
### Release note
<!-- One paragraph on what users will notice, or None. -->
### Check List (For Author)
<!-- Behavior changed: "No", or "Yes (see Details)" with a Behavior change
field in Details. -->
<!-- Does this need documentation: "No", or "Yes" with the
apache/doris-website PR or the plan. -->
<!-- Pre-submission status: "Ready"; "Partially verified: " and what is not
verified; or "Not ready: " and why, for a Draft PR. -->
- Behavior changed:
- Does this need documentation:
- Pre-submission status:
### AI Disclosure
<!-- Tool: the agent and model, or None. Generated: the parts it wrote
(code, tests, this description), or None. Human review: what you reviewed of
the generated parts, or "Not applicable" without AI tools. You may add "-
Prompts:" to summarize how you directed the agent. -->
- Tool:
- Generated:
- Human review:
--
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]