diff --git a/server/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java b/server/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java index 3d05293f7b7..235d8b46e5b 100644 --- a/server/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java +++ b/server/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java @@ -78,9 +78,9 @@ public class HierarchyCircuitBreakerService extends CircuitBreakerService { new Setting<>("indices.breaker.request.type", "memory", CircuitBreaker.Type::parseValue, Property.NodeScope); public static final Setting ACCOUNTING_CIRCUIT_BREAKER_LIMIT_SETTING = - Setting.memorySizeSetting("indices.breaker.accounting.limit", "100%", Property.NodeScope); + Setting.memorySizeSetting("indices.breaker.accounting.limit", "100%", Property.Dynamic, Property.NodeScope); public static final Setting ACCOUNTING_CIRCUIT_BREAKER_OVERHEAD_SETTING = - Setting.doubleSetting("indices.breaker.accounting.overhead", 1.0d, 0.0d, Property.NodeScope); + Setting.doubleSetting("indices.breaker.accounting.overhead", 1.0d, 0.0d, Property.Dynamic, Property.NodeScope); public static final Setting ACCOUNTING_CIRCUIT_BREAKER_TYPE_SETTING = new Setting<>("indices.breaker.accounting.type", "memory", CircuitBreaker.Type::parseValue, Property.NodeScope); @@ -146,6 +146,7 @@ public class HierarchyCircuitBreakerService extends CircuitBreakerService { clusterSettings.addSettingsUpdateConsumer(FIELDDATA_CIRCUIT_BREAKER_LIMIT_SETTING, FIELDDATA_CIRCUIT_BREAKER_OVERHEAD_SETTING, this::setFieldDataBreakerLimit); clusterSettings.addSettingsUpdateConsumer(IN_FLIGHT_REQUESTS_CIRCUIT_BREAKER_LIMIT_SETTING, IN_FLIGHT_REQUESTS_CIRCUIT_BREAKER_OVERHEAD_SETTING, this::setInFlightRequestsBreakerLimit); clusterSettings.addSettingsUpdateConsumer(REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, REQUEST_CIRCUIT_BREAKER_OVERHEAD_SETTING, this::setRequestBreakerLimit); + clusterSettings.addSettingsUpdateConsumer(ACCOUNTING_CIRCUIT_BREAKER_LIMIT_SETTING, ACCOUNTING_CIRCUIT_BREAKER_OVERHEAD_SETTING, this::setAccountingBreakerLimit); } private void setRequestBreakerLimit(ByteSizeValue newRequestMax, Double newRequestOverhead) { @@ -174,6 +175,14 @@ public class HierarchyCircuitBreakerService extends CircuitBreakerService { logger.info("Updated breaker settings field data: {}", newFielddataSettings); } + private void setAccountingBreakerLimit(ByteSizeValue newAccountingMax, Double newAccountingOverhead) { + BreakerSettings newAccountingSettings = new BreakerSettings(CircuitBreaker.ACCOUNTING, newAccountingMax.getBytes(), + newAccountingOverhead, HierarchyCircuitBreakerService.this.inFlightRequestsSettings.getType()); + registerBreaker(newAccountingSettings); + HierarchyCircuitBreakerService.this.accountingSettings = newAccountingSettings; + logger.info("Updated breaker settings for accounting requests: {}", newAccountingSettings); + } + private boolean validateTotalCircuitBreakerLimit(ByteSizeValue byteSizeValue) { BreakerSettings newParentSettings = new BreakerSettings(CircuitBreaker.PARENT, byteSizeValue.getBytes(), 1.0, CircuitBreaker.Type.PARENT); validateSettings(new BreakerSettings[]{newParentSettings}); diff --git a/server/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java b/server/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java index 58149a24fbe..a3e02308be4 100644 --- a/server/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java +++ b/server/src/test/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java @@ -60,7 +60,6 @@ import java.util.stream.Stream; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; -import static org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService.IN_FLIGHT_REQUESTS_CIRCUIT_BREAKER_LIMIT_SETTING; import static org.elasticsearch.search.aggregations.AggregationBuilders.cardinality; import static org.elasticsearch.search.aggregations.AggregationBuilders.terms; import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST; @@ -89,7 +88,9 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase { HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_OVERHEAD_SETTING, HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_OVERHEAD_SETTING, - IN_FLIGHT_REQUESTS_CIRCUIT_BREAKER_LIMIT_SETTING, + HierarchyCircuitBreakerService.ACCOUNTING_CIRCUIT_BREAKER_LIMIT_SETTING, + HierarchyCircuitBreakerService.ACCOUNTING_CIRCUIT_BREAKER_OVERHEAD_SETTING, + HierarchyCircuitBreakerService.IN_FLIGHT_REQUESTS_CIRCUIT_BREAKER_LIMIT_SETTING, HierarchyCircuitBreakerService.IN_FLIGHT_REQUESTS_CIRCUIT_BREAKER_OVERHEAD_SETTING, HierarchyCircuitBreakerService.TOTAL_CIRCUIT_BREAKER_LIMIT_SETTING).forEach(s -> resetSettings.putNull(s.getKey())); assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(resetSettings)); @@ -342,7 +343,7 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase { return; } Settings insane = Settings.builder() - .put(IN_FLIGHT_REQUESTS_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(), "5b") + .put(HierarchyCircuitBreakerService.IN_FLIGHT_REQUESTS_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(), "5b") .build(); client().admin().cluster().prepareUpdateSettings().setTransientSettings(insane).get(); @@ -399,7 +400,7 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase { } Settings limitSettings = Settings.builder() - .put(IN_FLIGHT_REQUESTS_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(), inFlightRequestsLimit) + .put(HierarchyCircuitBreakerService.IN_FLIGHT_REQUESTS_CIRCUIT_BREAKER_LIMIT_SETTING.getKey(), inFlightRequestsLimit) .build(); assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(limitSettings));