Skip to content

Commit 77b1091

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

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
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-2
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,6 @@ public void testNoneFeatureStateOnCreation() {
898898
assertThat(snapshottedIndices, allOf(hasItem(regularIndex), not(hasItem(SystemIndexTestPlugin.SYSTEM_INDEX_NAME))));
899899
}
900900

901-
// TODO, Do we need to test this for Datastreams?
902901
/**
903902
* Ensures that if we can only capture a partial snapshot of a system index, then the feature state associated with that index is
904903
* not included in the snapshot, because it would not be safe to restore that feature state.
@@ -1202,7 +1201,7 @@ public Collection<SystemDataStreamDescriptor> getSystemDataStreamDescriptors() {
12021201

12031202
@Override
12041203
public String getFeatureName() {
1205-
return SystemDataStreamTestPlugin.class.getSimpleName();
1204+
return SystemDataStreamManyShardsTestPlugin.class.getSimpleName();
12061205
}
12071206

12081207
@Override

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

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

41284128
if (featureSystemIndices.size() > 0 || featureAssociatedIndices.size() > 0 || featureDataStreamBackingIndices.size() > 0) {
41294129

4130-
featureStates.add(new SnapshotFeatureInfo(featureName, List.copyOf(featureSystemIndices)));
4130+
featureStates.add(
4131+
new SnapshotFeatureInfo(
4132+
featureName,
4133+
List.copyOf(
4134+
Stream.concat(featureSystemIndices.stream(), featureDataStreamBackingIndices.stream())
4135+
.collect(Collectors.toSet())
4136+
)
4137+
)
4138+
);
41314139
indexNames.addAll(featureSystemIndices);
41324140
indexNames.addAll(featureAssociatedIndices);
41334141
indexNames.addAll(featureDataStreamBackingIndices);

0 commit comments

Comments
 (0)