cpoerschke commented on code in PR #1871:
URL: https://github.com/apache/solr/pull/1871#discussion_r1308917303


##########
solr/core/src/java/org/apache/solr/util/circuitbreaker/CircuitBreakerRegistry.java:
##########
@@ -64,13 +77,16 @@ public List<CircuitBreaker> checkTripped() {
   }
 
   /**
-   * Returns true if *any* circuit breaker has triggered, false if none have 
triggered.
+   * Returns true if *any* circuit breaker has triggered for a given request 
type, false if none
+   * have triggered.
    *
-   * <p>NOTE: This method short circuits the checking of circuit breakers -- 
the method will return
-   * as soon as it finds a circuit breaker that has triggered.
+   * @param requestType Request type to check for.
+   *     <p>NOTE: This method short circuits the checking of circuit breakers 
-- the method will
+   *     return as soon as it finds a circuit breaker that is enabled and has 
triggered.

Review Comment:
   ```suggestion
      *     return as soon as it finds a circuit breaker that has triggered for 
the given request type.
   ```



##########
solr/core/src/java/org/apache/solr/util/circuitbreaker/RequestType.java:
##########
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.util.circuitbreaker;
+
+/*
+ *  Request types that can be registered for a CB

Review Comment:
   ```suggestion
    *  Request types that can be registered for a circuit breaker
   ```
   
   or
   
   ```suggestion
    *  Request types that can be registered for a {@link CircuitBreaker}
   ```



##########
solr/core/src/java/org/apache/solr/handler/ContentStreamHandlerBase.java:
##########
@@ -63,6 +70,17 @@ public void handleRequestBody(SolrQueryRequest req, 
SolrQueryResponse rsp) throw
           SolrException.ErrorCode.SERVER_ERROR,
           "Updates are temporarily paused for core: " + 
req.getCore().getName());
     }
+    List<CircuitBreaker> trippedCircuitBreakers =
+        
req.getCore().getCircuitBreakerRegistry().checkTripped(RequestType.UPDATE);

Review Comment:
   Noting that in `SearchHandler` there is a `if 
(circuitBreakerRegistry.isEnabled())` guard -- wondering if it might be helpful 
here too?



##########
solr/core/src/java/org/apache/solr/handler/ContentStreamHandlerBase.java:
##########
@@ -63,6 +70,17 @@ public void handleRequestBody(SolrQueryRequest req, 
SolrQueryResponse rsp) throw
           SolrException.ErrorCode.SERVER_ERROR,
           "Updates are temporarily paused for core: " + 
req.getCore().getName());
     }
+    List<CircuitBreaker> trippedCircuitBreakers =
+        
req.getCore().getCircuitBreakerRegistry().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:
   I think a `solrCoreState.deregisterInFlightUpdate();` call is needed before 
returning, or for the circuit breaker to be checked first before registering 
the update as in-flight.



-- 
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

Reply via email to