Skip to content

AbstractProperty's constraint flags are read lock free by DocumentValidator but are not safely published, while two fields in the same class are volatile #9989

Closed

Description

@ruispereira

Summary

AbstractProperty's constraint flags are written by ALTER PROPERTY and read lock free by
DocumentValidator on every write, with no safe publication. Two members of that same class already
carry volatile for exactly this argument, which is what makes the omission visible rather than
debatable.

protected              Map<String, Object> custom          = new HashMap<>();   // :39
protected              boolean             readonly        = false;            // :40
protected              boolean             mandatory       = false;            // :41
protected              boolean             notNull         = false;            // :42
protected              boolean             hidden          = false;            // :43
protected volatile     boolean             external        = false;            // :49  <-- volatile
protected              String              compression     = null;             // :55
protected              String              max             = null;             // :56
protected              String              min             = null;             // :57
protected              String              regexp          = null;             // :58
protected              String              ofType          = null;             // :59
protected volatile     DefaultValue        defaultValue    = DefaultValue.NOT_SET; // :65  <-- volatile

A thread executing an insert can therefore validate against a stale notNull, mandatory, min,
max or regexp after another thread has altered the property, with no happens before edge between
the two.

The sweep that should have caught it

#7033 declared the copy on write family, documented it, grew it to six members and, unusually and
commendably, enforced it with a reflective sweep test that fails on any non final, non volatile
member. That is the one fix in its batch that expressed a rule rather than patching a case.

The sweep stops at LocalDocumentType and does not descend to AbstractProperty. It also accepts
final as a proxy for "immutable or concurrent", which is why the custom map survives it: the field
is a plain HashMap, one field away from the map #6799 made concurrent for the very same
toJSON() after unlock reason.

Suggested fix and the guarantee

Mark the constraint flags volatile, as external and defaultValue already are, and make custom
concurrent as #6799 did for its neighbour.

The guarantee already exists and only needs widening: extend #7033's reflective sweep to
AbstractProperty and tighten its final acceptance so that a final field of a non concurrent
mutable type does not pass. Without the second half, a final HashMap keeps satisfying the test while
being exactly the thing the test exists to prevent.

Scope

Verified at 8564d3ad79. Static argument: no race is demonstrated here, since a missing happens before
edge is not reliably reproducible, but the inconsistency within one class is on the lines above.

Activity

  1. added
    concurrency
    engine
    severity:minor
    on Oct 13, 2026
  2. added
    in progress
    on Oct 14, 2026
  3. self-assigned this
    on Oct 14, 2026
  4. added this to the 26.11.1 milestone on Oct 14, 2026
  5. added 3 commits that reference this issue on Oct 14, 2026
  6. lvca commented on Oct 14, 2026

    @lvca
    Member

    Fixed in #10011 (release 26.11.1).

    Property constraints (MANDATORY, NOTNULL, READONLY, MIN, MAX, REGEXP, custom values...) changed with ALTER PROPERTY are now always seen right away by writes running at the same time. The automated check that guards this now covers properties too, and it found and fixed a few more schema structures with the same problem. As a bonus, a REGEXP is no longer recompiled on every write.


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

  7. removed
    in progress
    on Oct 14, 2026
  8. added 3 commits that reference this issue on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

concurrencyengineseverity:minor

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions