Repository navigation
Description
Summary
The native fluent Select API installs the caller's timeout on one iterator shape only. Of the four sources buildIterator() can return, two are not MultiIterators, so timeout() is silently dropped for every index-answered plan and for a single-bucket fromBuckets(...). Nothing else on the serial path consults select.timeoutInMs.
Where (HEAD 9c9d024db)
engine/src/main/java/com/arcadedb/query/select/SelectExecutor.java:224-226:
if (select.timeoutInMs > 0 && iterator instanceof MultiIterator<? extends Identifiable> multiIterator)
multiIterator.setTimeout(...);The two sources that are not MultiIterator:
- the index-answered plan returns
iteratorFromIndexes, aMultiIndexCursor(engine/src/main/java/com/arcadedb/index/MultiIndexCursor.java:30-implements IndexCursor) - a single-bucket
fromBuckets(...)returnsdatabase.iterateBucket(...)->bucket.iterator()(SelectExecutor.java:216)
grep timeoutInMs finds only Select.java, SelectExecutor.java:224, SelectParallelIterator.java and SelectCompiled.json(). Neither MultiIndexCursor nor the bucket iterator has a timeout field or a WorkGuard hook. This affects documents()/vertices()/edges(), count() and exists() alike, since all go through buildIterator().
Repro
The index case is the common one - any fromType plus an indexed WHERE leaf:
db.getSchema().createVertexType("V").createProperty("id", Type.INTEGER)
.createIndex(Schema.INDEX_TYPE.LSM_TREE, true);
db.transaction(() -> { for (int i = 0; i < 100_000; i++) db.newVertex("V").set("id", i).save(); });
final SelectIterator<Vertex> it = db.select().fromType("V")
.where().property("id").ge().value(0) // -> range() cursor -> MultiIndexCursor
.timeout(1, TimeUnit.MILLISECONDS, true).vertices();
while (it.hasNext()) { it.next(); Thread.sleep(1); } // never throws TimeoutExceptionThe same query with the WHERE on a non-indexed property does time out.
SelectExecutionTest.errorTimeout() (engine/src/test/java/com/arcadedb/query/select/SelectExecutionTest.java:282) documents the blind spot without catching it: its first block uses the unindexed name property (so it gets a MultiIterator and passes), and its second block (:299-303) builds an indexed id < 10 select with a timeout and then never iterates it, so it asserts nothing.
Suggested fix
Enforce the deadline in the consumer rather than in one source type: capture the deadline in SelectIterator/SelectExecutor and check it in SelectIterator.fetchNext() and in the executeCount()/executeExists() loops. SelectParallelIterator already does exactly this via it.checkForTimeout(). Keep the MultiIterator.setTimeout() call as the fast path.
Scope / confidence
High. This is about the native fluent Select's own timeout(), not the SQL-side arcadedb.command.timeout covered by #6266/#6465.
Activity
ruispereira commentedon Aug 27, 2026
Companion finding on the same feature: #6816 -
MultiIterator.hasNextInternal()throws unconditionally, so even on the paths where the timeout is installed,Select.timeout(v, unit, false)(the non-throwing mode) cannot truncate. The two together are why the fluenttimeout()is effectively unusable today.fix(sql): native Select must honour its own timeout() and round-trip …
robfrank commentedon Aug 28, 2026
Fixed in #6872.
The timeout was being handed to the source iterator, and only one of the four kinds of source the planner can pick knew what to do with it. An index-answered query and a single-bucket
fromBuckets(...)both got a source that had nowhere to store a deadline, sotimeout()quietly did nothing for them - which covered the most common query shape of all, anyfromTypewith an indexed WHERE.The deadline now belongs to the code that consumes the records rather than to the iterator that produces them, so every plan shape passes through the same check. This applies to
documents()/vertices()/edges(),count()andexists()alike, and a select with notimeout()set is unaffected.One related gap is tracked separately in #6873: the vector k-NN path (
nearestTo()) is a fifth plan shape that still ignorestimeout().❤️ 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.