Skip to content

Commit 969dc0a

Browse files
authored
Fix system data stream snapshot bug (#124931) (#124933)
This PR fixes a bug in the snapshot service that was allowing partial snapshots to restore features that use system data streams.
1 parent 149f161 commit 969dc0a

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
@@ -4084,7 +4084,15 @@ private SnapshotsInProgress createSnapshot(
40844084

40854085
if (featureSystemIndices.size() > 0 || featureAssociatedIndices.size() > 0 || featureDataStreamBackingIndices.size() > 0) {
40864086

4087-
featureStates.add(new SnapshotFeatureInfo(featureName, List.copyOf(featureSystemIndices)));
4087+
featureStates.add(
4088+
new SnapshotFeatureInfo(
4089+
featureName,
4090+
List.copyOf(
4091+
Stream.concat(featureSystemIndices.stream(), featureDataStreamBackingIndices.stream())
4092+
.collect(Collectors.toSet())
4093+
)
4094+
)
4095+
);
40884096
indexNames.addAll(featureSystemIndices);
40894097
indexNames.addAll(featureAssociatedIndices);
40904098
indexNames.addAll(featureDataStreamBackingIndices);

0 commit comments

Comments
 (0)