From a820b4802fb5ed7296ca42aa925a686fdbdf2e5c Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Mon, 16 Aug 2021 12:36:32 +0200 Subject: [PATCH] Fix Broken Serialization of SnapshotsInProgress in 7.x We must not send the by-repo-shard-id map for normal snapshots. The conditional got lost in `7.x` and `7.14` because of a merge error. This aligns master and 7.x behavior. closes #76552 --- .../org/elasticsearch/cluster/SnapshotsInProgress.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java b/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java index 068fa49585891..8e600d2e5b0ed 100644 --- a/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java +++ b/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java @@ -558,7 +558,7 @@ private Entry(Snapshot snapshot, boolean includeGlobalState, boolean partial, St List dataStreams, List featureStates, long startTime, long repositoryStateId, ImmutableOpenMap shards, String failure, Map userMetadata, Version version, @Nullable SnapshotId source, - ImmutableOpenMap shardStatusByRepoShardId) { + @Nullable ImmutableOpenMap shardStatusByRepoShardId) { this.state = state; this.snapshot = snapshot; this.includeGlobalState = includeGlobalState; @@ -658,7 +658,7 @@ private static Entry readFrom(StreamInput in) throws IOException { } return new SnapshotsInProgress.Entry( snapshot, includeGlobalState, partial, state, indices, dataStreams, featureStates, startTime, repositoryStateId, - shards, failure, userMetadata, version, source, source == null ? null : clones); + shards, failure, userMetadata, version, source, clones); } private static boolean assertShardsConsistent(SnapshotId source, State state, Map indices, @@ -1028,7 +1028,11 @@ public void writeTo(StreamOutput out) throws IOException { } if (out.getVersion().onOrAfter(SnapshotsService.CLONE_SNAPSHOT_VERSION)) { out.writeOptionalWriteable(source); - out.writeMap(shardStatusByRepoShardId); + if (source == null) { + out.writeMap(ImmutableOpenMap.of()); + } else { + out.writeMap(shardStatusByRepoShardId); + } } if (out.getVersion().onOrAfter(FEATURE_STATES_VERSION)) { out.writeList(featureStates);