Skip to content

Commit eeecdbf

Browse files
authored
Additional trace logging for desired balance computer (#105910)
1 parent 8d93a93 commit eeecdbf

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ public void testRestoreSnapshotAllocationDoesNotExceedWatermark() throws Excepti
162162
}
163163

164164
@TestIssueLogging(
165-
value = "org.elasticsearch.cluster.routing.allocation.allocator.DesiredBalanceReconciler:DEBUG,"
165+
value = "org.elasticsearch.cluster.routing.allocation.allocator.DesiredBalanceComputer:TRACE,"
166+
+ "org.elasticsearch.cluster.routing.allocation.allocator.DesiredBalanceReconciler:DEBUG,"
166167
+ "org.elasticsearch.cluster.routing.allocation.allocator.DesiredBalanceShardsAllocator:TRACE",
167168
issueUrl = "https://github.com/elastic/elasticsearch/issues/105331"
168169
)

server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputer.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,18 @@ public DesiredBalance compute(
7777
Predicate<DesiredBalanceInput> isFresh
7878
) {
7979

80-
logger.debug("Recomputing desired balance for [{}]", desiredBalanceInput.index());
80+
if (logger.isTraceEnabled()) {
81+
logger.trace(
82+
"Recomputing desired balance for [{}]: {}, {}, {}, {}",
83+
desiredBalanceInput.index(),
84+
previousDesiredBalance,
85+
desiredBalanceInput.routingAllocation().routingNodes().toString(),
86+
desiredBalanceInput.routingAllocation().clusterInfo().toString(),
87+
desiredBalanceInput.routingAllocation().snapshotShardSizeInfo().toString()
88+
);
89+
} else {
90+
logger.debug("Recomputing desired balance for [{}]", desiredBalanceInput.index());
91+
}
8192

8293
final var routingAllocation = desiredBalanceInput.routingAllocation().mutableCloneForSimulation();
8394
final var routingNodes = routingAllocation.routingNodes();
@@ -283,7 +294,6 @@ public DesiredBalance compute(
283294
hasChanges = true;
284295
clusterInfoSimulator.simulateShardStarted(shardRouting);
285296
routingNodes.startShard(logger, shardRouting, changes, 0L);
286-
logger.trace("starting shard {}", shardRouting);
287297
}
288298
}
289299
}

server/src/main/java/org/elasticsearch/snapshots/SnapshotShardSizeInfo.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,9 @@ public long getShardSize(ShardRouting shardRouting, long fallback) {
4646
}
4747
return shardSize;
4848
}
49+
50+
@Override
51+
public String toString() {
52+
return "SnapshotShardSizeInfo{snapshotShardSizes=" + snapshotShardSizes + '}';
53+
}
4954
}

0 commit comments

Comments
 (0)