Skip to content

[BUG] GPU merges don't check MergeState.checkAborted() (Lucene 10.5+) #3089

Open

Description

@imotov

Describe the bug
Lucene 10.5 added MergeState.checkAborted(), which throws MergeAbortedException once IndexWriter aborts a merge (for example on rollback(), close() without waiting for merges, deleteAll(), or shutdown). Lucene's Lucene99HnswVectorsWriter passes it to the HNSW graph builder, which calls it before inserting each node, so an aborted CPU merge stops almost at once.

The cuvs-lucene GPU writers never call it. When the merge scheduler is ConcurrentMergeScheduler, abort is still caught on writes, but the CAGRA build writes nothing. An abort during that build therefore goes unnoticed until it finishes and the writer writes the graph.

Proposed fix

  • Add LuceneCompat.checkAborted(MergeState). On 10.5 and later it calls mergeState.checkAborted(). On 10.2–10.4 it does nothing; Lucene's own builder doesn't check on those releases either.
  • Call it at these points:
    • in Lucene99AcceleratedHNSWVectorsWriter and the scalar- and binary-quantized HNSW writers: after the flat-vector merge and before the CAGRA build;
    • in AcceleratedHNSWUtils: between the per-layer builds;
    • in CuVS2510GPUVectorsWriter: before CagraIndex.merge and before the rebuild fallback;
    • in the Java loops that copy vectors and convert the graph, every few thousand nodes.
  • Check that GPU resources are released on MergeAbortedException. It's an IOException, so it should take the existing cleanup paths.
  • Add a test, run on 10.5 and 10.6, that aborts a merge and asserts the writer throws MergeAbortedException without starting the GPU build.

Out of scope

For now this won't interrupt a CAGRA build that's already running. That would need cancellation support in cuVS, which neither the C API nor the CAGRA and nn-descent build loops have today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

LucenebugSomething isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions