Skip to content

Commit 56b0f19

Browse files
Snapshot Stability Fixes
* Backport of various snapshot stability fixes from `master` to `6.7` * Includes elastic#38368, elastic#38025 and elastic#37612
1 parent 1c709af commit 56b0f19

File tree

4 files changed

+445
-546
lines changed

4 files changed

+445
-546
lines changed

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

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
2525
import org.elasticsearch.Version;
2626
import org.elasticsearch.cluster.ClusterState.Custom;
27+
import org.elasticsearch.common.Nullable;
2728
import org.elasticsearch.common.collect.ImmutableOpenMap;
2829
import org.elasticsearch.common.io.stream.StreamInput;
2930
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -93,9 +94,11 @@ public static class Entry {
9394
private final ImmutableOpenMap<String, List<ShardId>> waitingIndices;
9495
private final long startTime;
9596
private final long repositoryStateId;
97+
@Nullable private final String failure;
9698

9799
public Entry(Snapshot snapshot, boolean includeGlobalState, boolean partial, State state, List<IndexId> indices,
98-
long startTime, long repositoryStateId, ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards) {
100+
long startTime, long repositoryStateId, ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards,
101+
String failure) {
99102
this.state = state;
100103
this.snapshot = snapshot;
101104
this.includeGlobalState = includeGlobalState;
@@ -110,15 +113,26 @@ public Entry(Snapshot snapshot, boolean includeGlobalState, boolean partial, Sta
110113
this.waitingIndices = findWaitingIndices(shards);
111114
}
112115
this.repositoryStateId = repositoryStateId;
116+
this.failure = failure;
117+
}
118+
119+
public Entry(Snapshot snapshot, boolean includeGlobalState, boolean partial, State state, List<IndexId> indices,
120+
long startTime, long repositoryStateId, ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards) {
121+
this(snapshot, includeGlobalState, partial, state, indices, startTime, repositoryStateId, shards, null);
113122
}
114123

115124
public Entry(Entry entry, State state, ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards) {
116125
this(entry.snapshot, entry.includeGlobalState, entry.partial, state, entry.indices, entry.startTime,
117-
entry.repositoryStateId, shards);
126+
entry.repositoryStateId, shards, entry.failure);
127+
}
128+
129+
public Entry(Entry entry, State state, ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards, String failure) {
130+
this(entry.snapshot, entry.includeGlobalState, entry.partial, state, entry.indices, entry.startTime,
131+
entry.repositoryStateId, shards, failure);
118132
}
119133

120134
public Entry(Entry entry, ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards) {
121-
this(entry, entry.state, shards);
135+
this(entry, entry.state, shards, entry.failure);
122136
}
123137

124138
public Snapshot snapshot() {
@@ -157,6 +171,10 @@ public long getRepositoryStateId() {
157171
return repositoryStateId;
158172
}
159173

174+
public String failure() {
175+
return failure;
176+
}
177+
160178
@Override
161179
public boolean equals(Object o) {
162180
if (this == o) return true;
@@ -437,14 +455,21 @@ public SnapshotsInProgress(StreamInput in) throws IOException {
437455
if (in.getVersion().onOrAfter(REPOSITORY_ID_INTRODUCED_VERSION)) {
438456
repositoryStateId = in.readLong();
439457
}
458+
final String failure;
459+
if (in.getVersion().onOrAfter(Version.V_6_7_0)) {
460+
failure = in.readOptionalString();
461+
} else {
462+
failure = null;
463+
}
440464
entries[i] = new Entry(snapshot,
441465
includeGlobalState,
442466
partial,
443467
state,
444468
Collections.unmodifiableList(indexBuilder),
445469
startTime,
446470
repositoryStateId,
447-
builder.build());
471+
builder.build(),
472+
failure);
448473
}
449474
this.entries = Arrays.asList(entries);
450475
}
@@ -476,6 +501,9 @@ public void writeTo(StreamOutput out) throws IOException {
476501
if (out.getVersion().onOrAfter(REPOSITORY_ID_INTRODUCED_VERSION)) {
477502
out.writeLong(entry.repositoryStateId);
478503
}
504+
if (out.getVersion().onOrAfter(Version.V_6_7_0)) {
505+
out.writeOptionalString(entry.failure);
506+
}
479507
}
480508
}
481509

server/src/main/java/org/elasticsearch/snapshots/SnapshotException.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ public SnapshotException(final Snapshot snapshot, final String msg, final Throwa
5151
}
5252
}
5353

54-
public SnapshotException(final String repositoryName, final SnapshotId snapshotId, final String msg) {
55-
this(repositoryName, snapshotId, msg, null);
56-
}
57-
5854
public SnapshotException(final String repositoryName, final SnapshotId snapshotId, final String msg, final Throwable cause) {
5955
super("[" + repositoryName + ":" + snapshotId + "] " + msg, cause);
6056
this.repositoryName = repositoryName;

0 commit comments

Comments
 (0)