Skip to content

algo.*: the first call after reopening a database runs on the record-by-record path instead of waiting for the restored Graph Analytical View #9220

Closed

Description

@lvca

After a restart, the first whole-graph algo.* call (algo.wcc, algo.pagerank, algo.bfs, algo.localClusteringCoefficient, algo.labelPropagation, algo.dijkstra.singleSource, ...) does not use the persisted Graph Analytical View, even though the view is restored from disk in under a second. It scans the records instead, which on a large graph takes minutes. Every later call is fast.

Cause

GraphAnalyticalView.isReady() dispatches the deferred restore-from-disk (#6632) as a side effect and returns false for that call (#6641), by design: the query it belongs to takes the ordinary path. AbstractAlgoProcedure.findProvider treats that false as "no view", so the first call after open() always takes the OLTP path. For a whole-graph algorithm that is an O(V+E) record scan, far more expensive than the restore it did not wait for. Callers who want to wait are meant to use awaitReady() (see GAV_RESTORE_AWAIT_TIMEOUT), but the algorithm procedures never do.

How it shows up

Embedded, datagen-7_5-fb from LDBC Graphalytics (633,432 vertices, 34,185,747 edges), database persisted together with its view, Temurin 25, 12 GB heap, ArcadeDB 26.10.1-SNAPSHOT built from main at c8e53a4b76 (includes #9135). The very first call after open(), no awaitReady:

CALL algo.wcc() YIELD componentId RETURN count(*) AS cnt
persisted view first call later calls
valid, restored from disk 87.8 s 0.05-0.16 s
unusable (file truncated, falls back to a rebuild) 110.8 s 0.05-0.16 s

Through the Docker server, over HTTP, the same first call took 173 s on the same database. The view itself was ready within a second of opening; the log shows restored CSR from disk almost immediately.

A local fix and what it does

A local, uncommitted change makes findProvider wait for a covering view that is still BUILDING (capped at 10 minutes) and then look again. Measured the same way:

persisted view first call with the change
valid 0.65 s
unusable (rebuild fallback) 28.0 s

That is the behaviour wanted, but the change as written needs these decisions before it is merged:

  1. Scope of the wait. It waits for any BUILDING view, not only a deferred restore. An ASYNCHRONOUS view flips to BUILDING after relevant commits (onRelevantCommit), so with the change every algo.* call issued during or right after writes would block for the rebuild, up to the cap, where it previously ran immediately on the record path. Restrict it to a restore in flight (the view already tracks deferredRestoreInFlight), or document and configure the behaviour.
  2. Timeout setting and abort. The cap is a hard-coded 10 minutes. GAV_RESTORE_AWAIT_TIMEOUT already exists (milliseconds, database scope, default 0 = do not wait); reuse or extend it so it can be tuned or disabled. The wait should also respect the procedure's work guard / command timeout, which the current blocking wait ignores.
  3. Selection details. The "which views to wait for" check should require the same coverage findReadyProvider does (including coversVertexType(null)), and after waiting it should always ask again instead of returning early when one view fails to become ready.

Tests wanted

  • every whole-graph procedure that uses findProvider, not only WCC (a parameterized test over algo.bfs, algo.pagerank, algo.localClusteringCoefficient, algo.labelPropagation, algo.dijkstra.singleSource);
  • a persisted view that cannot be restored (corrupt file): the call waits for the rebuild fallback;
  • a BUILDING view that does not cover the request is not waited for;
  • the ASYNCHRONOUS commit-rebuild case, with whatever behaviour decision 1 settles on.

Out of scope, noted

Planner-side callers go through GraphTraversalProviderRegistry.findProvider directly (the Cypher count push-downs, MATCH traversals) and will still take the ordinary path on the first call after a restart. That costs much less than a whole-graph scan, but it is the same cause; if a slow first query shows up there, the wait belongs in that registry method.

Activity

  1. added
    enhancement
    engine
    on Oct 4, 2026
  2. added
    severity:minor
    in progress
    on Oct 4, 2026
  3. added 4 commits that reference this issue on Oct 4, 2026
  4. self-assigned this
    on Oct 4, 2026
  5. added this to the 26.10.1 milestone on Oct 4, 2026
  6. added a commit that references this issue on Oct 5, 2026
  7. added 4 commits that reference this issue on Oct 6, 2026
  8. robfrank commented on Oct 22, 2026

    @robfrank
    Collaborator

    Fixed by #9221. Right after a database was reopened, the persisted Graph Analytical View is restored in the background, and the first whole-graph algo.* call did not wait for it, so it always fell back to the slow record-by-record path. algo.* procedures now wait for a restore in progress (and only a restore, not an ordinary rebuild after a commit) before choosing their path, within a budget set by the new database setting arcadedb.gavAlgoRestoreAwaitTimeout (default 60000 ms, 0 keeps the old behaviour), and the command timeout still ends the wait. On a 34M-edge graph the first algo.wcc() after a reopen went from 87.8 s to 0.65 s.

    Still open: Cypher and MATCH paths that look up the view directly (count push-downs, traversals) still take the ordinary path on the first call after a restart, and the whole-graph fallback lookup still accepts a ready view on edge coverage alone, without requiring every vertex type. Neither was changed by #9221, and no follow-up issue number was given for them.


    ❤️ 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.

  9. removed
    in progress
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

engineenhancementopencypherperformanceseverity:minor

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions