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

Refactor TransportSearchAction to allow run can_match exclusively #95064

Merged
merged 4 commits into from
Apr 17, 2023

Conversation

dnhatn
Copy link
Member

@dnhatn dnhatn commented Apr 6, 2023

I am currently testing the privileges of cluster_search_shards and evaluating whether we should create a new transport action or enhance the current one. In either scenario, we will require the capability to exclusively run the can_match phase using TransportSearchAction. I opened this pull request containing only the required changes (spun-off from #94534). This will enable us to review the change while we decide on the transport action option.

Relates #94534

@dnhatn dnhatn added >non-issue :Search/Search Search-related issues that do not fall into other categories v8.8.0 labels Apr 6, 2023
@dnhatn dnhatn changed the title Refactor TransportSearchAction to allow run can_match separately Refactor TransportSearchAction to allow run can_match exclusively Apr 6, 2023
@dnhatn dnhatn marked this pull request as ready for review April 6, 2023 05:51
@dnhatn dnhatn requested a review from javanna April 6, 2023 05:51
@elasticsearchmachine elasticsearchmachine added the Team:Search Meta label for search team label Apr 6, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

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

left a couple of questions. Looks neat!

);
};
return searchAsyncAction;
AbstractSearchAsyncAction<? extends SearchPhaseResult> searchAsyncAction = switch (searchRequest.searchType()) {
Copy link
Member

Choose a reason for hiding this comment

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

you can return what the switch returns directly.

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 fixed it in 18b7182.


runCoordinatorRewritePhase();
if (getNumShards() == 0) {
finishPhase();
Copy link
Member

Choose a reason for hiding this comment

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

I believe you added this if because you removed the same check that happens before at the beginning of the start method. As far as I can see, runCoordinatorRewritePhase loops over the iterators which does nothing if they are empty, and then calls finishPhase. That makes me wonder if we need this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I removed it in e412458.

)
);
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

+1 on removing this if not needed. The only reason I can think of that this was here is to return as early as possible and avoid calling executor.execute rather than returning a little later.

If I had to pick between this check and the one you added above (provided we need one of them, which we maybe don't?), I would keep this one as it happens earlier. Maybe we could call finishPhase directly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion. I added the early finish back in 18b7182.

@dnhatn
Copy link
Member Author

dnhatn commented Apr 17, 2023

run elasticsearch-ci/part-3

@dnhatn
Copy link
Member Author

dnhatn commented Apr 17, 2023

@javanna Thanks for the review.

@dnhatn dnhatn merged commit 9b73004 into elastic:main Apr 17, 2023
@dnhatn dnhatn deleted the refactor-search-action branch April 17, 2023 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>refactoring :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants