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
Keep parameters in mapping for _timestamp
and _size
even if disabled
#7475
Conversation
@@ -488,6 +492,7 @@ public ClusterState execute(final ClusterState currentState) throws Exception { | |||
// only add the current relevant mapping (if exists) | |||
if (indexMetaData.mappings().containsKey(request.type())) { | |||
indexService.mapperService().merge(request.type(), indexMetaData.mappings().get(request.type()).source(), false); | |||
typeIsNew = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this line of code, are the lines above that also set typeIsNew to false still useful? Or could they be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought because of the continue after typeIsNew = false;
above the line 495 will never be reached.
@brwe Just left minor comments, but the change looks great in general. |
private void assertSizeMappingEnabled(String index, String type) throws IOException { | ||
String errMsg = String.format(Locale.ROOT, "Expected size field mapping to be enabled for %s/%s", index, type); | ||
@Test | ||
public void testThatTimestampCanBeSwitchedOnAndOff() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix naming here
could the some minor things, but looks close |
… disabled Settings that are not default for _size and _timestamp were only build in toXContent if these fields were actually enabled. _timestamp and _size can be dynamically enabled or disabled. Therfore the settings must be kept, even if the field is disabled. (Dynamic enabling/disabling was intended, see TimestampFieldMapper.merge(..) and SizeMappingTests#testThatDisablingWorksWhenMerging but actually never worked, see below). To avoid that _timestamp is overwritten by a default mapping this commit also adds a check to mapping merging if the type is already in the mapping. In this case the default is not applied anymore. (see SimpleTimestampTests#testThatUpdatingMappingShouldNotRemoveTimestampConfiguration) As a side effect, this fixes - overwriting of paramters from the _source field by default mappings (see DefaultSourceMappingTests). - dynamic enabling and disabling of _timestamp and _size () (see SimpleTimestampTests#testThatTimestampCanBeSwitchedOnAndOff and SizeMappingIntegrationTests#testThatTimestampCanBeSwitchedOnAndOff ) Tests: Enable UpdateMappingOnClusterTests#test_doc_valuesInvalidMappingOnUpdate again The missing settings in the mapping for _timestamp and _size caused a the failure: When creating a mapping which has settings other than default and the field disabled, still empty field mappings were built from the type mappers. When creating such a mapping, the mapping source on master and the rest of the cluster can be out of sync for some time: 1. Master creates the index with source _timestamp:{_store:true} mapper classes are in a correct state but source is _timestamp:{} 2. Nodes update mapping and refresh source which then completely misses _timestamp 3. After a while source is refreshed again also on master and the _timestamp:{} vanishes there also. The test UpdateMappingOnCusterTests#test_doc_valuesInvalidMappingOnUpdate failed because the cluster state was sampled from master between 1. and 3. because the randomized testing injected a default mapping with disabled _size and _timestamp fields that have settings which are not default. The test TimestampMappingTests#testThatDisablingFieldMapperDoesNotReturnAnyUselessInfo must be removed because it actualy expected the timestamp to remove parameters when it was disabled.
26215d1
to
bfd4f47
Compare
@spinscale I think IndexFieldMapper has the same problem. Will fix that also. |
_index had the same problems as the _timestamp and _size field. In addition, it always appeared to have no doc_values although you can set them.
ok, fixed IndexFieldMapper. Also fixed the default template applying. Thanks for spotting it! |
LGTM |
pushing to 1.3 is hard - I get many merge conflicts and am unsure about possible side effects of missing commits (current status here brwe@35819ac). |
Managed to pick in 1.2 also and think now that changes are isolated enough. Will push to master, 1.x, 1.3 and 1.2 |
_timestamp
and _size
even if disabled
_timestamp
and _size
even if disabled_timestamp
and _size
even if disabled
Settings that are not default for _size and _timestamp were only build in
toXContent if these fields were actually enabled.
_timestamp and _size can be dynamically enabled or disabled.
Therfore the settings must be kept, even if the field is disabled.
(Dynamic enabling/disabling was intended, see TimestampFieldMapper.merge(..)
and SizeMappingTests#testThatDisablingWorksWhenMerging
but actually never worked, see below).
To avoid that _timestamp is overwritten by a default mapping
this commit also adds a check to mapping merging if the type is already
in the mapping. In this case the default is not applied anymore.
(see
SimpleTimestampTests#testThatUpdatingMappingShouldNotRemoveTimestampConfiguration)
As a side effect, this fixes
(see DefaultSourceMappingTests).
(see SimpleTimestampTests#testThatTimestampCanBeSwitchedOnAndOff and
SizeMappingIntegrationTests#testThatTimestampCanBeSwitchedOnAndOff )
Tests:
Enable UpdateMappingOnClusterTests#test_doc_valuesInvalidMappingOnUpdate again
The missing settings in the mapping for _timestamp and _size caused a the
failure: When creating a mapping which has settings other than default and the
field disabled, still empty field mappings were built from the type mappers.
When creating such a mapping, the mapping source on master and the rest of the cluster
can be out of sync for some time:
mapper classes are in a correct state but source is _timestamp:{}
vanishes there also.
The test UpdateMappingOnCusterTests#test_doc_valuesInvalidMappingOnUpdate failed
because the cluster state was sampled from master between 1. and 3. because the
randomized testing injected a default mapping with disabled _size and _timestamp
fields that have settings which are not default.
The test
TimestampMappingTests#testThatDisablingFieldMapperDoesNotReturnAnyUselessInfo
must be removed because it actualy expected the timestamp to remove
parameters when it was disabled.