Skip to content

Commit d6fe54b

Browse files
authored
WriteLoadConstraintDecider: Have separate rate limiting for canRemain and canAllocate decisions (#138067)
1 parent 9df1314 commit d6fe54b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/WriteLoadConstraintDecider.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,18 @@ public class WriteLoadConstraintDecider extends AllocationDecider {
3333

3434
public static final String NAME = "write_load";
3535

36-
private final FrequencyCappedAction logInterventionMessage;
36+
private final FrequencyCappedAction logCanRemainMessage;
37+
private final FrequencyCappedAction logCanAllocateMessage;
3738
private final WriteLoadConstraintSettings writeLoadConstraintSettings;
3839

3940
public WriteLoadConstraintDecider(ClusterSettings clusterSettings) {
4041
this.writeLoadConstraintSettings = new WriteLoadConstraintSettings(clusterSettings);
41-
logInterventionMessage = new FrequencyCappedAction(System::currentTimeMillis, TimeValue.ZERO);
42-
clusterSettings.initializeAndWatch(
43-
WriteLoadConstraintSettings.WRITE_LOAD_DECIDER_MINIMUM_LOGGING_INTERVAL,
44-
logInterventionMessage::setMinInterval
45-
);
42+
logCanRemainMessage = new FrequencyCappedAction(System::currentTimeMillis, TimeValue.ZERO);
43+
logCanAllocateMessage = new FrequencyCappedAction(System::currentTimeMillis, TimeValue.ZERO);
44+
clusterSettings.initializeAndWatch(WriteLoadConstraintSettings.WRITE_LOAD_DECIDER_MINIMUM_LOGGING_INTERVAL, timeValue -> {
45+
logCanRemainMessage.setMinInterval(timeValue);
46+
logCanAllocateMessage.setMinInterval(timeValue);
47+
});
4648
}
4749

4850
@Override
@@ -87,7 +89,7 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
8789
shardRouting.shardId()
8890
);
8991
if (logger.isDebugEnabled()) {
90-
logInterventionMessage.maybeExecute(() -> logger.debug(explain));
92+
logCanAllocateMessage.maybeExecute(() -> logger.debug(explain));
9193
}
9294
return allocation.decision(Decision.NOT_PREFERRED, NAME, explain);
9395
} else {
@@ -113,7 +115,7 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
113115
nodeWriteThreadPoolStats.totalThreadPoolThreads()
114116
);
115117
if (logger.isDebugEnabled()) {
116-
logInterventionMessage.maybeExecute(() -> logger.debug(explain));
118+
logCanAllocateMessage.maybeExecute(() -> logger.debug(explain));
117119
}
118120
return allocation.decision(Decision.NOT_PREFERRED, NAME, explain);
119121
} else {
@@ -162,7 +164,7 @@ public Decision canRemain(IndexMetadata indexMetadata, ShardRouting shardRouting
162164
nodeWriteThreadPoolStats.averageThreadPoolUtilization()
163165
);
164166
if (logger.isDebugEnabled()) {
165-
logInterventionMessage.maybeExecute(() -> logger.debug(explain));
167+
logCanRemainMessage.maybeExecute(() -> logger.debug(explain));
166168
}
167169
return allocation.decision(Decision.NOT_PREFERRED, NAME, explain);
168170
} else {

0 commit comments

Comments
 (0)