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][PPL] Production hardening and validation for progressive query execution #5801
Turn the validated asynchronous and partial-result prototypes into a production-quality implementation with explicit module boundaries, bounded resource use, and complete regression coverage.
Scope
Keep ProgressiveQueryExecution as the only lifecycle-facing execution contract.
Remove PoC-only routing and physical-plan hooks in favor of explicit production integration seams.
Keep execution callback, Context, StateStore, and aggregation observer details out of the lifecycle layer.
Define memory limits and failure behavior for APPEND and REPLACE state.
Make partial-reduce cadence configurable and bounded.
Validate cleanup, owner-node loss, FGAC, cancellation, expiration, and shutdown.
Document supported partial-result shapes and progress semantics.
Acceptance criteria
No synchronous behavior or performance regression outside the accepted threshold.
All existing Calcite integration tests and YAML REST tests pass.
A REST matrix covers non-blocking rows, Composite aggregation, fully pushed aggregation, pushed aggregation with Calcite post-processing, blocking plans, and failure cases.
Every final async result is equivalent to the synchronous result.
First-data and final latency, memory usage, and aggregation reduce overhead are reported on a multi-shard large dataset.
Resource cleanup and lifecycle race tests show no leaked tasks, search contexts, statements, or StateStores.
Enhancement: PENDING status + max-lifetime backstop for async PPL jobs
Context from PR #5832: an async PPL submission with wait_for_completion_timeout=0 can leak a RUNNING job on the owner node if the engine never completes the runner's CompletableFuture. Retention is only armed on terminal transitions, so a stuck future never gets evicted.
plugins.ppl.query.timeout (default 300s) catches the common case via Thread.interrupt() on the engine thread (confirmed in AsyncPPLQueryLifecycleIT.async_perNodeTimeoutDrivesJobToFailedWithSyncShapeError — timeout fires at the first interruptible blocking call, async GET reaches FAILED with the sync-shape error body).
The interrupt is cooperative, so it does not cover:
Worker-pool saturation. sql-worker pool full → task silently dropped or indefinitely queued → runner never starts → interrupt is never scheduled.
CPU-bound sections without interrupt checks (Calcite planner passes, pure Java eval loops).
Swallowed InterruptedException in third-party or legacy code.
Lost completion signal — any dispatcher bug that drops onResponse / onFailure keeps the CompletableFuture pending forever.
Proposed work
1. Expose PENDING on GET (preferred over admission-control rejection).
The lifecycle state machine already has PENDING as the state between construction and startRunner(), but today OpenSearchQueryJobService.submit calls startRunner() immediately after publishing, so clients never see it.
Mirror Livy's waiting → running model: when the sql-worker pool can't accept the task yet, keep the job in PENDING and let the engine thread notify via a new onStarted callback on QueryRunner when it actually begins work. GET returns {"status":"PENDING"} until that happens, then {"status":"RUNNING"}.
Why this is better than returning 429 and rejecting:
No work is dropped — the client always gets a durable job id and can keep polling.
Natural backpressure: pressure manifests as PENDING tail length, not failure.
Decouples admission from scheduling; the worker pool runs at full utilization.
Matches a well-known REST analytics protocol (Livy), so clients built against Livy semantics port cleanly.
2. Submit-time max-lifetime timer (backstop).
Schedule a hard timeout in QueryJobService.submit (not inside the runner body) on ThreadPool.Names.GENERIC using the plugins.ppl.query.timeout budget. Fire → move the job to FAILED with reason "query timed out after Xs" and let retention evict after keep_alive. Cancel on terminal transition. Covers hangs from any of (2)-(4) above and from (1) when PENDING outlives the budget.
3. Observability.
Metric for terminal transitions bucketed by trigger: cooperative interrupt vs. backstop timer vs. explicit cancel. Tells us whether the backstop is doing real work.
Reproduction
Set the sql-worker pool to 1 slot; submit two long-running queries back-to-back with wait_for_completion_timeout=0. Without PENDING exposure, the second id returns RUNNING forever.
Credit: this scenario and the "lifetime timer at submit" shape were raised by akhcs on PR #5832 review.
Track async PPL GET/DELETE transport compatibility during rolling upgrades as part of this production-hardening issue, deferred from #5846.
CancelAsyncQueryActionRequest and GetAsyncQueryResultActionRequest read/write queryId with readOptionalString / writeOptionalString, without a wire-version gate. Older decoders read only the superclass fields. Frame-level probes reproduced unread trailing bytes for a new writer with an older reader, and EOF for an older writer with a new reader. Owner forwarding therefore needs a defined compatibility contract. GET serialization and the shared owner-routing helper were introduced in #5832; #5846 adds DELETE owner forwarding.
OpenSearch version checks alone cannot distinguish different SQL plugin builds targeting the same OpenSearch version. The solution must account for that case through capability negotiation or an explicitly unsupported upgrade combination.
Suggested acceptance criteria:
Define and document supported mixed-version and mixed-plugin-build behavior for async PPL GET/DELETE, including owner restart and loss of in-memory jobs.
Negotiate a compatible request format or reject unsupported owner forwarding clearly before sending an incompatible frame; do not silently lose the query ID.
Cover old-to-new and new-to-old serialization, complete frame consumption, owner forwarding, and unsupported combinations with regression tests.
At the author's request, the proposed compatibility gates, old-owner rejection, compatibility tests, and upgrade documentation are being removed from the uncommitted #5846 follow-up. This concern is intentionally deferred to #5801; the cancellation/fallback fixes remain in #5846.
Async PPL GET waits behind queued queries on sql-worker
GET /_plugins/_async_query/{id} for a PPL job runs on the sql-worker pool (RestAsyncQueryManagementAction schedules it with Scheduler.schedule, whose default pool is sql-worker). DELETE for PPL ids already runs on GENERIC.
When sql-worker is busy with queries, a poll waits in the same queue behind them. On a 2-node cluster (sql-worker size 8, queue 1000) with about 1,100 async queries submitted at once, GET calls took more than 30 seconds to return. A client that polls with a short timeout sees its poll fail even though the job is fine.
If the pool's queue is full, the rejection of the GET task is dropped inside ThreadPool.schedule, so the GET request gets no response at all. This is the same pattern as the query hand-off that dropped rejections.
Suggested fix: run GET for PPL ids on GENERIC, as DELETE does. It only looks up the job and formats the stored result. Also submit it through the executor rather than ThreadPool.schedule, so a rejection reaches the client as an error.
Activity
Pin async timeout behavior to the sync-shape error body
penghuo commentedon Oct 6, 2026
Enhancement: PENDING status + max-lifetime backstop for async PPL jobs
Context from PR #5832: an async PPL submission with
wait_for_completion_timeout=0can leak aRUNNINGjob on the owner node if the engine never completes the runner'sCompletableFuture. Retention is only armed on terminal transitions, so a stuck future never gets evicted.plugins.ppl.query.timeout(default 300s) catches the common case viaThread.interrupt()on the engine thread (confirmed inAsyncPPLQueryLifecycleIT.async_perNodeTimeoutDrivesJobToFailedWithSyncShapeError— timeout fires at the first interruptible blocking call, async GET reaches FAILED with the sync-shape error body).The interrupt is cooperative, so it does not cover:
InterruptedExceptionin third-party or legacy code.onResponse/onFailurekeeps theCompletableFuturepending forever.Proposed work
1. Expose
PENDINGon GET (preferred over admission-control rejection).The lifecycle state machine already has
PENDINGas the state between construction andstartRunner(), but todayOpenSearchQueryJobService.submitcallsstartRunner()immediately after publishing, so clients never see it.Mirror Livy's
waiting→runningmodel: when the sql-worker pool can't accept the task yet, keep the job inPENDINGand let the engine thread notify via a newonStartedcallback onQueryRunnerwhen it actually begins work. GET returns{"status":"PENDING"}until that happens, then{"status":"RUNNING"}.Why this is better than returning 429 and rejecting:
PENDINGtail length, not failure.2. Submit-time max-lifetime timer (backstop).
Schedule a hard timeout in
QueryJobService.submit(not inside the runner body) onThreadPool.Names.GENERICusing theplugins.ppl.query.timeoutbudget. Fire → move the job toFAILEDwith reason"query timed out after Xs"and let retention evict afterkeep_alive. Cancel on terminal transition. Covers hangs from any of (2)-(4) above and from (1) whenPENDINGoutlives the budget.3. Observability.
Metric for terminal transitions bucketed by trigger: cooperative interrupt vs. backstop timer vs. explicit cancel. Tells us whether the backstop is doing real work.
Reproduction
wait_for_completion_timeout=0. WithoutPENDINGexposure, the second id returnsRUNNINGforever.Credit: this scenario and the "lifetime timer at submit" shape were raised by akhcs on PR #5832 review.
penghuo commentedon Oct 7, 2026
Track async PPL GET/DELETE transport compatibility during rolling upgrades as part of this production-hardening issue, deferred from #5846.
CancelAsyncQueryActionRequestandGetAsyncQueryResultActionRequestread/writequeryIdwithreadOptionalString/writeOptionalString, without a wire-version gate. Older decoders read only the superclass fields. Frame-level probes reproduced unread trailing bytes for a new writer with an older reader, and EOF for an older writer with a new reader. Owner forwarding therefore needs a defined compatibility contract. GET serialization and the shared owner-routing helper were introduced in #5832; #5846 adds DELETE owner forwarding.OpenSearch version checks alone cannot distinguish different SQL plugin builds targeting the same OpenSearch version. The solution must account for that case through capability negotiation or an explicitly unsupported upgrade combination.
Suggested acceptance criteria:
At the author's request, the proposed compatibility gates, old-owner rejection, compatibility tests, and upgrade documentation are being removed from the uncommitted #5846 follow-up. This concern is intentionally deferred to #5801; the cancellation/fallback fixes remain in #5846.
penghuo commentedon Oct 13, 2026
Related to #5849
Queue async PPL queries instead of rejecting them (opensearch-project…
2 remaining items
Document the async PPL query lifecycle and tidy the scheduler (opense…
Report an async PPL query as RUNNING only once it executes (opensearc…
penghuo commentedon Oct 27, 2026
Async PPL GET waits behind queued queries on
sql-workerGET /_plugins/_async_query/{id}for a PPL job runs on thesql-workerpool (RestAsyncQueryManagementActionschedules it withScheduler.schedule, whose default pool issql-worker). DELETE for PPL ids already runs onGENERIC.When
sql-workeris busy with queries, a poll waits in the same queue behind them. On a 2-node cluster (sql-workersize 8, queue 1000) with about 1,100 async queries submitted at once, GET calls took more than 30 seconds to return. A client that polls with a short timeout sees its poll fail even though the job is fine.If the pool's queue is full, the rejection of the GET task is dropped inside
ThreadPool.schedule, so the GET request gets no response at all. This is the same pattern as the query hand-off that dropped rejections.Suggested fix: run GET for PPL ids on
GENERIC, as DELETE does. It only looks up the job and formats the stored result. Also submit it through the executor rather thanThreadPool.schedule, so a rejection reaches the client as an error.Drop the async wait and keep_alive limit settings (opensearch-project…
Restore the submitter's context in the async scheduler (opensearch-pr…
Move the retained job limit to the retention follow-up (opensearch-pr…
Drop comment edits the change does not need (opensearch-project#5801)
Simplify the async wait and drop code kept for later work (opensearch…
Size async running slots from the sql-worker pool (opensearch-project…
Drop comments that explain the change rather than the code (opensearc…
Preserve the thread context explicitly when submitting to SQL pools (o…
Rely on the executor to preserve the thread context (opensearch-proje…
Require the scheduler and drop paths only tests reached (opensearch-p…
Cover sql-worker saturation in WorkerPoolSaturationIT (opensearch-pro…
Clarify the comments in WorkerPoolSaturationIT (opensearch-project#5801)