Repository navigation
fix(#6295, #6300, #6301, #6302): a weight belongs to its own edge, and the phase a call spends its time in is the one that has to be abortable - #6306
Conversation
…d the phase a call spends its time in is the one that has to be abortable #6301 - algo.steinerTree paired edge weights with neighbours BY ITERATION POSITION. The adjacency was built with the relTypes filter applied and in the backing store's order; the weights were filled positionally from an unfiltered getEdges(BOTH) walk in OLTP order. Nothing reconciled the two, and that array feeds Dijkstra, so the TREE moved, not only the reported weight. An excluded edge type lent its 999.0 to an included edge (totalWeight 1000.0 for a tree costing 2.0), and the mere presence of a Graph Analytical View made the procedure return a 51.0 tree where it had returned 2.0. Replaced by GraphData.weightedAdjacency(), which produces the neighbour list and its weights from ONE walk of the same edges - columnar when the view has them, edge records otherwise - so the pairing is correct by construction and both backings return the same answer. The same broken helper also made algo.apsp throw ArrayIndexOutOfBounds on a view with no relTypes filter, and made algo.bellmanford silently use a unit weight for EVERY edge whenever the view had no column for the requested property. GraphTraversalProvider.hasEdgeProperties() now also asserts that getEdgeProperty's positional mapping is exact, and GraphAnalyticalView answers false while a delta overlay is active. #6295 - algo.hashgnn's MinHash reduction runs AFTER the loop `iterations` drives and costs 4 x embeddingDimension^2 per node, so a bounded per-node figure times an unbounded node count. Measured: 112,988 ms against a 1000 ms arcadedb.command.timeout, and the call returned rather than aborting. The question that finds this is "which loop over the node count has no checkpoint", not "which knob has no cap" - which also turned up the pre-loop initialisation of hashgnn, fastrp and graphsage, and slpa's post-processing and mostFrequent. #6302 - the four densest procedures had no WorkGuard at all. The #6263 budget's 64 MB floor admits n ~ 2890 for algo.apsp, and 2890^3 is ~2.4e10 Floyd-Warshall iterations that ignored Thread.interrupt(), command.timeout and client cancellation. Swept all 68 procedures: every one whose dominant loop is superlinear in the graph is now abortable, 22 in total. Single O(V + E) passes are deliberately left alone. #6300 - algo.mst builds three edge-sized arrays plus the index sort, 24 bytes per edge, unpriced: the one dense path #6263 missed, because its criterion was knob-sized or node-quadratic and this one is edge-linear. Reserved through the new MemoryBudget.capacityFor(), consulted AS the counting pass runs, so a graph too large to serve stops being walked rather than being refused after a full traversal.
|
Tick the box to add this pull request to the merge queue (same as
|
Not up to standards ⛔🟢 Coverage
|
| Metric | Results |
|---|---|
| Coverage variation | Report missing for d71b26a1 |
| Diff coverage | ✅ 95.38% diff coverage |
Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (d71b26a) Report Missing Report Missing Report Missing Head commit (0dc5467) 192250 139566 72.60% Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>
Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#6306) 260 248 95.38% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Review of #6306Reviewed via multi-angle analysis of Overall this is a careful, well-documented PR with strong test coverage for its primary claims. The items below are gaps found on top of that. Correctness
Test coverage
Minor / cleanup
None of the above should block merging on their own given the strength of the existing tests and the PR's explicit self-documentation of scope (the "Follow-up worth filing" section already flags a related instance of item 1's root cause). Items 1, 2, 6, and 7 seem the most worth a quick follow-up. |
…and guard the walk that reads it Review round 1 on PR #6306. 1. hasEdgeProperties() answers "are there edge property columns at all", so a view built over `distance` said yes to a call asking for `cost`; every getEdgeProperty then returned null and the whole graph was silently unweighted - the same wrong answer #6301 is about, reached from the other direction. New GraphTraversalProvider.servesEdgeProperty(propertyName, edgeTypes...) resolves "all types" against what the provider holds and checks each one, and is now the gate for algo.apsp, algo.bellmanford, algo.steinerTree, algo.dijkstra.singleSource, SQLFunctionAstar and SQLFunctionBellmanFord. The last of those also passed a null edge type to getEdgeProperty, which can never resolve a column store, so its CSR path had been unit-weighting every edge unconditionally. 2. GraphData.weightedAdjacency now takes the WorkGuard: it walks every edge of the graph, including the record path with its ghost-edge handling, so it is one of the graph-driven loops that has to be abortable - and it is the one helper algo.apsp, algo.bellmanford and algo.steinerTree all funnel through. The record path throttles by EDGE, not by vertex, since one supernode can hold millions. 3. algo.mst's two edge-collecting passes throttle by edge rather than by vertex for the same reason: with algoMaxWorkingMemory disabled the budget never fires, and a near-star graph left one vertex's whole edge list unabortable. 4. algo.kTruss's setup phases - the neighbour bit matrix and the O(E) initial support computation, in both execute() and computeFullTrussDecomposition() - run before the peeling loop that carried the only checkpoint. 5. algo.bellmanford's negative-cycle pass is guarded like the relaxation passes above it, rather than being the one unabortable loop left in the method. Tests: a view materialising a different property than the one requested (verified red on the coarse gate: 1.0 instead of 2.0), an active delta overlay asserted to flip hasEdgeProperties() from true to false with algo.bellmanford still reading the right weights, and algo.msa over a graph whose cheapest-incoming selection forms a cycle, so the guard is exercised through the contraction recursion rather than only at level 1. Declined, with reasons in the PR thread: consolidating algo.kShortestPaths and algo.msa onto weightedAdjacency (they resolve neighbours by index already, so they carry no alignment bug - it is a CSR-acceleration change, not a fix), a checked-iterator primitive baked into GraphData (placement genuinely differs per loop complexity), and the non-atomic repeated snapshot reads (pre-existing lock-free design, unchanged in kind by this diff).
|
Thanks - actioned 8 of the 11 points in dfb2d8b. Three declined, with reasons. 1. You are right that this is the same failure class as #6301 arrived at from the other direction, and the new abstraction is the place to close it. New Chasing it into those callers turned up a live instance:
2. 3. 4. 5. 6. No test for 7. No test for the overlay narrowing — actioned. 8. 10. No structural "checked iterator" primitive — declined. A shared primitive would have to pick one throttling policy, and the placement genuinely differs per loop: unthrottled 11. Repeated non-atomic Re-ran after the changes: 1631 tests across |
|
Reviewed this PR (the SteinerTree weight-alignment fix, hashgnn/apsp/mst checkpointing, and the MST edge-array budget). The core diagnosis and fixes for #6301/#6295/#6302/#6300 are solid: Two issues found in the two 1.
2. Neither Minor style nit: One maintainability note, not a defect: the WorkGuard checkpoint convention ( Suggest fixing the two |
…not four hand-rolled copies Review round 2 on PR #6306, which found the same bug class still live in the two SQL functions this PR had touched - and reachable by DEFAULT in one of them. getEdgeProperty() is addressed by (type, direction, position), and pairing it with getNeighborIds() by hand is wrong in two independent ways, both silent: - a multi-type neighbour list is MERGED AND SORTED across types while the property columns are per type, so position j in the list is not position j in any one column; - DIRECTION.BOTH has no column at all. A provider resolves OUT and IN, so a BOTH lookup returns null for every edge and the caller reads the whole neighbourhood at its default weight. SQLFunctionBellmanFord's direction argument defaults to BOTH, so the plain three-argument call bellmanFord(src, dst, 'weight') had been unit-weighting the entire graph the moment a view existed - on the fixture here that returns the two-hop A-C-D instead of the weighted A-B-C-D. SQLFunctionAstar hit the same branch with direction 'BOTH' and priced every edge at MIN (0.0), so every path tied, and separately read a merged multi-type list against only paramEdgeTypeNames[0]'s column. New GraphTraversalProvider.edgeWeightsOf(nodeId, direction, property, defaultWeight, types...) returns one node's neighbours and weights together, splitting BOTH into OUT+IN and taking one slice per (type, direction) - each of which IS positional. It is the single place that knows how to pair a CSR edge with its own weight, and all three CSR readers now go through it: GraphData.weightedAdjacencyFromColumns (whose duplicate of the logic is deleted), SQLFunctionAstar and SQLFunctionBellmanFord. New record NodeEdgeWeights carries the pair. algo.dijkstra.singleSource needs no change beyond round 1's gate: GraphAlgorithms.dijkstraSingleSource walks the forward and backward CSR arrays itself with the column index rather than through getEdgeProperty, so it has no BOTH hazard. Issue6301CsrEdgeWeightAlignmentTest is the coverage the review noted was missing entirely - neither SQL function had a Graph-Analytical-View-backed case, so the whole CSR branch of both was untested. The fixture is the discriminator: A-B-C-D at 1.0 per hop against a direct A-C at 100.0, so wrong weights return a different PATH, not merely a different number. Verified red on the round-1 code for both functions. Also actioned: the fully-qualified com.arcadedb.graph.Vertex references in the test are imports now.
|
Both findings confirmed and fixed in 26f7516. You were right that the two Verified both, red-before-fix, on the round-1 code:
The fix takes your suggestion of routing through the one-walk builder, but pushes it one level lower. NodeEdgeWeights edgeWeightsOf(int nodeId, Vertex.DIRECTION direction, String propertyName,
double defaultWeight, String... edgeTypes)It splits
On the missing coverage: you are right that the CSR branch of both functions was untested outright. Style nit — fixed, Maintainability note — agreed, and worth being precise about why it is not addressed here. The gap is not that a checkpoint is easy to forget; it is that the right placement is a per-loop judgement (unthrottled where one iteration is already O(V), throttled on a running counter where the unbounded thing is the product of two loops), so a base-class hook would standardise the part that is already easy and leave the part that is hard. The enforceable version is a lint over the package — "a loop over Re-ran: 1634 tests across |
ReviewThis is an exceptionally well-engineered PR: each fix comes with a "verified red before fix" regression test, the reasoning for scope decisions (what's included vs. explicitly declined) is spelled out, and the iterative self-review rounds (visible in the commit history) already caught and fixed several real bugs - the Possible gap: no per-edge checkpoint in the columnar weight-reading path
This is very likely fine in practice - CSR reads are array indexing rather than record deserialization, so the per-edge cost is much lower than the OLTP path this reasoning was applied to. But given how carefully this PR documents why a gap is acceptable elsewhere (e.g. the Minor:
|
…om the traversal SPI, resolve the overlay instead GraphTraversalProvider.getEdgeProperty addressed an edge by its position in the node's neighbour list. That position identified the same edge getNeighborIds reported only while nothing else was in play: an active DeltaOverlay drops deleted edges, merges added ones in and re-sorts the list, while the property columns stay aligned with the base CSR's forward slots. Delete the first of three outgoing edges and every remaining neighbour shifts down a slot, so position 1 came back with the deleted edge's weight - a wrong shortest path, a wrong MST, a wrong Steiner tree, and never an exception. PR ArcadeData#6306 closed that for the callers that existed by narrowing hasEdgeProperties() to false whenever an overlay was active, leaving the accessor itself for the next caller to find and the rule for it to remember. The accessor is gone. In its place edgeWeightsForSlice() returns one (type, direction) slice's neighbours and their weights together, produced by the walk that decided which edges the slice holds, so no index crosses the SPI boundary and there is nothing left to re-derive wrongly. edgeWeightsOf() composes the slices, which is where the multi-type merge and the BOTH split already lived, and a slice the provider cannot answer for makes the whole node unanswerable rather than a neighbourhood with edges silently missing from it. Resolving the overlay rather than refusing it also keeps the columnar path alive while a view is being updated, which is the state UpdateMode.SYNCHRONOUS leaves it in after every commit: - a base edge the overlay has not deleted takes its own forward column slot, tracked through the merge by packing each entry's provenance into the low half of the sort key; - an edge the overlay added takes the value DeltaCollector captured for it at commit time - it has no column slot, the columns having been built with the base CSR; - a run of parallel edges between one pair, partially deleted, is refused: deletions are counted per pair, which is all the neighbour list needs, but not enough to say which of the run died, and parallel edges need not weigh the same; - an edge whose properties were updated marks the columns out of date until the rebuild that repairs them lands, so no stale weight is served. An update to an edge the overlay itself holds is applied there and dirties nothing, which is what keeps the ordinary newEdge(...).save() - one create and one update of the same edge - from forcing a rebuild per insert. Two consequences follow from the view now serving edge properties through an overlay. GraphAlgorithms's Dijkstra kernel reads the CSR arrays directly and was kept off them only as a side effect of that narrowing; it refuses for itself now. And AbstractAlgoProcedure's columnar build reads the records for a node the provider cannot answer for, through the same row reader its whole-graph record build uses, so the fallback cannot answer differently from the path it stands in for.
Fixes #6295, #6300, #6301, #6302.
#6301 - an edge weight was attached to whatever neighbour sat at that index
AlgoSteinerTree.buildWeightedAdjpaired weights with neighbours by iteration position.adj[i]was builtwith the
relTypesfilter applied and in the backing store's order;tmpWwas filled positionally from anunfiltered
getEdges(BOTH)walk in OLTP order.nbIdxwas computed and then used only as a skip test, never asthe index to write at. That array is what Dijkstra runs on in step 1, so the tree itself changed, not only the
weightcolumn.Both reproductions from the issue are pinned as tests and both were verified red before the fix:
NOISEedge of weight 999 landed on an includedROADedge →weight: 999.0,totalWeight: 1000.0for a tree that costs 2.0;
to be a transparent accelerator, so this is the worst failure mode it has.
The fix removes the second traversal rather than repairing it.
GraphData.weightedAdjacency(direction, weightProperty, relTypes)produces the neighbour list and its weights from one walk of the same edges - fromthe view's columnar edge properties when it has them, from the edge records otherwise - so the pairing is correct
by construction and the two backings return the same multiset of
(neighbour, weight)pairs.buildWeightedAdjisdeleted, and so is the old
GraphData.edgeWeights.The issue suggested reusing
edgeWeights(...). That could not be taken as-is, and the reason is the interestingpart:
getEdgePropertyreturns null forDIRECTION.BOTH, which is the directionalgo.steinerTreeneeds, andgetNeighborIds(i, BOTH, type)is a sorted merge of the OUT and IN slices, so no positional mapping to thecolumn store exists for it at all.
weightedAdjacencyFromColumnswalks one slice per (type, direction) instead,each of which is positional, and concatenates them.
The same helper was broken for its two existing callers, and both are fixed with it:
algo.apspwith norelTypesfilter on a view with edge properties produced an empty weight row against anon-empty neighbour row: an
ArrayIndexOutOfBoundsExceptionfor a query that worked without the view. Withseveral edge types it mismatched silently, because the adjacency is sorted across types while the weights were
concatenated per type.
algo.bellmanfordfell back to a unit weight for every edge whenever the graph was CSR-backed and theview had no column for the property - ignoring
weightPropertyentirely, and only when a view existed. Its edgelist is now parallel primitive arrays rather than
List<int[]>+List<Double>, which the O(V x E) relaxationreads up to
V - 1times.One provider-contract change.
GraphTraversalProvider.hasEdgeProperties()now means "the columns arematerialised and the positional mapping
getEdgePropertyrelies on is exact", andGraphAnalyticalViewanswersfalsewhile a delta overlay is active: the columns are aligned with the base CSR's forward slots whilegetNeighborIdsserves the overlay's view of the node (deletions dropped, additions merged, list re-sorted), sothe n-th neighbour is not the n-th edge of the column store.
SQLFunctionAstar,SQLFunctionBellmanFordandalgo.dijkstra.singleSourcepair positionally too and gain the same protection: in that state they read the edgerecords, which is slower and exact. Same "say unknown rather than guess" convention as
countEdgesBetweenandgetMeanEdgesPerConnectedPair.#6295 - the phase a call spends its time in was outside every checkpoint
algo.hashgnn's MinHash reduction runs after the loopiterationsdrives, and costs4 x embeddingDimension²operations per node - a bounded per-node figure multiplied by an unbounded node count.Reproduced as the issue measured it: the deadline overshot by two orders of magnitude and the call returned.
The generalisable lesson, and the one applied here: #6216 and #6264 hunted knobs with no ceiling;
embeddingDimensionHAS one (#6065), which is exactly why the lens walked past it. Ask "which loop over the nodecount has no checkpoint", not "which knob has no cap". That sweep also found the pre-loop initialisation of
algo.hashgnn,algo.fastrpandalgo.graphsage, andalgo.slpa's post-processing and its O(degree²)mostFrequent. All now carry a checkpoint; the two-phase ones use a counter spanning both loops, because aper-node check is too coarse on a wide embedding and a per-dimension clock read is too expensive on a narrow one.
#6302 - a guard belongs wherever the work is unbounded, not only where a knob multiplies it
algo.apspmakes the case alone: the #6263 budget's 64 MB floor admits n ≈ 2890, and 2890³ is ~2.4e10Floyd-Warshall iterations during which
Thread.interrupt(),arcadedb.command.timeoutand client cancellation alldid nothing. The memory half of the guarantee was waving through a run the time half could not stop.
Taking the issue's "better framing" rather than its four-procedure list, all 68 procedures were swept with the
question "can one call of this run for minutes on an accepted input?". 22 are now abortable:
apsp,kShortestPaths,steinerTree,mst,bellmanford,betweenness,closeness,harmonic,eccentricity,maxFlow,msa,knn,hierarchicalClustering,clique,allSimplePaths,kTruss,triangleCount,localClusteringCoefficient,densestSubgraph,bipartiteMatching,voteRank,richClub.Procedures making a single O(V + E) pass are deliberately left alone: one pass costs what loading the graph and
emitting the rows already cost, so a checkpoint there bounds nothing the surrounding pipeline does not. One gap is
named rather than hidden:
algo.localClusteringCoefficient's CSR path delegates to aGraphAlgorithmskernel thatcounts triangles across a thread pool, and
WorkCheckpointis specified to be called between iterations on thecalling thread - covering it is a change to how that kernel partitions its work.
#6300 -
algo.mst's edge arrays are the one dense path #6263 did not price24 bytes per edge across
eu/ev/ewand the index sort, unreserved. #6263's criterion was "knob-sized orquadratic in the node count", and edge-linear reads like the graph paying for itself - but the edge count is the
largest linear dimension a graph has, and 100M edges is ~2.4 GB with nothing between it and the allocator.
The issue asked for the reservation to be made before the pass-1 count loop, which cannot be done as stated:
nothing knows the edge count before the walk, and every cheap upper bound (
countTypeover the edge types) isitself a scan. What it wants is achievable another way, and that is what is implemented: the new
MemoryBudget.capacityFor(bytesPerItem)turns the budget into a bound the walk carries, so the count stops themoment it passes what the budget allows. The refusal still goes through
reserve(), so the message names the samecomponent and the same setting either way. The issue's Borůvka-over-CSR alternative is not taken here - it would
remove the allocation rather than bound it, but it changes tie-breaking and result ordering, which is a different
change from closing a hole in the budget.
algo.mst'sList<Vertex>+Map<RID, Integer>are noted in the issue and left alone on purpose: that is theshared OLTP loading path every procedure uses, so pricing it in one procedure would be inconsistent. It belongs in
loadGraph, as one change, if it is wanted.Verification
Issue6301AlgoSteinerTreeWeightAlignmentTest(6) - both reproductions, the analytical-view comparison with anexplicit
CSR_ACCELERATED_VARassertion so it cannot silently pin the OLTP path twice, parallel edges, thebellmanford unit-weight fallback, the apsp all-types crash. 4 of 6 verified red on the pre-fix code.
Issue6302AlgoGraphDrivenWorkGuardTest(42) - every one of the 22 procedures aborts on a pending threadinterrupt and still returns its result without one, plus a
@Tag("slow")deadline test onalgo.apspat 1500nodes. Verified: with the Floyd-Warshall checkpoint removed the same test runs the loop to completion and
returns.
Issue6295AlgoUnguardedPhaseTest(2) - the MinHash reduction aborts on a deadline that the single message-passinground comfortably survives. Verified red (no exception, ran to completion) with the checkpoint removed.
Issue6300AlgoMSTEdgeBudgetTest(5) - refusal, the message naming the count the walk stopped at, a budget thatfits, a disabled budget, and the MST itself unchanged. 2 of 5 verified red on the pre-fix code.
Only
algo.hashgnn's reduction is pinned as a binary abort, and the test javadoc records why the others are not:SLPA's propagation and its post-processing are both O(nodeCount x iterations) and measured at the same order, so
any threshold between them would be measuring the fixture rather than the checkpoint. They are covered by the
no-regression test instead.
Full runs: 2541 tests across
Algo*/Issue62*/Issue63*/Cypher*/GraphAnalyticalView*/SQLFunction*, 1639across
com.arcadedb.graph.**andcom.arcadedb.function.**, plus theslowlane for the touched classes. Allgreen.
Follow-up worth filing
GraphAnalyticalView.getEdgeProperty's positional contract is broken by an active overlay for any caller, notonly these. This PR makes the four known callers fall back safely via
hasEdgeProperties(), but the SPI methoditself still returns a value addressed against the base CSR while
getNeighborIdsreturns the overlay's list. Aprovider-side fix (an overlay-aware property lookup, or an explicit "unknown" return) would close the shape rather
than the instances.
🤖 Generated with Claude Code
https://claude.ai/code/session_016yjKJXMNMQeLPKdCno7cFX