Repository navigation
Conversation
…rch-project#5801) When the SQL worker pools were full, ThreadPool.schedule dropped the rejection, so a sync query never got a response and an async query stayed RUNNING forever. Submit to the executor directly and report the rejection as 429 "thread pool is saturated; retry later". Run at most plugins.ppl.async.node_concurrent_running_queries async queries per node. Extra queries wait as PENDING in a queue bounded by plugins.ppl.async.max_queued_queries and fail after plugins.ppl.async.max_queued_time. Limit the finished queries kept for polling with plugins.ppl.async.max_retained_jobs. A queued query starts with its submitter's thread context. Signed-off-by: Peng Huo <penghuo@gmail.com>
…oject#5801) Only a queued job starts on another thread, and the scheduler is what starts it. Capture the submitting thread's context when the job is queued and restore it when the job starts, as the other executors in the opensearch module do for the query task. This replaces ContextPreservingQueryRunner in the plugin module and works for any QueryRunner. Signed-off-by: Peng Huo <penghuo@gmail.com>
…oject#5801) plugins.ppl.async.max_retained_jobs bounds finished jobs kept for polling, as the retained result budget does. Both are tracked in opensearch-project#5804, so this change keeps only the running and queue limits. Signed-off-by: Peng Huo <penghuo@gmail.com>
Signed-off-by: Peng Huo <penghuo@gmail.com>
…-project#5801) Report a job whose submit wait expires as PENDING while it is queued and RUNNING otherwise, without re-reading its outcome; the inline race handling belongs with the retained result budget (opensearch-project#5804). Drop the executor-shutdown flag that only the removed retry read, make failQueued void, and keep the scheduler's counters package-private. Signed-off-by: Peng Huo <penghuo@gmail.com>
…#5801) A running limit only makes sense at or below the worker threads, and users cannot pick it well. Run as many async queries as sql-worker has threads and drop plugins.ppl.async.node_concurrent_running_queries; further queries wait as PENDING in the scheduler's queue instead of the worker pool's. Signed-off-by: Peng Huo <penghuo@gmail.com>
…h-project#5801) Signed-off-by: Peng Huo <penghuo@gmail.com>
…pensearch-project#5801) Wrap the task with ThreadContext.preserveContext before execute, as ThreadPool.schedule does, so the submitted task carries the caller's context regardless of the executor implementation. Signed-off-by: Peng Huo <penghuo@gmail.com>
…ct#5801) Signed-off-by: Peng Huo <penghuo@gmail.com>
…roject#5801) The plugin always wires the scheduler, so the service no longer starts jobs without one; tests pass a scheduler instead. Remove the QueryResult.Running(id) constructor that only tests used, and arm the wait deadline before queueing so a failure to schedule it cannot leave the job queued. Signed-off-by: Peng Huo <penghuo@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR stops async PPL queries from overloading a node, and stops queries from hanging when the SQL worker pools are full.
Busy worker pools. When the SQL worker pools were full, a new query was dropped without an error. A normal query never got a response, and an async query showed
RUNNINGforever. Now the query fails right away with429"thread pool is saturated; retry later". An async query whose id was already returned endsFAILEDwith the same error.Too many async queries. One user could start thousands of async queries and slow down everyone else. Now each node runs only as many async queries at a time as its
sql-workerthread pool has threads. Extra queries wait in a queue with the statusPENDINGand start in the order they were submitted, like a thread pool with a bounded work queue. When the queue is full, new submits get429. A query that waits too long endsFAILED.plugins.ppl.async.max_queued_queries100PENDING. Extra submits get429.plugins.ppl.async.max_queued_time5mPENDINGbefore it endsFAILED.A queued query can start on a different thread from the one that submitted it, so it runs with the submitting user's permissions and context.
Normal queries share the SQL worker pools and are not counted. An async query can still be refused by a full pool, and then it fails as described above. Admitting every query through one scheduler is tracked in opensearch-project#5912.
All new settings can be changed at runtime. They are documented in
docs/user/ppl/admin/settings.mdanddocs/user/ppl/interfaces/endpoint.md.docs/dev/ppl-async-query-lifecycle.mdexplains the states of an async query and how it moves between them.Related Issues
Part of opensearch-project#5801. Parent: opensearch-project#5765.
Check List
--signoffor-s.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.