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

Conversation

Projects
None yet
5 participants
@dnhatn
Copy link
Contributor

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

Use type of mapper instead of source when parse doc
We introduce a typeless API in #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 #36769
@elasticmachine

This comment has been minimized.

Copy link

commented Dec 21, 2018

dnhatn added some commits Dec 21, 2018

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

dnhatn added some commits Dec 21, 2018

@dnhatn

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Contributor

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

@jpountz
Copy link
Contributor

left a comment

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 added some commits Dec 21, 2018

@dnhatn

This comment has been minimized.

Copy link
Contributor Author

commented Dec 23, 2018

run Gradle build tests 1

@dnhatn

This comment has been minimized.

Copy link
Contributor Author

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

7 checks passed

CLA Commit author is a member of Elasticsearch
Details
elasticsearch-ci-1 Build finished.
Details
elasticsearch-ci-2 Build finished.
Details
elasticsearch-ci/default-distro Build finished.
Details
elasticsearch-ci/docbldesx Build finished.
Details
elasticsearch-ci/oss-distro-docs Build finished.
Details
elasticsearch-ci/packaging-sample Build finished.
Details

@dnhatn dnhatn deleted the dnhatn:doc-type branch Dec 23, 2018

dnhatn added a commit that referenced this pull request Dec 24, 2018

Make SourceToParse immutable (#36971)
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
You can’t perform that action at this time.