-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle rejection in PrioritizedThrottledTaskRunner #92621
Handle rejection in PrioritizedThrottledTaskRunner #92621
Conversation
Today `PrioritizedThrottledTaskRunner` submits a bare `Runnable` to the executor, wrapping around the `Runnable` received from the caller, which effectively assumes that tasks are never rejected from the threadpool. However this utility accepts any `Executor`, so this is not a safe assumption to make. This commit moves to submitting an `AbstractRunnable` to the executor, and to requiring callers to pass in an `AbstractRunnable`, so that failures and rejections can be handled properly.
Pinging @elastic/es-distributed (Team:Distributed) |
Hi @DaveCTurner, I've created a changelog YAML for you. |
|
spawnThread.interrupt(); | ||
spawnThread.join(); | ||
assertThat(taskRunner.runningTasks(), equalTo(0)); | ||
assertThat(taskRunner.queueSize(), equalTo(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we assert at least one rejection happened?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I think we can do that. See 0fc9484.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering since we now use AbstractRunnable
, would it make sense to also require an EsThreadPoolExecutor
instead of an Executor
? From what I understand, isForceExecution
is enforced only if we use one of our own Executors.
I think not, for instance because IMO it's up to the caller to use an executor which is appropriate for their tasks. If they're relying on |
@elasticmachine please run elasticsearch-ci/part-2 |
I could see some value in accepting a plain |
Today
PrioritizedThrottledTaskRunner
submits a bareRunnable
to the executor, wrapping around theRunnable
received from the caller, which effectively assumes that tasks are never rejected from the threadpool. However this utility accepts anyExecutor
, so this is not a safe assumption to make. This commit moves to submitting anAbstractRunnable
to the executor, and to requiring callers to pass in anAbstractRunnable
, so that failures and rejections can be handled properly.