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

Remove dangerous default executor from HandledTransportAction #100162

Conversation

DaveCTurner
Copy link
Contributor

Today subclasses of HandledTransportAction can specify the executor on
which they run, but the executor is optional and if omitted will use
DIRECT_EXECUTOR_SERVICE, which means the action runs on a transport
thread. This is a dangerous default behaviour because it makes it easy
to add new transport actions which implicitly run on a network thread,
which is very hard to pick up in reviews.

This commit makes the executor explicit in all callers, and marks the
dangerous methods for removal.

Today subclasses of `HandledTransportAction` can specify the executor on
which they run, but the executor is optional and if omitted will use
`DIRECT_EXECUTOR_SERVICE`, which means the action runs on a transport
thread. This is a dangerous default behaviour because it makes it easy
to add new transport actions which implicitly run on a network thread,
which is very hard to pick up in reviews.

This commit makes the executor explicit in all callers, and marks the
dangerous methods for removal.
@DaveCTurner DaveCTurner added :Distributed/Network Http and internode communication implementations >refactoring v8.11.0 labels Oct 2, 2023
@DaveCTurner
Copy link
Contributor Author

@elasticmachine please run elasticsearch-ci/part-2

@DaveCTurner DaveCTurner marked this pull request as ready for review October 3, 2023 11:18
@DaveCTurner DaveCTurner requested a review from a team as a code owner October 3, 2023 11:18
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Meta label for distributed team label Oct 3, 2023
@elasticsearchmachine
Copy link
Collaborator

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

No need for callers to specify `canTripCircuitBreaker`, the default for
this is safe.
@DaveCTurner
Copy link
Contributor Author

NB this was almost completely mechanical, just automatically inlining the bad methods within HandledTransportAction and then bringing them back to mark them as deprecated. However then I realised that this added the unnecessary canTripCircuitBreaker parameter to all callers too so I did another almost-completely mechanical change to remove that in 0f18e27.

Copy link
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

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

Fleet change LGTM

Copy link
Contributor

@DiannaHohensee DiannaHohensee left a comment

Choose a reason for hiding this comment

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

Nice, much more obvious :)

import org.elasticsearch.transport.TransportService;

import java.util.concurrent.Executor;

/**
* A TransportAction that self registers a handler into the transport service
* A {@link TransportAction} which registers a handler for itself with the transport service.
Copy link
Contributor

Choose a reason for hiding this comment

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

[opt] not really sure what 'self registers' or now 'for itself' add in terms of information. Could perhaps remove entirely -- or elaborate, if there is some meaning I'm missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm yeah in a sense what other action could we really be registering here? But we do register subsidiary handlers for actions with names like actionName + "[x]" elsewhere. I changed it to make it clearer that we're not mangling the name at all with the registration.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, that's a better lead on what it's doing, thank you.

I don't think I myself have an understanding of what registering action names means in the bigger picture, but that's not something to be documented in this patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not very well documented today; I opened #100229

Copy link
Contributor

Choose a reason for hiding this comment

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

Great, thank you!

@DaveCTurner DaveCTurner added the auto-merge Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Oct 3, 2023
@elasticsearchmachine elasticsearchmachine merged commit 0a31ce6 into elastic:main Oct 3, 2023
11 checks passed
@DaveCTurner DaveCTurner deleted the 2023/10/02/HandledTransportAction-default-executor branch October 3, 2023 21:55
DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Oct 4, 2023
These things are no longer used. Relates elastic#100162
DaveCTurner added a commit that referenced this pull request Oct 4, 2023
These things are no longer used. Relates #100162
@DaveCTurner DaveCTurner restored the 2023/10/02/HandledTransportAction-default-executor branch June 17, 2024 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Distributed/Network Http and internode communication implementations >refactoring Team:Distributed Meta label for distributed team v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants