You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE] Support task cancellation for long-running PPL queries. #4887
Is your feature request related to a problem?
Followup to #4857, #4886 -- if a query has a very long timeout and is unexpectedly taking longer than expected, we should be able to cancel queries via the _tasks/_cancel API.
What solution would you like?
For the most part cancellation should already be supported fundamentally by #4857, we just need to integrate with the actual task endpoint and let that interrupt the query thread. We may also need to support canceling whatever background IO is running during that process (but I think this will self-interrupt anyway, since the socket will get closed & OpenSearch detects that).
I've been looking into this and started putting together a design doc for the backend cancel API. A few things I noticed while exploring:
The thread interruption infra from Support timeouts for Calcite queries #4857 does most of the heavy lifting already — cancel is basically triggering that same interrupt externally instead of via timeout.
For the Discover cancel button use case (@anasalkouz), we'd need an additional client-provided query ID in the request body, so the frontend can reference which query to cancel on a separate connection.
For the endpoint, I was thinking POST /_plugins/_query/{queryId}/_cancel — following the same _cancel convention as OpenSearch core's _tasks API.
Do we need a custom endpoint? Queries are already tasks that show up in the core _tasks list, but they're not registered. We should just hook directly to core's task cancellation service. I don't think we want to try and implement our own task ID routing infrastructure (suppose you try to cancel a query ID from another node?).
For the most part this should be doable by extending TransportPPLQueryRequest to extend TaskAwareRequest and override createTask. Will need a task type that supports cancellation (PPLQueryTask?) and some light infra to ensure the task knows which thread to interrupt when onCancelled is called. Can just use the regular query UUID that we pass around for the task ID.
Can just use the regular query UUID that we pass around for the task ID.
The query ID is mainly for Discover cancel button use case, when the client-side sends a query, the server won't respond until the query finishes, so we need the query ID to be generated on the client-side, otherwise the client would have no way to learn which query to cancel when using query cancellation API. I think we can just use client-side UUID for this
That should be fine, just register the task with that ID (assuming some interface exists for it). How does it exist with existing query cancellation flows? If the task API doesn't support some sort of ID registration then that means no OSD cancellation is supported for regular OS operations.
Yes, I think we can override createTask on TransportPPLQueryRequest to return a PPLQueryTask extends CancellableTask, with the client-provided UUID in the task description via getDescription(). Cancellation uses the native _tasks/_cancel API — no new endpoint needed on the SQL plugin side. On the OSD side, a new server route takes the queryId from the browser, resolves it to a task ID via _tasks list, and calls _cancel.
Activity
anasalkouz commentedon Feb 26, 2026
This should also be connected to the Discover page cancel button
Swiddis commentedon Mar 2, 2026
That can be a frontend feature after we have backend support
ahkcs commentedon Mar 2, 2026
I've been looking into this and started putting together a design doc for the backend cancel API. A few things I noticed while exploring:
POST /_plugins/_query/{queryId}/_cancel— following the same_cancelconvention as OpenSearch core's_tasksAPI.Swiddis commentedon Mar 2, 2026
Do we need a custom endpoint? Queries are already tasks that show up in the core
_taskslist, but they're not registered. We should just hook directly to core's task cancellation service. I don't think we want to try and implement our own task ID routing infrastructure (suppose you try to cancel a query ID from another node?).For the most part this should be doable by extending TransportPPLQueryRequest to extend TaskAwareRequest and override
createTask. Will need a task type that supports cancellation (PPLQueryTask?) and some light infra to ensure the task knows which thread to interrupt whenonCancelledis called. Can just use the regular query UUID that we pass around for the task ID.sunil9977 commentedon Mar 5, 2026
Please let me know if I can take this up.
ahkcs commentedon Mar 16, 2026
The query ID is mainly for Discover cancel button use case, when the client-side sends a query, the server won't respond until the query finishes, so we need the query ID to be generated on the client-side, otherwise the client would have no way to learn which query to cancel when using query cancellation API. I think we can just use client-side UUID for this
Swiddis commentedon Mar 16, 2026
That should be fine, just register the task with that ID (assuming some interface exists for it). How does it exist with existing query cancellation flows? If the task API doesn't support some sort of ID registration then that means no OSD cancellation is supported for regular OS operations.
Swiddis commentedon Mar 16, 2026
Yeah, createTask takes an ID param
ahkcs commentedon Mar 16, 2026
Yes, I think we can override
createTaskonTransportPPLQueryRequestto return aPPLQueryTaskextendsCancellableTask, with the client-provided UUID in the task description via getDescription(). Cancellation uses the native _tasks/_cancel API — no new endpoint needed on the SQL plugin side. On the OSD side, a new server route takes the queryId from the browser, resolves it to a task ID via_taskslist, and calls_cancel.