Skip to content

Commit 61d0459

Browse files
Fix mount frozen index during rolling upgrade (#71777)
If master ends up on a newer version than other cluster members, we cannot apply the new index setting for shard limits. We skip doing so for now. Relates #71392
1 parent d786a04 commit 61d0459

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/TransportMountSearchableSnapshotAction.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package org.elasticsearch.xpack.searchablesnapshots.action;
99

1010
import org.elasticsearch.ElasticsearchException;
11+
import org.elasticsearch.Version;
1112
import org.elasticsearch.action.ActionListener;
1213
import org.elasticsearch.action.StepListener;
1314
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest;
@@ -126,7 +127,8 @@ private static Settings buildIndexSettings(
126127
String repoName,
127128
SnapshotId snapshotId,
128129
IndexId indexId,
129-
MountSearchableSnapshotRequest.Storage storage
130+
MountSearchableSnapshotRequest.Storage storage,
131+
Version minNodeVersion
130132
) {
131133
final Settings.Builder settings = Settings.builder();
132134

@@ -145,9 +147,17 @@ private static Settings buildIndexSettings(
145147
.put(INDEX_RECOVERY_TYPE_SETTING.getKey(), SearchableSnapshotsConstants.SNAPSHOT_RECOVERY_STATE_FACTORY_KEY);
146148

147149
if (storage == MountSearchableSnapshotRequest.Storage.SHARED_CACHE) {
150+
if (minNodeVersion.before(Version.V_7_12_0)) {
151+
throw new IllegalArgumentException("shared cache searchable snapshots require minimum node version " + Version.V_7_12_0);
152+
}
148153
settings.put(SearchableSnapshotsConstants.SNAPSHOT_PARTIAL_SETTING.getKey(), true)
149-
.put(DiskThresholdDecider.SETTING_IGNORE_DISK_WATERMARKS.getKey(), true)
150-
.put(ShardLimitValidator.INDEX_SETTING_SHARD_LIMIT_GROUP.getKey(), ShardLimitValidator.FROZEN_GROUP);
154+
.put(DiskThresholdDecider.SETTING_IGNORE_DISK_WATERMARKS.getKey(), true);
155+
156+
// we cannot apply this setting during rolling upgrade.
157+
// todo: update version after backport
158+
if (minNodeVersion.onOrAfter(Version.V_8_0_0)) {
159+
settings.put(ShardLimitValidator.INDEX_SETTING_SHARD_LIMIT_GROUP.getKey(), ShardLimitValidator.FROZEN_GROUP);
160+
}
151161
}
152162

153163
return settings.build();
@@ -228,7 +238,16 @@ protected void masterOperation(
228238
.put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, false) // can be overridden
229239
.put(DataTierAllocationDecider.INDEX_ROUTING_PREFER, getDataTiersPreference(request.storage()))
230240
.put(request.indexSettings())
231-
.put(buildIndexSettings(repoData.getUuid(), request.repositoryName(), snapshotId, indexId, request.storage()))
241+
.put(
242+
buildIndexSettings(
243+
repoData.getUuid(),
244+
request.repositoryName(),
245+
snapshotId,
246+
indexId,
247+
request.storage(),
248+
state.nodes().getMinNodeVersion()
249+
)
250+
)
232251
.build();
233252

234253
// todo: restore archives bad settings, for now we verify just the data tiers, since we know their dependencies are available

0 commit comments

Comments
 (0)