We are using `FORCE_STALE_PRIMARY_INSTANCE` in instance equality checks `==` but were creating new instances of `ExistingStoreRecoverySource` when reading from the wire. This could break these checks in corner cases, causing `org.elasticsearch.cluster.routing.allocation.IndexMetadataUpdater#shardStarted` to not remove the force allocation fake id when starting a shard. Closes #55513
This commit is contained in:
parent
4b11adf074
commit
dc899781f2
|
@ -64,7 +64,7 @@ public abstract class RecoverySource implements Writeable, ToXContentObject {
|
||||||
Type type = Type.values()[in.readByte()];
|
Type type = Type.values()[in.readByte()];
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EMPTY_STORE: return EmptyStoreRecoverySource.INSTANCE;
|
case EMPTY_STORE: return EmptyStoreRecoverySource.INSTANCE;
|
||||||
case EXISTING_STORE: return new ExistingStoreRecoverySource(in);
|
case EXISTING_STORE: return ExistingStoreRecoverySource.read(in);
|
||||||
case PEER: return PeerRecoverySource.INSTANCE;
|
case PEER: return PeerRecoverySource.INSTANCE;
|
||||||
case SNAPSHOT: return new SnapshotRecoverySource(in);
|
case SNAPSHOT: return new SnapshotRecoverySource(in);
|
||||||
case LOCAL_SHARDS: return LocalShardsRecoverySource.INSTANCE;
|
case LOCAL_SHARDS: return LocalShardsRecoverySource.INSTANCE;
|
||||||
|
@ -153,12 +153,8 @@ public abstract class RecoverySource implements Writeable, ToXContentObject {
|
||||||
this.bootstrapNewHistoryUUID = bootstrapNewHistoryUUID;
|
this.bootstrapNewHistoryUUID = bootstrapNewHistoryUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExistingStoreRecoverySource(StreamInput in) throws IOException {
|
private static ExistingStoreRecoverySource read(StreamInput in) throws IOException {
|
||||||
if (in.getVersion().onOrAfter(Version.V_6_5_0)) {
|
return in.readBoolean() ? FORCE_STALE_PRIMARY_INSTANCE : INSTANCE;
|
||||||
bootstrapNewHistoryUUID = in.readBoolean();
|
|
||||||
} else {
|
|
||||||
bootstrapNewHistoryUUID = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -168,10 +164,8 @@ public abstract class RecoverySource implements Writeable, ToXContentObject {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void writeAdditionalFields(StreamOutput out) throws IOException {
|
protected void writeAdditionalFields(StreamOutput out) throws IOException {
|
||||||
if (out.getVersion().onOrAfter(Version.V_6_5_0)) {
|
|
||||||
out.writeBoolean(bootstrapNewHistoryUUID);
|
out.writeBoolean(bootstrapNewHistoryUUID);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldBootstrapNewHistoryUUID() {
|
public boolean shouldBootstrapNewHistoryUUID() {
|
||||||
|
|
Loading…
Reference in New Issue