Repository navigation
Description
Summary
DROP TYPE does not remove the dropped type's ALIASES from the schema's shared type map. LocalSchema.dropType
removes exactly one key - the type's own name - and nothing anywhere removes the alias keys, which still point
at the dropped LocalDocumentType instance.
Three consequences, all reproduced:
existsType("<alias>")keeps answeringtrueandgetType("<alias>")keeps returning the dropped,
bucket-less type.- A later
ALTER TYPE Other ALIASES <alias>is refused with "already used by type 'Order'", naming a type
that no longer exists. This one is new: LocalDocumentType.setAliases does a check-then-put on the shared type map with no write lock, the two holes just closed in rename(), createProperty and dropProperty #8064's fix replaced the check-then-put with an atomic
putIfAbsent, so the stale entry is now a hard refusal rather than a silently overwritten map value. - Worse than either, the dropped type is written back into
schema.jsonand comes back alive after a
restart.serializeConfigurationiteratestypeMap().values()and keys each entry byt.getName(), and
the dropped instance is still reachable through its alias key - so it is re-serialised under its own name,
with zero buckets, andexistsType("Order")answerstrueagain on the next open.
This is a different mechanism from #8064 (which was about the reservation in setAliases not being atomic) and
is not a regression from it; #8064's fix only turns consequence 2 from silent into loud.
Where (HEAD 9a88be7)
The drop removes one key, the type's own name -
engine/src/main/java/com/arcadedb/schema/LocalSchema.java:2465-2466
if (typeMap().remove(typeName) == null)
throw new SchemaException("Type '" + typeName + "' not found");Everything else the drop tears down is enumerated just above it (indexes, edge files, buckets, the TimeSeries
engine); aliases are not among them. The only other typeMap().remove call sites in the tree are inside
LocalDocumentType - :376 and :385 for rename(), :589 and :596 inside setAliases - so no path
deregisters an alias on drop.
The lookups that then answer for a dropped type -
engine/src/main/java/com/arcadedb/schema/LocalSchema.java:2355-2359 and :2388-2390
public LocalDocumentType getType(final String typeName) {
final LocalDocumentType t = typeMap().get(typeName);
if (t == null)
throw new SchemaException("Type with name '" + typeName + "' was not found");
return t;
} public boolean existsType(final String typeName) {
return typeMap().containsKey(typeName);
}The refusal that now names a non-existent type, from #8064's atomic reservation -
engine/src/main/java/com/arcadedb/schema/LocalDocumentType.java:575-583
final LocalDocumentType owner = schema.typeMap().putIfAbsent(alias, this);
if (owner != null)
...
throw new SchemaException(owner == this ?
"Cannot set alias '" + alias + "' for type '" + name + "' because it is the name of the type itself" :
"Cannot set alias '" + alias + "' for type '" + name + "' because it is already used by type '"
+ owner.getName() + "'");And the resurrection, in the serialiser that dropType's own finally calls through saveConfiguration() -
engine/src/main/java/com/arcadedb/schema/LocalSchema.java:3534-3538
final JSONObject types = new JSONObject();
root.put("types", types);
for (final DocumentType t : typeMap().values())
types.put(t.getName(), t.toJSON());typeMap().values() still contains the dropped instance, once for each alias key that survived.
Repro
On a fresh embedded database:
CREATE DOCUMENT TYPE Order;
CREATE DOCUMENT TYPE Invoice;
ALTER TYPE Order ALIASES PO;
DROP TYPE Order;Same session:
before drop: existsType(PO)=true
after drop: existsType(Order)=false
after drop: existsType(PO)=true
after drop: getType(PO)=Order buckets=0
ALTER TYPE Invoice ALIASES PO -> SchemaException: Cannot set alias 'PO' for type 'Invoice' because it is already used by type 'Order'
The refusal names Order, which the line above proves does not exist.
Close the database and reopen it. schema.json as written by the drop:
{"Invoice":{"type":"d","parents":[],"buckets":["Invoice_0"],"aliases":[],"properties":{},"indexes":{},"custom":{}},
"Order":{"type":"d","parents":[],"buckets":[],"aliases":["PO"],"properties":{},"indexes":{},"custom":{}}}
and after the reopen:
after reopen : existsType(Order)=true existsType(PO)=true
after reopen : INSERT INTO Order -> SchemaException: Cannot retrieve a bucket for type 'Order' because there are no buckets associated
The dropped type is back, permanently, as an unusable bucket-less type that has to be dropped a second time -
and dropping it a second time leaves the alias behind again.
Suggested fix
Deregister the type's aliases in dropType, alongside the name:
for (final String alias : type.getAliases())
typeMap().remove(alias, type);
if (typeMap().remove(typeName, type) == null)
throw new SchemaException("Type '" + typeName + "' not found");remove(key, value) rather than remove(key) for the same reason setAliases uses it: an alias that has
since been reassigned to another type must not be taken away from it.
A regression test should assert, after DROP TYPE of a type carrying an alias: existsType(alias) is false,
getType(alias) throws, a later ALTER TYPE Other ALIASES <alias> succeeds, and - the one that matters most -
the type does not reappear after a close and reopen. It is also worth asserting that getTypes() no longer
contains the dropped instance; it is deduplicated by LinkedHashSet (LocalSchema.java:2352) but the stale
alias entry keeps the instance in values(), so it is listed today.
Scope / confidence
Reproduced end to end against this HEAD; every line of output above is from the run, including the
schema.json contents. Pre-existing, and independent of #8064 - that fix is only what turns the alias
collision into a loud refusal instead of a silent overwrite. Severity is medium to high: the on-disk schema
is corrupted by an ordinary DROP TYPE, the corruption survives restarts, and the only symptom an operator
sees is a nonsensical error message naming a type they deleted.
Activity
fix(#8169): DROP TYPE deregisters the type's ALIASES, so the dropped …
robfrank commentedon Sep 22, 2026
Fixed in #8195.
DROP TYPEremoved only the type's own key from the schema's type map and left every alias key still pointing at the dropped, bucket-less instance. The save thatdropTypeperforms in its ownfinallythen serialised that instance straight back intoschema.jsonunder the type's real name with zero buckets, which is why the type reappeared at the next open, whyexistsType(<alias>)kept answeringtrue, why a laterALTER TYPE ... ALIASESrefused the alias while naming a type that no longer existed, and whyCHECK DATABASEstill walked it. The type is now deregistered under every name it answers to, so nothing survives the drop to be written back.Working on it turned up a second way in that you did not report:
getType()resolves aliases, so the argument toDROP TYPEcan itself be an alias, and three places compared the caller's raw string against the canonical one. That meantDROP TYPE <alias>could drop a materialized view's or continuous aggregate's source type out from under it. The canonical name is now resolved once up front and used for those guards.Still open
DROP TYPEon it a second time, which now actually sticks where before it did not. That needs a release note and possibly a load-time warning when a type is restored with zero buckets.DROP TYPE <alias>now drops the whole type, rather than refusing because the name given was an alias. That is the behaviour the fix settles on.❤️ 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(ArcadeData#8187,ArcadeData#8170,ArcadeData#8158,ArcadeData#8153,A…