Skip to content

Commit

Permalink
Fix NPE in Partial Snapshot Without Global State (#55776)
Browse files Browse the repository at this point in the history
We make sure to filter shard generations for indices that are missing
from the metadata when finalizing a partial snapshot (from concurrent index deletion)
but we failed to account for the case where we manually build a fake metadata instance
for snapshots without the global state.
Fixed this by handling missing indices by skipping, same way we do it for filtering the
shard generations.

Relates #50234
  • Loading branch information
original-brownbear authored Apr 27, 2020
1 parent b2a15c6 commit 1fbc974
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,12 @@ private static Metadata metadataForSnapshot(SnapshotsInProgress.Entry snapshot,
// Remove global state from the cluster state
Metadata.Builder builder = Metadata.builder();
for (IndexId index : snapshot.indices()) {
builder.put(metadata.index(index.getName()), false);
final IndexMetadata indexMetadata = metadata.index(index.getName());
if (indexMetadata == null) {
assert snapshot.partial() : "Index [" + index + "] was deleted during a snapshot but snapshot was not partial.";
} else {
builder.put(indexMetadata, false);
}
}
metadata = builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ public void testConcurrentSnapshotDeleteAndDeleteIndex() throws IOException {

continueOrDie(createIndicesListener, createIndexResponses ->
client().admin().cluster().prepareCreateSnapshot(repoName, snapshotName).setWaitForCompletion(false)
.setPartial(partialSnapshot).execute(createSnapshotResponseStepListener));
.setPartial(partialSnapshot).setIncludeGlobalState(randomBoolean()).execute(createSnapshotResponseStepListener));

continueOrDie(createSnapshotResponseStepListener,
createSnapshotResponse -> client().admin().indices().delete(new DeleteIndexRequest(index), new ActionListener<>() {
Expand Down

0 comments on commit 1fbc974

Please sign in to comment.