Skip to content

Commit ff20c4e

Browse files
committed
Remove include_relocations setting
Setting `cluster.routing.allocation.disk.include_relocations` to `false` is a bad idea since it will lead to the kinds of overshoot that were otherwise fixed in elastic#46079. This setting was deprecated in elastic#47443. This commit removes it.
1 parent 9d67a02 commit ff20c4e

File tree

5 files changed

+21
-48
lines changed

5 files changed

+21
-48
lines changed

docs/reference/modules/cluster/disk_allocator.asciidoc

+13-12
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,6 @@ PUT /twitter/_settings
6767
How often Elasticsearch should check on disk usage for each node in the
6868
cluster. Defaults to `30s`.
6969

70-
`cluster.routing.allocation.disk.include_relocations`::
71-
72-
deprecated[7.5, Future versions will always account for relocations.]
73-
Defaults to +true+, which means that Elasticsearch will take into account
74-
shards that are currently being relocated to the target node when computing
75-
a node's disk usage. Taking relocating shards' sizes into account may,
76-
however, mean that the disk usage for a node is incorrectly estimated on
77-
the high side, since the relocation could be 90% complete and a recently
78-
retrieved disk usage would include the total size of the relocating shard
79-
as well as the space already used by the running relocation.
80-
81-
8270
NOTE: Percentage values refer to used disk space, while byte values refer to
8371
free disk space. This can be confusing, since it flips the meaning of high and
8472
low. For example, it makes sense to set the low watermark to 10gb and the high
@@ -100,3 +88,16 @@ PUT _cluster/settings
10088
}
10189
}
10290
--------------------------------------------------
91+
92+
{es} accounts for the future disk usage of ongoing shard relocations and
93+
recoveries to help prevent these shard movements from breaching a watermark.
94+
This mechanism may double-count some data that has already been relocated onto
95+
a node. For instance, if a relocation of a 100GB shard is 90% complete then
96+
{es} has copied 90GB of data onto the target node. This 90GB consumes disk
97+
space and will be reflected in the node's disk usage statistics. However {es}
98+
also treats the relocation as if it will consume another full 100GB in the
99+
future, even though the shard may really only consume a further 10GB of space.
100+
If the node's disks are close to a watermark then this may temporarily prevent
101+
other shards from moving onto the same node. Eventually the relocation will
102+
complete and then {es} will use the node's true disk usage statistics again.
103+

server/src/main/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdSettings.java

-14
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ public class DiskThresholdSettings {
5555
(s) -> validWatermarkSetting(s, "cluster.routing.allocation.disk.watermark.flood_stage"),
5656
new FloodStageValidator(),
5757
Setting.Property.Dynamic, Setting.Property.NodeScope);
58-
public static final Setting<Boolean> CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING =
59-
Setting.boolSetting("cluster.routing.allocation.disk.include_relocations", true,
60-
Setting.Property.Dynamic, Setting.Property.NodeScope, Setting.Property.Deprecated);
6158
public static final Setting<TimeValue> CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING =
6259
Setting.positiveTimeSetting("cluster.routing.allocation.disk.reroute_interval", TimeValue.timeValueSeconds(60),
6360
Setting.Property.Dynamic, Setting.Property.NodeScope);
@@ -68,7 +65,6 @@ public class DiskThresholdSettings {
6865
private volatile Double freeDiskThresholdHigh;
6966
private volatile ByteSizeValue freeBytesThresholdLow;
7067
private volatile ByteSizeValue freeBytesThresholdHigh;
71-
private volatile boolean includeRelocations;
7268
private volatile boolean enabled;
7369
private volatile TimeValue rerouteInterval;
7470
private volatile Double freeDiskThresholdFloodStage;
@@ -90,13 +86,11 @@ public DiskThresholdSettings(Settings settings, ClusterSettings clusterSettings)
9086
setHighWatermark(highWatermark);
9187
setLowWatermark(lowWatermark);
9288
setFloodStage(floodStage);
93-
this.includeRelocations = CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.get(settings);
9489
this.rerouteInterval = CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING.get(settings);
9590
this.enabled = CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.get(settings);
9691
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING, this::setLowWatermark);
9792
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING, this::setHighWatermark);
9893
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_DISK_FLOOD_STAGE_WATERMARK_SETTING, this::setFloodStage);
99-
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING, this::setIncludeRelocations);
10094
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING, this::setRerouteInterval);
10195
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING, this::setEnabled);
10296
}
@@ -227,10 +221,6 @@ private static void doValidateAsBytes(final String low, final String high, final
227221
}
228222
}
229223

230-
private void setIncludeRelocations(boolean includeRelocations) {
231-
this.includeRelocations = includeRelocations;
232-
}
233-
234224
private void setRerouteInterval(TimeValue rerouteInterval) {
235225
this.rerouteInterval = rerouteInterval;
236226
}
@@ -300,10 +290,6 @@ public ByteSizeValue getFreeBytesThresholdFloodStage() {
300290
return freeBytesThresholdFloodStage;
301291
}
302292

303-
public boolean includeRelocations() {
304-
return includeRelocations;
305-
}
306-
307293
public boolean isEnabled() {
308294
return enabled;
309295
}

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

+8-15
Original file line numberDiff line numberDiff line change
@@ -335,23 +335,16 @@ private DiskUsage getDiskUsage(RoutingNode node, RoutingAllocation allocation,
335335
// If there is no usage, and we have other nodes in the cluster,
336336
// use the average usage for all nodes as the usage for this node
337337
usage = averageUsage(node, usages);
338-
if (logger.isDebugEnabled()) {
339-
logger.debug("unable to determine disk usage for {}, defaulting to average across nodes [{} total] [{} free] [{}% free]",
340-
node.nodeId(), usage.getTotalBytes(), usage.getFreeBytes(), usage.getFreeDiskAsPercentage());
341-
}
338+
logger.debug("unable to determine disk usage for {}, defaulting to average across nodes [{} total] [{} free] [{}% free]",
339+
node.nodeId(), usage.getTotalBytes(), usage.getFreeBytes(), usage.getFreeDiskAsPercentage());
342340
}
343341

344-
if (diskThresholdSettings.includeRelocations()) {
345-
long relocatingShardsSize = sizeOfRelocatingShards(node, allocation, subtractLeavingShards, usage.getPath());
346-
DiskUsage usageIncludingRelocations = new DiskUsage(node.nodeId(), node.node().getName(), usage.getPath(),
347-
usage.getTotalBytes(), usage.getFreeBytes() - relocatingShardsSize);
348-
if (logger.isTraceEnabled()) {
349-
logger.trace("usage without relocations: {}", usage);
350-
logger.trace("usage with relocations: [{} bytes] {}", relocatingShardsSize, usageIncludingRelocations);
351-
}
352-
usage = usageIncludingRelocations;
353-
}
354-
return usage;
342+
final long relocatingShardsSize = sizeOfRelocatingShards(node, allocation, subtractLeavingShards, usage.getPath());
343+
final DiskUsage usageIncludingRelocations = new DiskUsage(node.nodeId(), node.node().getName(), usage.getPath(),
344+
usage.getTotalBytes(), usage.getFreeBytes() - relocatingShardsSize);
345+
logger.trace("getDiskUsage: usage [{}] with [{}] bytes relocating yields [{}]",
346+
usage, relocatingShardsSize, usageIncludingRelocations);
347+
return usageIncludingRelocations;
355348
}
356349

357350
/**

server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java

-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ public void apply(Settings value, Settings current, Settings previous) {
213213
DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING,
214214
DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_FLOOD_STAGE_WATERMARK_SETTING,
215215
DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING,
216-
DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING,
217216
DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING,
218217
SameShardAllocationDecider.CLUSTER_ROUTING_ALLOCATION_SAME_HOST_SETTING,
219218
InternalClusterInfoService.INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING,

server/src/test/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdSettingsTests.java

-6
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public void testDefaults() {
4444
assertEquals(15.0D, diskThresholdSettings.getFreeDiskThresholdLow(), 0.0D);
4545
assertEquals(60L, diskThresholdSettings.getRerouteInterval().seconds());
4646
assertTrue(diskThresholdSettings.isEnabled());
47-
assertTrue(diskThresholdSettings.includeRelocations());
4847
assertEquals(zeroBytes, diskThresholdSettings.getFreeBytesThresholdFloodStage());
4948
assertEquals(5.0D, diskThresholdSettings.getFreeDiskThresholdFloodStage(), 0.0D);
5049
}
@@ -55,7 +54,6 @@ public void testUpdate() {
5554

5655
Settings newSettings = Settings.builder()
5756
.put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), false)
58-
.put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.getKey(), false)
5957
.put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), "500mb")
6058
.put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "1000mb")
6159
.put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_FLOOD_STAGE_WATERMARK_SETTING.getKey(), "250mb")
@@ -71,10 +69,6 @@ public void testUpdate() {
7169
assertEquals(0.0D, diskThresholdSettings.getFreeDiskThresholdFloodStage(), 0.0D);
7270
assertEquals(30L, diskThresholdSettings.getRerouteInterval().seconds());
7371
assertFalse(diskThresholdSettings.isEnabled());
74-
assertFalse(diskThresholdSettings.includeRelocations());
75-
76-
assertWarnings("[cluster.routing.allocation.disk.include_relocations] setting was deprecated in Elasticsearch and " +
77-
"will be removed in a future release! See the breaking changes documentation for the next major version.");
7872
}
7973

8074
public void testInvalidConstruction() {

0 commit comments

Comments
 (0)