Skip to content

Improve FutureUtils.get exception handling#50339

Merged
henningandersen merged 4 commits intoelastic:masterfrom
henningandersen:fix_step_listener_exception
Dec 20, 2019
Merged

Improve FutureUtils.get exception handling#50339
henningandersen merged 4 commits intoelastic:masterfrom
henningandersen:fix_step_listener_exception

Conversation

@henningandersen
Copy link
Copy Markdown
Contributor

@henningandersen henningandersen commented Dec 18, 2019

FutureUtils.get() would unwrap ElasticsearchWrapperExceptions. This
is trappy, since nearly all usages of FutureUtils.get() expected only to
not have to deal with checked exceptions.

In particular, StepListener builds upon ListenableFuture which uses
FutureUtils.get to be informed about the exception passed to onFailure.
This had the bad consequence of masking away any exception that was an
ElasticsearchWrapperException like RemoteTransportException.
Specifically for recovery, this made CircuitBreakerExceptions happening
on the target node look like they originated from the source node.

The only usage that expected that behaviour was AdapterActionFuture.
The unwrap behaviour has been moved to that class.

I marked this for 7.5.2, please consider that too during reviews.

StepListener builds upon ListenableFuture, which used to use
FutureUtils.get to be informed about the exception passed to onFailure.
This had the bad consequence of masking away any exception that was an
ElasticsearchWrapperException like RemoteTransportException.
Specifically for recovery, this made CircuitBreakerExceptions happening
on the target node look like they originated from the source node.
@henningandersen henningandersen added >non-issue :Distributed/Recovery Anything around constructing a new shard, either from a local or a remote source. v8.0.0 v7.6.0 v7.5.2 labels Dec 18, 2019
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-distributed (:Distributed/Recovery)

@jaymode
Copy link
Copy Markdown
Member

jaymode commented Dec 18, 2019

FutureUtils doesn't document why the top level ElasticsearchException is thrown away, do you know why it does so? That seems trappy

@henningandersen
Copy link
Copy Markdown
Contributor Author

henningandersen commented Dec 19, 2019

Thanks @jaymode , you are right, it is trappy. I originally refrained from fixing it there because this is used in AdapterActionFuture.actionGet (which is used in 100s of places and affects 7.x transport client). Doing more home-work on this, it seems this was originally introduced there to precisely unwrap things like RemoteTransportException. A refactor moved the code out into FutureUtils and it has since been used in a couple more places (I believe only to avoid handling checked exceptions, not to get the unwrap effect).

I think the right solution is to not unwrap in FutureUtils and do the unwrap in AdapterActionFuture instead. I will amend the PR to reflect that.

Now only do the unwrap when using AdapterActionFuture.
@henningandersen henningandersen changed the title Improve ListenableFuture exception handling Improve FutureUtils.get exception handling Dec 19, 2019
@henningandersen
Copy link
Copy Markdown
Contributor Author

This PR has been updated to fix this in FutureUtils.get() instead and is ready for review.

Copy link
Copy Markdown
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks Henning.

@henningandersen henningandersen merged commit c82113e into elastic:master Dec 20, 2019
henningandersen added a commit to henningandersen/elasticsearch that referenced this pull request Dec 20, 2019
FutureUtils.get() would unwrap ElasticsearchWrapperExceptions. This
is trappy, since nearly all usages of FutureUtils.get() expected only to
not have to deal with checked exceptions.

In particular, StepListener builds upon ListenableFuture which uses
FutureUtils.get to be informed about the exception passed to onFailure.
This had the bad consequence of masking away any exception that was an
ElasticsearchWrapperException like RemoteTransportException.
Specifically for recovery, this made CircuitBreakerExceptions happening
on the target node look like they originated from the source node.

The only usage that expected that behaviour was AdapterActionFuture.
The unwrap behaviour has been moved to that class.
henningandersen added a commit that referenced this pull request Jan 3, 2020
FutureUtils.get() would unwrap ElasticsearchWrapperExceptions. This
is trappy, since nearly all usages of FutureUtils.get() expected only to
not have to deal with checked exceptions.

In particular, StepListener builds upon ListenableFuture which uses
FutureUtils.get to be informed about the exception passed to onFailure.
This had the bad consequence of masking away any exception that was an
ElasticsearchWrapperException like RemoteTransportException.
Specifically for recovery, this made CircuitBreakerExceptions happening
on the target node look like they originated from the source node.

The only usage that expected that behaviour was AdapterActionFuture.
The unwrap behaviour has been moved to that class.
henningandersen added a commit that referenced this pull request Jan 3, 2020
FutureUtils.get() would unwrap ElasticsearchWrapperExceptions. This
is trappy, since nearly all usages of FutureUtils.get() expected only to
not have to deal with checked exceptions.

In particular, StepListener builds upon ListenableFuture which uses
FutureUtils.get to be informed about the exception passed to onFailure.
This had the bad consequence of masking away any exception that was an
ElasticsearchWrapperException like RemoteTransportException.
Specifically for recovery, this made CircuitBreakerExceptions happening
on the target node look like they originated from the source node.

The only usage that expected that behaviour was AdapterActionFuture.
The unwrap behaviour has been moved to that class.
SivagurunathanV pushed a commit to SivagurunathanV/elasticsearch that referenced this pull request Jan 23, 2020
FutureUtils.get() would unwrap ElasticsearchWrapperExceptions. This
is trappy, since nearly all usages of FutureUtils.get() expected only to
not have to deal with checked exceptions.

In particular, StepListener builds upon ListenableFuture which uses
FutureUtils.get to be informed about the exception passed to onFailure.
This had the bad consequence of masking away any exception that was an
ElasticsearchWrapperException like RemoteTransportException.
Specifically for recovery, this made CircuitBreakerExceptions happening
on the target node look like they originated from the source node.

The only usage that expected that behaviour was AdapterActionFuture.
The unwrap behaviour has been moved to that class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/Recovery Anything around constructing a new shard, either from a local or a remote source. >non-issue v7.5.2 v7.6.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants