Skip to content

Commit d340432

Browse files
authored
Remove frozen cache setting leniency (#71013)
We previously allowed but deprecated the ability for the shared cache to be positively sized on nodes without the frozen role. This is because we only allocate shared_cache searchable snapshots to nodes with the frozen role. This commit completes our intention to deprecate/remove this ability.
1 parent 9b1ef49 commit d340432

File tree

6 files changed

+80
-36
lines changed

6 files changed

+80
-36
lines changed

docs/reference/migration/migrate_8_0/settings.asciidoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,22 @@ Discontinue use of the removed settings. If needed, use
167167
cluster recovery pending a certain number of data nodes.
168168
====
169169

170+
.Setting the searchable snapshots shared cache size on non-frozen nodes is no
171+
longer permitted.
172+
[%collapsible]
173+
====
174+
*Details* +
175+
Setting `xpack.searchable.snapshot.shared_cache.size` to be positive on a node
176+
that does not have the `data_frozen` role was deprecated in {es} 7.12.0 and has
177+
been removed in {es} 8.0.0.
178+
179+
*Impact* +
180+
Discontinue use of the removed setting. Note that searchable snapshots mounted
181+
using the `shared_cache` storage option were only allocated to nodes that had
182+
the `data_frozen` role, so removing this setting on nodes that do not have the
183+
`data_frozen` role will have no impact on functionality.
184+
====
185+
170186
.By default, destructive index actions do not allow wildcards.
171187
[%collapsible]
172188
====

docs/reference/searchable-snapshots/index.asciidoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ You can configure the setting in `elasticsearch.yml`:
171171
xpack.searchable.snapshot.shared_cache.size: 4TB
172172
----
173173

174-
IMPORTANT: Currently, you can configure
175-
`xpack.searchable.snapshot.shared_cache.size` on any node. In a future release,
176-
you will only be able to configure this setting on nodes with the
174+
IMPORTANT: You can only configure this setting on nodes with the
177175
<<data-frozen-node,`data_frozen`>> role.
178176

179177
You can set `xpack.searchable.snapshot.shared_cache.size` to any size between a

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

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,20 @@
1616

1717
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
1818
import org.elasticsearch.action.index.IndexRequestBuilder;
19-
import org.elasticsearch.xpack.searchablesnapshots.cache.blob.BlobStoreCacheService;
19+
import org.elasticsearch.cluster.node.DiscoveryNode;
20+
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
2021
import org.elasticsearch.common.Strings;
2122
import org.elasticsearch.common.settings.Settings;
2223
import org.elasticsearch.common.unit.ByteSizeUnit;
2324
import org.elasticsearch.common.unit.ByteSizeValue;
2425
import org.elasticsearch.index.IndexSettings;
2526
import org.elasticsearch.plugins.Plugin;
2627
import org.elasticsearch.snapshots.AbstractSnapshotIntegTestCase;
28+
import org.elasticsearch.test.ESIntegTestCase;
2729
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
2830
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
2931
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest.Storage;
32+
import org.elasticsearch.xpack.searchablesnapshots.cache.blob.BlobStoreCacheService;
3033
import org.elasticsearch.xpack.searchablesnapshots.cache.full.CacheService;
3134
import org.elasticsearch.xpack.searchablesnapshots.cache.shared.FrozenCacheService;
3235
import org.junit.After;
@@ -35,13 +38,16 @@
3538
import java.util.Collection;
3639
import java.util.List;
3740
import java.util.Locale;
41+
import java.util.Set;
3842
import java.util.concurrent.TimeUnit;
3943

4044
import static org.elasticsearch.license.LicenseService.SELF_GENERATED_LICENSE_TYPE;
45+
import static org.elasticsearch.test.NodeRoles.addRoles;
4146
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
4247
import static org.elasticsearch.xpack.searchablesnapshots.cache.shared.SharedBytes.pageAligned;
4348
import static org.hamcrest.Matchers.equalTo;
4449

50+
@ESIntegTestCase.ClusterScope(supportsDedicatedMasters = false, numClientNodes = 0)
4551
public abstract class BaseSearchableSnapshotsIntegTestCase extends AbstractSnapshotIntegTestCase {
4652
@Override
4753
protected boolean addMockInternalEngine() {
@@ -55,9 +61,16 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
5561

5662
@Override
5763
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
58-
final Settings.Builder builder = Settings.builder()
59-
.put(super.nodeSettings(nodeOrdinal, otherSettings))
60-
.put(SELF_GENERATED_LICENSE_TYPE.getKey(), "trial");
64+
final Settings settings;
65+
{
66+
final Settings initialSettings = super.nodeSettings(nodeOrdinal, otherSettings);
67+
if (DiscoveryNode.canContainData(otherSettings)) {
68+
settings = addRoles(initialSettings, Set.of(DiscoveryNodeRole.DATA_FROZEN_NODE_ROLE));
69+
} else {
70+
settings = initialSettings;
71+
}
72+
}
73+
final Settings.Builder builder = Settings.builder().put(settings).put(SELF_GENERATED_LICENSE_TYPE.getKey(), "trial");
6174
if (randomBoolean()) {
6275
builder.put(
6376
CacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(),
@@ -76,14 +89,16 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
7689
: new ByteSizeValue(randomIntBetween(1, 10), ByteSizeUnit.MB)
7790
);
7891
}
79-
builder.put(
80-
FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(),
81-
rarely()
82-
? randomBoolean()
83-
? new ByteSizeValue(randomIntBetween(0, 10), ByteSizeUnit.KB)
84-
: new ByteSizeValue(randomIntBetween(0, 1000), ByteSizeUnit.BYTES)
85-
: new ByteSizeValue(randomIntBetween(1, 10), ByteSizeUnit.MB)
86-
);
92+
if (DiscoveryNode.canContainData(otherSettings)) {
93+
builder.put(
94+
FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(),
95+
rarely()
96+
? randomBoolean()
97+
? new ByteSizeValue(randomIntBetween(0, 10), ByteSizeUnit.KB)
98+
: new ByteSizeValue(randomIntBetween(0, 1000), ByteSizeUnit.BYTES)
99+
: new ByteSizeValue(randomIntBetween(1, 10), ByteSizeUnit.MB)
100+
);
101+
}
87102
builder.put(
88103
FrozenCacheService.SNAPSHOT_CACHE_REGION_SIZE_SETTING.getKey(),
89104
rarely()

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.elasticsearch.action.search.SearchResponse;
1515
import org.elasticsearch.cluster.metadata.DataStream;
1616
import org.elasticsearch.cluster.metadata.IndexMetadata;
17+
import org.elasticsearch.cluster.node.DiscoveryNode;
1718
import org.elasticsearch.common.Strings;
1819
import org.elasticsearch.common.settings.Settings;
1920
import org.elasticsearch.common.unit.ByteSizeUnit;
@@ -64,14 +65,19 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
6465
}
6566

6667
@Override
67-
protected Settings nodeSettings(int nodeOrdinal, Settings nodeSettings) {
68-
return Settings.builder()
69-
.put(super.nodeSettings(nodeOrdinal, nodeSettings))
70-
// Use an unbound cache so we can recover the searchable snapshot completely all the times
71-
.put(CacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(), new ByteSizeValue(Long.MAX_VALUE, ByteSizeUnit.BYTES))
72-
// Have a shared cache of reasonable size available on each node because tests randomize over frozen and cold allocation
73-
.put(FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(), ByteSizeValue.ofMb(randomLongBetween(1, 10)))
74-
.build();
68+
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
69+
final Settings initialSettings = super.nodeSettings(nodeOrdinal, otherSettings);
70+
if (DiscoveryNode.canContainData(otherSettings)) {
71+
return Settings.builder()
72+
.put(initialSettings)
73+
// Use an unbound cache so we can recover the searchable snapshot completely all the times
74+
.put(CacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(), new ByteSizeValue(Long.MAX_VALUE, ByteSizeUnit.BYTES))
75+
// Have a shared cache of reasonable size available on each node because tests randomize over frozen and cold allocation
76+
.put(FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(), ByteSizeValue.ofMb(randomLongBetween(1, 10)))
77+
.build();
78+
} else {
79+
return initialSettings;
80+
}
7581
}
7682

7783
public void testSearchableSnapshotShardsAreSkippedWithoutQueryingAnyNodeWhenTheyAreOutsideOfTheQueryRange() throws Exception {

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
1717
import org.elasticsearch.common.lease.Releasable;
1818
import org.elasticsearch.common.lease.Releasables;
19-
import org.elasticsearch.common.logging.DeprecationCategory;
2019
import org.elasticsearch.common.logging.DeprecationLogger;
2120
import org.elasticsearch.common.settings.Setting;
2221
import org.elasticsearch.common.settings.Settings;
@@ -111,10 +110,8 @@ public void validate(final ByteSizeValue value, final Map<Setting<?>, Object> se
111110
@SuppressWarnings("unchecked")
112111
final List<DiscoveryNodeRole> roles = (List<DiscoveryNodeRole>) settings.get(NodeRoleSettings.NODE_ROLES_SETTING);
113112
if (DataTier.isFrozenNode(Set.of(roles.toArray(DiscoveryNodeRole[]::new))) == false) {
114-
deprecationLogger.deprecate(
115-
DeprecationCategory.SETTINGS,
116-
"shared_cache",
117-
"setting [{}] to be positive [{}] on node without the data_frozen role is deprecated, roles are [{}]",
113+
throw new SettingsException(
114+
"setting [{}] to be positive [{}] is only permitted on nodes with the data_frozen role, roles are [{}]",
118115
SHARED_CACHE_SETTINGS_PREFIX + "size",
119116
value.getStringRep(),
120117
roles.stream().map(DiscoveryNodeRole::roleName).collect(Collectors.joining(","))

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

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.elasticsearch.cluster.coordination.DeterministicTaskQueue;
1111
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
1212
import org.elasticsearch.common.settings.Settings;
13+
import org.elasticsearch.common.settings.SettingsException;
1314
import org.elasticsearch.common.unit.ByteSizeValue;
1415
import org.elasticsearch.env.NodeEnvironment;
1516
import org.elasticsearch.env.TestEnvironment;
@@ -24,6 +25,9 @@
2425
import java.io.IOException;
2526

2627
import static org.elasticsearch.node.Node.NODE_NAME_SETTING;
28+
import static org.hamcrest.Matchers.instanceOf;
29+
import static org.hamcrest.Matchers.is;
30+
import static org.hamcrest.Matchers.notNullValue;
2731

2832
public class FrozenCacheServiceTests extends ESTestCase {
2933

@@ -194,19 +198,27 @@ public void testDecay() throws IOException {
194198
}
195199
}
196200

197-
public void testCacheSizeDeprecatedOnNonFrozenNodes() {
201+
public void testCacheSizeRejectedOnNonFrozenNodes() {
198202
final Settings settings = Settings.builder()
199203
.put(FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(), new ByteSizeValue(size(500)).getStringRep())
200204
.put(FrozenCacheService.SNAPSHOT_CACHE_REGION_SIZE_SETTING.getKey(), new ByteSizeValue(size(100)).getStringRep())
201205
.putList(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), DiscoveryNodeRole.DATA_HOT_NODE_ROLE.roleName())
202206
.build();
203-
FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.get(settings);
204-
assertWarnings(
205-
"setting ["
206-
+ FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey()
207-
+ "] to be positive ["
208-
+ new ByteSizeValue(size(500)).getStringRep()
209-
+ "] on node without the data_frozen role is deprecated, roles are [data_hot]"
207+
final IllegalArgumentException e = expectThrows(
208+
IllegalArgumentException.class,
209+
() -> FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.get(settings)
210+
);
211+
assertThat(e.getCause(), notNullValue());
212+
assertThat(e.getCause(), instanceOf(SettingsException.class));
213+
assertThat(
214+
e.getCause().getMessage(),
215+
is(
216+
"setting ["
217+
+ FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey()
218+
+ "] to be positive ["
219+
+ new ByteSizeValue(size(500)).getStringRep()
220+
+ "] is only permitted on nodes with the data_frozen role, roles are [data_hot]"
221+
)
210222
);
211223
}
212224

0 commit comments

Comments
 (0)