Skip to content

WHERE-less aggregation/ORDER BY/DISTINCT over a plain scan ignores arcadedb.command.timeout (plain scan sources carry no WorkGuard) #6465

Closed

Description

@ruispereira

Summary

A query with no WHERE clause and no explicit SQL TIMEOUT clause that feeds a blocking consumer (aggregation, ORDER BY, DISTINCT) drains the whole type server-side with nothing consulting arcadedb.command.timeout. The plain scan sources carry no WorkGuard, and the blocking consumers honor only the legacy TIMEOUT-clause value, not the command deadline.

Where (HEAD 0291182af)

Unguarded scan sources (zero WorkGuard/getCommandDeadline references): engine/src/main/java/com/arcadedb/query/sql/executor/FetchFromTypeExecutionStep.java (sequential path), FetchFromClusterExecutionStep.java, FetchFromClustersExecutionStep.java, FetchFromIndexStep.java, FetchFromIndexValuesStep.java, FetchFromRidsStep.java. Only ScanWithFilterStep/FilterStep (used when a WHERE exists) are guarded.
Blocking consumers honoring only the legacy TIMEOUT clause (timeoutMillis, not the command deadline): AggregateProjectionCalculationStep.java:129-130, OrderByStep.java:113-114; DistinctExecutionStep.java:124 honors no timeout at all. info.timeout is only the explicit SQL TIMEOUT clause (SelectExecutionPlanner.java:148-154), so with no clause timeoutMillis == -1 and the legacy check is disabled — while the planner comment claims the command deadline is "carried ... [where] no statement kind can miss" it.

Repro (server has arcadedb.command.timeout set, no per-query TIMEOUT clause)

  • SELECT max(x) FROM HugeType (or sum/avg/any GROUP BY, no WHERE) — the aggregate drains the unguarded scan past the deadline.
  • SELECT FROM HugeType ORDER BY x — ORDER BY accumulates the unguarded scan (only bounded by QUERY_MAX_HEAP_ELEMENTS_ALLOWED_PER_OP, not by time).
  • SELECT DISTINCT lowCardinalityField FROM HugeType — one next() scans the whole table inside a single fetchNext with no check.
    (SELECT count(*) FROM HugeType is safe — O(1) CountFromTypeStep.)

Suggested fix

Add WorkGuard.forCommandDeadline(context) + guard.checkPeriodically() to the plain scan iterators, or have the blocking consumers guard their drain loops on the command deadline (not just timeoutMillis).

Scope / confidence

Medium — behavior is certain (the plain-scan sources have no guard, verified); the only open question is whether the authors consider the WHERE-less + blocking case in scope, but their own "no statement kind can miss the deadline" comment says it should be. Distinct from #5886 and #6373.

Activity

  1. added this to the 26.9.1 milestone on Aug 19, 2026
  2. added
    in progress
    on Aug 23, 2026
  3. self-assigned this
    on Aug 23, 2026
  4. lvca commented on Aug 24, 2026

    @lvca
    Member

    Fixed in #6662 (merged).

    If you set a server-wide query timeout (arcadedb.command.timeout) and ran a query with no WHERE clause that also needed aggregation, ORDER BY, or DISTINCT (e.g. SELECT max(x) FROM HugeType), the timeout was silently ignored - the query could run to completion no matter how long it took. Queries with a WHERE clause were already correctly bounded by the timeout. Now every plain full-table/index scan respects the configured timeout too.


    ❤️ 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.

  5. removed
    in progress
    on Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions