Skip to content

Vector search ignores query cancellation and the command timeout, and waits on rebuilds without a bound #9896

Closed

Description

@lvca

Problem

Vector search never checks the command deadline or the termination flag. A cancelled query (terminate() from the running-query registry, a client cancel, a gRPC deadline) or one past arcadedb.command.timeout / SQL TIMEOUT keeps running, and can also wait for a long time without any bound.

Loops without a WorkGuard (nothing in index/vector uses one):

  • the graph search and the graph build/rebuild in LSMVectorIndex,
  • the while (true) in SQLFunctionVectorNeighbors that doubles the candidate count (fetchK) until enough results survive the filters.

Waits that ignore termination:

  • awaitPendingSearchRebuild(...): an untimed Condition.await() on another query's graph rebuild,
  • graphBuildLock.lock(): uninterruptible,
  • REBUILD_SEMAPHORE.tryAcquire(timeout): one permit for the whole JVM, with a default wait of 600 s.

So a cancelled ANN query can stay alive (and keep its admission slot) for minutes after cancellation, especially while an index is rebuilding.

Proposed fix

  • Pass the command guard into the search, the fetchK loop and the rebuild loops that run on a query thread (checkPeriodically).
  • Replace the untimed waits with timed waits in a loop that checks the guard, and register an onTerminate listener so a terminated query is woken up instead of waiting for the timeout.
  • Tests: a vectorNeighbors / vector.neighbors query cancelled while waiting on a rebuild, and one with a SQL TIMEOUT, end promptly with the right exception.

Activity

  1. added
    engine
    vector
    on Oct 13, 2026
  2. added
    concurrency
    severity:minor
    on Oct 13, 2026
  3. added this to the 26.11.1 milestone on Oct 13, 2026
  4. added
    in progress
    on Oct 13, 2026
  5. self-assigned this
    on Oct 13, 2026
  6. added 2 commits that reference this issue on Oct 13, 2026
  7. lvca commented on Oct 13, 2026

    @lvca
    MemberAuthor

    Fixed in #9905, released in 26.11.1.

    A vector search (vector.neighbors() in SQL, db.index.vector.queryNodes in Cypher, select().nearestTo() in Java) now stops within a fraction of a second when its query is cancelled or reaches its timeout (arcadedb.command.timeout, a SQL TIMEOUT, Select.timeout()). This also applies while it waits for a vector graph to be built or for a rebuild slot, which used to take up to 10 minutes. The query fails with the usual timeout or termination error.

    The graph build itself is not thrown away. It keeps running in the background, and the next search uses the graph it produces. Before, cancelling the build with the query could leave a large index with no graph at all, as long as its build took longer than the timeout.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  8. removed
    in progress
    on Oct 13, 2026
  9. added a commit that references this issue on Oct 15, 2026
  10. added 2 commits that reference this issue on Oct 21, 2026
  11. added 2 commits that reference this issue on Oct 28, 2026
  12. added a commit that references this issue on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugconcurrencyengineseverity:minorvector

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions