Skip to content

fix(#11938): a sparse vector index scans its bucket for missing vectors once per load, not on every build - #11977

Open
shaunpatterson wants to merge 1 commit into
ArcadeData:mainfrom
shaunpatterson:fix/11938-sparse-vector-doc-scan-once
Open

shaunpatterson wants to merge 1 commit into
ArcadeData:mainfrom
shaunpatterson:fix/11938-sparse-vector-doc-scan-once

Conversation

@shaunpatterson

Copy link
Copy Markdown
Contributor

Fixes #11938.

Problem

An LSM_VECTOR index on a property that only some records carry always parses fewer vectors from its pages than its bucket has records. Every graph build therefore went through the #3722 cross-check: it logged a WARNING, scanned the whole bucket, and recovered nothing. That happened on every search that rebuilds a small graph after a write, on every background rebuild, and on every node of a cluster. With 800 vectors among 1,000,800 records, the scan took 220-360 ms per build, and a search after a write went from 184 ms (dense) to 391 ms (sparse).

Change

  • A document scan that recovered nothing is not repeated until the index is loaded again (documentScanFoundNothing). The scan guards against pages that an older version wrote (old-format tombstones), and a load either finds those or it does not. A scan that did recover something keeps the cross-check on every build, as before.
  • The line logged before the scan is now FINE. A scan that recovers vectors logs a WARNING afterwards with the recovered count, so the corruption case still reaches the operator.
  • When the scan is skipped, the in-memory recovery (the "tertiary defense") runs as it does for any build without a scan.

Test

Issue11938SparseVectorIndexScansOnceTest builds an index of 20 vectors among 120 records twice, with a write in between, while capturing the log lines of the index:

  • One document scan across the two builds. On main there are two, so the test fails there.
  • No WARNING.
  • The second build, which skips the scan, still indexes the new vector: a search by its value answers it.
  • After a reopen, the next build scans again. This is the control that the cross-check is still reached.

The related vector suites pass too, 310 tests in 17 classes. LSMVectorIndexRecoveryTest is among them; it holds the #3722 cases, including the old-format tombstone parse and the bucket-scoped fallback scan. The others are VectorRebuildLifecycleTest, VectorGraphStalenessTest, GroupedVectorSearchTest, VectorPrefilterTest, DeltaScanVectorSearchTest, VectorDeltaScanTest, LSMVectorIndexRebuildTest, LSMVectorIndexCompactionTest, VectorTransactionSearchTest, LSMVectorIndexRebuildRacingWritesTest, VectorGraphPersistTest, VectorIndexRebuildsOnEveryCloseTest, VectorLocationIndexTest, LSMVectorIndexGraphConnectivityTest and LSMVectorIndexGraphStorageTest.

This PR edits the same block of LSMVectorIndex as #11969 (issue #11962), which makes the in-memory recovery run after a document scan as well. The hunks do not overlap.

…ctors once per load when the scan recovers nothing

- An index on a property only some records carry parses fewer page vectors than its bucket has records, so every build
  scanned the whole bucket and logged a WARNING to recover nothing.
- A scan that recovered nothing is not repeated until the index is loaded again; one that recovered keeps the check.
- The pre-scan line is FINE; a scan that recovers vectors logs a WARNING with the count.
- Issue11938SparseVectorIndexScansOnceTest counts the scans from the index's log lines, with a reopen as control.
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8048bfd2-a78f-4f32-8558-7f42e06e40fa
Commits

Reviewing files that changed from the base of the PR and between 2eb615c and f42c544.

Files selected for processing: 2

  • engine/src/main/java/com/arcadedb/index/vector/LSMVectorIndex.java
  • engine/src/test/java/com/arcadedb/index/vector/Issue11938SparseVectorIndexScansOnceTest.java
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@mergify

mergify Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@github-actions

Copy link
Copy Markdown
Contributor

Triage: triage:lgtm · severity:minor · areas: vector, engine · has-issue

Review of #11977

The change is small and focused, and it has a regression test. I found nothing that blocks the merge. I did not run the tests.

What it does

  • LSMVectorIndex.java adds a volatile documentScanFoundNothing flag. When the Missing images when vector neighbors query #3722 document scan recovers nothing, later builds skip it until the index is loaded again.
  • The flag is set only after the scan finishes without throwing. A scan that failed or recovered something is still retried on every build.
  • The pre-scan log drops to FINE. A scan that recovers vectors now logs a WARNING with the recovered count, so a real corruption case still reaches the operator.

Tests

  • Issue11938SparseVectorIndexScansOnceTest covers the following:
    • one scan across two builds with a write in between;
    • no WARNING;
    • the new vector is still searchable after the scan is skipped;
    • the scan runs again after a reopen, as a control.
  • It follows the project's TestHelper and AssertJ style. It makes no wall-clock assertions and uses no fixed ports.

Suggestions, none blocking

  • Check whether the flag should also be cleared wherever the index drops or replaces its state (truncate, drop, or compaction that rewrites pages). The PR says the flag lasts "until the index is loaded again", so this is probably fine. A short comment, or a reset on those paths, would make that explicit.
  • The test's capture helper restores a fresh DefaultLogger instead of the logger that was set before. That is probably fine for this suite, but restoring the previous logger would be safer if other tests install their own.
  • Several of the new comments are long. This is cosmetic.
  • The PR notes that it edits the same block as fix(#11962): a vector graph build keeps in the delta the live vectors it could not read (commit in flight on a Raft leader) #11969. The hunks do not overlap, but the second PR to merge should rebase and rerun the vector suites.

@shaunpatterson

Copy link
Copy Markdown
Contributor Author

Thanks for the triage. On the suggestions:

shaunpatterson added a commit to shaunpatterson/arcadedb that referenced this pull request Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine Core engine: document/schema API has-issue The PR links an issue it resolves severity:minor Cosmetic, documentation, edge case, or a workaround exists triage:lgtm PR triage: nothing blocking, ready for a maintainer vector Vector index and embedding search

Projects

None yet

1 participant