Skip to content

Commit 3e6025b

Browse files
committed
Changes
1 parent 1504271 commit 3e6025b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1972,9 +1972,10 @@ public Builder reshardAddShards(int shardCount) {
19721972
}
19731973
settings = Settings.builder().put(settings).put(SETTING_NUMBER_OF_SHARDS, shardCount).build();
19741974
var newPrimaryTerms = new long[shardCount];
1975+
Arrays.fill(newPrimaryTerms, this.primaryTerms.length, newPrimaryTerms.length, SequenceNumbers.UNASSIGNED_PRIMARY_TERM);
19751976
System.arraycopy(primaryTerms, 0, newPrimaryTerms, 0, this.primaryTerms.length);
19761977
primaryTerms = newPrimaryTerms;
1977-
routingNumShards = shardCount;
1978+
routingNumShards = MetadataCreateIndexService.calculateNumRoutingShards(shardCount, indexCreatedVersion(settings));
19781979
return this;
19791980
}
19801981

server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ public void writeTo(StreamOutput out) throws IOException {
341341
out.writeByte((byte) Reason.PRIMARY_FAILED.ordinal());
342342
} else if (reason.equals(Reason.RESHARD_ADDED)
343343
&& out.getTransportVersion().before(TransportVersions.UNASSIGENEDINFO_RESHARD_ADDED)) {
344+
// We should have protection to ensure we do not reshard in mixed clusters
345+
assert false;
344346
out.writeByte((byte) Reason.FORCED_EMPTY_PRIMARY.ordinal());
345347
} else {
346348
out.writeByte((byte) reason.ordinal());

0 commit comments

Comments
 (0)