← Back to Pull requests

[BugFix] Bind a PPL query to its task whichever plugin sent it #5934

Closed
unknown closed this pull request without merging on Nov 06, 2026 00:13 UTC
View on GitHub
unknown unknown commented on Nov 05, 2026 22:45 UTC
Author

Description

A PPL query sent by another plugin is never linked to its task, so it can't be cancelled and its searches have no parent.

TransportPPLQueryAction bound the task only when it was this plugin's own class:

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

Alerting PPL monitors and Skills PPL tools bundle their own copy of the SQL classes rather than extending opensearch-sql, so core builds the task from the caller's TransportPPLQueryRequest and hands back the caller's PPLQueryTask — a different class, loaded by a different classloader. The check fails and the thread local is never set.

Two things follow:

  • the searches the query runs aren't children of the PPL task, so they can't be grouped under it

  • POST _tasks/<id>/_cancel marks the task cancelled, but the query keeps running
  • Check for CancellableTask instead. It comes from the server classloader, so it's the same class in every plugin. Nothing on this path needs PPLQueryTask specifically: QueryProgressTracker#attach already takes a CancellableTask, and CancellableTask#cancel(String) is public.

    Related Issues

    Resolves #5911

    Related: #5933 makes the query timeout cancel the task, which only helps these callers once the task is bound.

    Check List

  • New functionality includes testing.

  • New functionality has been documented.

  • API changes companion pull request created.

  • Commits are signed per the DCO using --signoff.

  • Public documentation issue/PR created.
  • Tests

    TransportPPLQueryActionCancellationTest gains a case that submits a CancellableTask which is not a PPLQueryTask, standing in for the copy another plugin's classloader creates, and asserts the runner still cancels it. The existing case rejecting a task that isn't cancellable at all keeps its coverage.

    Diff: 247 lines (+185 / -62) across 3 files Reviewer: Swiddis Review duration: 87m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 247 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.330
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5934"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 38.9% (MEDIUM) · Higher = larger blast radius
    38.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.4% · Safe to merge
    15.4%