Skip to content

Commit

Permalink
Check shard availability before including in stats
Browse files Browse the repository at this point in the history
With this commit we check whether there is an available shard routing
before we test whether it has been started. This makes
`DataTiersUsageTransportAction` more resilient to potential temporary
inconsistencies between cluster state and node stats due to concurrent
shard movement.

Closes elastic#87001
Closes elastic#96000
  • Loading branch information
danielmitterdorfer committed May 11, 2023
1 parent 592cfaf commit 57dce54
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ private static void aggregateDataTierShardStats(NodeStats nodeStats, Index index
accumulator.docCount += shardStat.getTotal().getDocs().getCount();

// Accumulate stats about started shards
if (node.getByShardId(shardStat.getShardId()).state() == ShardRoutingState.STARTED) {
ShardRouting shardRouting = node.getByShardId(shardStat.getShardId());
if (shardRouting != null && shardRouting.state() == ShardRoutingState.STARTED) {
accumulator.totalShardCount += 1;

// Accumulate stats about started primary shards
Expand Down

0 comments on commit 57dce54

Please sign in to comment.