Make searchable snapshot cache size effectively zero on non-frozen nodes#70846
Closed
dakrone wants to merge 3 commits intoelastic:masterfrom
Closed
Make searchable snapshot cache size effectively zero on non-frozen nodes#70846dakrone wants to merge 3 commits intoelastic:masterfrom
dakrone wants to merge 3 commits intoelastic:masterfrom
Conversation
This commits makes the shared_cache searchable snapshot cache size setting resolve to 0 for nodes that to do have the `data_frozen` node role. It turns out there is not a simple way to do this with the existing Settings infrastructure. Given that setting this on non-frozen nodes is already deprecated (and already outputs a deprecated log message), After talking to Ryan, we agreed it was better to handle this upon reading the setting rather than adding anything to the `Settings` code for only this purpose. I also attempted to make the shared cache setting private (so it actually couldn't be retrieved outside of the static method), however, it's still needed in the `SearchableSnapshots` plugin interface, so without moving it there, it has to remain public (I can move it there if we decide that would be better). Tangentially related to elastic#70341
Collaborator
|
Pinging @elastic/es-distributed (Team:Distributed) |
dakrone
added a commit
to dakrone/elasticsearch
that referenced
this pull request
Mar 29, 2021
This commit converts the index metadata of searchable snapshot indices using the `shared_cache` storage type to: - Remove all the `index.routing.allocation.(include|exclude|require)._tier` settings - Sets `index.routing.allocation.include._tier_preference` to `data_frozen` automatically when the index metadata is read This is in preperation to enforcing that the `_tier_preference` setting is always set to `data_frozen` for shared cache SBIs. Relates to elastic#70846, elastic#71013, elastic#70786, elastic#70141
Member
|
I think that we can do this in the existing settings infrastructure by overriding |
Member
|
Here's an untested patch that provides the concept: diff --git a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache/FrozenCacheService.java b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache/FrozenCacheService.java
index b1ebbaa5cdf..ac8ca7a3e66 100644
--- a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache/FrozenCacheService.java
+++ b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache/FrozenCacheService.java
@@ -117,7 +117,20 @@ public class FrozenCacheService implements Releasable {
},
Setting.Property.NodeScope
- );
+ ) {
+
+ @Override
+ public ByteSizeValue get(final Settings settings) {
+ final ByteSizeValue value = super.get(settings);
+ final List<DiscoveryNodeRole> roles = NodeRoleSettings.NODE_ROLES_SETTING.get(settings);
+ if (DataTier.isFrozenNode(Set.of(roles.toArray(DiscoveryNodeRole[]::new)))) {
+ return value;
+ } else {
+ return ByteSizeValue.ZERO;
+ }
+ }
+
+ };
public static final Setting<ByteSizeValue> FROZEN_CACHE_RECOVERY_RANGE_SIZE_SETTING = Setting.byteSizeSetting(
SHARED_CACHE_SETTINGS_PREFIX + "recovery_range_size",
diff --git a/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/cache/FrozenCacheServiceTests.java b/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/cache/FrozenCacheServiceTests.java
index 499b0cf4fce..d71d31cfb0f 100644
--- a/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/cache/FrozenCacheServiceTests.java
+++ b/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/cache/FrozenCacheServiceTests.java
@@ -10,6 +10,7 @@ package org.elasticsearch.xpack.searchablesnapshots.cache;
import org.elasticsearch.cluster.coordination.DeterministicTaskQueue;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.index.shard.ShardId;
@@ -26,6 +27,7 @@ import java.nio.file.Path;
import java.util.Set;
import static org.elasticsearch.node.Node.NODE_NAME_SETTING;
+import static org.hamcrest.Matchers.is;
public class FrozenCacheServiceTests extends ESTestCase {
@@ -213,6 +215,24 @@ public class FrozenCacheServiceTests extends ESTestCase {
);
}
+ public void testCacheSizeClampsToZeroOnNonFrozenNodes() {
+ DiscoveryNode.setAdditionalRoles(
+ Set.of(DataTier.DATA_HOT_NODE_ROLE, DataTier.DATA_WARM_NODE_ROLE, DataTier.DATA_COLD_NODE_ROLE, DataTier.DATA_FROZEN_NODE_ROLE)
+ );
+ final Settings settings = Settings.builder()
+ .put(FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(), "500b")
+ .put(FrozenCacheService.SNAPSHOT_CACHE_REGION_SIZE_SETTING.getKey(), "100b")
+ .putList(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), DataTier.DATA_HOT_NODE_ROLE.roleName())
+ .build();
+ final ByteSizeValue value = FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.get(settings);
+ assertThat(value, is(ByteSizeValue.ZERO));
+ assertWarnings(
+ "setting ["
+ + FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey()
+ + "] to be positive [500b] on node without the data_frozen role is deprecated, roles are [data_hot]"
+ );
+ }
+
private static CacheKey generateCacheKey() {
return new CacheKey(
randomAlphaOfLength(10), |
dakrone
added a commit
that referenced
this pull request
Mar 31, 2021
This commit converts the index metadata of searchable snapshot indices using the `shared_cache` storage type to: - Remove all the `index.routing.allocation.(include|exclude|require)._tier` settings - Sets `index.routing.allocation.include._tier_preference` to `data_frozen` automatically when the index metadata is read This is in preperation to enforcing that the `_tier_preference` setting is always set to `data_frozen` for shared cache SBIs. Relates to #70846, #71013, #70786, #70141
dakrone
added a commit
to dakrone/elasticsearch
that referenced
this pull request
Mar 31, 2021
This commit converts the index metadata of searchable snapshot indices using the `shared_cache` storage type to: - Remove all the `index.routing.allocation.(include|exclude|require)._tier` settings - Sets `index.routing.allocation.include._tier_preference` to `data_frozen` automatically when the index metadata is read This is in preperation to enforcing that the `_tier_preference` setting is always set to `data_frozen` for shared cache SBIs. Relates to elastic#70846, elastic#71013, elastic#70786, elastic#70141
dakrone
added a commit
to dakrone/elasticsearch
that referenced
this pull request
Mar 31, 2021
This commits makes the shared_cache searchable snapshot cache size setting resolve to 0 for nodes that to do have the data_frozen node role. Tangentially related to elastic#70341 Supercedes elastic#70846
Member
Author
|
@jasontedor yep that's a much better solution. I'm closing this in favor of #71134 which only targets 7.x (since you already have a PR for removing the leniency on master up) |
dakrone
added a commit
that referenced
this pull request
Mar 31, 2021
…#71129) This commit converts the index metadata of searchable snapshot indices using the `shared_cache` storage type to: - Remove all the `index.routing.allocation.(include|exclude|require)._tier` settings - Sets `index.routing.allocation.include._tier_preference` to `data_frozen` automatically when the index metadata is read This is in preperation to enforcing that the `_tier_preference` setting is always set to `data_frozen` for shared cache SBIs. Relates to #70846, #71013, #70786, #70141
dakrone
added a commit
that referenced
this pull request
Apr 1, 2021
…des (#71134) * Make searchable snapshot cache size effectively zero on non-frozen nodes This commits makes the shared_cache searchable snapshot cache size setting resolve to 0 for nodes that to do have the data_frozen node role. Tangentially related to #70341 Supercedes #70846 * Update message in HasFrozenCacheAllocationDecider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commits makes the shared_cache searchable snapshot cache size setting resolve to 0 for nodes
that to do have the
data_frozennode role.It turns out there is not a simple way to do this with the existing Settings infrastructure. Given
that setting this on non-frozen nodes is already deprecated (and already outputs a deprecated log
message), After talking to Ryan, we agreed it was better to handle this upon reading the setting
rather than adding anything to the
Settingscode for only this purpose.I also attempted to make the shared cache setting private (so it actually couldn't be retrieved
outside of the static method), however, it's still needed in the
SearchableSnapshotsplugininterface, so without moving it there, it has to remain public (I can move it there if we decide
that would be better).
Tangentially related to #70341