Query Limits
A runtime-entity query that loads every entity of a CK type can exhaust the memory of the asset repository, especially when
the type carries large attributes (raw messages, documents, JSON payloads). The asset repository therefore watches for
unbounded queries and, depending on its configuration, logs and counts them or refuses them with the error code
ASSET1007. Every runtime query also has a server-side time limit (error ASSET1008).
What counts as unbounded
A query is bounded when it selects no items, edges or nodes, when it is an aggregation or grouping aggregation
query, or when at least one of these holds:
- it has
firstat most the configured maximum page size (default 1000), - it is a key lookup (
rtId/rtIds) with at most the maximum page size of keys (with or withoutfirst).
Every other query that selects items, edges or nodes is unbounded, that is one with
- no
firstargument and no key lookup, firstabove the maximum page size and no key lookup within the limit,- a key lookup with more keys than the maximum page size and no
firstwithin the limit.
These queries are therefore never unbounded:
- a page with
firstat most the maximum page size, - a key lookup with at most the maximum page size of keys,
- a query that selects only
totalCount(noitems/edges), - aggregation and grouping aggregation queries (persisted or transient).
The limit applies to these GraphQL entry points of the asset repository:
| Entry point | Example |
|---|---|
runtime.<CkType> | runtime { industryEnergyEnergyMeter(first: 100) { items { rtId } } } |
runtime.runtimeEntities | runtime { runtimeEntities(ckId: "Industry.Energy/EnergyMeter", first: 100) { items { rtId } } } |
| Persisted query rows | runtime { runtimeQuery(rtId: "…") { items { rows(first: 100) { items { … } } } } } |
| Transient query rows | runtime { transientQuery { simple(…) { items { rows(first: 100) { items { … } } } } } } |
The SDK, octo-cli and the MCP tools reach the asset repository through these entry points, so the same rules apply to them. Calls that services make inside the platform (communication controller, background jobs, blueprint installation, CK migrations, pipelines that read through the engine) are not affected.
Modes
The limit is staged per deployment:
| Mode | An unbounded query |
|---|---|
Off | runs; nothing is checked |
Warn (default) | runs as before; the asset repository writes a warning to its log and counts the query in the metric octo_asset_runtime_query_unbounded_total |
Enforce | is refused with ASSET1007 before the entities are read; logged and counted as in Warn. The result is never shortened silently |
Operators switch a cluster to Enforce only after the warnings show that no caller still sends unbounded queries.
Configuration
Asset repository settings (section RuntimeQueryGuard, environment variables with the OCTO_ prefix):
| Setting | Environment variable | Values | Default |
|---|---|---|---|
RuntimeQueryGuard:Mode | OCTO_RUNTIMEQUERYGUARD__MODE | Off, Warn, Enforce | Warn |
RuntimeQueryGuard:MaxPageSize | OCTO_RUNTIMEQUERYGUARD__MAXPAGESIZE | positive integer | 1000 |
Monitoring
In Warn and Enforce (never in Off), each unbounded query increments the counter octo.asset.runtime_query.unbounded (PromQL:
octo_asset_runtime_query_unbounded_total) with the labels tenant, ck_type, client_id and mode (ck_type is unknown when runtimeEntities is called with
an id that is no CK type of the tenant). Example: unbounded
queries per client in the last day:
sum by (client_id, ck_type) (increase(octo_asset_runtime_query_unbounded_total[1d]))
The warning log line (also Warn and Enforce only) names the tenant, the CK type, the requested first, the number of keys, the client id, the subject id,
the GraphQL operation name and an error id.
Error ASSET1007
{
"errors": [
{
"message": "The query on CK type 'Industry.Energy/EnergyMeter-1' is unbounded and was refused: it selects items without 'first'. Request at most 1000 items per page with 'first' (and 'after' for the next page), or select only 'totalCount' to count. Error id 3f2c9a….",
"path": ["runtime", "industryEnergyEnergyMeter"],
"extensions": {
"code": "ASSET1007",
"errorId": "3f2c9a…",
"parameters": {
"ckTypeId": "Industry.Energy/EnergyMeter-1",
"maxPageSize": 1000,
"requestedFirst": null,
"keyCount": null,
"reason": "NoFirst"
}
}
}
]
}
parameters.reason is NoFirst, FirstAboveLimit or TooManyKeys. Quote the errorId when you report the error; the
same id is in the asset repository log.
Time limit
Every runtime-entity query and count the asset repository runs - by CK type, by id, by CK type with navigation and by
CK interface - carries a server-side time limit. A query that runs longer is stopped on the database, so it no longer
keeps MongoDB and the asset repository busy, and the caller receives the error ASSET1008 instead of a generic error or
a request that never answers.
| Setting | Environment variable | Helm value (chart octo-mesh) | Default |
|---|---|---|---|
RuntimeQuery:MaxTimeMs | OCTO_RUNTIMEQUERY__MAXTIMEMS | services.assetRepository.runtimeQuery.maxTimeMs | 120000 (2 minutes) |
The value is in milliseconds; 0 switches the limit off. A changed Helm value rolls the asset repository; the new limit
applies from then on. The limit applies to each database operation of a query: a paged query that also returns
totalCount reads its page and its count separately, and each of them has the full limit.
- Warning before the limit. A query that completes but takes more than 80 % of its limit is answered normally; the asset repository logs a warning with the tenant, the CK type, the duration and the limit. These warnings show which queries come close to the limit before they fail.
- Internal batch work is not limited. Blueprint installation, update and uninstall and CK model migrations run without the limit; each of them switches it off explicitly where it starts. Exports run in the bot services and are not limited either.
- Not covered yet. Association queries (the
associationsand navigation connection fields of an entity) and deep-graph queries do not carry the limit yet. A root query by CK type that selects navigation properties is limited.
Error ASSET1008
GraphQL:
{
"errors": [
{
"message": "The runtime query on CK type 'Industry.Energy/EnergyMeter-1' exceeded the time limit of 120000 ms and was stopped. Narrow the query (filters, paging) or ask an administrator about the limit (RuntimeQuery:MaxTimeMs). Error id 7b1e04….",
"path": ["runtime", "industryEnergyEnergyMeter"],
"extensions": {
"code": "ASSET1008",
"errorId": "7b1e04…",
"parameters": {
"ckTypeId": "Industry.Energy/EnergyMeter-1",
"maxTimeMs": 120000,
"elapsedMs": 120004
}
}
}
]
}
REST endpoints answer 504 Gateway Timeout with problem details (application/problem+json) that carry the same
code, errorId, ckTypeId, maxTimeMs and elapsedMs. The asset repository logs every time-out once as a warning
with the tenant, the CK type, the duration, the limit and the error id; quote the errorId when you report the error.
What to do: narrow the query with filters and page through the result with first and after (below). A count with
totalCount is limited too: add a filter when it times out. Raise the limit of a deployment only for a measured reason; a query that needs minutes is usually
missing a filter or an index.
How to page and count
Page through a large result set with first (at most the maximum page size of the deployment) and the cursor of the previous page:
query meters($after: String) {
runtime {
industryEnergyEnergyMeter(first: 100, after: $after) {
pageInfo {
endCursor
hasNextPage
}
items {
rtId
name
}
}
}
}
Repeat with after: <endCursor> until hasNextPage is false.
Count without loading entities by selecting only totalCount:
query {
runtime {
industryEnergyEnergyMeter {
totalCount
}
}
}
See also Best Practices and Error Handling.