Introduce mapping version to index metadata#33147
Introduce mapping version to index metadata#33147jasontedor merged 13 commits intoelastic:masterfrom
Conversation
This commit introduces mapping version to index metadata. This value is monotonically increasing and is updated on mapping updates. This will be useful in cross-cluster replication so that we can request mapping updates from the leader only when there is a mapping update as opposed to the strategy we employ today which is to request a mapping update any time there is an index metadata update. As index metadata updates can occur for many reasons other than mapping updates, this leads to some unnecessary requests and work in cross-cluster replication.
|
Pinging @elastic/es-core-infra |
s1monw
left a comment
There was a problem hiding this comment.
I left 2 comments and LGTM. I do wonder if we can add an assertion somewhere in our code that ensures that when we update a mapping and the version is different it's source is different too? Same goes for if the version doesn't change ie in MapperService#updateMapping()` ?
|
|
||
| this.index = index; | ||
| this.version = version; | ||
| this.mappingVersion = mappingVersion; |
There was a problem hiding this comment.
can we assert that mappingVersion is positive here?
| } else if (KEY_VERSION.equals(currentFieldName)) { | ||
| builder.version(parser.longValue()); | ||
| } else if (KEY_MAPPING_VERSION.equals(currentFieldName)) { | ||
| builder.mappingVersion(parser.longValue()); |
There was a problem hiding this comment.
can we somehow make sure that if the index is 7.0 that the version is present? I really want to make sure we are not missing it.
There was a problem hiding this comment.
Let me know what you think of that one @s1monw.
martijnvg
left a comment
There was a problem hiding this comment.
This looks good. I left one question about where to maintain the mapping version.
| index = in.readString(); | ||
| routingNumShards = in.readInt(); | ||
| version = in.readLong(); | ||
| if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { |
There was a problem hiding this comment.
I assume when this is backported the version will be changed to 6.5.0?
There was a problem hiding this comment.
If we set the version to 6.5.0 now then the BWC tests will fail.
| private final Index index; | ||
| private final long version; | ||
|
|
||
| private final long mappingVersion; |
There was a problem hiding this comment.
I wonder whether MappingMetaData would be a better place to maintain the mapping version. The reason it feels like a better place to me is that this version is about an instance of MappingMetaData.
There was a problem hiding this comment.
I considered this but it ends up that we construct mapping metadata in quite a few places where having the mapping version is not natural. We do not hold on to the mapping metadata in the mapping service, so in some of these places it means we would have to hold on to the mapping version in the mapper service. But then we would have multiple places in the system carrying the mapping version. Because of this I considered the index metadata to be better. Additionally, like that we have the builder for the index metadata. Let me know if you feel strongly about this, or see a good way to have it on the mapping metadata.
There was a problem hiding this comment.
I don't feel strongly about this. I was just wondering about this. Your explanation is a good reason why to add the version to IndexMetadata instead of MappingMetaData.
* master: Fix a mappings update test (elastic#33146) Reload Secure Settings REST specs & docs (elastic#32990) Refactor CachingUsernamePassword realm (elastic#32646) Add proxy support to RemoteClusterConnection (elastic#33062)
@s1monw I pushed 0a6f7c9 for this. Let me know what you think. Note that this assertion will fail without #33153, the act of adding the assertion uncovered that bug so I will need that PR integrated and merged into this branch before I can get a green build here. |
* master: Do not lose default mapper on metadata updates (elastic#33153)
s1monw
left a comment
There was a problem hiding this comment.
LGTM thanks for the extra iterations.
This commit introduces mapping version to index metadata. This value is monotonically increasing and is updated on mapping updates. This will be useful in cross-cluster replication so that we can request mapping updates from the leader only when there is a mapping update as opposed to the strategy we employ today which is to request a mapping update any time there is an index metadata update. As index metadata updates can occur for many reasons other than mapping updates, this leads to some unnecessary requests and work in cross-cluster replication.
* master: Adjust BWC version on mapping version Token API supports the client_credentials grant (#33106) Build: forked compiler max memory matches jvmArgs (#33138) Introduce mapping version to index metadata (#33147) SQL: Enable aggregations to create a separate bucket for missing values (#32832) Fix grammar in contributing docs SECURITY: Fix Compile Error in ReservedRealmTests (#33166) APM server monitoring (#32515) Support only string `format` in date, root object & date range (#28117) [Rollup] Move toBuilders() methods out of rollup config objects (#32585) Fix forbiddenapis on java 11 (#33116) Apply publishing to genreate pom (#33094) Have circuit breaker succeed on unknown mem usage Do not lose default mapper on metadata updates (#33153) Fix a mappings update test (#33146) Reload Secure Settings REST specs & docs (#32990) Refactor CachingUsernamePassword realm (#32646)
* 6.x: Introduce mapping version to index metadata (#33147) Move non duplicated actions back into xpack core (#32952) HLRC: Create server agnostic request and response (#32912) Build: forked compiler max memory matches jvmArgs (#33138) * Added breaking change section for GROUP BY behavior: now it considers null or empty values as a separate group/bucket. Previously, they were ignored. * This is part of backporting of #32832 SQL: Enable aggregations to create a separate bucket for missing values (#32832) [TEST] version guard for reload rest-api-spec Fix grammar in contributing docs APM server monitoring (#32515) Support only string `format` in date, root object & date range (#28117) [Rollup] Move toBuilders() methods out of rollup config objects (#32585) Accept Gradle build scan agreement (#30645) Fix forbiddenapis on java 11 (#33116) Run forbidden api checks with runtimeJavaVersion (#32947) Apply publishing to genreate pom (#33094) Fix a mappings update test (#33146) Reload Secure Settings REST specs & docs (#32990) Refactor CachingUsernamePassword realm (#32646)
This commit introduces mapping version to index metadata. This value is monotonically increasing and is updated on mapping updates. This will be useful in cross-cluster replication so that we can request mapping updates from the leader only when there is a mapping update as opposed to the strategy we employ today which is to request a mapping update any time there is an index metadata update. As index metadata updates can occur for many reasons other than mapping updates, this leads to some unnecessary requests and work in cross-cluster replication.