-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Makes search action cancelable by task management API #20405
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
Conversation
|
@imotov, want me to review it? |
|
@nik9000 sure - you from Task Management perspective and we will need somebody closer to Lucene ideally. |
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'd be cool to be able to list the phase and/or which shards you are waiting for. You could put all kinds of cool stuff in here one day! But for now this seems like the right thing to do.
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.
Yes, that's the plan, but I didn't want to clump everything into a single PR.
|
@jpountz, would you like to have a look at this from a Lucene perspective? |
jpountz
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.
In general it looks good to me, however I am concerned that wrapping the collector can cause significant slow downs so I'd like to either remove it or make it an opt-in for now and see what other options we have. For instance I'm wondering that we could make the slow down more acceptable by checking whether tasks are cancelled at the bulk scorer level so that we can perform the check less often.
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.
nit: I'd prefer that we move the sendRequest call to the try block and remove the return from the catch block
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 don't think task should ever be null at that point? Should we just assert that task is not null?
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 part can cause significant slow downs. There may be ways that we can make it better, eg. by doing it at the bulk scorer level so that we can perform the check less often. Can we remove it for now and work on making this part cancellable in another PR. Or at least make it an opt-in for now with a setting?
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.
@jpountz what do you think about this 662e1f5e3a2e9db89511749fe104e922edbb86ad?
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'm not a fan of the name (but I don't have better ideas) but this looks good to me.
773b9e1 to
662e1f5
Compare
jpountz
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.
I left a few more comments about the search part of the PR.
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.
Can we avoid taking a SearchContext as it makes this class hard to unit test, maybe we could eg. replace the search context with a BooleanSupplier and use a method reference? Then can you add some basic unit tests to this class?
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.
should we be consistent with the number of l? there is only one here while you put 2 in cancellation? (feel free to ignore, it could easily a special case in english that I don't know about!)
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.
Can you make it an actual javadoc and explain the trade-off?
662e1f5 to
fcb1be4
Compare
|
@jpountz I have implemented the changes that you have requested and rebased it against the current master since it quite a few things has changed. Would you mind taking another look when you have a chance? |
jpountz
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.
I left a question.
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.
construction contractor? :)
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.
why do we only do it in the fetch phase?
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.
sorry I just realized this is the createContext method and not executeFetchPhase as I initially thought.
then I'm wondering if we could have the lowLevelCancellation only on DefaultSearchContext rather than the SearchContext base class?
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.
done
|
The search part looks good to me. |
nik9000
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.
I left 19 review comments, mostly just comments and a few nits. Please make whatever changes you think are appropriate and merge when ready.
This is a huge start for canceling searches but I think it is worth expanding on the PR's description so folks know exactly what they are getting. Even with it's limitations I think this should be a release highlight for whatever release gets it. 5.1 I think....
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 guess you could make this a final class that takes a functional interface as its only parameter and runs it and you could still use lambdas for it. My instincts are that that is marginally better from a design standpoint (composition vs inheritance) and a little easier to read but I'm not sure.
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 sounds like an interesting idea, but I think we should do it on the TransportRequestHandler then and should, probably, be another PR.
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 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.
Can haz javadoc?
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.
Maybe mention that this amounts to a volatile read.
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's supplier implementation detail, isn't it? It seems to be wrong place to say something like this. However, the information about how often it will be called can be useful here. I will add that.
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.
Something like "This class assumes that the supplier is fast, with performance on the order of a volatile read." would give a lot of context to the decisions around how to use the Supplier.
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.
Can you remove the empty javdoc? We are going to fail the build on those at some point....
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.
Can you explain why this is needed in a comment? I'm never sure when to use this and when not to so I figure it'd be nice to have it explained.
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.
Because I want nodes with specific settings and I don't want other tests to run with these settings.
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.
Then could you do something like:
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE) // Changes settings
That'd make it clear why it is needed so folks don't go copying it into their tests without knowing why... 👼
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.
If we keep this maybe we should rename it so it doesn't run by default? And javadoc it? It is fairly obvious what it is for but I expect it isn't worth doing it during a regular test run because no one is reading it....
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.
Leftovers, deleted.
docs/reference/search.asciidoc
Outdated
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.
s/Long running search/Searchs/ ?
docs/reference/search.asciidoc
Outdated
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.
Mention that it only effects searches after the change to the setting.
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.
Are we thinking of automatically opting certain thing into this setting? Maybe we can have search benchmarks that compare?
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.
No, we are thinking about making it generally faster in the next iteration, so we can opt everything in.
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'm sorry about this nightmare.....
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'd love some way to say "just match anything in this position that looks like X" so you don't have to describe the whole path....
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.
Collector?
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.
Like, with the backticks.
Long running searches now can be cancelled using standard task cancellation mechanism.
67842a0 to
17ad88d
Compare
Long running searches now can be cancelled using standard task cancellation mechanism.