Skip to content

feat(cagra,ivfpq): ignore and record rows the index cannot store (#31583) - #32036

Merged
mergify[bot] merged 6 commits into
matrixorigin:mainfrom
cpegeric:issue_31583_ivfpq_cagra
Nov 2, 2026
Merged

mergify[bot] merged 6 commits into
matrixorigin:mainfrom
cpegeric:issue_31583_ivfpq_cagra

Conversation

@cpegeric

@cpegeric cpegeric commented Nov 2, 2026

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 #31583 (CAGRA and IVF-PQ; IVF-Flat and FULLTEXT2 remain)

What this PR does / why we need it:

CAGRA and IVF-PQ now follow the ignored-rows contract HNSW got in #31596 (docs/design/20261028-index-ignored-rows.md): MAX_BAD_RECORDS, the hidden ignored table, SHOW INDEX IGNORED / SHOW INDEX STATUS, a permanent stop past the limit, REINDEX restarting it, a restore following the limit.

Before this change one row such an index cannot store broke it. Measured on a GPU with QUANTIZATION 'float16' and an element of 100000: a CAGRA build failed with RAFT failure ... Could not generate an intermediate CAGRA graph; an IVF-PQ build succeeded and then returned no row for any query while SHOW INDEX STATUS said running. A row arriving by incremental sync was searched from the brute-force tail and then broke every later rebuild from the source (REINDEX, restore, ALTER COPY, the scheduled reindex).

  • What cannot be stored (decided by @cpegeric): with float16 storage of a vecf32 column, an element beyond the float16 range (HNSW's rule); and, for both indexes, a vector whose squared L2 norm exceeds float32 max / 4, since both compute L2 distances in float32 (an element of 1e20 also failed a CAGRA build). One check, cuvs.CheckStorable, serves the CDC writer, both builds and the search.
  • Builds. A build plans its sub-indexes from the count of non-NULL rows, and cuVS builds none below its minimum (CAGRA intermediate_graph_degree, IVF-PQ lists), so a left-out row could shorten the last sub-index, or a shard of a sharded build, below it. The build holds the first minimum rows of each sub-index (devices × the minimum rounded up to 32 when sharded) until they arrive, and rows still held at the end go to the brute-force tail, where they are searched with their INCLUDE values (decided by @cpegeric). The held rows are charged to the host memory the build plans with.
  • Search vectors a rule rejects are rejected with the same error; before, the search returned no row.
  • HNSW and both cuVS builds share one tracker of left-out rows (ignoredBuild). An index created before this change keeps building and syncing as before.

The design doc gains a CAGRA and IVF-PQ section and claims I11–I14, each with unit tests and a section of test/distributed/gpu_cases/vector/vector_cuvs_ignored.sql, which runs every section for both indexes.

Validation

  • GPU black box: gpu_cases/vector/vector_cuvs_ignored.sql 173/173; gpu_cases/vector 1509 statements, all passing (vector_cagra.result / vector_ivfpq.result list the new ignored hidden table).
  • Controls: with the holding disabled, the short-sub-index case fails both builds (number of vectors per shard (15) must be larger than build_params.intermediate_graph_degree (16); IVF-PQ build requires at least n_lists vectors (got 2 vectors, n_lists=4)); without the sharded rule the sharded case fails both (CAGRA build requires at least 2 vectors (got 0); ... (got 0 vectors, n_lists=4)).
  • Unit: pkg/iscp, pkg/vectorindex, pkg/vectorindex/cuvs, pkg/vectorindex/hnsw/..., pkg/vectorindex/cagra/..., pkg/vectorindex/ivfpq/..., pkg/sql/colexec/table_function pass with and without the gpu tag; pkg/sql/plan, pkg/sql/compile pass. golangci-lint v2.14.0: 0 issues with and without the gpu tag.
Environment and run summaries

GPU: NVIDIA GeForce RTX 5070 Laptop GPU, driver 610.88, 8151 MiB; MO_CL_CUDA=1 build of 1de7d50, single-process launch, fresh data directory.

[vector_cuvs_ignored.sql] COST : 139.744s, TOTAL :173, SUCCESS :173, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%
[vector_cagra_sharded.sql] COST : 2.012s, TOTAL :30, SUCCESS :30, FAILED :0
[vector_ivfpq_filter.sql] COST : 1.272s, TOTAL :20, SUCCESS :20, FAILED :0
gpu_cases/vector: TOTAL :1509 (the one failure in that run was this suite's 60 s wait after the whole directory; the waits are now 120 s and the suite passes)
ok   github.com/matrixorigin/matrixone/pkg/iscp 15.680s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex 1.923s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cuvs 0.623s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/hnsw 342.238s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/hnsw/plugin/compile 1.192s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/hnsw/plugin/idxcron 1.481s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/hnsw/plugin/plan 1.784s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/hnsw/plugin/runtime 1.488s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/hnsw/plugin/search 2.451s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cagra 30.961s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cagra/plugin 1.703s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cagra/plugin/compile 1.614s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cagra/plugin/idxcron 1.602s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cagra/plugin/plan 1.689s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cagra/plugin/runtime 1.432s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cagra/plugin/search 2.174s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/ivfpq 11.703s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/ivfpq/plugin 1.685s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/ivfpq/plugin/compile 2.059s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/ivfpq/plugin/idxcron 1.590s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/ivfpq/plugin/plan 2.096s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/ivfpq/plugin/runtime 1.645s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/ivfpq/plugin/search 2.524s
ok   github.com/matrixorigin/matrixone/pkg/sql/colexec/table_function 5.447s
ok   github.com/matrixorigin/matrixone/pkg/sql/colexec/table_function 5.953s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cagra 11.972s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cagra/plugin 1.094s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cagra/plugin/compile 0.971s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cagra/plugin/idxcron 0.813s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cagra/plugin/plan 1.076s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cagra/plugin/runtime 0.897s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/cagra/plugin/search 1.477s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/ivfpq 7.011s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/ivfpq/plugin 1.340s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/ivfpq/plugin/compile 0.877s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/ivfpq/plugin/idxcron 0.942s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/ivfpq/plugin/plan 1.240s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/ivfpq/plugin/runtime 1.036s
ok   github.com/matrixorigin/matrixone/pkg/vectorindex/ivfpq/plugin/search 1.498s
ok   github.com/matrixorigin/matrixone/pkg/iscp 8.619s

🤖 Generated with Claude Code

cpegeric and others added 2 commits November 2, 2026 14:05
…rixorigin#31583)

CAGRA and IVF-PQ now follow the ignored-rows contract HNSW got in matrixorigin#31596
(docs/design/20261028-index-ignored-rows.md): MAX_BAD_RECORDS, the
ignored hidden table, SHOW INDEX IGNORED / STATUS, permanent stop past
the limit, REINDEX restart, restore following the limit.

Before this change one such row broke the index: with QUANTIZATION
'float16' an element of 100000 failed a CAGRA build (RAFT failure) and
left IVF-PQ answering no row for any query, and a row arriving by CDC
broke every later rebuild from the source.

- A row is unstorable when a vecf32 element overflows float16 under
  float16 storage, or its squared L2 norm exceeds float32 max / 4 (both
  indexes compute L2 in float32). One check, cuvs.CheckStorable, used by
  the CDC writer and by cagra_create / ivfpq_create.
- The builds plan sub-indexes from an up-front count and cuVS builds no
  sub-index below its minimum (CAGRA intermediate_graph_degree, IVF-PQ
  lists). The first minimum rows of each sub-index are held until they
  all arrive; rows still held at the end go to the brute-force tail.
  With the holding disabled the same data fails both builds.
- An index without an ignored table keeps its previous behaviour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er (matrixorigin#31583)

Self-review of 22e9dfe:

- A sharded build is one sub-index split (rows / devices) &^ 31 per shard,
  so left-out rows could leave a shard below the cuVS minimum (both builds
  failed on 63 stored of 66 planned rows over 2 devices). The build holds
  devices x the minimum rounded up to 32 (minSubIndexRows), and charges the
  held rows to the host memory it plans with (reserveHeldRows).
- A search vector either rule rejects is rejected (cuvs.CheckQuery in both
  newSearch); before, CAGRA and IVF-PQ returned no row.
- HNSW and both cuVS builds share one tracker of left-out rows
  (ignoredBuild); the cuVS builds route rows through one helper and keep the
  same cursor convention. Float16Overflow lives in pkg/vectorindex.
- The ignored table is cleared with DELETE ... WHERE TRUE, as HNSW's; the CDC
  writer matches the quantization exactly, as the builds do; held vectors are
  released after each flush.
- vector_cuvs_ignored.sql: sharded and search-vector sections; waits 120 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added kind/bug Something isn't working kind/feature kind/documentation Improvements or additions to documentation kind/test-ci labels Nov 2, 2026
@XuPeng-SH

XuPeng-SH commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 19549c32f0e5f76435675efdb152efa54bee5500

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 19549c32f0e5f76435675efdb152efa54bee5500

Assessment: approve

Reviewed the complete delta, discussion and affected consumers. Ignored-row limits, transactional updates, short-subindex handling and legacy behavior are coherent. No actionable defects remain.

Model: gpt-6-astra / xhigh

Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2

Validation:

  • Isolation preflight and native builds passed with recorded source provenance.

  • Nine cuVS/plugin package suites passed; receipt checks/1793639016128940453-3.json and cpu-plugin-tests.log.

  • Focused ISCP, build-helper and HNSW tests passed in three packages; receipt checks/1793639088155426598-3.json and cpu-lifecycle-tests.log.

  • Reused the author's GPU suite report: 173/173 statements passed at 1de7d50. All 39 changed files match that revision.

  • Receipt/log reconciliation, clean frozen HEAD and complete discussion coverage verified; records saved in validation-evidence.json and discussion-assessment.json.

Limitations:

  • GPU execution was not repeated locally; supplied GPU evidence lacks raw logs and covers a single-process deployment.

  • The reported broader 1509-statement GPU run included a wait timeout and is not counted as a complete pass.

@mergify

mergify Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue · pull request branch update failed

14 min in the queue, 10 min of it CI.

So far

  • ✅ Entered the queue Mon 2 Nov, 20:00 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 20:15 · aacb9ae

Reason

The pull request can't be updated

Mergify successfully updated the branch with its base branch, but timed out after 10 minutes waiting for GitHub to update the pull request head. GitHub still reports the previous head aacb9ae, so no CI has run on the updated branch.

To get back in the queue

  • Update or rebase the branch yourself: the pull request is queued again once its queue conditions match.
  • If the failure is a flake, tick the box below to queue it again as it is.

Requeued — the merge queue status continues in this comment ↓.

3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = CI Required
    • check-neutral = CI Required
    • check-skipped = CI Required

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added dequeued and removed queued labels Nov 2, 2026
@mergify

mergify Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue · pull request branch update failed

1 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Mon 2 Nov, 20:22 · rule main · triggered by @cpegeric with the merge queue checkbox
  • 🚫 Left the queue 20:23 · aacb9ae

Reason

The pull request can't be updated

The head SHA of this pull request changed unexpectedly, which prevents Mergify from safely performing a rebase.
To proceed, please rebase or requeue the pull request manually.
GitHub response: expected head sha didn’t match current head ref.

To get back in the queue

  • Update or rebase the branch yourself: the pull request is queued again once its queue conditions match.
  • If the failure is a flake, tick the box below to queue it again as it is.

Requeued — the merge queue status continues in this comment ↓.

Times in UTC · dashboard · how the merge queue works

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify

mergify Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

✅ Merged into main as 07c0607 at 21:25 UTC

Less than a minute in the queue, with no time running CI.

So far

  • ✅ Entered the queue Mon 2 Nov, 21:25 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged 21:25 · 07c0607 · squash
3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = CI Required
    • check-neutral = CI Required
    • check-skipped = CI Required

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot removed the queued label Nov 2, 2026
mergify Bot pushed a commit that referenced this pull request Nov 9, 2026
#31583) (#32096)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

issue #31583 (IVF-Flat and FULLTEXT2; completes the issue after #32036)

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

IVF-Flat and FULLTEXT2 now follow the ignored-rows contract HNSW, CAGRA and IVF-PQ follow (`docs/design/20261028-index-ignored-rows.md`): `MAX_BAD_RECORDS`, the hidden `ignored` table, `SHOW INDEX IGNORED` / `SHOW INDEX STATUS`, a permanent stop past the limit, REINDEX restarting it. Before this change one row such an index cannot store failed the build or the statement, and on an asynchronous index stopped every later sync.

**IVF-Flat** (decided by @cpegeric: the check and the recording live in `product_l2`; the cast stays in SQL)
- **What cannot be stored**: an element beyond the range of the `QUANTIZATION` type, an int8/uint8 code that is not finite, a squared L2 norm beyond max/4 of the distance type, a NaN or infinite element. One check, `ivfflat.Storage`, serves `product_l2`, the k-means samples and the search.
- `product_l2` leaves out and records such rows in every path that assigns rows to centroids: the build, the async build and its sync, REINDEX, restore, and DML on a synchronous index. The index reaches it as JSON on `CENTROIDX(optype, params, config)` (the catalog row does not exist yet during CREATE INDEX); only internal SQL may pass that form.
- DML on a synchronous index follows `MAX_BAD_RECORDS` (decided by @cpegeric): within it the row is recorded, past it the statement fails. The count is the one the statement's transaction sees (decided by @cpegeric, 2026-11-04): concurrent transactions may together commit past the limit, by at most the rows each could add; every later statement that records a row then fails until rows are fixed or REINDEX runs. A lock serializing them was rejected (it serializes bad-row DML and adds a lock the DML path does not take). Deleting a row, or updating it to a value the index stores, removes its record, in DML and in the sync.
- k-means skips the samples the index cannot store; fewer good samples than `lists` seed one NULL centroid, as a table with fewer rows does. A query vector the index cannot store is rejected.

**FULLTEXT2** (new reason codes, decided by @cpegeric)
- Text the `json` parser cannot parse (20351) and a DATALINK that cannot be read (20352: missing stage or file, unsupported url, text that cannot be extracted) are recorded with their message in the new reason column, in the build and the sync. Timeouts, lost connections and unreachable endpoints are retried; a local source for an asynchronous index stays an error, since it is a setting of the table.

Keys read as users see them: a composite key as `(a, b)`, an ENUM key as its member, in `SHOW INDEX IGNORED` and in the stop messages. An index created before this change has no ignored table and keeps its SQL; its bad rows now carry the new codes.

The design doc gains IVF-Flat and FULLTEXT2 sections and claims I15–I20, each with unit tests and a section of `pessimistic_transaction/vector/vector_ivfflat_ignored.sql` or `pessimistic_transaction/fulltext2/fulltext2_ignored.sql`.

Known limit: an ENUM part of a composite key shows its number in the stop message (`SHOW INDEX IGNORED` shows the member).

### Validation

- BVT (CPU, fresh instance, `-g -n`): `vector_ivfflat_ignored.sql` 71/71, `fulltext2_ignored.sql` 31/31; `vector` 3505/3507 (2 ignored), `pessimistic_transaction/vector` 1156/1198 (42 ignored), `fulltext2` 1374/1374, `pessimistic_transaction/fulltext2` passing. Eight existing `.result` files list the new hidden `ignored` table.
- DATALINK from a remote stage (not reachable from BVT) checked live against a MinIO stage, build and sync: a missing file is recorded with `stage://ms/missing.txt: file ftdocs/missing.txt is not found`.
- Unit: every touched package passes, including `pkg/sql/plan`, `pkg/sql/compile`, `pkg/iscp`, `pkg/sql/colexec/productl2`, `pkg/sql/colexec/table_function`, `pkg/vectorindex/...`, `pkg/fulltext2/...`; the new tests pass `-race -count=30`. golangci-lint: 0 issues.

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



Approved-by: iamlinjunhong <[email protected]>
Approved-by: XuPeng-SH <[email protected]>
Approved-by: aunjgr <[email protected]>
Approved-by: fengttt <[email protected]>

This branch was previously deployed

1 inactive deployment
ci — 6cb2cb89 Deployed Nov 2, 2026 by cpegeric
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/documentation Improvements or additions to documentation kind/feature kind/test-ci size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants