From 50518359fe52e8f5902f557a52987002ea8b4064 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 24 Oct 2019 09:43:46 +0200 Subject: [PATCH] Fix relocating shards size calculation (#48421) In #48392 we added a second computation of the sizes of the relocating shards in `canRemain()` but passed the wrong value for `subtractLeavingShards`. This fixes that. It also removes some unnecessary logging in a test case added in the same commit. --- .../routing/allocation/decider/DiskThresholdDecider.java | 2 +- .../allocation/decider/DiskThresholdDeciderTests.java | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java index 4408a03751d..740fdb60a91 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java @@ -317,7 +317,7 @@ public class DiskThresholdDecider extends AllocationDecider { "this shard is not allocated on the most utilized disk and can remain"); } if (freeBytes < 0L) { - final long sizeOfRelocatingShards = sizeOfRelocatingShards(node, false, usage.getPath(), + final long sizeOfRelocatingShards = sizeOfRelocatingShards(node, true, usage.getPath(), allocation.clusterInfo(), allocation.metaData(), allocation.routingTable()); logger.debug("fewer free bytes remaining than the size of all incoming shards: " + "usage {} on node {} including {} bytes of relocations, shard cannot remain", diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java index 93d87edad4d..d0a79a5a783 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java @@ -754,17 +754,13 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase { AllocationCommand moveAllocationCommand = new MoveAllocationCommand("test2", 0, "node2", "node3"); AllocationCommands cmds = new AllocationCommands(moveAllocationCommand); - logger.info("--> before starting: {}", clusterState); clusterState = startInitializingShardsAndReroute(strategy, clusterState); - logger.info("--> after starting: {}", clusterState); clusterState = strategy.reroute(clusterState, cmds, false, false).getClusterState(); - logger.info("--> after running another command: {}", clusterState); logShardStates(clusterState); clusterInfoReference.set(overfullClusterInfo); - clusterState = strategy.reroute(clusterState, "foo"); - logger.info("--> after another reroute: {}", clusterState); + strategy.reroute(clusterState, "foo"); // ensure reroute doesn't fail even though there is negative free space } }