Skip to content
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

Disallow changing 'enabled' on the root mapper. #54463

Merged
merged 2 commits into from
Apr 2, 2020

Conversation

jtibshirani
Copy link
Contributor

In #33933 we disallowed changing the enabled parameter in object mappings.
However, the fix didn't cover the root object mapper. This PR adjusts the change
to also include the root mapper and clarifies the error message.

@jtibshirani jtibshirani added >bug :Search Foundations/Mapping Index mappings, including merging and defining field types v8.0.0 v7.8.0 labels Mar 30, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Mapping)

@jtibshirani jtibshirani force-pushed the root-mapper-enabled branch from 4982bd6 to ea9433a Compare March 30, 2020 19:56
ObjectMapper secondMapper = createRootObjectMapper(type, false, Collections.emptyMap());

MapperException e = expectThrows(MapperException.class, () -> firstMapper.merge(secondMapper));
assertEquals("The [enabled] parameter can't be updated for the object mapping [" + type + "].", e.getMessage());
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 pretty confusing that this error message will contain the singleton type name: "The [enabled] parameter can't be updated for the object mapping [_doc]." I think we should address this in a separate, more general change to not pass in the type as the root object mapper's name.

@jtibshirani jtibshirani force-pushed the root-mapper-enabled branch from 625a312 to 16ddeb9 Compare April 1, 2020 21:24
@jtibshirani jtibshirani force-pushed the root-mapper-enabled branch from 16ddeb9 to df69ea7 Compare April 1, 2020 21:38
@@ -236,7 +235,6 @@ public void testRestoreMinmal() throws IOException {
IndexMetadata metadata = runAsSnapshot(threadPool, () -> repository.getSnapshotIndexMetadata(snapshotId, indexId));
IndexShard restoredShard = newShard(
shardRouting, metadata, null, SourceOnlySnapshotRepository.getEngineFactory(), () -> {}, RetentionLeaseSyncer.EMPTY);
restoredShard.mapperService().merge(shard.indexSettings().getIndexMetadata(), MapperService.MergeReason.MAPPING_RECOVERY);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll double check with someone from the distributed team that this change is okay.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@original-brownbear would you be up for taking a look? I saw that you made several changes in this area recently.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is fine. This line seems unnecessary and makes the test behave less like a real restore as far as I can see anyway (just restoring the meta from the repo in a real restore).
=> LGTM :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @original-brownbear ! It also seemed strange to me, that we would add the original mappings as part of restoring a source-only snapshot.

Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@jtibshirani jtibshirani merged commit 1500651 into elastic:master Apr 2, 2020
@jtibshirani jtibshirani deleted the root-mapper-enabled branch April 2, 2020 19:49
@jtibshirani
Copy link
Contributor Author

Although it could be considered breaking, I plan to backport this to 7.8. This matches how we handled #33933, which prevented changing enabled on other object fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>breaking >bug :Search Foundations/Mapping Index mappings, including merging and defining field types v7.8.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants