Skip to content

Filter out upgraded version index settings when starting index following #38838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ static void validate(
Settings leaderSettings = filter(leaderIndex.getSettings());
Settings followerSettings = filter(followIndex.getSettings());
if (leaderSettings.equals(followerSettings) == false) {
throw new IllegalArgumentException("the leader and follower index settings must be identical");
throw new IllegalArgumentException("the leader index setting[" + leaderSettings + "] and follower index settings [" +
followerSettings + "] must be identical");
}

// Validates if the current follower mapping is mergable with the leader mapping.
Expand Down Expand Up @@ -456,6 +457,11 @@ static Settings filter(Settings originalSettings) {
settings.remove(IndexMetaData.SETTING_INDEX_PROVIDED_NAME);
settings.remove(IndexMetaData.SETTING_CREATION_DATE);

// Follower index may be upgraded, while the leader index hasn't been upgraded, so it is expected
// that these settings are different:
settings.remove(IndexMetaData.SETTING_VERSION_UPGRADED);
settings.remove(IndexMetaData.SETTING_VERSION_UPGRADED_STRING);

Iterator<String> iterator = settings.keys().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ public void testValidation() throws IOException {
.put("index.analysis.analyzer.my_analyzer.type", "custom")
.put("index.analysis.analyzer.my_analyzer.tokenizer", "standard").build(), customMetaData);
Exception e = expectThrows(IllegalArgumentException.class, () -> validate(request, leaderIMD, followIMD, UUIDs, null));
assertThat(e.getMessage(), equalTo("the leader and follower index settings must be identical"));
assertThat(e.getMessage(), equalTo("the leader index setting[{\"index.analysis.analyzer.my_analyzer.tokenizer\"" +
":\"whitespace\",\"index.analysis.analyzer.my_analyzer.type\":\"custom\",\"index.number_of_shards\":\"5\"}] " +
"and follower index settings [{\"index.analysis.analyzer.my_analyzer.tokenizer\":\"standard\"," +
"\"index.analysis.analyzer.my_analyzer.type\":\"custom\",\"index.number_of_shards\":\"5\"}] must be identical"));
}
{
// should fail because the following index does not have the following_index settings
Expand Down Expand Up @@ -242,6 +245,21 @@ public void testDynamicIndexSettingsAreClassified() {
}
}

public void testFilter() {
Settings.Builder settings = Settings.builder();
settings.put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), "");
settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), "");
settings.put(IndexMetaData.SETTING_INDEX_VERSION_CREATED.getKey(), "");
settings.put(IndexMetaData.SETTING_INDEX_UUID, "");
settings.put(IndexMetaData.SETTING_INDEX_PROVIDED_NAME, "");
settings.put(IndexMetaData.SETTING_CREATION_DATE, "");
settings.put(IndexMetaData.SETTING_VERSION_UPGRADED, "");
settings.put(IndexMetaData.SETTING_VERSION_UPGRADED_STRING, "");

Settings result = TransportResumeFollowAction.filter(settings.build());
assertThat(result.size(), equalTo(0));
}

private static IndexMetaData createIMD(String index,
int numberOfShards,
Settings settings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@

public class CcrRollingUpgradeIT extends AbstractMultiClusterUpgradeTestCase {

public void test() {
// dummy test otherwise test run fails when both tests are ignored.
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/38835")
public void testIndexFollowing() throws Exception {
logger.info("clusterName={}, upgradeState={}", clusterName, upgradeState);

Expand Down