softWsong opened a new issue, #70877:
URL: https://github.com/apache/doris/issues/70877

   ### 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
   
   - Doris: `doris-4.1.3-rc02-7126cf65d96`
   - Deployment: Kubernetes + Doris Operator (3 FE, 8 BE; `beSpec.replicas` 9, 
one BE pod missing)
   - Table: 96 columns, `DUPLICATE KEY(APNNO)`, 55,751,264 rows, ~435 GB
     - `PARTITION BY RANGE(APP_DATE)` — 15 partitions, one per year band
     - `DISTRIBUTED BY RANDOM BUCKETS 9`
     - `replication_allocation = tag.location.default: 1` (single replica)
   - ANN index:
   
   ```sql
   CREATE INDEX idx_embedding_patent ON YUANSUDATA.ODS_PATENT_BASE (EMBEDDING) 
USING ANN
   PROPERTIES(
     "dim"             = "1024",
     "index_type"      = "hnsw",
     "metric_type"     = "inner_product",
     "max_degree"      = "16",
     "ef_construction" = "40",
     "quantizer"       = "sq8"
   );
   ```
   
   ### What's Wrong?
   
   On a 55.7M-row table with an HNSW ANN index, running `full` compaction via 
the BE HTTP API reduces the segment count
   (400 → 186) but leaves **68 of 187 segments without a usable index**. Those 
segments fall back to brute-force scan,
   and the ANN query degrades from sub-second to **124 seconds**.
   
   After that, there is **no supported way to repair the index**:
   
   - `ALTER TABLE ... ADD INDEX ... USING ANN` (i.e. `CREATE INDEX`) on the 
already-indexed table returns `FINISHED`
     in **0–2 seconds** for every partition, but no index is actually built (no 
`ann_index_writer` on any BE).
   - The only thing that did build the index originally was the very first 
`CREATE INDEX`, which took **31–85 minutes**
     per partition.
   
   So a single `full` compaction permanently degrades the index, and the 
documented rebuild path silently does nothing.
   
   ### What You Expected?
   
   All segments keep their ANN index after compaction, or the index is rebuilt 
as part of compaction.
   
   ### How to Reproduce?
   
   
   1. Create the table (no ANN index in the DDL), load 55.7M rows.
   2. `CREATE INDEX idx_embedding_patent ... USING ANN` — this really builds 
the index, taking **31–85 min** per
      partition (15 partitions, `SHOW BUILD INDEX` shows `ADD INDEX` jobs 
starting `2026-11-20 22:41` and finishing
      between `23:12` and `00:05`). ANN queries afterwards are fast and use the 
index.
   3. Trigger full compaction on every BE:
   
   ```bash
   for i in 0 1 2 3 4 5 6 7; do
     curl -s -X POST \
       
"http://doriscluster-helm-be-$i.doriscluster-helm-be-internal.doris.svc.cluster.local:8040/api/compaction/run?table_id=1789467786945&compact_type=full";
   done
   ```
   
   4. Segment count drops 400 → 186, all `full` tasks `FINISHED`.
   5. Run an ANN top-1 query and inspect the profile.
   
   Query used:
   
   ```sql
   SELECT TITLE, APPL, APNNO, inner_product_approximate(EMBEDDING, 
EMBED('bge_m3_embed', '<text>')) AS score
   FROM YUANSUDATA.ODS_PATENT_BASE
   ORDER BY score DESC
   LIMIT 1;
   
   ### Anything Else?
   
   
   Attempting to repair by re-creating the index:
   
   ```sql
   CREATE INDEX idx_embedding_patent ON YUANSUDATA.ODS_PATENT_BASE (EMBEDDING) 
USING ANN PROPERTIES(...);
   ```
   
   `SHOW BUILD INDEX` shows 60 `ADD INDEX` records for this table on the same 
day (4 batches x 15 partitions), **all
   `FINISHED` within 0–2 seconds**. Example:
   
   ```
   p2026      2026-11-23 13:28:27.029 -> 2026-11-23 13:28:28.005  FINISHED
   p_0000_2011 2026-11-23 09:40:29.466 -> 2026-11-23 09:40:30.446  FINISHED
   ```
   
   For comparison, the original build of the same index on the same data took 
**1,898–5,079 seconds per partition**.
   
   On the BE side there is **no index build activity at all**: `grep 
ann_index_writer be.INFO` returns nothing for the
   compaction/rebuild day on all 8 BEs (last entries are from the previous day, 
i.e. the original build).
   
   So the statement reports success in ~1 s while doing nothing, and the 
operator is left with a permanently degraded
   index. Note there is no `DROP INDEX` before these `ADD INDEX` statements, so 
the index already exists with identical
   properties — Doris appears to treat the duplicate `ADD INDEX` as a no-op 
instead of raising an error or rebuilding.
   
   Related: #69816 mentions that `BUILD INDEX` skips rowsets that already 
declare the index ID and can report a
   0 ms success that does not mean the physical index files are intact. This 
looks like the same class of problem for
   `ADD INDEX` on an already indexed table.
   
   ### 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]

Reply via email to