Browse Source

[CORE] Log if CircuitBreaker is tripping

Today we only throw an exception which might not be logged at all. This
commit adds debug logging if we are tripping a CB.

Closes #8050
Simon Willnauer 11 years ago
parent
commit
1792822bae

+ 4 - 2
src/main/java/org/elasticsearch/common/breaker/ChildMemoryCircuitBreaker.java

@@ -90,9 +90,11 @@ public class ChildMemoryCircuitBreaker implements CircuitBreaker {
     @Override
     public void circuitBreak(String fieldName, long bytesNeeded) {
         this.trippedCount.incrementAndGet();
-        throw new CircuitBreakingException("[" + this.name + "] Data too large, data for [" +
+        final String message = "[" + this.name + "] Data too large, data for [" +
                 fieldName + "] would be larger than limit of [" +
-                memoryBytesLimit + "/" + new ByteSizeValue(memoryBytesLimit) + "]",
+                memoryBytesLimit + "/" + new ByteSizeValue(memoryBytesLimit) + "]";
+        logger.debug(message);
+        throw new CircuitBreakingException(message,
                 bytesNeeded, this.memoryBytesLimit);
     }
 

+ 4 - 2
src/main/java/org/elasticsearch/common/breaker/MemoryCircuitBreaker.java

@@ -79,8 +79,10 @@ public class MemoryCircuitBreaker implements CircuitBreaker {
      */
     public void circuitBreak(String fieldName, long bytesNeeded) throws CircuitBreakingException {
         this.trippedCount.incrementAndGet();
-        throw new CircuitBreakingException("Data too large, data for field [" + fieldName + "] would be larger than limit of [" +
-                memoryBytesLimit + "/" + new ByteSizeValue(memoryBytesLimit) + "]");
+        final String message = "Data too large, data for field [" + fieldName + "] would be larger than limit of [" +
+                memoryBytesLimit + "/" + new ByteSizeValue(memoryBytesLimit) + "]";
+        logger.debug(message);
+        throw new CircuitBreakingException(message);
     }
 
     /**