Repository navigation
Description
ArcadeDB version
Reproduced on arcadedata/arcadedb:26.7.3 and arcadedata/arcadedb:26.8.1-SNAPSHOT.
Not present on 26.4.1-SNAPSHOT (which errors instead), so this is a behaviour
regression introduced after 26.4.1.
Summary
When a property already carries a NOTUNIQUE index, CREATE INDEX IF NOT EXISTS ... UNIQUE on that same property returns success without creating a unique
constraint. The caller is told the unique index exists; duplicates are then
accepted. Issuing the same statement without IF NOT EXISTS correctly reports
the conflict, so the guard clause is suppressing an error the server already
knows how to raise.
IF NOT EXISTS appears to match on the indexed property set alone and to ignore
the requested uniqueness. It affects plain and BY ITEM indexes equally.
Steps to reproduce
CREATE VERTEX TYPE T;
CREATE PROPERTY T.Scalar STRING;
CREATE INDEX ON T (Scalar) NOTUNIQUE;
-- reports success, but creates no unique constraint
CREATE INDEX IF NOT EXISTS ON T (Scalar) UNIQUE;
INSERT INTO T SET Tag = 'a', Scalar = 'x';
INSERT INTO T SET Tag = 'b', Scalar = 'x'; -- accepted
Expected
Either the unique index is created and the second insert is rejected with
DuplicatedKeyException, or the statement fails because the existing index
conflicts with the requested definition.
Actual
CREATE INDEX IF NOT EXISTS ... UNIQUE returns success. SELECT FROM schema:indexes shows only non-unique indexes on T:
T[Scalar] unique=false
T_0_516462088483265 unique=false
The duplicate insert succeeds.
Contrast: without the guard clause, the conflict is reported
CREATE INDEX ON T (Scalar) UNIQUE;
{"error":"Cannot execute command",
"exception":"com.arcadedb.exception.CommandExecutionException",
"detail":"Index 'T[Scalar]' already exists"}
Also affects BY ITEM
CREATE VERTEX TYPE L;
CREATE PROPERTY L.Items LIST OF STRING;
CREATE INDEX ON L (Items BY ITEM) NOTUNIQUE;
CREATE INDEX IF NOT EXISTS ON L (Items BY ITEM) UNIQUE; -- reports success
INSERT INTO L SET Tag = 'a', Items = ['x'];
INSERT INTO L SET Tag = 'b', Items = ['x']; -- accepted
Not affected: the reverse direction
Creating UNIQUE first and then a guarded NOTUNIQUE leaves the unique
constraint intact and correctly rejects the duplicate.
Behaviour on 26.4.1-SNAPSHOT
The guarded statement fails loudly rather than silently:
{"error":"Error on transaction commit",
"exception":"com.arcadedb.index.IndexException",
"detail":"Error on creating index on type 'T', properties [Items by item]
-> ... Index 'T[Itemsbyitem]' is not valid."}
Impact
Schema-migration DDL commonly uses CREATE INDEX IF NOT EXISTS so it can be
re-applied idempotently. Under that pattern, tightening an index from
NOTUNIQUE to UNIQUE silently does nothing, and the application proceeds
believing a uniqueness constraint protects the data.
Activity
fix(engine) #5675: restore the page size too, and scope a manual inde…
fix(engine) #5675: pin the manual-name restore, the inherited refusal…
fix(engine) #5675: say what satisfiesRequest does not compare, and po…
docs(engine) #5675: mark the getOrCreateTypeIndex change BREAKING
fix(engine) #5675: CREATE INDEX IF NOT EXISTS answers for the index a…
lvca commentedon Aug 2, 2026
Fixed in #5740, merged as 4966b4b. Thanks for the precise report — the contrast you drew between the guarded and unguarded forms, and the note that 26.4.1 failed loudly, is what located this quickly.
What was wrong.
IF NOT EXISTSmatched a pre-existing index on the auto-derived index name, and that name is built from the indexed property set alone — it says nothing about what the index does. So aNOTUNIQUEindex answered "already there" to a request for aUNIQUEone. Your diagnosis was exactly right.What it does now.
IF NOT EXISTSis satisfied only when the existing index provides what was asked for: the same index kind, and a uniqueness constraint at least as strong.NOTUNIQUEtoUNIQUEtells you the existing index is in the way instead of silently doing nothing.UNIQUEindex indexes the same keys aNOTUNIQUEone would, and it is never weakened into a plain index.BY ITEMform behaves identically — it was the same bug.FULL_TEXTindex where a range index was requested) was ignored the same way, and is now reported too.Two things your report uncovered that were worse than the symptom. Underneath the guard, the builder reacted to a uniqueness mismatch by dropping the existing index and rebuilding it. When the stored data cannot satisfy the new definition the rebuild fails — and the type is left with no index at all. That path also took away a parent type's index when the index was inherited (#4083). Both are gone: nothing is dropped implicitly, and the one caller that genuinely means "make this the definition" (Cypher
CREATE CONSTRAINT ... IS UNIQUE) restores the previous index if the new one cannot be built.One thing to know if you use the embedded API.
LocalSchema.getOrCreateTypeIndex(...)inherits this: asked for aUNIQUEindex where aNOTUNIQUEone exists, it now raises instead of rebuilding. If you were using it as an "ensure/upgrade this index" helper, drop the old index explicitly, or build throughbuildTypeIndex(...).withReplaceIfIncompatible(true)if replacing is really what you mean. It is flagged as BREAKING in the 26.8.1 release notes because it surfaces at runtime, not at compile time.lvca commentedon Aug 2, 2026
Follow-ups from this fix are tracked in #5765 — chiefly that
ManualIndexBuilderstill carries the same silent drop-and-rebuild and the same dead null-strategy condition that this issue removed from the type-index path.fix(engine) #5765: creating a manual index no longer fences the datab…
fix(engine) #5675: CREATE INDEX IF NOT EXISTS answers for the index a…
fix(engine) #5765: creating a manual index no longer fences the datab…
fix(schema): same copy point for the bucket-level builder swap (#5606)
fix(schema): one copy point for the index builder swap (ArcadeData#5606)