Context Deadline Exceeded Leaves Flux Query Running in InfluxDB OSS 2.x
0 reputation · 13 Dec 2023, 17:40 UTC
0 reputation · 13 Dec 2023, 17:40 UTC
When a client aborts an HTTP request to the InfluxDB query API before a Flux query completes, the response returns a context deadline exceeded error or a 504 Gateway Timeout, yet the query may keep running on the server. This behavior matters for long-running or high-cardinality queries where wasted CPU and memory accumulate.
In InfluxDB OSS 2.x, the client abort signal does not appear to propagate to the Flux query engine, leaving operators without an explicit cancellation token. Write requests seem to honor connection resets more promptly by discarding partial batches, but query cancellation behavior differs. Enterprise editions reportedly add a query-cancel endpoint, though its availability in OSS remains unclear.
What is the supported mechanism for ensuring a Flux query terminates promptly after a client-side timeout in OSS? Does the /api/v2/query?type=active endpoint expose enough state to identify and cancel orphaned queries? Are there configuration options or version upgrades that close the gap between client disconnect and server-side query abort?
31775 reputation · 13 Dec 2023, 19:42 UTC
In InfluxDB OSS 2.x there is no documented, universally supported public API to cancel a running Flux query by ID after a client timeout. The /api/v2/query?type=active endpoint is observability only. It can identify in-flight queries with an identifier, query text and elapsed time, but it does not provide a cancel operation in OSS. The supported way to bound the impact of orphaned queries in OSS is resource limits, not cancellation.
Enterprise and Cloud builds have had additional control endpoints in some releases; route registration differs by edition and build. Do not assume a cancel route exists in OSS because it is mentioned for other editions.
context deadline exceeded or a 504 when the client or an intermediary times out.The HTTP handler derives the query context from the request. Cancellation only reaches the Flux engine at points where the engine checks that context. Long storage scans, grouping, sorting or a slow first result can run past the client deadline before a check occurs. A 504 usually means a reverse proxy, load balancer or gateway timed out. Whether the upstream connection is closed depends on that proxy's configuration, so InfluxDB may never observe a disconnect at all.
influxd version and note the OSS 2.x patch. Context propagation and active-query behavior changed across 2.x releases.influxd print-config and confirm the [query] section values actually in force for your instance: concurrency, queue-size, per-query memory and total memory. These are the OSS levers./api/v2/query?type=active after an abort to confirm orphaned work and correlate with logs. It is a diagnostic snapshot, not a control plane.To reduce waste, keep query concurrency and memory caps conservative, ensure the proxy closes the upstream on client disconnect, and prefer query patterns that return early results.
What exact influxd version and proxy/gateway sits in front of the query API? Version determines whether any cancel-related route exists in your build, and proxy timeout/keep-alive settings determine whether the server ever sees the client abort.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.