Repository navigation
Description
Summary
LocalDocumentType.setAliases mutates the schema's shared type map with a check-then-act sequence and no write lock, which is the arrangement the neighbouring mutators were just converted away from.
Two separate holes in the same method:
- Check-then-put. It refuses an alias already used by another type by calling
schema.existsType(alias), then, several statements later, puts the alias intoschema.typeMap(). Nothing holds the map between the two, so two concurrentALTER TYPE ... ALIASESon different types can both pass the check and the second put silently wins. - Unconditional deregistration. It removes every previous alias from
schema.typeMap()before installing the new set. A concurrent reader resolving one of those names sees it disappear even when the new set still contains it, because the remove loop and the put loop are separate passes over a shared map.
The class's own comment on the field already claims the protection this method does not take.
Where (HEAD 28b71e3)
engine/src/main/java/com/arcadedb/schema/LocalDocumentType.java:470-492:
public LocalDocumentType setAliases(final Set<String> aliases) {
checkForSchemaMutation();
final Set<String> newAliases = new HashSet<>(aliases);
newAliases.removeAll(this.aliases);
for (String alias : newAliases) {
if (schema.existsType(alias))
throw new SchemaException("Cannot set alias '" + alias + "' for type '" + name + "' because it is already used by type '"
+ schema.getType(alias).getName() + "'");
}
// DEREGISTER ALL PREVIOUS ALIASES
for (String alias : this.aliases)
schema.typeMap().remove(alias);
for (String alias : aliases)
schema.typeMap().put(alias, this);checkForSchemaMutation() is a precondition check, not a lock. Compare the mutators that were converted: createProperty (:701) and dropProperty (:859) both run every check AND the mutation inside a single recordFileChanges(...) callback, and their javadocs (:678-683, :841-845) state why. rename() (:244) does the same and additionally uses a write-locked typeMap().putIfAbsent.
The field comment at :68-70 says the aliases set is "reassigned by setAliases under the schema mutation lock", which this method never takes.
Repro
Two concurrent ALTER TYPE A ALIASES X / ALTER TYPE B ALIASES X against the same database: both pass existsType("X"), both put, and X resolves to whichever ran second while both types believe they own it. For the second hole, resolve an existing alias repeatedly from another thread while setAliases re-installs a superset: the lookup intermittently fails.
Suggested fix
Wrap the checks and both loops in one recordFileChanges(...) callback, as createProperty and dropProperty now do, and use the write-locked putIfAbsent that rename() uses so the check and the install are one step. Then the field comment at :68 becomes true.
Scope / confidence
Code read. Narrow by nature: it needs concurrent DDL, which is not the common case, and the window is small. Reported because it is the exact pair of holes closed in the sibling mutators, in a method whose own documentation already assumes they were closed here too. What would falsify it: a lock taken by every caller of setAliases above this frame. AlterTypeStatement's aliases arm calls it directly.
Activity
test(schema): assert the claimant threads actually finished before re…
fix(schema): a self-named alias is refused as such, not blamed on the…
Merge pull request #8094 from ArcadeData/fix/issues-8064-8042
lvca commentedon Sep 21, 2026
Fixed in #8094, released in 26.10.1.
ALTER TYPE ... ALIASESchecked whether an alias was already taken and then registered it as two separate steps, with no lock in between. Two such statements running at the same time on different types could both pass the check and both register the same alias, leaving two types believing they owned one name.A second problem in the same place: setting a new alias list first removed all the previous aliases and only then added the new ones, so a name present in both the old and the new list briefly stopped resolving for anyone reading the schema concurrently.
Both are fixed. The alias is now reserved in a single atomic step under the schema lock, only aliases actually being dropped are removed, and a rejected
ALTER TYPEno longer leaves a half-applied alias list behind.❤️ 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.
fix(schema): setAliases reserves a name atomically under the schema w…