Repository navigation
Conversation
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 7abe947.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
Codecov Report❌ Patch coverage is
❌ Your project check has failed because the head coverage (63.26%) is below the target coverage (99.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #5809 +/- ##
============================================
+ Coverage 63.23% 63.26% +0.02%
- Complexity 8823 8829 +6
============================================
Files 938 939 +1
Lines 40236 40276 +40
Branches 4537 4537
============================================
+ Hits 25445 25480 +35
- Misses 13966 13971 +5
Partials 825 825
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| * <p>This class is thread-safe. The registry is concurrent, capacity counters are guarded by {@code | ||
| * admissionLock}, and each job synchronizes its own lifecycle transitions. | ||
| */ | ||
| public final class PPLAsyncQueryService extends AbstractLifecycleComponent { |
There was a problem hiding this comment.
- Can we make this new lifecycle layer language-neutral, similar to Livy’s control plane over Spark?
- Probably the execution boundary can also be engine-neutral? SQL and PPL can both run on AE too, although AE does not currently support progress listeners.
| * lock. | ||
| * | ||
| * <pre> | ||
| * Every job starts in RUNNING. It becomes retained when wait_for_completion_timeout expires. |
There was a problem hiding this comment.
Could we separate execution state from retention and treat wait_for_completion_timeout only as submit-response behavior? In a BigQuery-style model, the job remains RUNNING whether or not the request is still waiting.
| private final Supplier<String> ownerNodeIdSupplier; | ||
| private final LongSupplier currentTimeMillis; | ||
| private final TimeoutScheduler timeoutScheduler; | ||
| private final IntSupplier maxRunningQueries; | ||
| private final IntSupplier maxRetainedJobs; | ||
| private final Supplier<TimeValue> maxWaitForCompletion; | ||
| private final Supplier<TimeValue> maxKeepAlive; | ||
| private final ThreadPool threadPool; | ||
| private final ConcurrentMap<String, PPLAsyncQueryJob> jobs = new ConcurrentHashMap<>(); | ||
| private final Object admissionLock = new Object(); |
There was a problem hiding this comment.
wondering shall we extract serveral internal components to offload the responsibilities of this service class, such as async-query-core’s JobStore, LeaseManager etc?
…ntegration Introduces org.opensearch.sql.job — a five-state query lifecycle (PENDING, RUNNING, SUCCEEDED, FAILED, CANCELLED) — and wires the existing synchronous PPL transport path through it, in response to review of opensearch-project#5809. 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. PPL is the first engine wired. 3. Execution state is decoupled from retention. State stays RUNNING regardless of whether a caller is still waiting. wait_for_timeout and keep_alive are deferred; sync = submit + block on completion() (wait_for_timeout=forever), async is submit + return ID (future PR). Service responsibilities split into QueryJobService (public control interface), QueryJobStore (in-memory registry SPI), and QueryJob (state machine active object). SecurityAdapter SPI keeps OpenSearch types out of core. Sync integration: * TransportPPLQueryAction constructs the engine-typed PPLQueryRunner directly and hands it to QueryJobService.submit(runner, principal). Every PPLQueryRequest field (include_metadata, time_bounds, format, fetch_size, ...) survives the boundary. * Statement-level explain (query text starts with "explain") stays on the pre-existing two-listener PPLService.execute path; the query-only QueryRunner SPI cannot carry an explain response. * OpenTelemetry span attribute db.query.text keeps its anonymized text: the sink is a typed constructor argument on PPLQueryRunner, not a string-keyed Map<String,Object> smuggle. Module layout: core/job/ neutral interface + value types + reference in-memory store + engine SPI opensearch/job/ OpenSearchQueryJobService (symmetric with the existing OpenSearchQueryManager) ppl/ PPLQueryRunner (adapter over PPLService.execute) plugin/ Guice binding + transport wiring MVP scope keeps the surface small: no wait_for_completion_timeout, no keep_alive, no retention, no admission control, no REST/async endpoint. Every deferred feature lands behind an existing interface without touching QueryJob. Verification: ./gradlew :core:test :opensearch:test :ppl:test :opensearch-sql-plugin:test ./gradlew doctest -DignorePrometheus -> 86/86 pass ./gradlew :integ-test:integTest -Dtests.class='org.opensearch.sql.calcite.*' -> 5253 passed 0 failed 0 errors 205 skipped-by-design Design doc: docs/dev/query-job-mvp-design.md (design/query-job-mvp branch). Signed-off-by: Peng Huo <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
|
close. due to #5818 |
Description
This is the first implementation slice of #5796, under the PPL async-query meta issue #5765. It adds the execution contract and owner-node lifecycle core without registering REST routes or changing the existing synchronous PPL API.
The lifecycle module depends only on:
A successful final result must be visible through
currentResult()beforecompletion()completes normally.Core components:
PPLAsyncQueryJob: synchronized state machine for one query.PPLAsyncQueryService: job registry, timeout race, leases, capacity, task ownership, cancellation, expiration, and cleanup.PPLAsyncQueryJobId: opaque owner-routable identifier.PPLAsyncQueryUser: retained-job owner identity.DefaultAsyncQueryExecution: final-result adapter for existing PPL execution.Result before timeout
sequenceDiagram participant C as Submit caller participant S as PPLAsyncQueryService participant J as PPLAsyncQueryJob participant E as AsyncQueryExecution participant T as Wait timeout C->>S: start(wait) S->>J: create RUNNING S->>T: schedule S->>E: start and attach E-->>S: completion() S-->>T: cancel S->>J: complete() J-->>S: DirectResponse S->>E: currentResult() S-->>C: final snapshot without ID S->>E: close()Timeout before result
sequenceDiagram participant C as Submit caller participant S as PPLAsyncQueryService participant J as PPLAsyncQueryJob participant E as AsyncQueryExecution participant T as Wait timeout C->>S: start(wait) S->>J: create RUNNING S->>T: schedule S->>E: start and attach T-->>S: wait expires S->>J: retain() J-->>S: Retained(RUNNING) S->>E: currentResult() S-->>C: RUNNING snapshot with ID E-->>S: completion() S->>J: complete() J-->>S: ExecutionFinished C->>S: get(ID) S->>J: get() J-->>S: succeeded snapshot source S->>E: currentResult() S-->>C: retained final snapshotDELETE, expiration, startup abort, and shutdown produce typed removal transitions. The service removes registry state and releases tasks/executions after leaving the job lock.
The follow-up PR adds request parsing, REST/transport actions, owner-node forwarding, response formatting, and integration tests.
Related Issues
Part of #5796.
Parent meta issue: #5765.
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.