-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Pass IndexReshardingMetadata over the wire #124841
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
Changes from all commits
7de0a2b
10221d1
fa136c9
15caadb
322d919
3782209
420631a
3f19484
75bd87b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 124841 | ||
| summary: Pass `IndexReshardingMetadata` over the wire | ||
| area: Distributed | ||
| type: bug | ||
| issues: [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1424,6 +1424,11 @@ public IndexLongFieldRange getTimeSeriesTimestampRange(DateFieldMapper.DateField | |
| } | ||
| } | ||
|
|
||
| @Nullable | ||
| public IndexReshardingMetadata getReshardingMetadata() { | ||
| return reshardingMetadata; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should add a check for the IndexReshardingMetadata being equal here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, this is a good point. It did get me to look at which fields are included and there are some others that are serialized but not included in equality comparison (e.g.,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in fa136c9 |
||
| if (this == o) { | ||
|
|
@@ -1478,6 +1483,9 @@ public boolean equals(Object o) { | |
| if (isSystem != that.isSystem) { | ||
| return false; | ||
| } | ||
| if (Objects.equals(reshardingMetadata, that.reshardingMetadata) == false) { | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
|
|
@@ -1497,6 +1505,7 @@ public int hashCode() { | |
| result = 31 * result + rolloverInfos.hashCode(); | ||
| result = 31 * result + inferenceFields.hashCode(); | ||
| result = 31 * result + Boolean.hashCode(isSystem); | ||
| result = 31 * result + Objects.hashCode(reshardingMetadata); | ||
| return result; | ||
| } | ||
|
|
||
|
|
@@ -1558,6 +1567,7 @@ private static class IndexMetadataDiff implements Diff<IndexMetadata> { | |
| private final IndexMetadataStats stats; | ||
| private final Double indexWriteLoadForecast; | ||
| private final Long shardSizeInBytesForecast; | ||
| private final IndexReshardingMetadata reshardingMetadata; | ||
|
|
||
| IndexMetadataDiff(IndexMetadata before, IndexMetadata after) { | ||
| index = after.index.getName(); | ||
|
|
@@ -1597,6 +1607,7 @@ private static class IndexMetadataDiff implements Diff<IndexMetadata> { | |
| stats = after.stats; | ||
| indexWriteLoadForecast = after.writeLoadForecast; | ||
| shardSizeInBytesForecast = after.shardSizeInBytesForecast; | ||
| reshardingMetadata = after.reshardingMetadata; | ||
| } | ||
|
|
||
| private static final DiffableUtils.DiffableValueReader<String, AliasMetadata> ALIAS_METADATA_DIFF_VALUE_READER = | ||
|
|
@@ -1669,6 +1680,11 @@ private static class IndexMetadataDiff implements Diff<IndexMetadata> { | |
| } else { | ||
| eventIngestedRange = IndexLongFieldRange.UNKNOWN; | ||
| } | ||
| if (in.getTransportVersion().onOrAfter(TransportVersions.INDEX_RESHARDING_METADATA)) { | ||
| reshardingMetadata = in.readOptionalWriteable(IndexReshardingMetadata::new); | ||
| } else { | ||
| reshardingMetadata = null; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -1707,6 +1723,9 @@ public void writeTo(StreamOutput out) throws IOException { | |
| out.writeOptionalLong(shardSizeInBytesForecast); | ||
| } | ||
| eventIngestedRange.writeTo(out); | ||
| if (out.getTransportVersion().onOrAfter(TransportVersions.INDEX_RESHARDING_METADATA)) { | ||
| out.writeOptionalWriteable(reshardingMetadata); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -1739,6 +1758,7 @@ public IndexMetadata apply(IndexMetadata part) { | |
| builder.stats(stats); | ||
| builder.indexWriteLoadForecast(indexWriteLoadForecast); | ||
| builder.shardSizeInBytesForecast(shardSizeInBytesForecast); | ||
| builder.reshardingMetadata(reshardingMetadata); | ||
| return builder.build(true); | ||
| } | ||
| } | ||
|
|
@@ -1810,6 +1830,9 @@ public static IndexMetadata readFrom(StreamInput in, @Nullable Function<String, | |
| builder.shardSizeInBytesForecast(in.readOptionalLong()); | ||
| } | ||
| builder.eventIngestedRange(IndexLongFieldRange.readFrom(in)); | ||
| if (in.getTransportVersion().onOrAfter(TransportVersions.INDEX_RESHARDING_METADATA)) { | ||
| builder.reshardingMetadata(in.readOptionalWriteable(IndexReshardingMetadata::new)); | ||
| } | ||
| return builder.build(true); | ||
| } | ||
|
|
||
|
|
@@ -1859,6 +1882,9 @@ public void writeTo(StreamOutput out, boolean mappingsAsHash) throws IOException | |
| out.writeOptionalLong(shardSizeInBytesForecast); | ||
| } | ||
| eventIngestedRange.writeTo(out); | ||
| if (out.getTransportVersion().onOrAfter(TransportVersions.INDEX_RESHARDING_METADATA)) { | ||
| out.writeOptionalWriteable(reshardingMetadata); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
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.
Do we not need any compatibility checks in this test ?
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 was also wondering if we have a cluster where the master node is on a different (older) version and the data node that initiates the reshard is on a newer version, how do we handle that ?
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 think we should check at the top of an autoshard action if the cluster-wide minimum version is too low to parse resharding metadata, and fail immediately if so. I don't think it goes in this change though.
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 haven't found BWC tests for the other fields that are conditionally serialized, but it does seem like a good idea. I'll add something.
Uh oh!
There was an error while loading. Please reload this page.
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.
Done in fa136c9