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

Rewrite SourceToParse with resolved docType #36921

Merged
merged 10 commits into from
Dec 23, 2018
Merged

Conversation

dnhatn
Copy link
Member

@dnhatn dnhatn commented Dec 21, 2018

We introduce a typeless API in #35790 where we translate the default docType "_doc" to the user-defined docType. However, we do not rewrite the SourceToParse with the resolved docType. This leads to a situation where we have two translog operations for the same document with different types:

  • prvOp [Index{id='9LCpwGcBkJN7eZxaB54L', type='_doc', seqNo=1, primaryTerm=1, version=1, autoGeneratedIdTimestamp=1545125562123}]

  • newOp [Index{id='9LCpwGcBkJN7eZxaB54L', type='not_doc', seqNo=1, primaryTerm=1, version=1, autoGeneratedIdTimestamp=-1}]

Closes #36769

We introduce a typeless API in elastic#35790 where we translate the default
docType "_doc" to the user-defined docType. However, we still use
docType from the source rather the translated type (i.e, type of the
Mapper) when parsing a document. This leads to a situation where we have
two translog operations for the same document with different types:

- prvOp [Index{id='9LCpwGcBkJN7eZxaB54L', type='_doc', seqNo=1, primaryTerm=1, version=1, autoGeneratedIdTimestamp=1545125562123}]
- newOp [Index{id='9LCpwGcBkJN7eZxaB54L', type='not_doc', seqNo=1, primaryTerm=1, version=1, autoGeneratedIdTimestamp=-1}]

Closes elastic#36769
@dnhatn dnhatn added >bug :Search Foundations/Mapping Index mappings, including merging and defining field types v7.0.0 labels Dec 21, 2018
@dnhatn dnhatn requested review from jpountz and ywelsch December 21, 2018 00:30
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@dnhatn dnhatn changed the title Use type of mapper instead of source when parse doc Rewrite SourceToParse with resolved docType Dec 21, 2018
@dnhatn
Copy link
Member Author

dnhatn commented Dec 21, 2018

We may have a BWC issue with the Typeless API if the primary is on 7.0 while replicas on 6.x. I'll test that scenario and post the result.

@markharwood
Copy link
Contributor

markharwood commented Dec 21, 2018

We may have a BWC issue with the Typeless API if the primary is on 7.0 while replicas on 6.x. I'll test that scenario and post the result.

I'm working on a PR for the bulk API which just hit this. @mayya-sharipova recently changed IndexRequest to default type to _doc but in my PR I need to default it to null so that I know a choice hasn't been made by the user and can inherit any default "global" type given to the containing BulkRequest. I found serializing a null type from 7.x to 6.x nodes was causing a null pointer so I had to make sure that the serialized type was defaulted to "_doc" if null.

The above detail may not change the status quo on the receiving 6.x end which you're tackling here (provided IndexRequest = _doc but mapping = custom type) but it may be useful to know the related work going on and the CI reproduce line that uncovered my issue: 2db6753

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

The change looks good to me.

Yannick talked to me about this issue earlier today and I do agree that we need to find a more robust way to make typeless APIs work on indices that still have a type whose name is different from _doc.

@dnhatn
Copy link
Member Author

dnhatn commented Dec 23, 2018

run Gradle build tests 1

@dnhatn
Copy link
Member Author

dnhatn commented Dec 23, 2018

Thanks @jpountz for reviewing and @markharwood for the heads-up.

@dnhatn dnhatn merged commit 40c7ae6 into elastic:master Dec 23, 2018
@dnhatn dnhatn deleted the doc-type branch December 23, 2018 20:14
dnhatn added a commit that referenced this pull request Dec 24, 2018
Today the routing of a SourceToParse is assigned in a separate step
after the object is created. We can easily forget to set the routing.
With this commit, the routing must be provided in the constructor of
SourceToParse.

Relates #36921
@jimczi jimczi added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search Foundations/Mapping Index mappings, including merging and defining field types v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CI] TranslogWriter assertion failed: seqNo was processed twice
5 participants