Skip to content

Conversation

@imotov
Copy link
Contributor

@imotov imotov commented Sep 9, 2016

Long running searches now can be cancelled using standard task cancellation mechanism.

@imotov imotov added >enhancement review :Search/Search Search-related issues that do not fall into other categories :Distributed Coordination/Task Management Issues for anything around the Tasks API - both persistent and node level. v6.0.0-alpha1 v5.1.1 labels Sep 9, 2016
@nik9000
Copy link
Member

nik9000 commented Sep 9, 2016

@imotov, want me to review it?

@imotov
Copy link
Contributor Author

imotov commented Sep 9, 2016

@nik9000 sure - you from Task Management perspective and we will need somebody closer to Lucene ideally.

Copy link
Member

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.

Copy link
Contributor Author

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.

@nik9000
Copy link
Member

nik9000 commented Sep 12, 2016

@jpountz, would you like to have a look at this from a Lucene perspective?

Copy link
Contributor

@jpountz jpountz left a 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.

Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Contributor

@jpountz jpountz Sep 20, 2016

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@imotov imotov force-pushed the make-searches-cancellable branch from 773b9e1 to 662e1f5 Compare October 13, 2016 04:00
Copy link
Contributor

@jpountz jpountz left a 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.

Copy link
Contributor

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?

Copy link
Contributor

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!)

Copy link
Contributor

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?

@imotov imotov force-pushed the make-searches-cancellable branch from 662e1f5 to fcb1be4 Compare October 17, 2016 16:45
@imotov
Copy link
Contributor Author

imotov commented Oct 17, 2016

@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?

Copy link
Contributor

@jpountz jpountz left a 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.

Copy link
Contributor

Choose a reason for hiding this comment

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

construction contractor? :)

Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@jpountz
Copy link
Contributor

jpountz commented Oct 20, 2016

The search part looks good to me.

Copy link
Member

@nik9000 nik9000 left a 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....

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

++

Copy link
Member

Choose a reason for hiding this comment

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

Can haz javadoc?

Copy link
Member

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.

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 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.

Copy link
Member

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.

Copy link
Member

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....

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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... 👼

Copy link
Member

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....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Leftovers, deleted.

Copy link
Member

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/ ?

Copy link
Member

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.

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.....

Copy link
Member

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....

Copy link
Member

Choose a reason for hiding this comment

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

Collector?

Copy link
Member

Choose a reason for hiding this comment

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

Like, with the backticks.

@nik9000 nik9000 removed the :Distributed Coordination/Task Management Issues for anything around the Tasks API - both persistent and node level. label Oct 20, 2016
Long running searches now can be cancelled using standard task cancellation mechanism.
@imotov imotov force-pushed the make-searches-cancellable branch from 67842a0 to 17ad88d Compare October 26, 2016 01:00
@imotov imotov merged commit 17ad88d into elastic:master Oct 26, 2016
@imotov imotov deleted the make-searches-cancellable branch May 1, 2020 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants