diff --git a/docs/changelog/124931.yaml b/docs/changelog/124931.yaml new file mode 100644 index 0000000000000..b98595a9a2a0a --- /dev/null +++ b/docs/changelog/124931.yaml @@ -0,0 +1,5 @@ +pr: 124931 +summary: This PR fixes a bug whereby partial snapshots of system datastreams could be used to restore system features. +area: "Snapshot/Restore" +type: bug +issues: [] diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SystemResourceSnapshotIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SystemResourceSnapshotIT.java index 8437590278301..a39f9eb26b0e9 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SystemResourceSnapshotIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SystemResourceSnapshotIT.java @@ -898,7 +898,6 @@ public void testNoneFeatureStateOnCreation() { assertThat(snapshottedIndices, allOf(hasItem(regularIndex), not(hasItem(SystemIndexTestPlugin.SYSTEM_INDEX_NAME)))); } - // TODO, Do we need to test this for Datastreams? /** * Ensures that if we can only capture a partial snapshot of a system index, then the feature state associated with that index is * not included in the snapshot, because it would not be safe to restore that feature state. @@ -1202,7 +1201,7 @@ public Collection getSystemDataStreamDescriptors() { @Override public String getFeatureName() { - return SystemDataStreamTestPlugin.class.getSimpleName(); + return SystemDataStreamManyShardsTestPlugin.class.getSimpleName(); } @Override diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java index 10ebd2e66c304..4b24e4706269a 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java @@ -4127,7 +4127,15 @@ private SnapshotsInProgress createSnapshot( if (featureSystemIndices.size() > 0 || featureAssociatedIndices.size() > 0 || featureDataStreamBackingIndices.size() > 0) { - featureStates.add(new SnapshotFeatureInfo(featureName, List.copyOf(featureSystemIndices))); + featureStates.add( + new SnapshotFeatureInfo( + featureName, + List.copyOf( + Stream.concat(featureSystemIndices.stream(), featureDataStreamBackingIndices.stream()) + .collect(Collectors.toSet()) + ) + ) + ); indexNames.addAll(featureSystemIndices); indexNames.addAll(featureAssociatedIndices); indexNames.addAll(featureDataStreamBackingIndices);