[BUG] Cancelling a PPL query sent by another plugin doesn't stop it, and its searches have no parent task
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 64/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- java
- Lĩnh vực
- backend, distributed-systems
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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>/_cancelmarks 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:
- Index 2M small docs into
big. To make one query run about 20 s, setindex.max_result_window: 10onbig, plusplugins.query.size_limit: 100000000andplugins.calcite.pushdown.enabled: false. Raiseplugins.alerting.ppl_query_max_execution_durationso the monitor waits for the whole query. - Run
source=big | where n < 0 | head 10from an Alerting PPL monitor (POST _plugins/_alerting/monitors/_execute?dryrun=truewith appl_monitor), and the same query throughPOST _plugins/_ppl. GET _tasks?detailed=true&actions=cluster:admin/opensearch/ppl,indices:data/read/search*. On main, the_plugins/_pplquery's searches have the PPL task asparent_task_id(300 of 300 sampled); the Alerting query's searches have none (0 of 279).POST _tasks/<ppl task id>/_cancelabout 5 s in. The_plugins/_pplquery stops right away. The Alerting query's task reports"cancelled": true, but the query runs all ~200k searches to completion, unlessplugins.ppl.query.timeoutfires 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.
- Ngôn ngữ chính
- Java
- Star
- 175
- Fork
- 233
- Merge trung bình
- 2 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 36
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của opensearch-project/sql
-
[Enhancement] Make the flat_object read depth cap configurable instead of a constantCó thể đã có người làm @RyanL1997 đã nhận 19 ngày trước. Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
opensearch-project/sql#5842 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] PromQL queries fail with InvalidTypeIdException when metric has a label named "type"Có thể đã có người làm @nagendramohan đã nhận 81 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
opensearch-project/sql#5684 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[DOC] Calcite settings documentation missing examplesCó thể đã có người làm @AzazelSensei đã nhận 39 ngày trước. Đang mởdocumentation PPL
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
opensearch-project/sql#4806 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] Analytics routing does not resolve aliases and wildcard index expressionsCó thể đã có người làm @KarstenSchnitter đã nhận 2 ngày trước. Đang mởuntriaged
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
opensearch-project/sql#5916 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug PPL
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
opensearch-project/sql#5904 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của opensearch-project/sql
Issue tương tự
-
Invalid If-Modified-Since or If-Unmodified-Since header results in 500 with Request.evaluatePreconditions()Có thể đã có người làm @pschaub đã nhận hôm nay. Đang mởkind/bug triage/needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
objectionary/eo#9764 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
apache/doris#69919 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
checkstyle/checkstyle#22354 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
frankframework/frankframework#11966 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày