Skip to content

Commit

Permalink
SOLR-17151 Check limits between calls to components in SearchHandler (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gus-asf authored Nov 10, 2024
1 parent bc0c226 commit 125fc3f
Show file tree
Hide file tree
Showing 11 changed files with 483 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.search.CpuAllowedLimit;
import org.apache.solr.search.QueryLimits;
import org.apache.solr.search.QueryLimitsExceededException;
import org.apache.solr.search.SyntaxError;
import org.apache.solr.security.PermissionNameProvider;
import org.apache.solr.update.processor.DistributedUpdateProcessor;
Expand Down Expand Up @@ -241,6 +242,8 @@ public void handleRequest(SolrQueryRequest req, SolrQueryResponse rsp) {
metrics.numTimeouts.mark();
rsp.setHttpCaching(false);
}
} catch (QueryLimitsExceededException e) {
rsp.setPartialResults(req);
} catch (Exception e) {
Exception normalized = normalizeReceivedException(req, e);
processErrorMetricsOnException(normalized, metrics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,17 +615,23 @@ protected int groupedDistributedProcess(ResponseBuilder rb) {
}

protected int regularDistributedProcess(ResponseBuilder rb) {
if (rb.stage < ResponseBuilder.STAGE_PARSE_QUERY) return ResponseBuilder.STAGE_PARSE_QUERY;
if (rb.stage < ResponseBuilder.STAGE_PARSE_QUERY) {
return ResponseBuilder.STAGE_PARSE_QUERY;
}
if (rb.stage == ResponseBuilder.STAGE_PARSE_QUERY) {
createDistributedStats(rb);
return ResponseBuilder.STAGE_EXECUTE_QUERY;
}
if (rb.stage < ResponseBuilder.STAGE_EXECUTE_QUERY) return ResponseBuilder.STAGE_EXECUTE_QUERY;
if (rb.stage < ResponseBuilder.STAGE_EXECUTE_QUERY) {
return ResponseBuilder.STAGE_EXECUTE_QUERY;
}
if (rb.stage == ResponseBuilder.STAGE_EXECUTE_QUERY) {
createMainQuery(rb);
return ResponseBuilder.STAGE_GET_FIELDS;
}
if (rb.stage < ResponseBuilder.STAGE_GET_FIELDS) return ResponseBuilder.STAGE_GET_FIELDS;
if (rb.stage < ResponseBuilder.STAGE_GET_FIELDS) {
return ResponseBuilder.STAGE_GET_FIELDS;
}
if (rb.stage == ResponseBuilder.STAGE_GET_FIELDS && !rb.onePassDistributedQuery) {
createRetrieveDocs(rb);
return ResponseBuilder.STAGE_DONE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ public ResponseBuilder(
* public static final String LOCAL_SHARD = "local"; public static final String DOC_QUERY = "dq";
* *
*/
public static int STAGE_START = 0;
public static final int STAGE_START = 0;

public static int STAGE_PARSE_QUERY = 1000;
public static int STAGE_TOP_GROUPS = 1500;
public static int STAGE_EXECUTE_QUERY = 2000;
public static int STAGE_GET_FIELDS = 3000;
public static int STAGE_DONE = Integer.MAX_VALUE;
public static final int STAGE_PARSE_QUERY = 1000;
public static final int STAGE_TOP_GROUPS = 1500;
public static final int STAGE_EXECUTE_QUERY = 2000;
public static final int STAGE_GET_FIELDS = 3000;
public static final int STAGE_DONE = Integer.MAX_VALUE;

public int stage; // What stage is this current request at?

Expand Down
Loading

0 comments on commit 125fc3f

Please sign in to comment.