Skip to content

Fix Edge Case Datastream Snapshot Create Bug #72747

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

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 @@ -744,8 +744,6 @@ private static Metadata metadataForSnapshot(SnapshotsInProgress.Entry snapshot,
for (Index index : dataStream.getIndices()) {
final String indexName = index.getName();
if (builder.get(indexName) == null || indicesInSnapshot.contains(indexName) == false) {
assert snapshot.partial() : "Data stream [" + dataStreamName +
"] is missing index [" + index + "] but snapshot was not partial.";
missingIndex = true;
break;
}
Expand Down Expand Up @@ -1300,9 +1298,8 @@ private void finalizeSnapshotEntry(SnapshotsInProgress.Entry entry, Metadata met
final SnapshotInfo snapshotInfo = new SnapshotInfo(
snapshot.getSnapshotId(),
finalIndices,
entry.partial() ? entry.dataStreams().stream()
.filter(metaForSnapshot.dataStreams()::containsKey)
.collect(Collectors.toList()) : entry.dataStreams(),
entry.dataStreams().stream().filter(metaForSnapshot.dataStreams()::containsKey)
.collect(Collectors.toList()),
entry.partial() ? onlySuccessfulFeatureStates(entry, finalIndices) : entry.featureStates(),
failure,
threadPool.absoluteTimeInMillis(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,4 +710,22 @@ public void testSnapshotDSDuringRolloverAndDeleteOldIndex() throws Exception {
assertEquals(restoreSnapshotResponse.successfulShards(), restoreSnapshotResponse.totalShards());
assertEquals(restoreSnapshotResponse.failedShards(), 0);
}

public void testExcludeDSFromSnapshotWhenExcludingItsIndices() {
final String snapshot = "test-snapshot";
final String indexWithoutDataStream = "test-idx-no-ds";
createIndexWithContent(indexWithoutDataStream);
final SnapshotInfo snapshotInfo = createSnapshot(REPO, snapshot, List.of("*", "-.*"));
assertThat(snapshotInfo.dataStreams(), empty());
assertAcked(client.admin().indices().prepareDelete(indexWithoutDataStream));
RestoreInfo restoreInfo = client.admin()
.cluster()
.prepareRestoreSnapshot(REPO, snapshot)
.setWaitForCompletion(true)
.setRestoreGlobalState(randomBoolean())
.get()
.getRestoreInfo();
assertThat(restoreInfo.failedShards(), is(0));
assertThat(restoreInfo.successfulShards(), is(1));
}
}