Skip to content

Commit 8bef504

Browse files
committed
Shared cache's recovery range should be aligned with page size (elastic#74439)
Shared cache expects read and write operations to be aligned with a given page size (4096 bytes). The recovery range size setting should be validated against this constraint and the integration tests should not try to set a non-aligned setting value. Closes elastic#74372
1 parent 08993af commit 8bef504

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
120120
if (randomBoolean()) {
121121
builder.put(
122122
FrozenCacheService.FROZEN_CACHE_RECOVERY_RANGE_SIZE_SETTING.getKey(),
123-
new ByteSizeValue(randomIntBetween(4, 1024), ByteSizeUnit.KB)
123+
rarely()
124+
? pageAligned(new ByteSizeValue(randomIntBetween(4, 1024), ByteSizeUnit.KB))
125+
: pageAligned(new ByteSizeValue(randomIntBetween(1, 10), ByteSizeUnit.MB))
124126
);
125127
}
126128
return builder.build();

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache/shared/FrozenCacheService.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ public class FrozenCacheService implements Releasable {
8181
Setting.Property.NodeScope
8282
);
8383

84+
public static final Setting<ByteSizeValue> FROZEN_CACHE_RECOVERY_RANGE_SIZE_SETTING = new Setting<>(
85+
SHARED_CACHE_SETTINGS_PREFIX + "recovery_range_size",
86+
ByteSizeValue.ofKb(128L).getStringRep(),
87+
s -> ByteSizeValue.parseBytesSizeValue(s, SHARED_CACHE_SETTINGS_PREFIX + "recovery_range_size"),
88+
getPageSizeAlignedByteSizeValueValidator(SHARED_CACHE_SETTINGS_PREFIX + "recovery_range_size"),
89+
Setting.Property.NodeScope
90+
);
91+
8492
public static final Setting<ByteSizeValue> SNAPSHOT_CACHE_REGION_SIZE_SETTING = new Setting<>(
8593
SHARED_CACHE_SETTINGS_PREFIX + "region_size",
8694
SHARED_CACHE_RANGE_SIZE_SETTING,
@@ -212,14 +220,6 @@ public void validate(ByteSizeValue value, Map<Setting<?>, Object> settings, bool
212220
Setting.Property.NodeScope
213221
);
214222

215-
public static final Setting<ByteSizeValue> FROZEN_CACHE_RECOVERY_RANGE_SIZE_SETTING = Setting.byteSizeSetting(
216-
SHARED_CACHE_SETTINGS_PREFIX + "recovery_range_size",
217-
new ByteSizeValue(128, ByteSizeUnit.KB), // default
218-
MIN_SNAPSHOT_CACHE_RANGE_SIZE, // min
219-
MAX_SNAPSHOT_CACHE_RANGE_SIZE, // max
220-
Setting.Property.NodeScope
221-
);
222-
223223
public static final TimeValue MIN_SNAPSHOT_CACHE_DECAY_INTERVAL = TimeValue.timeValueSeconds(1L);
224224
public static final Setting<TimeValue> SNAPSHOT_CACHE_DECAY_INTERVAL_SETTING = Setting.timeSetting(
225225
SHARED_CACHE_SETTINGS_PREFIX + "decay.interval",

0 commit comments

Comments
 (0)