Skip to content

Commit 5ef2a8a

Browse files
Fix Broken Serialization of SnapshotsInProgress in 7.x (elastic#76553)
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 elastic#76552
1 parent da22b1e commit 5ef2a8a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ private Entry(Snapshot snapshot, boolean includeGlobalState, boolean partial, St
559559
List<String> dataStreams, List<SnapshotFeatureInfo> featureStates, long startTime, long repositoryStateId,
560560
ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards, String failure, Map<String, Object> userMetadata,
561561
Version version, @Nullable SnapshotId source,
562-
ImmutableOpenMap<RepositoryShardId, ShardSnapshotStatus> shardStatusByRepoShardId) {
562+
@Nullable ImmutableOpenMap<RepositoryShardId, ShardSnapshotStatus> shardStatusByRepoShardId) {
563563
this.state = state;
564564
this.snapshot = snapshot;
565565
this.includeGlobalState = includeGlobalState;
@@ -659,7 +659,7 @@ private static Entry readFrom(StreamInput in) throws IOException {
659659
}
660660
return new SnapshotsInProgress.Entry(
661661
snapshot, includeGlobalState, partial, state, indices, dataStreams, featureStates, startTime, repositoryStateId,
662-
shards, failure, userMetadata, version, source, source == null ? null : clones);
662+
shards, failure, userMetadata, version, source, clones);
663663
}
664664

665665
private static boolean assertShardsConsistent(SnapshotId source, State state, Map<String, IndexId> indices,
@@ -1044,7 +1044,11 @@ public void writeTo(StreamOutput out) throws IOException {
10441044
}
10451045
if (out.getVersion().onOrAfter(SnapshotsService.CLONE_SNAPSHOT_VERSION)) {
10461046
out.writeOptionalWriteable(source);
1047-
out.writeMap(shardStatusByRepoShardId);
1047+
if (source == null) {
1048+
out.writeMap(ImmutableOpenMap.of());
1049+
} else {
1050+
out.writeMap(shardStatusByRepoShardId);
1051+
}
10481052
}
10491053
if (out.getVersion().onOrAfter(FEATURE_STATES_VERSION)) {
10501054
out.writeList(featureStates);

0 commit comments

Comments
 (0)