Skip to content

Commit

Permalink
Fix NPE in Partial Snapshot Without Global State (elastic#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 elastic#50234
  • Loading branch information
original-brownbear committed Apr 27, 2020
1 parent 79c9ef9 commit 6a161f4
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 @@ -646,7 +646,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 @@ -637,7 +637,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),
Expand Down

0 comments on commit 6a161f4

Please sign in to comment.