Repository navigation
Description
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:
- Scope of the wait. It waits for any
BUILDINGview, not only a deferred restore. AnASYNCHRONOUSview flips toBUILDINGafter relevant commits (onRelevantCommit), so with the change everyalgo.*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 tracksdeferredRestoreInFlight), or document and configure the behaviour. - Timeout setting and abort. The cap is a hard-coded 10 minutes.
GAV_RESTORE_AWAIT_TIMEOUTalready 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. - Selection details. The "which views to wait for" check should require the same coverage
findReadyProviderdoes (includingcoversVertexType(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 overalgo.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
BUILDINGview that does not cover the request is not waited for; - the
ASYNCHRONOUScommit-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
fix(#9220): review follow-ups - bounded, abortable wait limited to a …
fix(#9220): always repeat the provider lookup after waiting for a res…
fix(#9220): 60 s default wait, null-safe abort hook, interrupt and RE…
Merge pull request #9221 from ArcadeData/fix/9220-algo-await-restored…
fix(ArcadeData#9220): algo.* waits for the restored Graph Analytical …
fix(#9220): algo.* waits for the restored Graph Analytical View on th…
fix(#9220): review follow-ups - bounded, abortable wait limited to a …
fix(#9220): always repeat the provider lookup after waiting for a res…
fix(#9220): 60 s default wait, null-safe abort hook, interrupt and RE…
robfrank commentedon Oct 22, 2026
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 settingarcadedb.gavAlgoRestoreAwaitTimeout(default 60000 ms,0keeps the old behaviour), and the command timeout still ends the wait. On a 34M-edge graph the firstalgo.wcc()after a reopen went from 87.8 s to 0.65 s.Still open: Cypher and
MATCHpaths 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.