Skip to content
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

Fix EsAbortPolicy to conform to API #29075

Merged
merged 7 commits into from
Mar 16, 2018

Conversation

jasontedor
Copy link
Member

The rejected execution handler API says that rejectedExecution(Runnable, ThreadPoolExecutor) throws a RejectedExecutionException if the task must be rejected due to capacity on the executor. We do throw something that smells like a RejectedExecutionException (it is named EsRejectedExecutionException) yet we violate the API because EsRejectedExecutionException is not a RejectedExecutionException. This has caused problems before where we try to catch RejectedExecution when invoking rejectedExecution but this causes EsRejectedExecutionException to go uncaught. This commit addresses this by modifying EsRejectedExecutionException to extend RejectedExecutionException. Addtionally, we fix an issue with how causes are unwrapped. Without this change, since EsRejectedExecutionException is no longer an ElasticsearchException, the root cause of a rejection would be reported as a remote_transport_exception instead of as an es_rejected_execution_exception.

Closes #19508

The rejected execution handler API says that rejectedExecution(Runnable,
ThreadPoolExecutor) throws a RejectedExecutionException if the task must
be rejected due to capacity on the executor. We do throw something that
smells like a RejectedExecutionException (it is named
EsRejectedExecutionException) yet we violate the API because
EsRejectedExecutionException is not a RejectedExecutionException. This
has caused problems before where we try to catch RejectedExecution when
invoking rejectedExecution but this causes EsRejectedExecutionException
to go uncaught. This commit addresses this by modifying
EsRejectedExecutionException to extend
RejectedExecutionException. Addtionally, we fix an issue with how causes
are unwrapped. Without this change, since EsRejectedExecutionException
is no longer an ElasticsearchException, the root cause of a rejection
would be reported as a remote_transport_exception instead of as an
es_rejected_execution_exception.
@jasontedor jasontedor added review :Core/Infra/Core Core issues without another label v7.0.0 v6.3.0 labels Mar 14, 2018
@jasontedor jasontedor requested a review from bleskes March 14, 2018 22:13
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@jasontedor
Copy link
Member Author

retest this please

Copy link
Contributor

@bleskes bleskes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though I presume the BWC bridge is coming in the 6.3 port?

@jasontedor
Copy link
Member Author

LGTM, though I presume the BWC bridge is coming in the 6.3 port?

That was the plan but after I started preparing that I realized it is a little hairy. I pushed it here and will change the version after I backport. Would you please take a look at the bridge that I pushed here?

@jasontedor
Copy link
Member Author

Addtionally, we fix an issue with how causes are unwrapped.

I think that this change should be made in a separate change so I have pulled it out of this one.

@jasontedor
Copy link
Member Author

@bleskes Can you take another look?

Copy link
Contributor

@bleskes bleskes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

} else if (throwable instanceof EsRejectedExecutionException) {
// TODO: remove the if branch when master is bumped to 8.0.0
assert Version.CURRENT.major < 8;
if (version.before(Version.V_7_0_0_alpha1)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like you're not planning to back port this any more. Can you push a comment in the 6.x branch to note that if you change the wire level there, you need to look at 7.x code too? I don't think we will so a comment seems enough (a test is tricky)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am planning to backport. I do it this way so BWC tests can pass on this branch. Then I backport and change the version. Then I remove this code from master.

A test is very tricky indeed. I thought about a qa test in 6.x only (with a bulk thread pool with queue 0 to force a rejection). I am not sure it’s worth it. I did test it manually like this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that a test is an overkill. At least any test I can think of.

@jasontedor jasontedor merged commit 6bf742d into elastic:master Mar 16, 2018
jasontedor added a commit that referenced this pull request Mar 16, 2018
The rejected execution handler API says that rejectedExecution(Runnable,
ThreadPoolExecutor) throws a RejectedExecutionException if the task must
be rejected due to capacity on the executor. We do throw something that
smells like a RejectedExecutionException (it is named
EsRejectedExecutionException) yet we violate the API because
EsRejectedExecutionException is not a RejectedExecutionException. This
has caused problems before where we try to catch RejectedExecution when
invoking rejectedExecution but this causes EsRejectedExecutionException
to go uncaught. This commit addresses this by modifying
EsRejectedExecutionException to extend
RejectedExecutionException.
@jasontedor jasontedor deleted the rejected-execution-exception branch March 16, 2018 19:51
@jasontedor
Copy link
Member Author

6.x: d72757f
Removing BWC layer from master: 1f1a4d1

jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Mar 20, 2018
* master: (476 commits)
  Fix compilation errors in ML integration tests
  Small code cleanups and refactorings in persistent tasks (elastic#29109)
  Update allocation awareness docs (elastic#29116)
  Configure error file for archive packages (elastic#29129)
  Configure heap dump path for archive packages (elastic#29130)
  Client: Add missing test
  getMinGenerationForSeqNo should acquire read lock (elastic#29126)
  Backport - Do not renew sync-id PR to 5.6 and 6.3
  Client: Wrap SSLHandshakeException in sync calls
  Fix creating keystore when upgrading (elastic#29121)
  Align thread pool info to thread pool configuration (elastic#29123)
  TEST: Adjust translog size assumption in new engine
  Docs: HighLevelRestClient#multiGet (elastic#29095)
  Client: Wrap synchronous exceptions (elastic#28919)
  REST: Clear Indices Cache API simplify param parsing (elastic#29111)
  Fix typo in ExceptionSerializationTests
  Remove BWC layer for rejected execution exception
  Fix EsAbortPolicy to conform to API (elastic#29075)
  [DOCS] Removed prerelease footnote from upgrade table.
  Docs: Support triple quotes (elastic#28915)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Core Core issues without another label v6.3.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EsAbortPolicy violates the RejectedExecutionHandler API
4 participants