-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Set INDICES_MAX_CLAUSE_COUNT dynamically #13568
base: main
Are you sure you want to change the base?
Set INDICES_MAX_CLAUSE_COUNT dynamically #13568
Conversation
Signed-off-by: Harsha Vamsi Kalluri <harshavamsi096@gmail.com>
❌ Gradle check result for dd140e2: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
IndexSearcher.setMaxClauseCount(INDICES_MAX_CLAUSE_COUNT_SETTING.get(settings)); | ||
clusterService.getClusterSettings().addSettingsUpdateConsumer(INDICES_MAX_CLAUSE_COUNT_SETTING, IndexSearcher::setMaxClauseCount); |
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 add local settings consumer? That can further delegate the new value to IndexSearcher.setMaxClauseCount. The local attribute can be used as is within checkForTooManyFields
method above.
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.
thx @jainankitk for the feedback! I'm wondering what the use-case for the consumer might be? If we're only setting the searcher clause count and feeding it to the settings consumer wouldn't that be enough?
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.
What is the purpose of below expression? Is it possible to override this setting at index or request level? If not, we can add getter in search using the consumer mentioned above.
Integer limit = SearchService.INDICES_MAX_CLAUSE_COUNT_SETTING.get(context.getIndexSettings().getSettings());
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 registers a consumer for and adds it to the cluster settings. The consumer is the IndexSearcher.setMaxClauseCount
.
Is it possible to override this setting at index or request level?
It is only possible to override this setting at the cluster level since we'd want all indices to have this effect.
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 is only possible to override this setting at the cluster level since we'd want all indices to have this effect.
In that case, why not change to below:
this.setMaxClauseCount(INDICES_MAX_CLAUSE_COUNT_SETTING.get(settings));
clusterService.getClusterSettings().addSettingsUpdateConsumer(INDICES_MAX_CLAUSE_COUNT_SETTING, this::setMaxClauseCount);
private void setMaxClauseCount(int maxClauseCount) {
this.maxClauseCount = maxClauseCount;
IndexSearcher.setMaxClauseCount(maxClauseCount);
}
// Used in SearchModule above
public int getMaxClauseCount() {
return this.maxClauseCount;
}
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 made it a static method and now using getter and setter.
6ccaa23
to
28d5525
Compare
Signed-off-by: Harsha Vamsi Kalluri <harshavamsi096@gmail.com>
28d5525
to
4ff1d13
Compare
❌ Gradle check result for 28d5525: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
@@ -177,7 +177,7 @@ static Map<String, Float> resolveMappingField( | |||
} | |||
|
|||
static void checkForTooManyFields(int numberOfFields, QueryShardContext context, @Nullable String inputPattern) { | |||
Integer limit = SearchModule.INDICES_MAX_CLAUSE_COUNT_SETTING.get(context.getIndexSettings().getSettings()); | |||
Integer limit = SearchService.INDICES_MAX_CLAUSE_COUNT_SETTING.get(context.getIndexSettings().getSettings()); |
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 be changed to below:
Integer limit = SearchService.getMaxClauseCount();
IndexSearcher.setMaxClauseCount(INDICES_MAX_CLAUSE_COUNT_SETTING.get(settings)); | ||
clusterService.getClusterSettings().addSettingsUpdateConsumer(INDICES_MAX_CLAUSE_COUNT_SETTING, IndexSearcher::setMaxClauseCount); |
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 is only possible to override this setting at the cluster level since we'd want all indices to have this effect.
In that case, why not change to below:
this.setMaxClauseCount(INDICES_MAX_CLAUSE_COUNT_SETTING.get(settings));
clusterService.getClusterSettings().addSettingsUpdateConsumer(INDICES_MAX_CLAUSE_COUNT_SETTING, this::setMaxClauseCount);
private void setMaxClauseCount(int maxClauseCount) {
this.maxClauseCount = maxClauseCount;
IndexSearcher.setMaxClauseCount(maxClauseCount);
}
// Used in SearchModule above
public int getMaxClauseCount() {
return this.maxClauseCount;
}
Signed-off-by: Harsha Vamsi Kalluri <harshavamsi096@gmail.com>
05f8d30
to
b11ca0b
Compare
b11ca0b
to
05f8d30
Compare
Signed-off-by: Harsha Vamsi Kalluri <harshavamsi096@gmail.com>
❌ Gradle check result for b11ca0b: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
❌ Gradle check result for a65cecc: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
❌ Gradle check result for de6d547: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
❌ Gradle check result for 05f8d30: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
❌ Gradle check result for 05f8d30: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
❌ Gradle check result for 55496a4: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Harsha Vamsi Kalluri <harshavamsi096@gmail.com>
55496a4
to
15d3f96
Compare
❌ Gradle check result for 15d3f96: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Harsha Vamsi Kalluri <harshavamsi096@gmail.com>
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!
@@ -177,7 +177,7 @@ static Map<String, Float> resolveMappingField( | |||
} | |||
|
|||
static void checkForTooManyFields(int numberOfFields, QueryShardContext context, @Nullable String inputPattern) { | |||
Integer limit = SearchModule.INDICES_MAX_CLAUSE_COUNT_SETTING.get(context.getIndexSettings().getSettings()); | |||
int limit = SearchService.INDICES_MAX_CLAUSE_COUNT_SETTING.get(context.getIndexSettings().getSettings()); |
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 not have getMaxClauseCount in SearchService as suggested earlier as well:
public int getMaxClauseCount() {
return this.maxClauseCount;
}
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.
So, I think the problem there would be to make maxClauseCount
static. If we do make it static the clause count is not dynamically update-able. I could be wrong 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.
No, you're right. Also, the QueryParserHelper class is helper
, so makes sense for it to be static and not have the SearchService instance injected. Thanks for clarifying!
❌ Gradle check result for 75331e8: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
@@ -465,6 +480,11 @@ private void setLowLevelCancellation(Boolean lowLevelCancellation) { | |||
this.lowLevelCancellation = lowLevelCancellation; | |||
} | |||
|
|||
private void setMaxClauseCount(int maxClauseCount) { | |||
this.maxClauseCount = maxClauseCount; | |||
IndexSearcher.setMaxClauseCount(maxClauseCount); |
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.
Ok, this is the only shaky place I see: trying to apply volatile semantics (maxClauseCount
) to non-volatile static variable (IndexSearcher::maxClauseCount
). It is certainly safer to keep this setting static, @msfroh 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.
@reta is there any way forward other than making IndexSearcher::maxClauseCount
volatile within lucene itself? I understand the semantics of this affect per shard state where some shards will reference the old clause count and new ones will have the new count but eventually consistency will prevail
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.
@reta is there any way forward other than making
IndexSearcher::maxClauseCount
volatile within lucene itself?
No (AFAIK), we need changes in Apache Lucene (either non static args or thread friendly primitives). We just need to accept the limitation may be and document that behaviour.
Signed-off-by: Harsha Vamsi Kalluri <harshavamsi096@gmail.com>
a265a2e
to
7ede1eb
Compare
❌ Gradle check result for a265a2e: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
❌ Gradle check result for 7ede1eb: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #13568 +/- ##
============================================
+ Coverage 71.42% 71.71% +0.29%
- Complexity 59978 61529 +1551
============================================
Files 4985 5081 +96
Lines 282275 289040 +6765
Branches 40946 41826 +880
============================================
+ Hits 201603 207295 +5692
- Misses 63999 64635 +636
- Partials 16673 17110 +437 ☔ View full report in Codecov by Sentry. |
Description
Changes the
INDICES_MAX_CLAUSE_COUNT_SETTING
to be dynamic instead of being static.This PR is virtually identical to #1527, but there was earlier push back around making this an updateable dynamic setting due to the assumption that users would abuse this setting rather than optimize their underlying query. Lucene has since updated the way the clause counts work and this is now enforced at the
indexSearcher
level -- https://issues.apache.org/jira/browse/LUCENE-8811.More info can be found in #12549 around the motivation for this change, but I ended up raising a PR to make a simple dynamic setting.
Related Issues
Resolves #1526 #12549
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.