← Back to Pull requests

[BugFix] Stop a PPL query at its timeout and report it as one #5933

Closed
unknown closed this pull request without merging on Nov 06, 2026 00:03 UTC
View on GitHub
unknown unknown commented on Nov 05, 2026 20:19 UTC
Author

Description

A PPL query that hits plugins.ppl.query.timeout has two problems today:

  • It often doesn't stop. The deadline only takes effect if the execution thread happens to be waiting on I/O at that moment. A query busy inside the engine keeps going.

  • When it does stop, nothing says it timed out. The response is HTTP 500 with a bare RuntimeException, so a client can't tell a deadline from a backend failure, and the request is counted as a plugin system fault.
  • This change makes the deadline actually stop the query, and report itself.

    Stopping the query. The timeout now cancels the query's task instead of only interrupting the thread. OpenSearchIndexEnumerator#moveNext already checks CancellableTask#isCancelled() on every row, so cancelling gives a busy query a checkpoint. The interrupt is kept, since that is what frees a thread already blocked on a fetch.

    Reporting it. The timeout now raises a QueryTimeoutException, which answers REQUEST_TIMEOUT. A deadline is not a gateway timeout: RestClient marks the node dead and retries on 502, 503 and 504, and opensearch-py retries the same three by default, so a 504 would get the query resent — the opposite of what a deadline is for. The subclass also separates a query exceeding its own deadline from an actionGet(timeout) failing to answer, which is a backend fault.

    ThreadPoolExecutionDispatcher previously had no timeout detection on either of its paths, so neither reported one.

    Counting it. 408 falls in the existing 4xx branch, so a deadline is counted as a caller outcome with no special case in the metric.

    Related Issues

    Resolves #5932

    Related: #5934 binds the task for queries sent by other plugins, which this change needs in order to help them.

    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

  • OpenSearchQueryManagerTest — the expired deadline surfaces as a 504 timeout, an unrelated failure is untouched, and expire cancels and interrupts.

  • SyncErrorReportRendererTest — a timeout is recognised through the wrapper chain; an ordinary failure is not.

  • PPLQueryTimeoutIT — both execution paths time out with 504, and a query inside its deadline still succeeds.
  • I left some implementation notes in a comment below.

    Diff: 319 lines (+239 / -80) across 3 files Reviewer: Swiddis Review duration: 224m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 319 lines diff across 3 files
    0.40
    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.345
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5933"
    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: 40.4% (MEDIUM) · Higher = larger blast radius
    40.4%
    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: 16.0% · Safe to merge
    16.0%