Skip to content

Follow-up to #7042: the ADD side of overlay re-application still dedups by presence, so a buffered add of a second parallel edge is dropped #7884

Closed

Description

@rspereiratech

Summary

#7042 gave the deletion side of post-compaction overlay re-application a multiplicity comparison:
it spends an exclusion budget only for as many occurrences of a pair as the freshly scanned base
CSR actually still carries. The add side, three hundred lines earlier in the same method, still
dedups by presence: it probes hasForwardEdge(srcId, tgtId) and skips the buffered add whenever
the fresh base holds ANY occurrence of the pair.

With parallel edges, that drops a real edge. If the fresh base run carries one occurrence of
s -> t and the overlay has buffered the add of a SECOND one, the add is skipped, and the second
edge then exists in neither the fresh base nor the overlay. getNeighborIds, isConnectedTo and
countEdgesBetween report the pair once instead of twice until the next compaction rebuilds the
base from the store.

This is already documented in-tree as the residual #7042 left behind.

Where (HEAD 06b033d)

engine/src/main/java/com/arcadedb/graph/olap/DeltaOverlay.java:315-318 - the add side, dedup by
presence:

      if (baseCsrPerType != null && srcId < baseNodeCount && tgtId < baseNodeCount) {
        final CSRAdjacencyIndex csr = baseCsrPerType.get(ed.edgeType);
        if (csr != null && csr.hasForwardEdge(srcId, tgtId)) {
          final long packed = packEdge(srcId, tgtId);

engine/src/main/java/com/arcadedb/graph/olap/DeltaOverlay.java:429-433 - the deletion side, dedup
by multiplicity, as #7042 left it:

      if (baseCsrPerType != null && preCount != null && srcId < baseNodeCount && tgtId < baseNodeCount) {
        final CSRAdjacencyIndex csr = baseCsrPerType.get(ed.edgeType);
        if (csr != null) {
          final int absorbable = preCount.occurrences(ed.edgeType, ed.source, ed.target)
              - csr.forwardEdgeCount(srcId, tgtId);

engine/src/main/java/com/arcadedb/graph/olap/GraphAnalyticalView.java:2597-2600 - the gap named
in the javadoc of countBetweenForType:

   * only for a deletion the fresh run still carries. What is left is #6777's RID reuse, and the add side's
   * dedup being by presence rather than by multiplicity (a buffered add of a SECOND parallel edge to a pair
   * the fresh base already holds one of is skipped, which undercounts rather than overspending). The clamp
   * stays: it costs nothing, and it is the last line between either of those and a corrupted cross-type sum.

engine/src/main/java/com/arcadedb/graph/olap/CSRAdjacencyIndex.java:156 - the primitive the fix
needs already exists, and the deletion side already uses it:

  public int forwardEdgeCount(final int src, final int tgt) {

Repro

Shape, on a Graph Analytical View with a compaction in flight:

  1. Edge type T has E1 (s -> t) in the base at compaction start.
  2. During the rebuild, a transaction adds a second parallel edge E2 (s -> t); the add is buffered
    in the overlay.
  3. The read-committed, non-atomic CSR scan crosses s's bucket BEFORE that commit, so the freshly
    built run carries only E1.
  4. Re-application reaches the buffered add of E2, finds hasForwardEdge(s, t) == true, and
    continues.

E2 is now in neither the fresh base nor the overlay: getNeighborIds(s, OUT, "T") lists t once,
countEdgesBetween(s, t, OUT, "T") answers 1 where the OLTP graph has 2, and the discrepancy
persists until the next compaction.

Note the symmetry with the deletion side: there the scan swallowing a change led to an OVER-spent
budget, which #7042 fixed by subtracting forwardEdgeCount. Here the scan missing a change leads
to an UNDER-count, and the same subtraction is the fix.

Suggested fix

Replace the presence probe with the same multiplicity comparison the deletion side uses: compare
the pair's occurrence count in the pre-compaction snapshot against
csr.forwardEdgeCount(srcId, tgtId) in the fresh base, and skip only as many buffered adds of that
pair as the fresh run demonstrably already carries. Keep the existing masked-as-deleted branch and
the alreadyInFreshBase / RID-reservation bookkeeping for the adds that are genuinely skipped.

Once the add side counts rather than probes, the residual named in
GraphAnalyticalView.countBetweenForType's javadoc can be struck from that comment (the #6777
RID-reuse item stays).

A regression test in the shape of the existing #7042 one, but adding a second parallel edge
during the rebuild instead of deleting one, would pin it.

Scope / confidence

Checked: both sides of DeltaOverlay.merge at today's HEAD (nothing in
engine/src/main/java/com/arcadedb/graph/olap/ has been touched since the drafting snapshot);
CSRAdjacencyIndex.hasForwardEdge (:140) and forwardEdgeCount (:156) both exist and are distinct;
the in-tree javadoc that names this exact residual. Searched the issue history for an existing
report of the add side and found only the deletion-side issues (#7042, #6769, #6775, #6777), none
of which covers this.

Also checked that the fix is implementable where it is needed: preCount is a parameter of the
same method (DeltaOverlay.java:239) as the add-side probe, so the pre-compaction occurrence count
is already in hand at :317 - no extra plumbing.

Confidence that it is real: high - the project documents it in place. What is genuinely open is
severity: the effect is an undercount confined to parallel edges on a pair the fresh base already
holds, only for the window of one compaction, and the clamp in countBetweenForType keeps it from
corrupting the cross-type sum. What would falsify it: a path that guarantees the fresh CSR scan can
never miss a buffered parallel add (making the presence probe sufficient in practice), or a
deliberate decision that an undercount here is the accepted trade against the risk of
double-counting an add the fresh run did capture.

Activity

  1. added
    concurrency
    engine
    on Sep 18, 2026
  2. added this to the 26.10.1 milestone on Sep 18, 2026
  3. added
    severity:critical
    on Sep 19, 2026
  4. added
    in progress
    on Sep 21, 2026
  5. self-assigned this
    on Sep 21, 2026
  6. added a commit that references this issue on Sep 21, 2026
  7. lvca commented on Sep 21, 2026

    @lvca
    Member

    Fixed in 26.10.1.

    On a Graph Analytical View, a compaction rebuilds the graph while transactions keep arriving, and those transactions are replayed on top afterwards. The replay skipped an edge whenever the rebuilt graph already held any edge between the same two vertices - so adding a second edge between an already-connected pair during a compaction dropped it. getNeighborIds, isConnectedTo and countEdgesBetween then reported that pair once instead of twice, until the next compaction.

    The replay now compares how many edges the pair had before the compaction with how many the rebuild captured, and skips only that many. This mirrors the fix already applied to the deletion side in #7042.


    ❤️ 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 Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugconcurrencyengineseverity:critical

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions