-
Notifications
You must be signed in to change notification settings - Fork 25.6k
MRT should default to true for CPS searches
#138105
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
base: main
Are you sure you want to change the base?
MRT should default to true for CPS searches
#138105
Conversation
| clusterSupportsFeature, | ||
| setSize, | ||
| searchUsageHolder, | ||
| Optional.empty() |
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.
Previously, this overload passed in false for crossProjectEnabled. Now it passes in Optional.empty() to be compatible. Same theory, different syntax.
|
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
|
Hi @pawankartik-elastic, I've created a changelog YAML for you. |
quux00
left a comment
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.
Left a few comments for feedback.
| public RestSearchTemplateAction(Predicate<NodeFeature> clusterSupportsFeature, Settings settings) { | ||
| this.clusterSupportsFeature = clusterSupportsFeature; | ||
| this.settings = settings; | ||
| this.crossProjectEnabled = settings != null && settings.getAsBoolean("serverless.cross_project.enabled", false); |
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 think we want to use the CrossProjectModeDecider for this, not hardcode the specific setting here.
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.
Oh, yes! Thanks for pointing this one out.
| size -> searchRequest.source().size(size) | ||
| size -> searchRequest.source().size(size), | ||
| null, | ||
| Optional.of(crossProjectEnabled) |
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.
It worries me that the only other RestAction (besides the obvious ones of RestSearchAction and the async RestSearchAction) you had to change was this one.
But there are other several Rest actions that converge on _search that are (or will be) also CPS enabled:
_msearch/template
_eql/search
_sql
_mvt
_<index>/_count
_cat/count
We should track down whether any of those allow setting ccs_minimize_roundtrips and if so, if additional code changes are needed.
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.
The endpoints you've listed have their own dedicated parsing strategies that are lenient wrt the query parameters being passed, and there's some inconsistency between our public-facing docs and how the endpoints work. For example, for some of them, you can pass MRT, but it's not consumed. Here's why I only had to touch only a few Rest*Action-s:
- Both
_eqland_msearch/templateaccept MRT and have their own dedicated parser. I can accommodate these changes there. _sqldoes not appear to accept MRT and has its own parser._mvtdoes not appear to accept MRT and has its own parser.{index}/_countdoes not appear to accept MRT and has its own simple parser._cat/countdoes not appear to accept MRT and has its own simple parser.
Endpoints that aren't explicitly consuming MRT are defaulting to true.
Own parser = the parsing happens within the respective Rest*Action with info manually being extracted via RestRequest#param() and passed to the respective *Request-s.
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.
Awesome. Thanks. Excellent analysis. 🥇
quux00
left a comment
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.
Nice work. This looks good. Down to the last few comments/changes.
| size -> searchRequest.source().size(size) | ||
| size -> searchRequest.source().size(size), | ||
| null, | ||
| Optional.of(crossProjectEnabled) |
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.
Awesome. Thanks. Excellent analysis. 🥇
| if (searchType != null) { | ||
| searchRequest.searchType(searchType); | ||
| } | ||
| // When crossProjectEnabled is true, ccsMinimizeRoundtrips is guaranteed to be true. |
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.
This comment seems out of place? Cross-project enabled part is handled down below, not here, so I'm not sure what this comment is getting at.
Also - be aware that a year from now this statement may no longer be true. We might go and change the default to be false for CPS everywhere if batched execution lives up to its promises, so comments like this will need to be tracked down and reversed/removed if/when that happens, so I would only add comments like this if there are really helpful to understand code flow.
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 have a followup question on this: are we guaranteed that for serverless/CPS, we will keep same MRT mode for everywhere and not give a choice like we do for stateful CCS? The reason I'm asking is that right now telemetry explicitly does not track MRT state for CPS, but if we would in the future allow the user to choose then we may need to change that and start tracking it again like we do for CCS.
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.
This comment is true but slightly misleading. MultiSearchRequest#readMultiLineFormat() is called from RestMultiSearchAction#parseMultiLineRequest(), and that's the method that passes down the ccsMinimizeRoundtrips you're seeing here — it refers to the MRT query parameter and is null when not specified. However, when provided an explicit value, we flip it to true anyway for CPS and pass it down here. That's what I meant by "ccsMinimizeRoundtrips is guaranteed to be true".
The misleading part: it only applies to CPS; should've mentioned this. I'll rewrite it in the next push.
| Boolean ccsMinimizeRoundtrips, | ||
| boolean allowExplicitIndex | ||
| boolean allowExplicitIndex, | ||
| Optional<Boolean> crossProjectEnabled |
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.
Optional suggestion: Add javadoc here what Optional.TRUE, Optional.FALSE and Optional.empty mean. That's not going to be obvious. Or if you feel like you have to document that 20 times, put a note here on where to see the javadoc for that?
| if (crossProjectEnabled.orElse(false)) { | ||
| if (request.hasParam("ccs_minimize_roundtrips")) { | ||
| request.param("ccs_minimize_roundtrips"); | ||
| HeaderWarning.addWarning(MRT_SET_IN_CPS_WARN); |
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.
This would be the place to check that we don't set this warning more than once (if that's possible).
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.
There's only 1 place where we don't want to set this warning multiple times: when parsing multiline requests. I could use a simple boolean value to see if we've already fired a warning in the respective multiline request parser itself, rather than bloating up this method just to accommodate one scenario. Wdyt?
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.
Does that one place (multiline requests) use this method?
One option here is to add a new method to HeaderWarning: HeaderWarning.addWarningIfUnique(), but if that would take a while to build and test and you don't need it here, then consider this an optional suggestion.
We could also file a follow-on ticket to handle it later. It's not essential for CPS Tech Preview. (If you choose this path, let me know so I can create the GA scope ticket for it.)
For Cross Project Search, we:
ccs_minimize_roundtrips. Should they attempt to do so, its value should be dropped, and,_async_searchshould defaultccs_minimize_roundtripstotrue. All other searches, anyway, at present, default totruesince they do not callsetCcsMinimizeRoundtrips()andSearchRequestsets it totrueupon its instantiation.Currently, we do accept values for
ccs_minimize_roundtripsfor Serverless, even though there's no Cross Cluster Search functionality. However, it's ineffective since the search is effectively a "local" search (seeTransportSearchAction#executeLocalSearch()) and the values get ignored. Since this parameter would have no effect in Serverless, moving forward, we plan on notifying the same to the user via a Kibana banner.At some point in the future, instead of ignoring this parameter, we'll error out (only for Serverless).
HeaderWarning#addWarning().