Skip to content

Commit

Permalink
Report shared_cache shards as zero size on disk (#69820)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ywelsch committed Mar 3, 2021
1 parent c7ad737 commit 03bbee3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1085,16 +1085,14 @@ public GetStats getStats() {
}

public StoreStats storeStats() {
if (DiskThresholdDecider.SETTING_IGNORE_DISK_WATERMARKS.get(indexSettings.getSettings())) {
// if this shard has no disk footprint then its size is reported as 0
return new StoreStats(0, 0);
}
try {
final long reservedBytes;
if (DiskThresholdDecider.SETTING_IGNORE_DISK_WATERMARKS.get(indexSettings.getSettings())) {
// if this shard has no disk footprint then it also needs no reserved space
reservedBytes = 0L;
} else {
final RecoveryState recoveryState = this.recoveryState;
final long bytesStillToRecover = recoveryState == null ? -1L : recoveryState.getIndex().bytesStillToRecover();
reservedBytes = bytesStillToRecover == -1 ? StoreStats.UNKNOWN_RESERVED_BYTES : bytesStillToRecover;
}
final RecoveryState recoveryState = this.recoveryState;
final long bytesStillToRecover = recoveryState == null ? -1L : recoveryState.getIndex().bytesStillToRecover();
final long reservedBytes = bytesStillToRecover == -1 ? StoreStats.UNKNOWN_RESERVED_BYTES : bytesStillToRecover;
return store.stats(reservedBytes);
} catch (IOException e) {
failShard("Failing shard because of exception during storeStats", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ public void testCreateAndRestorePartialSearchableSnapshot() throws Exception {
shardStats.getStats().getStore().getReservedSize().getBytes(),
equalTo(0L)
);
assertThat(shardStats.getShardRouting().toString(), shardStats.getStats().getStore().getSize().getBytes(), equalTo(0L));
}
}
}, "test-stats-watcher");
Expand Down

0 comments on commit 03bbee3

Please sign in to comment.