Skip to content

LSM_VECTOR: a search whose query vector sits in a deleted region returns an empty neighbor list #5558

Closed

Description

@lvca

Verified on main (no local changes), found while working on #5516.

A vector.neighbors search returns [] - not "the nearest surviving vectors" - when the query vector lands where a group of deleted vectors used to be. The live vectors are still there, still searchable with any other query.

Reproduction

Vertex type with an LSM_VECTOR index (16 dimensions, COSINE, INT8), 100 vertices doc0..doc99 with well-separated embeddings, then delete doc0..doc29:

database.transaction(() -> {
  for (int i = 0; i < 30; i++)
    database.command("sql", "DELETE FROM Doc WHERE id = ?", "doc" + i);
});
  • query with the embedding of doc50 (alive, far from the deleted block) -> 5 neighbors, doc50 first. Correct.
  • query with the embedding of doc3 (deleted, its neighbors doc0..doc6 all deleted) -> []

Reproduces both before and after a reopen, so it is not a persistence problem: the entry count is right (70 live), and every other query works.

Why it looks like a real defect

The graph walk lands in a neighborhood whose nodes are all filtered out as deleted and returns nothing rather than expanding the search to the surviving nodes. So the answer is silently wrong - an empty result reads as "there is nothing similar in this database", when there are 70 live vectors, some of them reasonably close.

The impact scales with the deletion pattern: an application that deletes a topical cluster (a tenant, a document set, a time range) leaves a hole where queries about that topic return nothing at all, which is exactly the query most likely to be asked.

Not caused by, but adjacent to, #5516

Found while verifying the tombstone-memory fix. It reproduces on pristine main, so it predates that work and is out of its scope. Filing separately so it does not get lost.

Activity

  1. added this to the 26.8.1 milestone on Jul 31, 2026
  2. self-assigned this
    on Aug 1, 2026
  3. added theissue type on Aug 1, 2026
  4. lvca commented on Aug 2, 2026

    @lvca
    MemberAuthor

    Fixed in ca241a087 (PR #5739).

    Both causes were real and independent:

    • The traversal accepted tombstones as answers. Bits.ALL was passed as JVector's accept-filter, and the beam stops once it holds rerankK acceptable candidates - so a query aimed at a deleted neighbourhood filled up with tombstones, declared itself finished, and the post-filter emptied the list. Now filtered by LiveVectorBitsFilter, which works because acceptOrds gates only result admission: JVector still expands a rejected node, so the survivors behind the hole stay reachable and the beam keeps walking until it finds them.
    • A tombstone was scored through a Float.MIN_NORMAL placeholder. Cosine cancels the magnitude and dimensions * MIN_NORMAL^2 underflows to zero in float, so the similarity came back Infinity - every tombstone was the best candidate in the beam, and on a JVM with assertions enabled the search failed outright on JVector's own 0 <= score <= 1 check.

    Your reproduction (100 vertices, delete 30) does not show the empty list on current main, because at that size the graph is rebuilt synchronously on the next search and the brute-force fallback covers what is left. The empty list reproduces exactly as reported on the PQ path - select().vectorNeighbors() on a PRODUCT-quantized index - which is the one search path with neither a delta scan nor a fallback behind it. That is now a regression test.

    Three follow-ups came out of the work, all filed:

    getStats() also gained a bruteForceScans counter: the fallback scan reads every vector in the index and was previously visible only as a WARNING. If filtered vector queries are slow, look there first.

  5. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions