-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Introduce a search_throttled
threadpool
#33732
Conversation
Today all searches happen on the search threadpool which is the correct behavior in almost any case. Yet, there are exceptions where for instance searches are required to succeed ie. in the case of a .security index. These searches should not be rejected if a node is under load. There are other more specialized usecases were searches should be passed through a single-thread threadpool to reduce impact on a node. Relates to elastic#33205
Pinging @elastic/es-search-aggs |
the majority of the change is cutting SearchService over to async execution. The actual addition of the setting and such is really a smallish change. |
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.
LGTM - I didn't expect this change to be so simple.
cleanContext(context); | ||
} | ||
public void executeQueryPhase(InternalScrollSearchRequest request, SearchTask task, | ||
ActionListener<ScrollQuerySearchResult> listener) { |
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: ident
this.canMatch = canMatch; | ||
} | ||
|
||
|
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: extra line
I'm curious why we now fork can_match tasks unless the default threadpool is used, what is the benefit compared to never forking? |
} | ||
if (ThreadPool.Names.SEARCH.equals(s) == false && ThreadPool.Names.GENERIC.equals(s) == false && | ||
ThreadPool.THREAD_POOL_TYPES.containsKey(s)) { | ||
throw new IllegalArgumentException("Invalid valid for [index.search.threadpool] - " + s + " is a reserved built-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.
valid
-> value
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 some concerns.
if (s == null || s.isEmpty()) { | ||
throw new IllegalArgumentException("Value for [index.search.threadpool] must be a non-empty string."); | ||
} | ||
if (ThreadPool.Names.SEARCH.equals(s) == false && ThreadPool.Names.GENERIC.equals(s) == 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 really do not like that these can go on the generic thread pool. This thread pool can be quite large (we only recently bound it but it's a really large bound) and it has no queue. Especially since the need for this only arises if the node is under load, now that we are going unbounded it might only add to the pain the node is already experiencing. I understand the entire point is so that certain search requests never get rejected but I think we should find a different solution than using the generic thread pool for that. For example, could we force put them? Could we enable force putting them at the top of the queue?
@jasontedor here is my suggestion.
@jpountz with 2. I think your question is more clear as well. for the I guess that makes this change more contained and addresses all concerns. |
@s1monw The plan sounds good, I think that we are mostly on the same page. I do wonder if we need to allow users to use |
I can do that. Private setting sounds good to me. then this PR will only add the setting and the reading. The test can add a plugin that allows changing it. |
Thanks @s1monw. |
The plan sounds good to me too. Then maybe call the setting "frozen_search" rather than "search_single" since it would be dedicated to frozen indices? |
@jpountz @jasontedor I pushed a new commit implementing the first 2 steps. I still need to do some followups to ensure respect the |
@elasticmachine test this please |
@jasontedor @jpountz I pushed more changes |
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.
Looks phenomenal @s1monw. Thank you for the extra iterations.
search_throttled
threadpool
Today all searches happen on the search threadpool which is the correct behavior in almost any case. Yet, there are exceptions where for instance searches searches should be passed through a single-thread thread-pool to reduce impact on a node. This change adds a index-private setting that allows to mark an index as throttled for searches and forks off all non-stats searcher access to this thread-pool for indices that are marked as `index.search.throttled`
Today all searches happen on the search threadpool which is the correct behavior in almost any case. Yet, there are exceptions where for instance searches searches should be passed through a single-thread thread-pool to reduce impact on a node. This change adds a index-private setting that allows to mark an index as throttled for searches and forks off all non-stats searcher access to this thread-pool for indices that are marked as `index.search.throttled`
Today all searches happen on the search threadpool which is the correct
behavior in almost any case. Yet, there are exceptions where for instance
searches searches should be passed through a single-thread
threadpool to reduce impact on a node. This change adds a index-private setting that allows to mark an index as throttled for searches and forks off all non-stats searcher access to this threadpool for indices that are marked as
index.search.throttled