Skip to content

Commit e7680af

Browse files
Check shard availability before including in stats (#96015) (#96016)
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 #87001 Closes #96000
1 parent a8a8c71 commit e7680af

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

docs/changelog/96015.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pr: 96015
2+
summary: Check shard availability before including in stats
3+
area: Distributed
4+
type: bug
5+
issues:
6+
- 96000
7+
- 87001

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTiersUsageTransportAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ private static void aggregateDataTierShardStats(NodeStats nodeStats, Index index
206206
accumulator.docCount += shardStat.getTotal().getDocs().getCount();
207207

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

212213
// Accumulate stats about started primary shards

0 commit comments

Comments
 (0)