Skip to content

[4.2] Fix vector index cache recovery lifecycle - #32404

Merged
XuPeng-SH merged 6 commits into
matrixorigin:4.2-devfrom
XuPeng-SH:fix/32403-vector-index-cache-lifecycle
Nov 9, 2026
Merged

XuPeng-SH merged 6 commits into
matrixorigin:4.2-devfrom
XuPeng-SH:fix/32403-vector-index-cache-lifecycle

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement

Which issue(s) this PR fixes:

Fixes #32403

What this PR does / why we need it:

Repeated FULLTEXT2 generation invalidations could make a search reload indefinitely; a load panic could strand other callers; and concurrent cache shutdowns could block. Search and SearchInto now share a bounded, cancellation-aware retry protocol, publish load outcomes to waiters, coordinate failed-entry cleanup, and make cache shutdown idempotent. An exhausted eviction retry returns a directly serializable error asking the caller to retry the query.

When a TTL or generation-change invalidation callback panics, an algorithm that supports local repair keeps the affected key reserved while registered cleanup waits for old readers and loads, repairs the generation, and removes the exact entry. The callback failure is published to waiters on that entry; cancellation or an already observed shutdown can take precedence. At most eight such recoveries are active per cache. If recovery cannot be admitted, or its outcome is unsafe, the cache stops admission and shutdown takes ownership of any remaining claimed entries after registered cleanup finishes. This bounds recovery work without adding a queue to the normal search path. Shutdown runs lifecycle hooks after the final drain.

FULLTEXT2 releases partially loaded segments, mappings, files and SQL results on failure. HNSW, GPU CAGRA and IVF-PQ clean up partially loaded models, temporary files, native index objects and overflow buffers through their respective owners. Their common SQL chunk reader cancels, drains and joins the producer on errors and panics. IVF-FLAT and the ProductL2 operator retain ownership of newly created brute-force indexes until loading succeeds; IVF-FLAT also owns the loaded centroid through subsequent metadata reads. A failed load releases the partial index without masking the original failure. GPU brute-force startup errors are returned and the partially created native object is cleaned up.

Compatibility and limits

  • VectorIndexSearch.Cond is removed. External Go users directly constructing or manipulating cache entries must use the cache-owned Search/SearchInto and Remove lifecycle. There is no persisted or wire-format change.
  • HnswSearch.Destroy calls each model's Destroy, including deletion of its owned Path; callers placing models in Indexes must follow the existing model file-ownership contract.
  • Saturating the recovery limit closes the affected cache to preserve safe ownership. Synchronous algorithm load, search and destruction cannot be forcibly interrupted, so a stuck operation can still delay shutdown.
  • FULLTEXT2 recovery fences the old cache entry, not independently constructed caches or direct loads sharing process pools. Reuse retains its existing checksum and transaction-snapshot assumptions; this is not a process-wide atomic commit fence.
  • FULLTEXT2's existing child streaming cancellation is not propagated to the cache's process context.

Validation

  • With Go 1.26.4, GOAMD64=v3 and GOEXPERIMENT=simd, production go build and go vet passed for the affected cache, FULLTEXT2, HNSW, IVF-FLAT, brute-force, SQL executor, ProductL2 and consumer packages. GPU-tagged brute-force, IVF-FLAT, CAGRA, IVF-PQ and ProductL2 also passed Go build and vet. Repository-configured incremental CPU and GPU lint passed.
  • The cache, IVF-FLAT and ProductL2 test binaries, including recovery-limit, shutdown-handoff and partial-load ownership scenarios, compiled with the repository CGo setup. At the user's request no local unit or race tests were executed for this revision.
  • GPU native linking and execution were not validated; no usable NVIDIA driver or cuVS runtime was available locally.
  • The recovery counter is touched only after an invalidation callback panics; normal search does not use it. Shutdown performs an additional map sweep to drain claims that could not start recovery.

@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 →

@XuPeng-SH

XuPeng-SH commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: e1e9e5a9d4a7c309c618cc0d00d5131fe25e5c18

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

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: e1e9e5a9d4a7c309c618cc0d00d5131fe25e5c18

Assessment: approve

Both search APIs now share bounded recovery. Separate lifecycle signals support canceled waiters and safe algorithm reuse, while FULLTEXT2 cleanup follows existing resource owners. No actionable in-scope defect remains.

Model: gpt-6.1-sol / max

Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0

Validation:

  • Reviewed all 12 changed paths, both discussion entries, issue #32403 and affected owners/consumers; index-plugin guards closed.

  • Isolation preflight passed. Four exact-source cache protocol probes passed 100 race repetitions each; a churn/control probe passed five repetitions. External dependencies were stubbed.

  • Source integrity, whitespace and formatting checks passed; receipt 1794203505874648218-2. All eight receipts and logs are reconciled in validation-ledger.json.

Limitations:

  • Full product/native/SQL/GPU tests and author-reported package/stress/benchmark results were not independently rerun.

  • Frozen CI has six failed checks and one in-progress BVT. Failure logs were not supplied; no CI pass is inferred.

  • Synchronous Load/Destroy cannot be forcibly canceled, and the existing FULLTEXT2 child-cancellation limitation remains.

@XuPeng-SH
XuPeng-SH force-pushed the fix/32403-vector-index-cache-lifecycle branch from e1e9e5a to 1a63f66 Compare November 9, 2026 06:47
@matrix-meow matrix-meow added size/XXL Denotes a PR that changes 2000+ lines and removed size/XL Denotes a PR that changes [1000, 1999] lines labels Nov 9, 2026
@XuPeng-SH

XuPeng-SH commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: 1a63f662787aac681d89301cc453cc3370eab524

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

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: 1a63f662787aac681d89301cc453cc3370eab524

Assessment: request_changes

The bounded recovery and resource cleanup coherently reuse existing owners. New invalidation fixtures skip their intended callbacks and fail the cache suite.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

  • P2 pkg/vectorindex/cache/invalidation_failure_test.go:155: Freshly loaded entries are removed with reason ttl_expired while their TTL remains valid. The same trigger appears at lines 101 and 206.
    Impact: The TTL guard correctly skips eviction, causing TestInvalidationPanicUnblocksLoadingWaiter and TestShutdownUnblocksRemovedWaiterAndJoinsEviction to fail before exercising their intended behavior. TestInvalidationPanicClosesCache also misses its remove branch. Expire the fixture entries first or use an appropriate forced invalidation reason; preserve the TTL renewal guard.
    Evidence: Both normal and race owner runs reproduce the failures. cache.go:373-383 rechecks TTL, enabled by cache.go:687 for ttl_expired. A test-only overlay changing the three triggers to generation_changed passes all three tests normally, under race, and for 100 race repetitions each. Logs, overlay hashes and receipts are retained in validation-ledger.json; production source is unchanged.

Validation:

  • Reviewed all 20 changed paths, relevant owners/consumers, issue #32403 and all four discussion entries; saved discussion dispositions and ownership/design analysis.

  • Isolation preflight passed. Native prerequisites matched 173 current inputs and 44 output hashes. Checks used Go 1.26.6, SIMD/v3 and assigned caches/executors.

  • FULLTEXT2 passed 252 top-level tests normally and under race. Cache passed 48 and failed two in each mode. HNSW passed 63 roots per mode across owner and recovery runs. Four compiler/plugin consumer tests and five-owner vet passed.

  • Adaptive race stress passed 45 candidate tests for 4,449 repetitions. Three diagnostic fixture controls passed another 300 repetitions; these do not make the maintained cache suite green.

  • Final audit reconciled 64 checks with command/source/exit receipts and retained logs. Formatting, patch integrity and unchanged-source checks passed.

Limitations:

  • Initial non-short HNSW runs exhausted the package budget. Unchanged tests were recovered using writable working directories and restored resource paths; short owner and SIFT guard checks ran in separate processes.

  • No SQL/BVT, GPU or independent end-to-end performance run was performed. The frozen CI snapshot remains unfinished.

@XuPeng-SH

XuPeng-SH commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: c0f0e5ccbea3b254915e494b10c9a23bd0cfcf3a

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

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: c0f0e5ccbea3b254915e494b10c9a23bd0cfcf3a

Assessment: approve

Bounded recovery reuses cache/pool ownership and shared stream cleanup with justified complexity. Prior TTL-fixture findings are resolved; no actionable defects remain.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Source and native provenance verified; receipts and retained logs reconciled in attempt-2/check-reconciliation.json.

  • Seven CPU owning packages and two consumer selections passed; four owning packages also passed -race without skips.

  • 38 exact tests passed 100 race repetitions each, including all three fixtures identified by the prior review.

  • GPU-tag archive build and vet passed for CAGRA, IVF-PQ and brute force.

Limitations:

  • GPU native linking/device execution and distributed SQL integration were not exercised; the supplied CI snapshot remains unfinished.

  • Existing synchronous-call cancellation and FULLTEXT2 child-stream cancellation limits remain accepted.

@XuPeng-SH

XuPeng-SH commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: 23c3cd77f025171091c36df7bef2f262a33e7f5e

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

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: 23c3cd77f025171091c36df7bef2f262a33e7f5e

Assessment: approve

Bounded recovery and partial-load cleanup reuse existing cache and algorithm owners with justified complexity. The prior TTL-fixture defects are resolved; no actionable in-scope issues remain.

Model: gpt-6.1-sol / max

Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0

Validation:

  • Reviewed the complete 37-file delta, issue #32403, all nine discussion entries and affected lifecycle owners/consumers.

  • Reconciled and reused execution from review 5827659105 after verifying identical patch and unchanged relevant inputs: seven CPU owners, two consumer selections, four race owners, and 38 exact tests passing 100 race repetitions each.

  • Verified 60 retained receipts/logs, 101 native inputs and 62 native outputs. GPU-tag archive build/vet coverage is retained separately; one recovered setup timeout is excluded from pass claims.

  • Current isolation preflight passed; source/evidence audits and automatic-stamp diagnostics are reconciled in reused-validation.json and validation-ledger.json.

Limitations:

  • Product checks were reused through source and semantic matching, rather than rerun on this head. HNSW owner runs used short mode.

  • GPU native linking/device execution and distributed SQL were not exercised; supplied CI does not establish full product validation.

  • Synchronous algorithm operations can delay shutdown; the existing FULLTEXT2 child-stream cancellation limit remains accepted.

@XuPeng-SH
XuPeng-SH merged commit c660611 into matrixorigin:4.2-dev Nov 9, 2026
@XuPeng-SH
XuPeng-SH deleted the fix/32403-vector-index-cache-lifecycle branch November 9, 2026 23:17
XuPeng-SH added a commit that referenced this pull request Nov 10, 2026
## 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 the failure in [coverage job
129509179850](https://github.com/matrixorigin/matrixone/actions/runs/42719261201/job/129509179850?pr=32256).

Related open reports: #32327, #32258. The relevant changes from #32354
and #32404 are already on 4.2-dev; their exact historical failure causes
remain unproven, so this PR does not claim to close them.

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

The spill ownership test submits two batches to concurrent pipeline
workers after reset. Their observations can arrive in either order, so
requiring the first value to be 19 flakes when the second block's value,
8211, arrives first. After `Sync` drains the jobs, check that both
values were observed without assuming their order. Keep the existing
ownership, panic, reset and memory-pool checks.

### Validation

- Go 1.26.4, Linux/amd64, CGo, `matrixone_test`: focused test passed 100
runs in coverage mode and 100 runs under `-race`; owning package passed
in coverage mode.
- Incremental formatting, `go vet`, and repository-configured
golangci-lint for `pkg/objectio/ioutil` passed.
- Current 4.2-dev: #32327's named cross-CN prepared-query scenario
passed under `-race`; #32258's original
`TestSQLFileAccessTenantStageCDC` passed once in package coverage mode,
and the existing cache/FULLTEXT2 lifecycle regression tests passed under
`-race`. These focused passes do not reproduce the full original CI
workload or prove the historical root causes.
- Test-only assertion change; no production performance impact.
aptend pushed a commit to aptend/matrixone that referenced this pull request Nov 22, 2026
## 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 the failure in [coverage job
129509179850](https://github.com/matrixorigin/matrixone/actions/runs/42719261201/job/129509179850?pr=32256).

Related open reports: matrixorigin#32327, matrixorigin#32258. The relevant changes from matrixorigin#32354
and matrixorigin#32404 are already on 4.2-dev; their exact historical failure causes
remain unproven, so this PR does not claim to close them.

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

The spill ownership test submits two batches to concurrent pipeline
workers after reset. Their observations can arrive in either order, so
requiring the first value to be 19 flakes when the second block's value,
8211, arrives first. After `Sync` drains the jobs, check that both
values were observed without assuming their order. Keep the existing
ownership, panic, reset and memory-pool checks.

### Validation

- Go 1.26.4, Linux/amd64, CGo, `matrixone_test`: focused test passed 100
runs in coverage mode and 100 runs under `-race`; owning package passed
in coverage mode.
- Incremental formatting, `go vet`, and repository-configured
golangci-lint for `pkg/objectio/ioutil` passed.
- Current 4.2-dev: matrixorigin#32327's named cross-CN prepared-query scenario
passed under `-race`; matrixorigin#32258's original
`TestSQLFileAccessTenantStageCDC` passed once in package coverage mode,
and the existing cache/FULLTEXT2 lifecycle regression tests passed under
`-race`. These focused passes do not reproduce the full original CI
workload or prove the historical root causes.
- Test-only assertion change; no production performance impact.

(cherry picked from commit bf15b1c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/api-change kind/bug Something isn't working kind/enhancement size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants