amanjain-cb opened a new issue, #71271: URL: https://github.com/apache/doris/issues/71271
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues. ### Version 4.1.5 (apache/doris:be-4.1.5, fe-4.1.5), 3 FE + 3 BE, coupled (local storage). ### What's Wrong? ### What's wrong? A column has two inverted indexes with different custom analyzers (supported since 3.1, see the custom analyzer docs, chosen with `USING ANALYZER`). After an **incremental clone** to a replica, the cloned rowsets' `tablet_schema` lists the second index with the **first index's index_id**. From then on, on that replica: - every cumulative compaction of the tablet fails (retried forever): ``` failed to do cumulative compaction, tablet=<id> : [E-7412][E-7412] Check failed: status.ok()[E-6001]Duplicate inverted index id <first_index_id> in one field ``` (stack through `InvertedIndexIterator::add_reader` in the compaction merge) - queries reading that replica fail with the same error (MATCH_PHRASE with either analyzer, also MATCH_ANY). Plain `count(*)` works. The replica is never repaired automatically. Other replicas are fine. `/api/meta/header/<tablet_id>` on the broken BE: the top-level schema is correct (two different index_ids), but `rs_metas[].tablet_schema.index` of the cloned rowsets shows both indexes with the same index_id. ### Cause `SnapshotManager::_rename_index_ids` (be/src/storage/snapshot/snapshot_manager.cpp), called for incremental clone: ```cpp auto local_index = tablet_schema->get_index(col_unique_id, index_pb->index_type(), index_pb->index_suffix_name()); if (local_index) { if (index_pb->index_id() != local_index->index_id()) { index_pb->set_index_id(local_index->index_id()); } break; } ``` The local index is looked up by (column, index type, suffix) only. Two inverted indexes on the same column have the same column, type and (empty) suffix, so the lookup always returns the first one, and the second index gets the first index's id. Full clone does not call this, so it is not affected. ### What You Expected? Each index keeps its own id after clone (e.g. match by index name, or by index properties / analyzer identity in addition to column + type + suffix), so compaction and queries keep working. ### How to Reproduce? ``sql CREATE INVERTED INDEX CHAR_FILTER IF NOT EXISTS t_nfkc_cf PROPERTIES ('type'='icu_normalizer','name'='nfkc_cf'); CREATE INVERTED INDEX ANALYZER IF NOT EXISTS t_icu PROPERTIES ('char_filter'='t_nfkc_cf','tokenizer'='icu','token_filter'='lowercase'); CREATE INVERTED INDEX TOKENIZER IF NOT EXISTS t_bigram_tok PROPERTIES ('type'='ngram','min_gram'='2','max_gram'='2','token_chars'='letter,digit'); CREATE INVERTED INDEX ANALYZER IF NOT EXISTS t_bigram PROPERTIES ('tokenizer'='t_bigram_tok','token_filter'='lowercase'); CREATE DATABASE dupidx; CREATE TABLE dupidx.t ( k1 BIGINT NOT NULL, k2 BIGINT NOT NULL, txt TEXT, updated_at DATETIME NOT NULL, INDEX idx_icu (txt) USING INVERTED PROPERTIES("analyzer"="t_icu","support_phrase"="true"), INDEX idx_bigram (txt) USING INVERTED PROPERTIES("analyzer"="t_bigram","support_phrase"="true")) UNIQUE KEY(k1,k2) DISTRIBUTED BY HASH(k1) BUCKETS 3 PROPERTIES ("replication_num"="3","enable_unique_key_merge_on_write"="true","light_schema_change"="true", "inverted_index_storage_format"="V3","function_column.sequence_col"="updated_at","disable_auto_compaction"="true"); ``` 1. Load some batches, e.g. 30 x: ```sql INSERT INTO dupidx.t SELECT number % 40, <b>*300+number, concat('営業職を募集 Sales engineer ', number), now() FROM numbers("number"="300"); ``` 2. Stop one BE (e.g. delete its pod). Load 5 more batches while it is down. 3. Start the BE again. FE repairs its replicas with an incremental clone ("successfully clone tablet"). 4. On that BE: ```sql SET use_fix_replica = <index of that BE's replica>; SELECT count(*) FROM dupidx.t WHERE txt MATCH_PHRASE '営業職' USING ANALYZER t_icu; ``` => `Duplicate inverted index id ... in one field`. Running cumulative compaction on that BE (`POST /api/compaction/run?tablet_id=<t>&compact_type=cumulative`) fails with the same error. Control: the same steps with the bigram index on a second column (one inverted index per column) work fine. A BE restart without missed loads (no incremental clone) also works fine. ### Anything Else? _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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]
