Skip to content

Commit

Permalink
Fix relocating shards size calculation (#48421)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DaveCTurner authored Oct 24, 2019
1 parent a14a222 commit 668919f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAl
"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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,17 +754,13 @@ public void testShardRelocationsTakenIntoAccount() {
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
}
}

Expand Down

0 comments on commit 668919f

Please sign in to comment.