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
Original file line number Diff line number Diff line change
@@ -40,6 +40,35 @@
public class SurroundQParserPlugin extends QParserPlugin {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public static final String NAME = "surround";
private static final String MAX_BASIC_QUERIES_SYSTEM_PROP = "solr.maxBasicQueriesOverride";
private static final int MAX_BASIC_QUERIES_OVERRIDE = readMaxBasicQueriesOverride();

private static int readMaxBasicQueriesOverride() {
String maxBasicQueriesSystemProp = System.getProperty(MAX_BASIC_QUERIES_SYSTEM_PROP);
if (maxBasicQueriesSystemProp != null) {
try {
int maxBasicQueriesOverride = Integer.parseInt(maxBasicQueriesSystemProp);
if (maxBasicQueriesOverride > 0) {
log.info(
"maxBasicQueries with system property {} with value {}",
MAX_BASIC_QUERIES_SYSTEM_PROP,
maxBasicQueriesSystemProp);
return maxBasicQueriesOverride;
} else {
log.info(
"Ignoring system property {} value {} since it is non-positive",
MAX_BASIC_QUERIES_SYSTEM_PROP,
maxBasicQueriesSystemProp);
}
} catch (NumberFormatException e) {
hiteshk25 marked this conversation as resolved.
Show resolved Hide resolved
log.warn(
"Invalid system property {} value {}",
MAX_BASIC_QUERIES_SYSTEM_PROP,
maxBasicQueriesSystemProp);
}
}
return -1; // -1 indicates no max basic queries override
}

@Override
public QParser createParser(
@@ -77,6 +106,11 @@ public Query parse() throws SyntaxError {
this.maxBasicQueries = DEFMAXBASICQUERIES;
}
}

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

Comment on lines +109 to +113
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.

// ugh .. colliding ParseExceptions
try {
sq = org.apache.lucene.queryparser.surround.parser.QueryParser.parse(qstr);