cpoerschke commented on code in PR #1871: URL: https://github.com/apache/solr/pull/1871#discussion_r1310115919
########## solr/core/src/java/org/apache/solr/handler/ContentStreamHandlerBase.java: ########## @@ -49,6 +56,21 @@ public void init(NamedList<?> args) { @Override public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { + CircuitBreakerRegistry circuitBreakerRegistry = req.getCore().getCircuitBreakerRegistry(); + if (circuitBreakerRegistry.isEnabled(RequestType.UPDATE)) { + List<CircuitBreaker> trippedCircuitBreakers = + circuitBreakerRegistry.checkTripped(RequestType.UPDATE); + if (trippedCircuitBreakers != null) { + String errorMessage = CircuitBreakerRegistry.toErrorMessage(trippedCircuitBreakers); + rsp.add(STATUS, FAILURE); + rsp.setException( + new SolrException( + SolrException.ErrorCode.SERVICE_UNAVAILABLE, + "Circuit Breakers tripped " + errorMessage)); + return; + } + } + Review Comment: subjective/possibly niche use case: having a `protected boolean checkCircuitBreakers(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception` method called as `if (checkCircuitBreakers(req, rsp) return;` could allow customisation e.g. overriding as no-op for one update handler but not another or to log-and-ignore the tripped circuit breakers if the `req` contained some special fields or something. ########## solr/core/src/java/org/apache/solr/util/circuitbreaker/CircuitBreakerRegistry.java: ########## @@ -97,6 +94,10 @@ public static String toErrorMessage(List<CircuitBreaker> circuitBreakerList) { } public boolean isEnabled() { - return !circuitBreakerList.isEmpty(); + return !circuitBreakerMap.isEmpty(); + } Review Comment: Could this be removed now then actually? ########## solr/core/src/java/org/apache/solr/util/circuitbreaker/CircuitBreaker.java: ########## @@ -52,4 +58,22 @@ public CircuitBreaker() {} /** Get error message when the circuit breaker triggers */ public abstract String getErrorMessage(); + + /** + * Set the request types for which this circuit breaker should be checked. If not called, the + * circuit breaker will be checked for all request types. Review Comment: ```suggestion * circuit breaker will be checked for the `SEARCH` request type only. ``` -- 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. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org