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

fix index refresh in test within 20_mix_typeless_typeful #39198

Merged
merged 11 commits into from
Mar 7, 2019

Conversation

talevy
Copy link
Contributor

@talevy talevy commented Feb 20, 2019

the test "Implicitly create a typeless ... typed template"
fails occasionally because the index operation hasn't
propogated to update the index mapping in time for the
following assertion about a dynamically mapped field "bar".

error failed with:

field [test-1.mappings.my_type.properties.bar] doesn't have a true value
Expected: not null
     but: was null

refreshing the index should resolve this timing issue.

the test "Implicitly create a typeless ... typed template"
fails occasionally because the index operation hasn't
propogated to update the index mapping in time for the
following assertion about a dynamically mapped field "bar".

error failed with:

```
field [test-1.mappings.my_type.properties.bar] doesn't have a true value
Expected: not null
     but: was null
```

refreshing the index should resolve this timing issue.
@talevy talevy added >test Issues or PRs that are addressing/adding tests :Search Foundations/Mapping Index mappings, including merging and defining field types v7.0.0 v6.7.0 v8.0.0 v7.2.0 labels Feb 20, 2019
@talevy talevy requested a review from jpountz February 20, 2019 19:03
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

jaymode
jaymode previously approved these changes Feb 20, 2019
Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@jtibshirani jtibshirani left a comment

Choose a reason for hiding this comment

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

Thanks @talevy for debugging this! To check I understand, it looks like the dynamic mapping update triggered by the index request isn't visible to the get_mapping call. Does an index refresh also ensure that mapping updates are available? As a side note, I came across this other test PR which ran into a similar issue: #38045

@talevy
Copy link
Contributor Author

talevy commented Feb 20, 2019

thanks for bringing that up Julie. In fact, I see no reason refresh should fix this problem, and I also don't see adding bar to the mapping as changing the nature of the test.

updated to add bar into the mapping

@dakrone
Copy link
Member

dakrone commented Feb 20, 2019

To check I understand, it looks like the dynamic mapping update triggered by the index request isn't visible to the get_mapping call.

Yep, that is the cause.

Does an index refresh also ensure that mapping updates are available?

It helps, but doesn't enforce it. Rather this is a timing issue with indexing and mapping updates. Mapping update visibility is asynchronous from the client's perspective (see #38873) so this hopefully will help.

@talevy
Copy link
Contributor Author

talevy commented Feb 20, 2019

@jaymode I updated the code. mind re-reviewing?

@jpountz
Copy link
Contributor

jpountz commented Feb 20, 2019

Thanks all for looking into this, I had missed that dynamic mapping updates were no longer acked!

Since we are now adding the field to the mappings in the template, the refresh is irrelevant I think?

Not including the mapping definition in the template was intentional, I wanted to test how Elasticsearch behaves when there is a typed template while an index and mappings are implicitly created via a typeless index call. I'm wondering whether there is something that we can do to force the mapping update to be visible to the client, eg. would running another put-mapping request give this guarantee?

@talevy
Copy link
Contributor Author

talevy commented Feb 20, 2019

Since we are now adding the field to the mappings in the template, the refresh is irrelevant I think?

it does seem to be irrelevant

Not including the mapping definition in the template was intentional, I wanted to test how Elasticsearch behaves when there is a typed template while an index and mappings are implicitly created via a typeless index call.

ah! I should have stuck with my gut. thanks.

I'm wondering whether there is something that we can do to force the mapping update to be visible to the client, eg. would running another put-mapping request give this guarantee?

I'll take a look at the code. that would obviously give a timing buffer, but I'm not sure whether the
update prioritization will always work in our favor.

@talevy
Copy link
Contributor Author

talevy commented Feb 20, 2019

@jpountz
now that I am looking at it again, I think I misunderstood the bit about PutMapping.

The test is interested in how the direct index-mapping and the index-template-mapping
interact. Doing an explicit create-index-request with the mapping for bar would be ok?

or is it specifically interested in dynamic-mapping behavior

@talevy
Copy link
Contributor Author

talevy commented Feb 20, 2019

ah nevermind. that is exactly what

"Create a typed index while there is a typeless template" is testing

@talevy
Copy link
Contributor Author

talevy commented Feb 20, 2019

I will update to put the same mapping as is done dynamically before getting the mapping. I think that is reasonable since the dynamic-mapping update just issues a regular put-mapping-request itself

talevy added a commit that referenced this pull request Feb 21, 2019
talevy added a commit that referenced this pull request Feb 21, 2019
talevy added a commit that referenced this pull request Feb 21, 2019
@talevy talevy removed the v6.7.0 label Feb 21, 2019
@talevy
Copy link
Contributor Author

talevy commented Feb 21, 2019

I muted the tests until we figure this out

@talevy
Copy link
Contributor Author

talevy commented Feb 21, 2019

build failed due to: #29880

run elasticsearch-ci/2

@talevy
Copy link
Contributor Author

talevy commented Feb 22, 2019

@jpountz do you have any further thoughts? My change is competing with reality, and probably even an empty put-mapping-request would due the trick due to timing, but 🤷‍♂️

I checked the internal update-mapping-request and it looked like it passed in a type, so that is why the request here uses types

weizijun pushed a commit to weizijun/elasticsearch that referenced this pull request Feb 22, 2019
weizijun pushed a commit to weizijun/elasticsearch that referenced this pull request Feb 22, 2019
@jaymode jaymode dismissed their stale review February 26, 2019 16:55

Fix has changed

@jaymode
Copy link
Member

jaymode commented Feb 26, 2019

I wonder if this should be moved from a rest yml test to an IT? This way we can add an awaitsBusy for the mapping update and not need the hacks of an empty put mapping or anything else.

@talevy
Copy link
Contributor Author

talevy commented Feb 26, 2019

@jaymode yes. yes it should since there does not seem to be another way of correctly fixing this. I'll update shortly. thanks!

@jpountz
Copy link
Contributor

jpountz commented Feb 27, 2019

If there is a simple way that we could wait for the mapping update to become visible, this would be my preference. In general I prefer REST tests over IT as I find them more realistic.

@jaymode
Copy link
Member

jaymode commented Feb 27, 2019

In general I prefer REST tests over IT as I find them more realistic.

@jpountz can you expand on this? If the IT runs against an external cluster and makes calls using an HTTP client, is it really less realistic?

@jpountz
Copy link
Contributor

jpountz commented Feb 27, 2019

Apologies, I had assumed you meant a test with an internal cluster.

@jpountz
Copy link
Contributor

jpountz commented Feb 28, 2019

I just had a quick discussion with @ywelsch and @DaveCTurner who told me that calling the cluster health API with waitForEvents = NORMAL would ensure that the mapping update is visible to get-mappings.

@talevy
Copy link
Contributor Author

talevy commented Mar 7, 2019

Just got back to this. thanks for the update Adrien. I missed the notification...

updated to use the cluster.health call to block. Much nicer than having to create new rest tests.

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.

Thanks Tal!

@talevy talevy merged commit 78c27b3 into elastic:master Mar 7, 2019
@talevy talevy deleted the fix-typeful branch March 7, 2019 18:06
talevy added a commit to talevy/elasticsearch that referenced this pull request Mar 7, 2019
the test "Implicitly create a typeless ... typed template"
fails occasionally because the index operation hasn't
propogated to update the index mapping in time for the
following assertion about a dynamically mapped field "bar".

error failed with:

```
field [test-1.mappings.my_type.properties.bar] doesn't have a true value
Expected: not null
     but: was null
```

refreshing the index should resolve this timing issue.
talevy added a commit to talevy/elasticsearch that referenced this pull request Mar 7, 2019
the test "Implicitly create a typeless ... typed template"
fails occasionally because the index operation hasn't
propogated to update the index mapping in time for the
following assertion about a dynamically mapped field "bar".

error failed with:

```
field [test-1.mappings.my_type.properties.bar] doesn't have a true value
Expected: not null
     but: was null
```

refreshing the index should resolve this timing issue.
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Mar 8, 2019
* elastic/master:
  Add pre-upgrade check to test cluster routing allocation is enabled (elastic#39340)
  Update logstash-management.json to use typeless template (elastic#38653)
  Small simplifications to mapping validation. (elastic#39777)
  Update distribution build instructions to reflect file names with OS/architecture classifiers. (elastic#39762)
  Give jspawnhelper execute permissions in bundled JDK (elastic#39787)
  Maintain step order for ILM trace logging (elastic#39522)
  [ML-DataFrame] fix wire serialization issues in data frame response objects (elastic#39790)
  fix index refresh in test within 20_mix_typeless_typeful (elastic#39198)
  Combine overriddenOps and skippedOps in translog (elastic#39771)
talevy added a commit that referenced this pull request Mar 8, 2019
…9804)

the test "Implicitly create a typeless ... typed template"
fails occasionally because the index operation hasn't
propogated to update the index mapping in time for the
following assertion about a dynamically mapped field "bar".

error failed with:

```
field [test-1.mappings.my_type.properties.bar] doesn't have a true value
Expected: not null
     but: was null
```

refreshing the index should resolve this timing issue.
talevy added a commit that referenced this pull request Mar 8, 2019
…9803)

the test "Implicitly create a typeless ... typed template"
fails occasionally because the index operation hasn't
propogated to update the index mapping in time for the
following assertion about a dynamically mapped field "bar".

error failed with:

```
field [test-1.mappings.my_type.properties.bar] doesn't have a true value
Expected: not null
     but: was null
```

refreshing the index should resolve this timing issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Search Foundations/Mapping Index mappings, including merging and defining field types >test Issues or PRs that are addressing/adding tests v7.0.0-rc1 v7.2.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants