Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert aborted snapshots have no pending shard work #102621

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,20 @@ private static boolean assertConsistentEntries(Map<String, ByRepo> entries) {
assert entry.repository().equals(repository) : "mismatched repository " + entry + " tracked under " + repository;
for (Map.Entry<RepositoryShardId, ShardSnapshotStatus> shard : entry.shardsByRepoShardId().entrySet()) {
final RepositoryShardId sid = shard.getKey();
final ShardSnapshotStatus shardSnapshotStatus = shard.getValue();
assert assertShardStateConsistent(
entriesForRepository,
assignedShards,
queuedShards,
sid.indexName(),
sid.shardId(),
shard.getValue()
shardSnapshotStatus
);

assert entry.state() != State.ABORTED
|| shardSnapshotStatus.state == ShardState.ABORTED
|| shardSnapshotStatus.state().completed()
: sid + " is in state " + shardSnapshotStatus.state() + " in aborted snapshot " + entry.snapshot;
}
}
// make sure in-flight-shard-states can be built cleanly for the entries without tripping assertions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,15 @@ public void testXContent() throws IOException {
}

public static State randomState(Map<ShardId, SnapshotsInProgress.ShardSnapshotStatus> shards) {
return SnapshotsInProgress.completed(shards.values())
? randomFrom(State.SUCCESS, State.FAILED)
: randomFrom(State.STARTED, State.INIT, State.ABORTED);
if (SnapshotsInProgress.completed(shards.values())) {
return randomFrom(State.SUCCESS, State.FAILED);
}
if (shards.values()
.stream()
.map(SnapshotsInProgress.ShardSnapshotStatus::state)
.allMatch(st -> st.completed() || st == ShardState.ABORTED)) {
return State.ABORTED;
}
return randomFrom(State.STARTED, State.INIT);
}
}