Summary
LocalDocumentType has now had three issues about the same pattern - #6678 made two fields volatile,
#7033 added buckets/bucketIds, #7119 added bucketSelectionStrategy - and each fix has addressed
only the member the issue named. The sweep #7119 asked for was not run, so a fourth pass finds a
fourth subset.
aliases is the sixth member, and it has a second problem at the same line: setAliases publishes
the caller's set by reference rather than the copy it already built.
1. aliases - non-volatile, and published by reference.
engine/src/main/java/com/arcadedb/schema/LocalDocumentType.java:63:
private Set<String> aliases = Collections.emptySet();
Copy-on-write reassigned at :438 in setAliases, under the schema mutation path. Read lock-free at
:347 by instanceOf(String), which openCypher's Labels calls during query planning
(engine/.../query/opencypher/Labels.java:344, :355, :372, :390) holding no database lock. That
is the identical argument #6678 and #7033 were accepted on. Also reassigned by a runtime caller,
integration/.../JsonlImporterFormat.java:364.
The second problem: setAliases builds newAliases and then assigns this.aliases = aliases - the
parameter - rather than this.aliases = newAliases. So the caller retains a live reference to schema
state that a lock-free instanceOf is reading, and can mutate it after the call.
2. name - same shape.
LocalDocumentType.java:59:
Non-volatile, reassigned on rename at :247 with a rollback at :264, read lock-free by getName()
and by instanceOf at :344.
3. PartitionedBucketSelectionStrategy.type - a nit, but it is the field the #7119 reasoning rests on.
engine/.../bucketselectionstrategy/PartitionedBucketSelectionStrategy.java:77:
private LocalDocumentType type;
Non-volatile, dereferenced on the lock-free read path (getBucketIdByRecord :182,
getBucketIdByKeys :202). setType (:113-116) does the volatile write first
(super.setType(type)) and the plain write second, so the volatile write gives this.type no
happens-before edge on the rebind route the total fix was written for.
Practical impact here is low - the rebind stores the same non-null object, and first publication is
carried by the volatile bucketSelectionStrategy write. Included because #7119's closing reasoning
depends on this field ("whose type reference was still null"), so it is worth being right about.
Repro
Item 1 is the live one. An openCypher query planning against a type whose aliases were just set by a
concurrent ALTER TYPE or by a JSONL import can read a stale or torn aliases reference, so
instanceOf answers on the previous alias set. Same visibility argument as the three accepted issues
before it.
The publish-by-reference half needs no concurrency at all: a caller that keeps its set and mutates it
later is changing live schema state directly.
Suggested fix
Make aliases and name volatile, and change setAliases to publish newAliases rather than the
parameter.
The more useful fix, and the reason this is a fourth report: add the shared helper #7119 suggested,
so publishing a copy-on-write member of this class is one call that does the copy and the volatile
write together. Six fields have now been found one at a time; a seventh will be found the same way
otherwise. A test that reflects over the class's fields and asserts every non-final reference member
is volatile would close the series properly.
Scope / confidence
Confidence high on items 1 and 2, including the lock-free reader paths, which were traced to the
openCypher call sites. Item 3 is filed explicitly as a nit rather than a defect, with the reason it is
worth mentioning stated.