Skip to content

Commit 811e4f0

Browse files
authored
Fix system data stream snapshot bug (#124931) (#124934)
This PR fixes a bug in the snapshot service that was allowing partial snapshots to restore features that use system data streams.
1 parent 014f0fe commit 811e4f0

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

docs/changelog/124931.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 124931
2+
summary: This PR fixes a bug whereby partial snapshots of system datastreams could be used to restore system features.
3+
area: "Snapshot/Restore"
4+
type: bug
5+
issues: []

server/src/internalClusterTest/java/org/elasticsearch/snapshots/SystemResourceSnapshotIT.java

-1
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,6 @@ public void testNoneFeatureStateOnCreation() {
893893
assertThat(snapshottedIndices, allOf(hasItem(regularIndex), not(hasItem(SystemIndexTestPlugin.SYSTEM_INDEX_NAME))));
894894
}
895895

896-
// TODO, Do we need to test this for Datastreams?
897896
/**
898897
* Ensures that if we can only capture a partial snapshot of a system index, then the feature state associated with that index is
899898
* not included in the snapshot, because it would not be safe to restore that feature state.

server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -4124,7 +4124,15 @@ private SnapshotsInProgress createSnapshot(
41244124

41254125
if (featureSystemIndices.size() > 0 || featureAssociatedIndices.size() > 0 || featureDataStreamBackingIndices.size() > 0) {
41264126

4127-
featureStates.add(new SnapshotFeatureInfo(featureName, List.copyOf(featureSystemIndices)));
4127+
featureStates.add(
4128+
new SnapshotFeatureInfo(
4129+
featureName,
4130+
List.copyOf(
4131+
Stream.concat(featureSystemIndices.stream(), featureDataStreamBackingIndices.stream())
4132+
.collect(Collectors.toSet())
4133+
)
4134+
)
4135+
);
41284136
indexNames.addAll(featureSystemIndices);
41294137
indexNames.addAll(featureAssociatedIndices);
41304138
indexNames.addAll(featureDataStreamBackingIndices);

0 commit comments

Comments
 (0)