-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Introduce a search_throttled
threadpool
#33732
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
711ccbe
Allow for pluggable search threadpool
s1monw 5d8e2b9
Merge branch 'master' into pluggable_search_thread_pool
s1monw 352e1b6
cut over to a boolean setting
s1monw 0b974f8
cut over to PrivateIndex settings
s1monw a166ed2
prepare validate action
s1monw bfb6daa
Merge branch 'master' into pluggable_search_thread_pool
s1monw 3f2fa47
Ensure all access to getSearcher executes on a search_sequential thre…
s1monw e447a2b
Fix imports
s1monw 1c39708
Merge branch 'master' into pluggable_search_thread_pool
s1monw 98a2aca
Rename search_sequentical to search_throttled and don't fork in canMatch
s1monw dd3172b
fix nits
s1monw 5f8aa3b
fix test
s1monw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
import org.elasticsearch.index.translog.Translog; | ||
import org.elasticsearch.ingest.IngestService; | ||
import org.elasticsearch.node.Node; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
@@ -277,6 +278,26 @@ public final class IndexSettings { | |
return s; | ||
}, Property.Dynamic, Property.IndexScope); | ||
|
||
/** | ||
* Allows to specify a dedicated threadpool to execute searches. This is an expert setting and should be used with care. | ||
* Indices that for instance contain metadata information that need to be always accessible and should not be rejected | ||
* can be served through a different threadpool. Or searches that have a lower priority can go through a threadpool with a | ||
* single thread to prevent larger impact on other searches with a higher priority. This setting allows for custom threadpools | ||
* or search and generic. Other build-in threadpools are disallowed. | ||
*/ | ||
public static final Setting<String> INDEX_SEARCH_THREAD_POOL = | ||
new Setting<>("index.search.threadpool", ThreadPool.Names.SEARCH, s -> { | ||
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 && | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"threadpool"); | ||
} | ||
return s; | ||
}, Property.IndexScope, Property.Dynamic); | ||
|
||
private final Index index; | ||
private final Version version; | ||
private final Logger logger; | ||
|
@@ -319,6 +340,7 @@ public final class IndexSettings { | |
private volatile int maxAnalyzedOffset; | ||
private volatile int maxTermsCount; | ||
private volatile String defaultPipeline; | ||
private volatile String searchThreadPool; | ||
|
||
/** | ||
* The maximum number of refresh listeners allows on this shard. | ||
|
@@ -402,6 +424,7 @@ public IndexSettings(final IndexMetaData indexMetaData, final Settings nodeSetti | |
this.indexMetaData = indexMetaData; | ||
numberOfShards = settings.getAsInt(IndexMetaData.SETTING_NUMBER_OF_SHARDS, null); | ||
|
||
this.searchThreadPool = INDEX_SEARCH_THREAD_POOL.get(settings); | ||
this.queryStringLenient = QUERY_STRING_LENIENT_SETTING.get(settings); | ||
this.queryStringAnalyzeWildcard = QUERY_STRING_ANALYZE_WILDCARD.get(nodeSettings); | ||
this.queryStringAllowLeadingWildcard = QUERY_STRING_ALLOW_LEADING_WILDCARD.get(nodeSettings); | ||
|
@@ -478,6 +501,7 @@ public IndexSettings(final IndexMetaData indexMetaData, final Settings nodeSetti | |
scopedSettings.addSettingsUpdateConsumer(MAX_REGEX_LENGTH_SETTING, this::setMaxRegexLength); | ||
scopedSettings.addSettingsUpdateConsumer(DEFAULT_PIPELINE, this::setDefaultPipeline); | ||
scopedSettings.addSettingsUpdateConsumer(INDEX_SOFT_DELETES_RETENTION_OPERATIONS_SETTING, this::setSoftDeleteRetentionOperations); | ||
scopedSettings.addSettingsUpdateConsumer(INDEX_SEARCH_THREAD_POOL, this::setSearchThreadPool); | ||
} | ||
|
||
private void setSearchIdleAfter(TimeValue searchIdleAfter) { this.searchIdleAfter = searchIdleAfter; } | ||
|
@@ -879,4 +903,15 @@ private void setSoftDeleteRetentionOperations(long ops) { | |
public long getSoftDeleteRetentionOperations() { | ||
return this.softDeleteRetentionOperations; | ||
} | ||
|
||
/** | ||
* Returns the thread-pool name to execute search requests on for this index. | ||
*/ | ||
public String getSearchThreadPool() { | ||
return searchThreadPool; | ||
} | ||
|
||
private void setSearchThreadPool(String searchThreadPool) { | ||
this.searchThreadPool = searchThreadPool; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?