-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-define index.mapper.dynamic setting in 8.x (#109341)
Currently when upgrading a 7.x cluster to 8.x with `index.mapper.dynamic` index setting defined the following happens: - In case of a full cluster restart upgrade, then the index setting gets archived and after the upgrade the cluster is in a green health. - In case of a rolling cluster restart upgrade, then shards of indices with the index setting fail to allocate as nodes start with 8.x version. The result is that the cluster has a red health and the index setting isn't archived. Closing and opening the index should archive the index setting and allocate the shards. The change is about ensuring the same behavior happens when upgrading a cluster from 7.x to 8.x with indices that have the `index.mapper.dynamic` index setting defined. By re-defining the `index.mapper.dynamic `index setting with `IndexSettingDeprecatedInV7AndRemovedInV8` property, the index is allowed to exist in 7.x indices, but can't be defined in new indices after the upgrade. This way we don't have to rely on index archiving and upgrading via full cluster restart or rolling restart will yield the same outcome. Based on the test in #109301. Relates to #109160 and #96075
- Loading branch information
Showing
5 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 109341 | ||
summary: Re-define `index.mapper.dynamic` setting in 8.x for a better 7.x to 8.x upgrade if this setting is used. | ||
area: Mapping | ||
type: bug | ||
issues: [] |
82 changes: 82 additions & 0 deletions
82
...start/src/javaRestTest/java/org/elasticsearch/upgrades/UpgradeWithOldIndexSettingsIT.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.upgrades; | ||
|
||
import com.carrotsearch.randomizedtesting.annotations.Name; | ||
|
||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.ResponseException; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.xcontent.support.XContentMapValues; | ||
import org.elasticsearch.test.cluster.ElasticsearchCluster; | ||
import org.elasticsearch.test.cluster.FeatureFlag; | ||
import org.elasticsearch.test.cluster.local.LocalClusterConfigProvider; | ||
import org.elasticsearch.test.cluster.local.distribution.DistributionType; | ||
import org.junit.ClassRule; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class UpgradeWithOldIndexSettingsIT extends ParameterizedFullClusterRestartTestCase { | ||
|
||
protected static LocalClusterConfigProvider clusterConfig = c -> {}; | ||
|
||
@ClassRule | ||
public static ElasticsearchCluster cluster = ElasticsearchCluster.local() | ||
.distribution(DistributionType.DEFAULT) | ||
.version(getOldClusterTestVersion()) | ||
.nodes(2) | ||
.setting("xpack.security.enabled", "false") | ||
.feature(FeatureFlag.FAILURE_STORE_ENABLED) | ||
.apply(() -> clusterConfig) | ||
.build(); | ||
|
||
@Override | ||
protected ElasticsearchCluster getUpgradeCluster() { | ||
return cluster; | ||
} | ||
|
||
public UpgradeWithOldIndexSettingsIT(@Name("cluster") FullClusterRestartUpgradeStatus upgradeStatus) { | ||
super(upgradeStatus); | ||
} | ||
|
||
public void testMapperDynamicIndexSetting() throws IOException { | ||
assumeTrue( | ||
"Setting deprecated in 6.x, but remained in 7.x and is no longer defined in 8.x", | ||
getOldClusterTestVersion().before("8.0.0") | ||
); | ||
String indexName = "my-index"; | ||
if (isRunningAgainstOldCluster()) { | ||
createIndex(indexName); | ||
|
||
var request = new Request("PUT", "/my-index/_settings"); | ||
request.setJsonEntity(org.elasticsearch.common.Strings.toString(Settings.builder().put("index.mapper.dynamic", true).build())); | ||
request.setOptions( | ||
expectWarnings( | ||
"[index.mapper.dynamic] setting was deprecated in Elasticsearch and will be removed in a future release! " | ||
+ "See the breaking changes documentation for the next major version." | ||
) | ||
); | ||
assertOK(client().performRequest(request)); | ||
} else { | ||
var indexSettings = getIndexSettings(indexName); | ||
assertThat(XContentMapValues.extractValue(indexName + ".settings.index.mapper.dynamic", indexSettings), equalTo("true")); | ||
ensureGreen(indexName); | ||
// New indices can never define the index.mapper.dynamic setting. | ||
Exception e = expectThrows( | ||
ResponseException.class, | ||
() -> createIndex("my-index2", Settings.builder().put("index.mapper.dynamic", true).build()) | ||
); | ||
assertThat(e.getMessage(), containsString("unknown setting [index.mapper.dynamic]")); | ||
} | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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