Skip to content

Commit

Permalink
Fix Broken Serialization of SnapshotsInProgress in 7.x
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 elastic#76552
  • Loading branch information
original-brownbear committed Aug 16, 2021
1 parent da22b1e commit 1493834
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,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 @@ -659,7 +659,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 @@ -1043,8 +1043,11 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeStringCollection(dataStreams);
}
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 1493834

Please sign in to comment.