Skip to content

Allow legacy index settings on legacy indices #90264

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 22 commits into from
Nov 2, 2022

Conversation

grcevski
Copy link
Contributor

Our backward compatibility on indices states that we support indices with one version less than the current version. Those legacy indices might have legacy index settings, which we typically archive on cluster restart. However, this archiving happens only on full cluster restart, not on rolling restarts, which effectively leaves the indices unusable in 8.x.

This PR adds code that ignores unknown settings on indices if the index created version is less than the current version.

Closes #84992

Nikola Grcevski added 3 commits September 22, 2022 09:18
Add code to ignore unknown index settings on
old indices, to allow rolling-upgrades to work.
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticsearchmachine
Copy link
Collaborator

Hi @grcevski, I've created a changelog YAML for you.

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't introduce a broad-brush lenience like this. We should instead reinstate the settings that we removed, along with a setting validator that prevents them from being set on 8.x indices.

By leaving these settings unregistered I think we prevent folks from adjusting or removing them on older indices, but these things should remain possible even in 8.x. I also think they'd still be archived in a full-cluster restart but we don't want that either.

(clarifying edit:) In the case of the slowlog settings I think it's ok if setting them has no effect in 8.x. But they still should remain registered.

@grcevski
Copy link
Contributor Author

We should instead reinstate the settings that we removed, along with a setting validator that prevents them from being set on 8.x indices.

Good idea! I'll take that approach instead, it's similar to what we had done for camel case date field support.

@grcevski
Copy link
Contributor Author

@DaveCTurner, I thought more about this and I think we should be archiving these settings before validation. If we silently accept them as valid settings for 7.x indices, we then run into a problem where the usage will be confusing to our end users.

For example, the slow logs setting did something in 7.x, even though we warned them of deprecation, but now in 8.x we will allow it to exist and be changed as a setting, but it will do nothing. So it's sort of valid setting you can set, but it does nothing anymore. It still breaks BWC, I'd rather we told them somehow their setting no longer works.

I think a better solution would be to archive the legacy settings when we validate them. I can bring back the list of these legacy settings and only archive those, but we archive all unknown settings already on restart, I think we might as well archive all of them.

@DaveCTurner
Copy link
Contributor

I would very much prefer not to archive any index settings. We almost never do a full-cluster-restart upgrade any more, and during a rolling upgrade it is not at all obvious when to do the archiving, nor how we should behave in the mixed-version cluster before the archival happens.

It is unfortunate that in this case we removed the associated slowlog functionality prematurely, but ISTR we had good reasons for doing so. I think that won't cause too many problems however: the settings were properly deprecated in 7.x so the user should have already seen guidance about their use, and as long as the settings are still marked as deprecated in 8.x the user will continue to see warnings about not using them. We could even perhaps customise those warnings to indicate that they're already no-ops, although I wouldn't put much effort into that until we start to see evidence that it's needed.

Are there other settings to be reinstated or is it just about these slowlog ones? If there are others, we'll need to think about what to do with them on a case-by-case basis.

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some thoughts mostly on code-habitability. I like this approach much more tho.

/**
* Indicates that this index-level setting was deprecated and removed in the current major
*/
DeprecatedAndRemovedInCurrentMajor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also reject non-index settings that use this property - see checkPropertyRequiresIndexScope. Also I think we can make this property mutually exclusive with Deprecated and DeprecatedWarning.

Also (maybe in a followup) can we forbid Deprecated on IndexScope settings and require all index settings to use this framework instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. About removing all Deprecated, I guess we'll need one more property, deprecated and removed in Next major, if we have deprecated any in 8.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By my reckoning there's currently exactly one such index setting that's deprecated in v8 and to be removed in v9: index.merge.policy.max_merge_at_once_explicit.

I'll leave it up to you whether to give this setting the same treatment now or later.

Comment on lines 563 to 577
new Setting.Validator<>() {
@Override
public void validate(Integer value) {}

@Override
public void validate(Integer value, Map<Setting<?>, Object> settings) {
validateVersionDependentDeprecatedSetting(MAX_ADJACENCY_MATRIX_FILTERS_SETTING.getKey(), settings);
}

@Override
public Iterator<Setting<?>> settings() {
final List<Setting<?>> settings = List.of(IndexMetadata.SETTING_INDEX_VERSION_CREATED);
return settings.iterator();
}
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I think we should do this validation automatically within the settings framework if a setting is marked as Property.DeprecatedAndRemovedInCurrentMajor. If we require implementors to remember to include this validator too then someone will forget and that'd be a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, I can add the validation at lower level.

Copy link
Contributor

@pgomulka pgomulka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the approach and left minor questions.

import static org.elasticsearch.rest.action.search.RestSearchAction.TOTAL_HITS_AS_INT_PARAM;
import static org.hamcrest.Matchers.is;

public class UpgradeWithOldIndexSettingsIT extends AbstractRollingTestCase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity.
Any particular reason not to use yml test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just my comfort level with writing yml tests, but that definitely means I should add one :). I'll add a yml test too!

@grcevski
Copy link
Contributor Author

@elasticsearchmachine run elasticsearch-ci/docs

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me; I left one optional suggestion

Comment on lines 190 to 196
if (propertiesAsSet.contains(Property.Deprecated) && propertiesAsSet.contains(Property.DeprecatedWarning)) {
throw new IllegalArgumentException("setting [" + key + "] cannot be deprecated at both critical and warning levels");
}
if ((propertiesAsSet.contains(Property.Deprecated) || propertiesAsSet.contains(Property.DeprecatedWarning))
&& propertiesAsSet.contains(Property.IndexSettingDeprecatedInV7AndRemovedInV8)) {
throw new IllegalArgumentException("setting [" + key + "] cannot be just deprecated and deprecated and removed in V7");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm suggestion got lost it seems. Here it is again:

Suggested change
if (propertiesAsSet.contains(Property.Deprecated) && propertiesAsSet.contains(Property.DeprecatedWarning)) {
throw new IllegalArgumentException("setting [" + key + "] cannot be deprecated at both critical and warning levels");
}
if ((propertiesAsSet.contains(Property.Deprecated) || propertiesAsSet.contains(Property.DeprecatedWarning))
&& propertiesAsSet.contains(Property.IndexSettingDeprecatedInV7AndRemovedInV8)) {
throw new IllegalArgumentException("setting [" + key + "] cannot be just deprecated and deprecated and removed in V7");
}
if (propertiesAsSet.stream().filter(DEPRECATED_PROPERTIES::contains).count() > 1) {
throw new IllegalArgumentException("setting [" + key + "] must be at most one of [" + DEPRECATED_PROPERTIES + "]");
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a really nice code simplification. I'll add it in.

@grcevski grcevski merged commit 0652a59 into elastic:main Nov 2, 2022
@grcevski grcevski deleted the fix/legacy_index_settings branch November 2, 2022 17:58
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.5

grcevski added a commit to grcevski/elasticsearch that referenced this pull request Nov 2, 2022
Add code to ignore unknown index settings on
old indices, to allow rolling-upgrades to work.

Co-authored-by: David Turner <[email protected]>
elasticsearchmachine pushed a commit that referenced this pull request Nov 2, 2022
Add code to ignore unknown index settings on
old indices, to allow rolling-upgrades to work.

Co-authored-by: David Turner <[email protected]>

Co-authored-by: David Turner <[email protected]>
weizijun added a commit to weizijun/elasticsearch that referenced this pull request Nov 3, 2022
* main: (1300 commits)
  update c2id/c2id-server-demo docker image to support ARM (elastic#91144)
  Allow legacy index settings on legacy indices (elastic#90264)
  Skip prevoting if single-node discovery (elastic#91255)
  Chunked encoding for snapshot status API (elastic#90801)
  Allow different decay values depending on the score function (elastic#91195)
  Fix handling indexed envelopes crossing the dateline in mvt API (elastic#91105)
  Ensure cleanups succeed in JoinValidationService (elastic#90601)
  Add overflow behaviour test for RecyclerBytesStreamOutput (elastic#90638)
  More actionable error for ancient indices (elastic#91243)
  Fix APM configuration file delete (elastic#91058)
  Clean up handshake test class (elastic#90966)
  Improve H3#hexRing logic and add H3#areNeighborCells method (elastic#91140)
  Restrict direct use of `ApplicationPrivilege` constructor (elastic#91176)
  [ML] Allow NLP truncate option to be updated when span is set (elastic#91224)
  Support multi-intersection for FieldPermissions (elastic#91169)
  Support intersecting multi-sets of queries with DocumentPermissions (elastic#91151)
  Ensure TermsEnum action works correctly with API keys (elastic#91170)
  Fix NPE in auditing authenticationSuccess for non-existing run-as user (elastic#91171)
  Ensure PKI's delegated_by_realm metadata respect run-as (elastic#91173)
  [ML] Update API documentation for anomaly score explanation (elastic#91177)
  ...

# Conflicts:
#	x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java
#	x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/RollupShardIndexer.java
#	x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TransportRollupIndexerAction.java
#	x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/RollupActionSingleNodeTests.java
arteam added a commit to arteam/elasticsearch that referenced this pull request Mar 13, 2025
…cation to a warning

This setting is not getting removed in ES 9.0, so its usage should not generate a critical deprecation warning.
This is an index setting and should have been marked as `IndexSettingDeprecatedInV8AndRemovedInV9`, but we can't
change that in 8.x and will mark it as `IndexSettingDeprecatedInV9AndRemovedInV10` in 9.0

See elastic#90264
See ES-11224
arteam added a commit to arteam/elasticsearch that referenced this pull request Mar 13, 2025
…ion to a warning

This setting is not getting removed in ES 9.0, so its usage should not generate a critical deprecation warning.
This is an index setting and should have been marked as `IndexSettingDeprecatedInV8AndRemovedInV9`, but we can't
change that in 8.x and will mark it as `IndexSettingDeprecatedInV9AndRemovedInV10` in 9.0

See elastic#90264
See ES-11224
arteam added a commit to arteam/elasticsearch that referenced this pull request Mar 13, 2025
This setting is not getting removed in ES 9.0, so its usage should not generate a critical deprecation warning.
This is an index setting and should have been marked as `IndexSettingDeprecatedInV8AndRemovedInV9`, but we can't
change that in 8.x and will mark it as `IndexSettingDeprecatedInV9AndRemovedInV10` in 9.0

See elastic#90264
See ES-11224
arteam added a commit to arteam/elasticsearch that referenced this pull request Mar 13, 2025
…ed in v10

Introduce `Property.IndexSettingDeprecatedInV9AndRemovedInV10` property setting to mark
index settings that accepted on 9.x indices, but not on 10.0.

See elastic#80574, elastic#90264
See ES-11224
arteam added a commit that referenced this pull request Mar 14, 2025
…ion (#124792)

This setting is not getting removed in ES 9.0, so its usage should not generate a critical deprecation warning.
This is an index setting and should have been marked as `IndexSettingDeprecatedInV8AndRemovedInV9`, but we can't
change that in 8.x and will mark it as `IndexSettingDeprecatedInV9AndRemovedInV10` in 9.0

See #90264
See ES-11224
arteam added a commit that referenced this pull request Mar 14, 2025
…ed in v10 (#124807)

Introduce `Property.IndexSettingDeprecatedInV9AndRemovedInV10` property setting to mark
index settings that accepted on 9.x indices, but not on 10.0.

See #80574, #90264
See ES-11224
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >enhancement Team:Core/Infra Meta label for core/infra team v8.5.1 v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate severity of upgrading to 8.0.1 despite terminal deprecation of old features
4 participants