Skip to content

Commit

Permalink
Throw exception on illegal RepositoryData updates (elastic#87654)
Browse files Browse the repository at this point in the history
In some edge cases we could attempt a broken write here today,
lets throw in addition to the assertion to not corrupt the repository
until a solution for the underlying problem is found.

relates elastic#86889
  • Loading branch information
original-brownbear committed Jun 21, 2022
1 parent 6ca2e79 commit f6bfd5c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/87654.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 87654
summary: Throw exception on illegal `RepositoryData` updates
area: Snapshot/Restore
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -682,18 +682,32 @@ public XContentBuilder snapshotsToXContent(final XContentBuilder builder, final

if (shouldWriteUUIDS) {
if (uuid.equals(MISSING_UUID)) {
assert permitMissingUuid : "missing uuid";
if (permitMissingUuid == false) {
assert false : "missing uuid";
throw new IllegalStateException("missing uuid");
}
} else {
builder.field(UUID, uuid);
}
if (clusterUUID.equals(MISSING_UUID)) {
assert permitMissingUuid : "missing clusterUUID";
if (permitMissingUuid == false) {
assert false : "missing clusterUUID";
throw new IllegalStateException("missing clusterUUID");
}
} else {
builder.field(CLUSTER_UUID, clusterUUID);
}
} else {
assert uuid.equals(MISSING_UUID) : "lost uuid " + uuid;
assert clusterUUID.equals(MISSING_UUID) : "lost clusterUUID " + clusterUUID;
if (uuid.equals(MISSING_UUID) == false) {
final IllegalStateException e = new IllegalStateException("lost uuid + [" + uuid + "]");
assert false : e;
throw e;
}
if (clusterUUID.equals(MISSING_UUID) == false) {
final IllegalStateException e = new IllegalStateException("lost clusterUUID + [" + uuid + "]");
assert false : e;
throw e;
}
}

// write the snapshots list
Expand Down

0 comments on commit f6bfd5c

Please sign in to comment.