diff --git a/docs/changelog/96015.yaml b/docs/changelog/96015.yaml new file mode 100644 index 0000000000000..d47fc7ddce001 --- /dev/null +++ b/docs/changelog/96015.yaml @@ -0,0 +1,7 @@ +pr: 96015 +summary: Check shard availability before including in stats +area: Distributed +type: bug +issues: + - 96000 + - 87001 diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTiersUsageTransportAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTiersUsageTransportAction.java index b7120f213cb15..92923ff99f29e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTiersUsageTransportAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTiersUsageTransportAction.java @@ -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