Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/reference/searchable-snapshots/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ xpack.searchable.snapshot.shared_cache.size: 4TB
----

IMPORTANT: Currently, you can configure
`xpack.searchable.snapshot.shared_cache.size` on any node. In a future release,
you will only be able to configure this setting on nodes with the
<<data-frozen-node,`data_frozen`>> role.
`xpack.searchable.snapshot.shared_cache.size` on any node. However, if the cache size is set on any
node that does not have the <<data-frozen-node,`data_frozen`>> role, it will be treated as though it
is set to `0b`.

You can set `xpack.searchable.snapshot.shared_cache.size` to any size between a
couple of gigabytes up to 90% of available disk space. We only recommend larger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
import org.elasticsearch.cluster.routing.RoutingNode;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
Expand Down Expand Up @@ -42,7 +43,9 @@ public class HasFrozenCacheAllocationDecider extends AllocationDecider {
NAME,
"node setting ["
+ SNAPSHOT_CACHE_SIZE_SETTING.getKey()
+ "] is set to zero, so frozen searchable snapshot shards cannot be allocated to this node"
+ "] is set to zero, or the node is not a ["
+ DiscoveryNodeRole.DATA_FROZEN_NODE_ROLE.roleName()
+ "] node, so frozen searchable snapshot shards cannot be allocated to this node"
);

private static final Decision UNKNOWN_FROZEN_CACHE = Decision.single(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
import org.elasticsearch.common.util.concurrent.KeyedLock;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.xpack.searchablesnapshots.cache.common.CacheKey;
import org.elasticsearch.xpack.searchablesnapshots.cache.common.SparseFileTracker;
import org.elasticsearch.node.NodeRoleSettings;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.core.DataTier;
import org.elasticsearch.xpack.searchablesnapshots.cache.common.ByteRange;
import org.elasticsearch.xpack.searchablesnapshots.cache.common.CacheKey;
import org.elasticsearch.xpack.searchablesnapshots.cache.common.SparseFileTracker;

import java.io.IOException;
import java.io.UncheckedIOException;
Expand All @@ -46,6 +46,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor;
Expand Down Expand Up @@ -92,7 +93,7 @@ private static Setting.Validator<ByteSizeValue> getPageSizeAlignedByteSizeValueV
};
}

public static final Setting<ByteSizeValue> SNAPSHOT_CACHE_SIZE_SETTING = new Setting<>(
public static final Setting<ByteSizeValue> SNAPSHOT_CACHE_SIZE_SETTING = new Setting<ByteSizeValue>(
SHARED_CACHE_SETTINGS_PREFIX + "size",
ByteSizeValue.ZERO.getStringRep(),
s -> ByteSizeValue.parseBytesSizeValue(s, SHARED_CACHE_SETTINGS_PREFIX + "size"),
Expand Down Expand Up @@ -132,7 +133,19 @@ public Iterator<Setting<?>> settings() {

},
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);
final Set<DiscoveryNodeRole> roleSet = new HashSet<>(roles);
if (DataTier.isFrozenNode(roleSet)) {
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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.IOException;

import static org.elasticsearch.node.Node.NODE_NAME_SETTING;
import static org.hamcrest.Matchers.equalTo;

public class FrozenCacheServiceTests extends ESTestCase {

Expand Down Expand Up @@ -210,6 +211,23 @@ public void testCacheSizeDeprecatedOnNonFrozenNodes() {
);
}

public void testCacheSizeReturnsZeroOnNonFrozenNodes() {
final Settings settings = Settings.builder()
.put(FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(), new ByteSizeValue(size(500)).getStringRep())
.put(FrozenCacheService.SNAPSHOT_CACHE_REGION_SIZE_SETTING.getKey(), new ByteSizeValue(size(100)).getStringRep())
.putList(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), DiscoveryNodeRole.DATA_HOT_NODE_ROLE.roleName())
.build();
final ByteSizeValue value = FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.get(settings);
assertThat(value, equalTo(ByteSizeValue.ZERO));
assertWarnings(
"setting ["
+ FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey()
+ "] to be positive ["
+ new ByteSizeValue(size(500)).getStringRep()
+ "] on node without the data_frozen role is deprecated, roles are [data_hot]"
);
}

private static CacheKey generateCacheKey() {
return new CacheKey(
randomAlphaOfLength(10),
Expand Down