atris commented on a change in pull request #1606:
URL: https://github.com/apache/lucene-solr/pull/1606#discussion_r445332160



##########
File path: 
solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
##########
@@ -289,6 +295,23 @@ public void handleRequestBody(SolrQueryRequest req, 
SolrQueryResponse rsp) throw
       rb.requestInfo.setResponseBuilder(rb);
     }
 
+    //TODO: Should this be for indexing requests as well?
+    CircuitBreakerManager circuitBreakerManager = 
req.getCore().getCircuitBreakerManager();
+    Map<CircuitBreakerType, CircuitBreaker> trippedCircuitBreakers = 
circuitBreakerManager.checkAllCircuitBreakers();
+
+    if (trippedCircuitBreakers != null) {
+      final RTimerTree timer = rb.isDebug() ? req.getRequestTimer() : null;
+
+      if (timer != null) {
+        RTimerTree subt = timer.sub("circuitbreaker");
+        rb.setTimer(subt.sub("circuitbreaker"));
+      }
+      String errorMessage = 
CircuitBreakerManager.constructFinalErrorMessageString(trippedCircuitBreakers);
+      rsp.add(STATUS, FAILURE);
+      rsp.setException(new 
SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE, "Circuit Breakers 
tripped " + errorMessage));

Review comment:
       I looked at a couple of HTTP codes and SERVICE_UNAVAILABLE seems to be 
the closest one matching the scenario 
(https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503). Did you have 
anything else in mind?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to