Skip to content

Commit 92dce9d

Browse files
committed
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 b0c2848 commit 92dce9d

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,16 +1085,14 @@ public GetStats getStats() {
10851085
}
10861086

10871087
public StoreStats storeStats() {
1088+
if (DiskThresholdDecider.SETTING_IGNORE_DISK_WATERMARKS.get(indexSettings.getSettings())) {
1089+
// if this shard has no disk footprint then its size is reported as 0
1090+
return new StoreStats(0, 0);
1091+
}
10881092
try {
1089-
final long reservedBytes;
1090-
if (DiskThresholdDecider.SETTING_IGNORE_DISK_WATERMARKS.get(indexSettings.getSettings())) {
1091-
// if this shard has no disk footprint then it also needs no reserved space
1092-
reservedBytes = 0L;
1093-
} else {
1094-
final RecoveryState recoveryState = this.recoveryState;
1095-
final long bytesStillToRecover = recoveryState == null ? -1L : recoveryState.getIndex().bytesStillToRecover();
1096-
reservedBytes = bytesStillToRecover == -1 ? StoreStats.UNKNOWN_RESERVED_BYTES : bytesStillToRecover;
1097-
}
1093+
final RecoveryState recoveryState = this.recoveryState;
1094+
final long bytesStillToRecover = recoveryState == null ? -1L : recoveryState.getIndex().bytesStillToRecover();
1095+
final long reservedBytes = bytesStillToRecover == -1 ? StoreStats.UNKNOWN_RESERVED_BYTES : bytesStillToRecover;
10981096
return store.stats(reservedBytes);
10991097
} catch (IOException e) {
11001098
failShard("Failing shard because of exception during storeStats", e);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ public void testCreateAndRestorePartialSearchableSnapshot() throws Exception {
519519
shardStats.getStats().getStore().getReservedSize().getBytes(),
520520
equalTo(0L)
521521
);
522+
assertThat(shardStats.getShardRouting().toString(), shardStats.getStats().getStore().getSize().getBytes(), equalTo(0L));
522523
}
523524
}
524525
}, "test-stats-watcher");

0 commit comments

Comments
 (0)