Skip to content

Concurrent SET a.counter = a.counter + 1 silently loses updates over HTTP #5227

Closed

Description

@shulei5831sl

ArcadeDB Version

26.8.1-SNAPSHOT (build a4834554)
Docker image ID: 7ddb11ca4db3
Digest: arcadedata/arcadedb@sha256:dd4bb8997495abeca132a93b496f9ae4da1120d0e5880867cf879505ab07fa6d

Description

When multiple HTTP clients concurrently execute SET a.counter = a.counter + 1 on the same node, some successfully acknowledged increments are silently lost. The server returns HTTP 200 with a result field and no error/exception, but the final counter value is lower than the number of successful responses. Two requests can even return the same counter value, proving both read an identical stale version.

Steps to Reproduce

See attached repro.py.

Summary: worker threads execute increments via independent HTTP sessions. The query is:

MATCH (a:Cnt {id:1})
SET a.counter = a.counter + 1
RETURN a.counter AS value

A response is only counted as successful if: HTTP 200, result array present with data, no error or exception field in the body. The final counter value is read only after all worker threads have completed.

Expected Behavior

ArcadeDB documents that optimistic-transaction integrity is checked at commit time and that a ConcurrentModificationException is thrown if the record was saved by another transaction in the interim. Therefore, concurrent dependent updates to the same vertex should either preserve every successfully acknowledged increment or report a retryable conflict.

Actual Behavior

All 5 runs show lost updates with zero conflict errors:

High-concurrency (20 threads x 50, 4 runs):

Run Successful Final Lost Rate MVCC conflicts
1 681 666 15 2.2% 0
2 666 651 15 2.3% 0
3 694 682 12 1.7% 0
4 481 470 11 2.3% 0

Low-concurrency (4 threads x 100):

Successful HTTP 503 Final Lost MVCC conflicts
281 119 280 1 0

Duplicate return values (4-thread run):

Two successful requests returned the same counter value, directly proving both read an identical stale version before writing:

value=50 returned by worker-2/iteration-19 and worker-0/iteration-24

Across all 5 runs: 0 MVCC conflict errors. No HTTP 200 response contained an error or exception field.

Why This Is a Bug

  1. Silent data loss. The server acknowledges 281–694 successful responses per run, but increments are missing from the final value. No error or conflict notification.

  2. Conflict detection never triggers. ArcadeDB documents that MVCC version conflicts should abort conflicting transactions. None were observed.

  3. A single dependent statement. SET a.counter = a.counter + 1 is one Cypher statement where the right-hand side directly depends on the property being updated. Two requests returning the same counter value prove both read the same pre-increment version.

Neo4j Reference

Neo4j 2026.05 Community (also default READ_COMMITTED) tested under identical conditions: 0 lost updates in 3 runs. Neo4j documents that for SET n.prop = n.prop + 1, the Cypher runtime reads the property under a write lock because the expression directly references the property being set, preventing lost updates without requiring SERIALIZABLE isolation.

Workarounds

No equivalent atomic increment or explicit locking mechanism was identified for this Cypher command path. Possible alternatives are:

  • Serialize the operation at the application layer;
  • Implement compare-and-set/version checking with client-side retry;
  • Rewrite the operation as an SQL Script using COMMIT RETRY or an explicit type/bucket lock (documented in ArcadeDB SQL Script reference).

These workarounds do not prevent an ordinary successful Cypher SET a.counter = a.counter + 1 request from silently losing an update.

Attachments

  • repro.py — Python reproduction script
  • evidence.md — Full evidence with 5-run results, duplicate value analysis, and Neo4j comparison

Activity

  1. self-assigned this
    on Jul 11, 2026
  2. added this to the 26.8.1 milestone on Jul 11, 2026
  3. added theissue type on Jul 11, 2026
  4. added a commit that references this issue on Jul 11, 2026
  5. lvca commented on Jul 11, 2026

    @lvca
    Member

    Confirmed and fixed on main for the next release.

    This was a regression: concurrent SET a.counter = a.counter + 1 on the same node could silently lose some increments, because the value on the right-hand side was read from the state loaded by MATCH rather than the record's latest committed state. If another transaction committed in that small window, its update was overwritten with no conflict reported.

    The fix makes SET evaluate the right-hand side against the record's current committed value before writing. Concurrent increments now either all apply, or surface a normal retryable conflict that ArcadeDB retries transparently. This keeps the simultaneous-assignment behaviour of SET a.x = a.y, a.y = a.x (still a swap).

    Thanks for the clear, reproducible report and the Neo4j comparison; both made this quick to pin down. Please upgrade once the next build is out.


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

  6. added a commit that references this issue on Aug 14, 2026
  7. added a commit that references this issue on Aug 28, 2026
  8. added a commit that references this issue on Sep 29, 2026
  9. added a commit that references this issue on Oct 6, 2026
  10. added a commit that references this issue on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions