Skip to content

feat(core): language-neutral query job lifecycle (MVP) - #14

Closed
penghuo wants to merge 1 commit into
mainfrom
feat/query-job-lifecycle-mvp
Closed

penghuo wants to merge 1 commit into
mainfrom
feat/query-job-lifecycle-mvp

Conversation

@penghuo

@penghuo penghuo commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Introduces the core/job package that carries a query through a five-state lifecycle (PENDING, RUNNING, SUCCEEDED, FAILED, CANCELLED) with no retention or wait-timeout coupling. Sync- and async-query transports share the same QueryJob; only the caller decides whether to block on completion().

Addresses review of opensearch-project#5809:

  • Lifecycle layer is language-neutral (Livy-style control plane).
  • Execution boundary is engine-neutral: PPL, SQL, and AE each implement the QueryRunner SPI. First engine wired is PPL.
  • Execution state is decoupled from retention (BigQuery-style).
  • Responsibilities split into QueryJobService (control plane), QueryJobStore (registry SPI + in-memory impl), and QueryJob (state machine).
  • SecurityAdapter SPI captures the caller identity without pulling OpenSearch types into core.

MVP scope: no wait_for_completion_timeout, no keep_alive, no retention, no admission control, no REST wiring. Every deferred feature lands behind one of the existing interfaces without touching QueryJob.

Design doc: docs/dev/query-job-mvp-design.md (design/query-job-mvp branch).

Description

[Describe what this change achieves]

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff or -s.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@penghuo
penghuo requested a review from dai-chen as a code owner September 28, 2026 15:15
@penghuo
penghuo force-pushed the feat/query-job-lifecycle-mvp branch 3 times, most recently from c9f299a to b80dc75 Compare September 28, 2026 17:41
…s only

Introduces org.opensearch.sql.job — a five-state query lifecycle
(PENDING, RUNNING, SUCCEEDED, FAILED, CANCELLED) — in response to
review of opensearch-project#5809.

Design-only PR: adds the neutral SPI, the state machine, the registry,
the OpenSearch-side lifecycle service, and their tests. No existing
API is touched. PPL / SQL / transport wiring lands in a follow-up.

Addresses @dai-chen's three review comments:

  1. Lifecycle layer is language-neutral, Livy-style. The job package
     does not import PPL; each engine implements the QueryRunner SPI.
  2. Execution boundary is engine-neutral. QueryRunner returns a
     neutral QueryResult (schema/rows/cursor/warnings/tookMillis);
     the same shape fits SQL and AE.
  3. Execution state is decoupled from retention. State stays RUNNING
     regardless of whether a caller is still waiting. Service
     responsibilities split into QueryJobService (public interface),
     QueryJobStore (in-memory registry SPI), and QueryJob (state
     machine active object). SecurityAdapter SPI keeps OpenSearch
     types out of core.

Module layout:

  core/job/       neutral interface + value types + reference
                  in-memory store + engine SPI
  opensearch/job/ OpenSearchQueryJobService — symmetric with the
                  existing OpenSearchQueryManager

Public surface (all in core/job/):

  QueryJobService        submit(runner, submitter) / get / cancel
  QueryJob               state machine active object (5-state)
  QueryJobId             opaque, node-routable, URL-safe
  QueryJobState          PENDING / RUNNING / SUCCEEDED / FAILED / CANCELLED
  QueryJobStatus         immutable snapshot with invariant checks
  QueryJobStore          registry SPI + InMemoryQueryJobStore
  QueryRunner            engine SPI: run() / cancel()
  QueryResult            neutral final result
  QueryFailure           neutral failure descriptor
  Principal              caller identity for owner authorization
  SecurityAdapter        SPI: runtime context -> Principal

Verification (rerun against the reduced scope):
  ./gradlew :core:test :opensearch:test    -> 39 job tests, 0 failures

MVP scope intentionally excludes wait_for_completion_timeout,
keep_alive, retention, admission control, and REST wiring. Every
deferred feature lands behind an existing interface without touching
QueryJob.

Design doc: docs/dev/query-job-mvp-design.md (design/query-job-mvp branch).

Signed-off-by: Peng Huo <penghuo@amazon.com>
@penghuo
penghuo force-pushed the feat/query-job-lifecycle-mvp branch from b80dc75 to 990c47b Compare September 28, 2026 17:47
@penghuo penghuo closed this Sep 29, 2026
@penghuo
penghuo deleted the feat/query-job-lifecycle-mvp branch September 29, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant