Repository navigation
Description
Summary
The pure-INSERT HNSW CDC path discards every error returned by HnswModel.AddWithoutIncr. The CDC update returns success even when usearch rejects a row, while the pre-reserved logical Len counter remains incremented.
This can persist an HNSW index with missing rows and an incorrect model length, and allows the CDC task/watermark to advance past data that was not indexed.
Version
Commit: 7f7de555c
Code path
pkg/vectorindex/hnsw/sync.go in insertAllInParallel:
last, _, err := s.getLastModelAndIncrForSync(sqlproc, maxcap, &mu)
if err != nil {
err_chan <- err
return
}
// Len counter already incremented. Just add to last model
last.AddWithoutIncr(row.PKey, row.Vec)The return value of AddWithoutIncr is ignored. getLastModelAndIncrForSync has already incremented last.Len before the physical add.
The sequential UPDATE/DELETE path checks Add and Remove errors correctly; the defect is specific to the parallel pure-INSERT path.
White-box reproduction
Create an empty 3-dimensional HNSW model and pass two pure CDC INSERT entries with the same primary key to insertAllInParallel:
cdc := &vectorindex.VectorIndexCdc[float32]{Data: []vectorindex.VectorIndexCdcEntry[float32]{
{Type: vectorindex.CDC_INSERT, PKey: 1, Vec: []float32{1, 2, 3}},
{Type: vectorindex.CDC_INSERT, PKey: 1, Vec: []float32{3, 2, 1}},
}}
err := syncer.insertAllInParallel(nil, 64, []int{-1, -1}, cdc)
physicalLen, _ := model.Index.Len()Actual result
returned error=<nil> logical Len=2 physical Len=1
usearch rejects the duplicate physical key, but the HNSW CDC layer reports success and retains the extra logical reservation. A nil/invalid vector produces the same false-success behavior with logical Len=1, physical Len=0.
Expected result
- Propagate every
AddWithoutIncrerror througherr_chanand fail the CDC iteration. - Roll back the pre-reserved
Lenvalue when the physical add fails. - Do not save the model or advance CDC state after any row fails.
- Make duplicate/replayed CDC entries idempotent or fail explicitly without corrupting model counters.
Distinction from existing issues
- [Bug] HNSW index omits rows inserted after index creation #25610 concerns observable asynchronous lag after ordinary HNSW DML.
- [Bug]: Prepared FULLTEXT and vector statements keep stale hidden-index plans after index DDL #25625 concerns stale prepared plans after index DDL.
This issue is a deterministic error-swallowing and internal-count divergence in the parallel CDC writer, not normal convergence delay or prepared-plan invalidation.
Activity
fix(vectorindex): propagate Add error and roll back Len in parallel C…
Ariznawlll commentedon Jul 15, 2026
最新 main 详细验证
origin/main@f1c0a92d882dbdad469ffd2c96f607796207c797。本 issue 对应测试过程
1000的 CDC INSERT。Update必须显式返回错误,不能把重复键吞掉并报告成功。Len与物理大小一致。结果
TestSyncInsertDuplicateKeyFailsCleanly:PASS 3/3。ok github.com/matrixorigin/matrixone/pkg/vectorindex/hnsw 0.534s。fix(vectorindex): propagate Add error and roll back Len in parallel C…
fix(vectorindex): propagate Add error and roll back Len in parallel C…
fix(vectorindex): propagate Add error and roll back Len in parallel C…