Make accounting circuit breaker settings dynamic (#34372)
* Make accounting circuit breaker settings dynamic These missed the original property making them dynamic. This fixes the issue so these can now be set at any time. Resolves #34368
This commit is contained in:
parent
fbb9ac34f9
commit
5dd79bf58c
|
@ -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<ByteSizeValue> 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<Double> 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<CircuitBreaker.Type> 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});
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue