Skip to content

Commit

Permalink
Fix Broken Serialization of SnapshotsInProgress in 7.x (#76557)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
original-brownbear authored Aug 16, 2021
1 parent 4ac690b commit 44bd97e
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ private Entry(Snapshot snapshot, boolean includeGlobalState, boolean partial, St
List<String> dataStreams, List<SnapshotFeatureInfo> featureStates, long startTime, long repositoryStateId,
ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards, String failure, Map<String, Object> userMetadata,
Version version, @Nullable SnapshotId source,
ImmutableOpenMap<RepositoryShardId, ShardSnapshotStatus> shardStatusByRepoShardId) {
@Nullable ImmutableOpenMap<RepositoryShardId, ShardSnapshotStatus> shardStatusByRepoShardId) {
this.state = state;
this.snapshot = snapshot;
this.includeGlobalState = includeGlobalState;
Expand Down Expand Up @@ -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<String, IndexId> indices,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 44bd97e

Please sign in to comment.