Skip to content
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

SAI-4737: System prop solr.MaxBasicQueriesOverride for surround query #172

Merged

Conversation

patsonluk
Copy link
Collaborator

@patsonluk patsonluk commented Dec 1, 2023

Description

To add a System prop solr.maxBasicQueriesOverride which:

  1. If undefined or set as non positive number, it will just behave exactly the same as w/o this change
  2. Otherwise, solr.maxBasicQueriesOverride value will always override the param maxBasicQueries from surround query.

Solution

Modified SurroundQParserPlugin to read the system property (this happens only once per class).

Take note that this is meant to be a temporary property for testing. We should NOT have this value set in long run, it should respect the maxBasicQueries from query param eventually.

Tests

Tested locally with case of 11000 matches surround query:

  1. Query with maxBasicQuery=10000 and no solr.maxBasicQueriesOverride -> TooManyBasicQueries error
  2. Query with maxBasicQuery=10000 and set system property solr.maxBasicQueriesOverride=15000 -> No error

Take note that this is run on unit test case MiniSolrCloudCluster with IndexSearcher.setMaxClauseCount(50_000). Otherwise the case would fail with org.apache.solr.common.SolrException: org.apache.lucene.search.IndexSearcher$TooManyNestedClauses: Query contains too many nested clauses; maxClauseCount is set to 1024

Remarks

This change will apply the override on all orgs, so we cannot do per org control with this change. However, that's probably okay to do it per node only.

…log it once.

And solr.absoluteMaxBasicQueries should only kick in if the original maxBasicQueries is greater
@@ -77,6 +106,16 @@ public Query parse() throws SyntaxError {
this.maxBasicQueries = DEFMAXBASICQUERIES;
}
}

if (ABSOLUTE_MAX_BASIC_QUERIES > 0 && this.maxBasicQueries > ABSOLUTE_MAX_BASIC_QUERIES) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about just setting value, if that is positive. Probably we don't need to log here.

Copy link
Collaborator Author

@patsonluk patsonluk Dec 6, 2023

Choose a reason for hiding this comment

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

This current logic basically only considers "solr.absoluteMaxBasicQueries" if it was provided and positive. Pretty similar to what your are suggesting?

Are you suggesting "solr.absoluteMaxBasicQueries" will just override maxBasicQueries in all cases? Currently "solr.absoluteMaxBasicQueries" acts as a absolute safeguard, maxBasicQueries is still effective as far as it stays below "solr.absoluteMaxBasicQueries".

The log was mostly to avoid the case that user is confused which a higher maxBasicQueries seems to have no impact (because of the solr.absoluteMaxBasicQueries). I have some concern that this could be noisy, though once per surround query is probably not too bad imo :) ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

log would be per query, per shard ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was per query on core I believe.

Since now it's a temporary override (the dev should be well aware of it, unlike the proposal before which could be long living), I have removed the logging :)

… this requires less deployment but is a more temporary implementation.
…ry-system-prop' into patsonluk/SAI-4737-max-basic-query-system-prop

# Conflicts:
#	solr/core/src/java/org/apache/solr/search/SurroundQParserPlugin.java
@patsonluk patsonluk changed the title SAI-4737: System prop solr.absoluteMaxBasicQueries for surround query SAI-4737: System prop solr.MaxBasicQueriesOverride for surround query Dec 7, 2023
Copy link
Collaborator

@hiteshk25 hiteshk25 left a comment

Choose a reason for hiding this comment

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

LGTM ( Thanks @patsonluk )

Comment on lines +109 to +113

if (MAX_BASIC_QUERIES_OVERRIDE > 0) {
this.maxBasicQueries = MAX_BASIC_QUERIES_OVERRIDE;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it preferable to have the sysprop completely override user-supplied localParam values? My understanding is that we want this to be an absolute ceiling on configured vals -- not to be an absolute override. i.e., query should still be able to specify a lower mbq setting, right?

Copy link
Collaborator Author

@patsonluk patsonluk Dec 7, 2023

Choose a reason for hiding this comment

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

@magibney Thank you for the question!

Yes that was the previous implementation (absolute max). But as discussed with @hiteshk25 , the previous implementation would have required re-deployment on all nodes since with such approach we would need to:

  1. Set absolute max override for all nodes as 10k, except selected nodes with 50k (and higher solr.max.booleanClauses)
  2. Redeploy all node so all nodes so they can process the absolute max
  3. Set higher maxBasicQueries from client side

While with the current approach:

  1. Set higher solr.maxBasicQueriesOverride (and higher solr.max.booleanClauses) only on selected nodes
  2. Redeploy on only selected nodes so they can process the absolute max
  3. All requests coming into the selected nodes will use higher limits (on all orgs). There is no need to set higher maxBasicQueries from client side.

So the current approach has major pro of not needing to restart all nodes (and the code logic is slightly simpler). The con is that we can no longer control it per org and such override basically just ignore all maxBasicQueries param from surround query.

The approach now meant to be a temporary measure for testing, I don't think we want to keep this around at all. We might even want to revert this commit later on since such system prop does not make sense in any normal scenario (unlike the absolute max, which could be useful in some normal scenarios)

Copy link
Collaborator

Choose a reason for hiding this comment

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

🤦 of course! sorry I overlooked the discussion that resulted in going this route, and thanks for the explanation.

Copy link
Collaborator

@magibney magibney left a comment

Choose a reason for hiding this comment

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

LGTM

@patsonluk patsonluk merged commit 463529c into fs/branch_9x Dec 7, 2023
3 checks passed
@patsonluk patsonluk deleted the patsonluk/SAI-4737-max-basic-query-system-prop branch December 7, 2023 20:29
patsonluk added a commit that referenced this pull request Dec 7, 2023
…ry (#172)

* Added support of system prop solr.absoluteMaxBasicQueries for surround query

* Moved param lookup logic to static, as we should only need to do and log it once.

And solr.absoluteMaxBasicQueries should only kick in if the original maxBasicQueries is greater

* ./gradlew tidy

* Changed solr.absoluteMaxBasicQueries to solr.maxBasicQueriesOverride, this requires less deployment but is a more temporary implementation.

* Renamed variable

* ./gradlew tidy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants