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

Update dynamic fields in mapping on master even if parsing fails for the rest of the doc #9874

Closed
wants to merge 1 commit into from

Conversation

brwe
Copy link
Contributor

@brwe brwe commented Feb 25, 2015

...ils for the rest of doc

The local DocumentMapper is updated while parsing and dynamic fields are added before
parsing has finished. If parsing fails after a dynamic field has been added already
then the field was not added to the cluster state but was present in the local mapper of this
node. New documents with the same field would not necessarily cause an update either and
after restarting the node the mapping for these fields were lost. Instead the new fields
should always be updated.

closes #9851

@brwe brwe added v2.0.0-beta1 review v1.5.0 v1.4.5 :Search/Mapping Index mappings, including merging and defining field types labels Feb 25, 2015
@@ -494,7 +494,7 @@ public ParsedDocument parse(SourceToParse source, @Nullable ParseListener listen
} catch (Throwable e) {
// if its already a mapper parsing exception, no need to wrap it...
if (e instanceof MapperParsingException) {
throw (MapperParsingException) e;
throw ((MapperParsingException) e).setMappingsModified(context.mappingsModified());
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we do it in such a way that we do not need to modify the incoming exception in-place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean. I added it now in the constructor of the MapperParsingException. Is this what you meant?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes! I like it much better!

@jpountz
Copy link
Contributor

jpountz commented Mar 5, 2015

LGTM

@jpountz
Copy link
Contributor

jpountz commented Mar 5, 2015

@brwe Since this change looks quite significant, I don't think it should be pushed to 1.4.5.

@brwe brwe closed this in d9a1540 Mar 6, 2015
brwe added a commit that referenced this pull request Mar 6, 2015
… fails for the rest of doc

The local DocumentMapper is updated while parsing and dynamic fields are added before
parsing has finished. If parsing fails after a dynamic field has been added already
then the field was not added to the cluster state but was present in the local mapper of this
node. New documents with the same field would not necessarily cause an update either and
after restarting the node the mapping for these fields were lost. Instead the new fields
should always be updated.

closes #9851
closes #9874
@brwe
Copy link
Contributor Author

brwe commented Mar 6, 2015

That was not a good idea - the change of MapperParsingException seemes to have screwed up bwc for Exception serialization, see for example http://build-us-00.elasticsearch.org/job/es_bwc_1x/8385/
I reverted the commit now.

@brwe brwe reopened this Mar 6, 2015
… fails for the rest of doc

The local DocumentMapper is updated while parsing and dynamic fields are added before
parsing has finished. If parsing fails after a dynamic field has been added already
then the field was not added to the cluster state but was present in the local mapper of this
node. New documents with the same field would not necessarily cause an update either and
after restarting the node the mapping for these fields were lost. Instead the new fields
should always be updated.

closes elastic#9851
closes elastic#9874
@brwe
Copy link
Contributor Author

brwe commented Mar 17, 2015

Ok, new plan. Instead of changing the mapper parsing exception we actually can just get the context from the document mapper and ask if the mapping was changed - much easier and I cannot see any downside to it. @jpountz would you mind taking another look?

@jpountz
Copy link
Contributor

jpountz commented Mar 24, 2015

I'm not too happy with getting back to the cache to check whether mappings have been modified, I liked the previous solution better. But on ther other hand, I don't have a better idea. Can we maybe just use this approach on 1.x and keep the previous approach on master?

@brwe
Copy link
Contributor Author

brwe commented Mar 26, 2015

Ok, I'll do that.

brwe added a commit that referenced this pull request Mar 26, 2015
… fails for the rest of doc

The local DocumentMapper is updated while parsing and dynamic fields are added before
parsing has finished. If parsing fails after a dynamic field has been added already
then the field was not added to the cluster state but was present in the local mapper of this
node. New documents with the same field would not necessarily cause an update either and
after restarting the node the mapping for these fields were lost. Instead the new fields
should always be updated.

closes #9851
closes #9874
@brwe brwe closed this in edb6319 Mar 26, 2015
@clintongormley clintongormley changed the title [mappings] update dynamic fields in mapping on master even if parsing fa... Update dynamic fields in mapping on master even if parsing fails for the rest of the doc May 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Mapping Index mappings, including merging and defining field types v1.6.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[mappings] partially parsed documents can cause mapping loss
4 participants