Repository navigation
Description
Body:
Summary
The concurrent-DDL guard now covers five planner surfaces: the SQL planner (#8855), and the openCypher MATCH,
MERGE, planner-statistics and relationship-index walks (#8918). Two surfaces are left, and both throw the
reported exception out to the caller rather than falling back to a scan.
SQL execution, not planning. SelectExecutionPlanner picks an index that is ready, builds a plan, and
FetchFromIndexStep then reads the index's key types at EXECUTION time with no guard. A DROP INDEX between
the two leaves the step holding an invalidated TypeIndex, and TypeIndex.checkIsValid() throws straight
through the result set. The planner-side guard cannot close this: nothing re-plans between the two points.
The native database.select() API. SelectExecutor.matchCompositeIndex walks getAllIndexes(true) and
calls candidate.getPropertyNames() with neither the readiness filter nor a try/catch - the same shape as the
three openCypher walks, in the one query surface that is not SQL and not Cypher. isTheNodeFullyIndexed
(SelectExecutor.java:857) has the other half of it, found.getType().isExactKeyLookup() with a null check on
found but not on what getType() answers, which is the NPE #8918 described.
Two more sites have the same unguarded getType() dereference and are reachable the same way, though I did not
reproduce them: LocalDatabase.lookupByKey (LocalDatabase.java:1133) and the Gremlin index pick
(ArcadeTraversalStrategy.java:158). All four reach the index through getPolymorphicIndexByProperties rather
than getAllIndexes, which is why a sweep that went by the collection did not find them.
Where
engine/src/main/java/com/arcadedb/query/select/SelectExecutor.java:435
for (final TypeIndex candidate : select.fromType.getAllIndexes(true))
if (candidate.getPropertyNames().size() >= 2 && candidate.supportsOrderedIterations())
candidates.add(candidate);engine/src/main/java/com/arcadedb/query/select/SelectExecutor.java:857
final TypeIndex propertyIndex = found != null && found.getType().isExactKeyLookup() ? found : null;engine/src/main/java/com/arcadedb/query/sql/executor/FetchFromIndexStep.java:619 (reached from init, at
execution time, on an index the planner validated earlier)
engine/src/main/java/com/arcadedb/database/LocalDatabase.java:1133
if (!idx.getType().isExactKeyLookup())gremlin/src/main/java/com/arcadedb/gremlin/ArcadeTraversalStrategy.java:158
if (index == null || !index.getType().isExactKeyLookup())Repro
200 documents of type Person with a LONG id. Eight reader threads, two per flavour
(database.lookupByKey, database.select(), SQL SELECT, openCypher MATCH), each querying a random id,
while the main thread runs 150 rounds of CREATE INDEX ON Person (id) NOTUNIQUE / DROP INDEX Person[id] -
DDL on the property the readers actually use:
answered=31667
20494x lookupByKey -> IllegalArgumentException: No index has been created on type 'Person' properties [id]
285x select -> IndexException: Index 'Person[id]' is not valid. Probably has been drop or rebuilt
105x sql -> IndexException: Index 'Person[id]' is not valid. Probably has been drop or rebuilt
0x opencypher
openCypher answers every one of its statements, which is the guard working. The lookupByKey line is that
method's documented answer when no index exists and is not part of this report. The stacks for the other two:
at com.arcadedb.index.TypeIndex.getFirstUnderlyingIndex(TypeIndex.java:793)
at com.arcadedb.index.TypeIndex.getBinaryKeyTypes(TypeIndex.java:585)
at com.arcadedb.query.sql.executor.FetchFromIndexStep.mapInexactIntegralBounds(FetchFromIndexStep.java:619)
at com.arcadedb.query.sql.executor.FetchFromIndexStep.init(FetchFromIndexStep.java:551)
at com.arcadedb.index.TypeIndex.getFirstUnderlyingIndex(TypeIndex.java:793)
at com.arcadedb.index.TypeIndex.getPropertyNames(TypeIndex.java:345)
at com.arcadedb.query.select.SelectExecutor.matchCompositeIndex(SelectExecutor.java:436)
at com.arcadedb.query.select.SelectExecutor.lookForIndexes(SelectExecutor.java:371)
Additional reproduction for the native path
A document type Person with ten records and a permanent unique index on id. Four threads run the
native database.select().fromType("Person").where().property("id").eq().value(n), four more run the
SQL equivalent SELECT id FROM Person WHERE id = n as a control, and the main thread runs 1500
CREATE INDEX ON Person (p, q) NOTUNIQUE / DROP INDEX Person[p,q] cycles on two unrelated
properties that no query mentions.
### Suggested fix
For `database.select()`, the two existing helpers already fit: `TypeIndex.filterReadyForQueries` for the
`matchCompositeIndex` walk and `getPropertyNamesIfExactKeyLookup` for `isTheNodeFullyIndexed`, exactly as the
openCypher walks now use them. `LocalDatabase.lookupByKey` and the Gremlin pick want the same
`getPropertyNamesIfExactKeyLookup` treatment.
For `FetchFromIndexStep` the answer is different, because the index was valid when the plan was built: the step
should treat an `IndexException` from the index it holds as "this plan is stale" and either re-plan or fall
back to the type scan, the way `NodeIndexRangeScan` already raises an explicit "re-plan the query" error rather
than letting the raw `IndexException` out. At minimum the exception should carry that explanation.
### Scope / confidence
Reproduced on a freshly built engine; the counts and stacks above are real output from one run. The existing
regression suite does not see this because it churns indexes on properties the readers never query, so the
reader never resolves the index being dropped; the run above moves the DDL onto the queried property. Severity:
a correct, read-only query fails outright during an online index rebuild. Frequency depends on the DDL rate -
roughly 1 statement in 100 here, with a create/drop pair running continuously.
Activity
github-actions commentedon Oct 6, 2026
Merged into #9362, which now tracks this together with the other related issues in concurrency. Closing here as a duplicate - reopen this issue if the grouping is wrong.
fix: TimeSeries engines built after WAL replay, index DDL during read…
fix: TimeSeries engines built after WAL replay, index DDL during read…
fix(#11219): a SQL MATCH whose index is dropped before the first row …
fix(#11219): a SQL MATCH whose index is dropped before the first row …
fix: five engine races and two test races behind the flaky engine tes…
fix: engine races and test races behind the flaky engine tests on main (
fix(#12139): a transaction reading a page of an index dropped under i…
fix(#11835): a write racing a DDL on its index is a retryable conflic…