Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[BUG] Cancelling a PPL query sent by another plugin doesn't stop it, and its searches have no parent task

Abierto
#5,911 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
64/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java

Línea de trabajo

Start in plugin/src/main/java/org/opensearch/sql/plugin/transport/TransportPPLQueryAction.java at the task checks in doExecute and submitAsync; compare them with OpenSearchQueryManager.setCancellableTask and OpenSearchNodeClient.applyParentTask. The issue proposes using the shared CancellableTask type for both paths. Done means PPL requests from another plugin link searches to their task, cancellation stops the query, and the async path accepts the task.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

untriaged

What is the bug?
A PPL query that another plugin sends through the cluster:admin/opensearch/ppl transport action, using its own bundled copy of the SQL classes, is not linked to its task. Examples are Alerting PPL monitors (PPLUtils → PPLPluginInterface.executeQuery) and Skills PPL tools (PPLTool, LogPatternTool, and tools that use PPLExecuteHelper). As a result:

  • the searches the query runs have no parent task, and
  • POST _tasks/<ppl task id>/_cancel marks the task cancelled, but the query keeps running.

TransportPPLQueryAction.doExecute only sets the query's cancellable task when the task is this plugin's own PPLQueryTask class (L212-L214):

if (task instanceof PPLQueryTask pplQueryTask) {
  OpenSearchQueryManager.setCancellableTask(pplQueryTask);
}

Alerting and Skills bundle their own copy of the SQL classes (the opensearch-sql-thin jar) and don't extend opensearch-sql, so those classes load in the caller's classloader. Core creates the task through request.createTask(...) on the caller's TransportPPLQueryRequest, which returns the caller's copy of PPLQueryTask. That copy is a different class from this plugin's PPLQueryTask, so the instanceof check fails and the ThreadLocal is never set. OpenSearchNodeClient.applyParentTask (L254-L258) then sets no parent, and the engine's cancellation checks find no task. submitAsync makes the same check (L314-L316), so an async PPL request from another plugin fails with Async PPL queries require a cancellable PPLQueryTask. Async PPL is only on main so far, and neither Alerting nor Skills sends async requests today, so this part is latent.

How can one reproduce the bug?
Reproduced on a local single-node cluster with opensearch-sql and opensearch-alerting, on 3.10.0-SNAPSHOT (SQL at 24bfaaf) and on 3.9.0:

  1. Index 2M small docs into big. To make one query run about 20 s, set index.max_result_window: 10 on big, plus plugins.query.size_limit: 100000000 and plugins.calcite.pushdown.enabled: false. Raise plugins.alerting.ppl_query_max_execution_duration so the monitor waits for the whole query.
  2. Run source=big | where n < 0 | head 10 from an Alerting PPL monitor (POST _plugins/_alerting/monitors/_execute?dryrun=true with a ppl_monitor), and the same query through POST _plugins/_ppl.
  3. GET _tasks?detailed=true&actions=cluster:admin/opensearch/ppl,indices:data/read/search*. On main, the _plugins/_ppl query's searches have the PPL task as parent_task_id (300 of 300 sampled); the Alerting query's searches have none (0 of 279).
  4. POST _tasks/<ppl task id>/_cancel about 5 s in. The _plugins/_ppl query stops right away. The Alerting query's task reports "cancelled": true, but the query runs all ~200k searches to completion, unless plugins.ppl.query.timeout fires first. Same result on 3.9.0.

What is the expected behavior?
A PPL query should be linked to its task whichever plugin sends it. Its searches should be children of the PPL task, and cancelling the task should stop the query.

Suggested fix: check for the core type instead of this plugin's class. CancellableTask is loaded by the server classloader, so it is the same class in every plugin.

if (task instanceof CancellableTask cancellableTask) {
  OpenSearchQueryManager.setCancellableTask(cancellableTask);
}

Apply the same change in submitAsync; CancellableTask#cancel(String) is public. OpenSearchQueryManager.setCancellableTask already takes a CancellableTask. Features that need PPLQueryTask-specific state can stay limited to PPLQueryTask. For example, #5760 adds Query Insights fields and edits this same check.

What is your host/environment?

  • Version: main (24bfaaf). The cancellation problem also affects releases since #5254: 3.6.0+ with Skills and 3.7.0+ with Alerting (reproduced on 3.9.0). In releases, searches issued by the background scanner have no parent task whoever sends the query (#5647, fixed on main by #5888), so the missing-parent part is specific to main. The async failure is main-only too.
  • Plugins: opensearch-sql together with alerting and/or skills (all in the default distribution)

Do you have any additional context?
Found while reviewing opensearch-project/query-insights#699, which shows a running PPL query in Live Queries as one row by nesting its searches under the PPL task. PPL queries from other plugins don't get that grouping.

Lenguaje dominante
Java
Estrellas
175
Forks
233
Merge medio
2 d 19 h
PR fusionados (30 d)
37

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de opensearch-project/sql

Todos los issues de opensearch-project/sql

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.