Skip to content

Commit f06dc63

Browse files
authored
Report shared_cache shards as zero size on disk (#69820)
Searchable snapshot shards that are using the shared_cache are not actually consuming as much disk space as they report today in the "store" section of the node/indices stats. This blocks plan changes on Cloud as they check if the new nodes have enough disk space to host all the (at least primary) shards from the old nodes. With this change here, searchable snapshot shards that are using the shared_cache will report 0 as store size.
1 parent f631008 commit f06dc63

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

server/src/main/java/org/elasticsearch/index/shard/IndexShard.java

+7-9
Original file line numberDiff line numberDiff line change
@@ -1054,16 +1054,14 @@ public GetStats getStats() {
10541054
}
10551055

10561056
public StoreStats storeStats() {
1057+
if (DiskThresholdDecider.SETTING_IGNORE_DISK_WATERMARKS.get(indexSettings.getSettings())) {
1058+
// if this shard has no disk footprint then its size is reported as 0
1059+
return new StoreStats(0, 0);
1060+
}
10571061
try {
1058-
final long reservedBytes;
1059-
if (DiskThresholdDecider.SETTING_IGNORE_DISK_WATERMARKS.get(indexSettings.getSettings())) {
1060-
// if this shard has no disk footprint then it also needs no reserved space
1061-
reservedBytes = 0L;
1062-
} else {
1063-
final RecoveryState recoveryState = this.recoveryState;
1064-
final long bytesStillToRecover = recoveryState == null ? -1L : recoveryState.getIndex().bytesStillToRecover();
1065-
reservedBytes = bytesStillToRecover == -1 ? StoreStats.UNKNOWN_RESERVED_BYTES : bytesStillToRecover;
1066-
}
1062+
final RecoveryState recoveryState = this.recoveryState;
1063+
final long bytesStillToRecover = recoveryState == null ? -1L : recoveryState.getIndex().bytesStillToRecover();
1064+
final long reservedBytes = bytesStillToRecover == -1 ? StoreStats.UNKNOWN_RESERVED_BYTES : bytesStillToRecover;
10671065
return store.stats(reservedBytes);
10681066
} catch (IOException e) {
10691067
failShard("Failing shard because of exception during storeStats", e);

x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsIntegTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ public void testCreateAndRestorePartialSearchableSnapshot() throws Exception {
515515
shardStats.getStats().getStore().getReservedSize().getBytes(),
516516
equalTo(0L)
517517
);
518+
assertThat(shardStats.getShardRouting().toString(), shardStats.getStats().getStore().getSize().getBytes(), equalTo(0L));
518519
}
519520
}
520521
}, "test-stats-watcher");

0 commit comments

Comments
 (0)