Skip to content

[devops] Verify BVT result in CI/CD - #777

Merged
yingfeng merged 1 commit into
matrixorigin:mainfrom
lignay:devops-760
Sep 18, 2021
Merged

yingfeng merged 1 commit into
matrixorigin:mainfrom
lignay:devops-760

Conversation

@lignay

@lignay lignay commented Sep 17, 2021

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #760

What this PR does / why we need it:

Not Available

Special notes for your reviewer:

Not Available

Additional documentation (e.g. design docs, usage docs, etc.):

Not Available

@lignay lignay added the devops label Sep 17, 2021
@lignay lignay added this to the v0.1.0 milestone Sep 17, 2021
@lignay lignay self-assigned this Sep 17, 2021
@yingfeng
yingfeng merged commit 9a82d9e into matrixorigin:main Sep 18, 2021
fengttt pushed a commit to fengttt/matrixone that referenced this pull request May 7, 2026
cpegeric added a commit to cpegeric/matrixone that referenced this pull request Oct 22, 2026
 and matrixorigin#30660 fixes

Replace thirdparties/usearch-2.25.3.tar.gz with usearch-2.26.5.tar.gz, built
(git archive, same layout) from cpegeric/usearch matrixone_20261022 =
upstream v2.26.5 + concurrent_add (matrixorigin#735 concurrent-add reachability) +
fix_delete_20261022 (remove()+add() slot-reuse relink, matrixorigin#30660).

v2.26.5 also brings upstream matrixorigin#769 (slot_lookup_ tombstone rehash; v2.25.3 could
spin in remove() under heavy churn). Upstream matrixorigin#777 makes Reserve(n) allocate
exactly n members instead of rounding up to the key table's power-of-two size.
MO always reserves its real capacity (MaxCapacity on build, IndexCapacity on
sync load), so no production path relied on that slack; TestModel loaded with
IndexCapacity 0 and is given a real capacity.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XuPeng-SH pushed a commit that referenced this pull request Oct 26, 2026
…; upgrade usearch to 2.26.5 (#30823)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes #30660

## What this PR does / why we need it:

After an HNSW index is built, a DELETE followed by an INSERT can make
other live rows unreachable through the index. In the issue's repro
(1000 rows on a line, delete id 100, insert a far row) the index returns
901 rows, with ids 1–99 missing. This persists after the new model is
published and after a restart; only `FORCE_SYNC` (a full rebuild)
restores it.

**Root cause (usearch, not ISCP).** The CDC path is correct:
`HnswSync.sequentialUpdate` applies `Remove(100)` then `Add(2001)`. The
same two calls on bare usearch, with no SQL or ISCP involved, give the
same 901 result. In usearch, `remove()` only tombstones the node and
queues its slot. The next `add()` reuses that slot, and
`index_gt::update()` rewrites the node in place at the new vector's
position, clearing its neighbour lists without repairing anything
(upstream leaves a TODO there). Whatever was reachable only through the
removed node is cut off. Points on a line make the removed node the only
bridge, so the loss is a whole range; on realistic data the same
mechanism causes partial recall loss. Full trace:
#30660 (comment)

**Fix.** The vendored usearch is upgraded from `usearch-2.25.3.tar.gz`
to **`usearch-2.26.5.tar.gz`**, built with `git archive` (same layout as
before) from [cpegeric/usearch
`matrixone_20261022`](https://github.com/cpegeric/usearch/tree/matrixone_20261022).
That branch is upstream v2.26.5 plus the existing `concurrent_add`
(#735) fix plus
[`fix_delete_20261022`](https://github.com/cpegeric/usearch/tree/fix_delete_20261022),
which cherry-picks cleanly onto upstream for its own upstream PR.
Upstream v2.26.5 still has this bug: the new line-reachability test
fails on unmodified v2.26.5.

Upgrading to 2.26.5 also brings upstream #769, which rehashes tombstones
in the key-lookup table. In v2.25.3, `remove()` could spin at 100% CPU
under heavy delete/insert churn.

Upstream #777 changes `Reserve(n)`: it now allocates exactly `n` slots,
where it used to round up to the key-lookup table's power-of-two size
(about +37%, e.g. `Reserve(1000)` gave 1365). MO always reserves its
real capacity: `MaxCapacity` on build, which the build path never
exceeds, and `IndexCapacity` on a sync load, which defaults to
1,000,000. Updates reuse the slot their own `Remove` freed. So no
production path depended on that extra room. Only `TestModel`, which
loaded with `IndexCapacity` 0, relied on it, and it now sets a real
capacity.

- **Repair:** before a removed node's slot is reused, `update()` relinks
the node's old neighbours on every level. Each neighbour drops its link
to the reused slot and re-picks its neighbours, using the existing
heuristic, from its own list plus the removed node's other neighbours.
Nodes are locked one at a time, as in `form_reverse_links_`. The
snapshot uses a reused per-thread buffer, and out-of-memory is reported
as an error.
- **Concurrency:** `index_dense_gt::add_()` serializes adds that reuse a
slot, because the in-place rewrite is not safe against concurrent
rewrites of neighbouring nodes. Fresh adds and searches stay concurrent.
MO's CDC update path is already sequential.

No memory growth: removed slots are still reused. Apart from the usearch
upgrade, the only MO change is the `TestModel` capacity in its test
setup.

## Tests

Validated on 2.26.5:
- **Unit tests:** all 43 `pkg/vectorindex/...` packages pass.
- **BVT:** `vector_hnsw_delete_insert` passes 44/44.
`pessimistic_transaction/vector` has 0 failures, `vector` passes
3301/3301, and `branch_hnsw_async_refresh`, `fulltext2_hnsw_clone`,
`index_cache_size_bounds`, `clone` and `branch_multi_index_restore_init`
have 0 failures.

The results below were first measured on the 2.25.3-based tarball:


- **Go:** new `TestRemoveAddKeepsGraphReachable`
(`pkg/vectorindex/hnsw`) goes through `HnswModel`: remove 100, remove
500, and save→load then remove, each followed by a far add, asserting
every live key is returned. **All three fail on the previous tarball**
(901 / 501 rows) and pass with this one. All `pkg/vectorindex/hnsw/...`
and `pkg/vectorindex/usearchex` packages pass.
- **usearch C++** (`cpp/test.cpp` in the fork): the remove + far add on
a line test for `slot32_t` and `uint40_t` fails without the fix.
Remove/add churn rounds, single- and multi-threaded, assert every live
key finds itself in an exhaustive search. On the merged branch, these
and the #735 concurrent-add reachability test pass 10/10 runs with
internal assertions enabled.
- **BVT:** new
`pessimistic_transaction/vector/vector_hnsw_delete_insert`. It mirrors
the issue (single-threaded build + `FORCE_SYNC`, DELETE id 100 + far
INSERT, then DELETE id 500 + another far INSERT) and waits for the
published model's checksum to change before querying. With this tarball:
44/44, and the index returns all 1000 rows, every id below the deleted
one, and the true nearest row. **On the previous tarball the same case
returns 901 / 502 rows, none of the ids below the deleted one, and id
101 as the nearest row to `[1,1,2]`.** The
`pessimistic_transaction/vector` (703 pass, 0 failed) and `vector`
suites stay green. The one suite-only failure, in IVF
`vector_filtered_search_knobs`, passes 51/51 when run alone and doesn't
involve HNSW.
- **Live SQL**, using the issue's exact repro after waiting for the
async model to be published: the index returns **1000/1000** for query
vectors `[1,1,2]`, `[777.2,1,2]` and `[1000,1,2]`, and 1000/1000 in the
delete-id-500 variant (was 501).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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