Fix NPE in Partial Snapshot Without Global State (#55776) (#55783)

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
This commit is contained in:
Armin Braun 2020-04-27 10:07:09 +02:00 committed by GitHub
parent 1a3f9e5a07
commit 4403b69048
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -494,7 +494,12 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
// 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();
}

View File

@ -693,7 +693,7 @@ public class SnapshotResiliencyTests extends ESTestCase {
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),