Skip to content

Bug Fix: System Data Streams Should Be Restorable #124651

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

Conversation

JVerwolf
Copy link
Contributor

@JVerwolf JVerwolf commented Mar 12, 2025

This PR deletes system data streams prior to a restore operation. To enable this, I refactored the way that datastreams are deleted to allow for a single metadata update operation that both deletes existing system datastreams and then restores them as part of a single operation.

closes #89261

@JVerwolf JVerwolf added >bug :Core/Infra/Core Core issues without another label labels Mar 12, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @JVerwolf, I've created a changelog YAML for you.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor initial comments. I suggest someone from data management review.

@JVerwolf JVerwolf added v9.0.1 v8.19.0 v8.18.1 auto-backport Automatically create backport pull requests when merged labels Mar 12, 2025
Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a couple of comments from the Data Management side, but nothing major. I agree with Ryan about trying to combine with MetadataDataStreamsService instead of adding a new service if possible.

// first delete the data streams and then the indices:
// (this to avoid data stream validation from failing when deleting an index that is part of a data stream
// without updating the data stream)
// TODO: change order when "delete index api" also updates the data stream the "index to be removed" is a member of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this TODO entirely, why would we want to change the order when invoked by the delete index API?

Copy link
Contributor Author

@JVerwolf JVerwolf Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me neither, but it was already there in the transport action so I kept it.

Copy link
Contributor

@nielsbauman nielsbauman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks a lot for the iterations, @JVerwolf!

@JVerwolf JVerwolf merged commit cb3c357 into elastic:main Mar 14, 2025
17 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.18 Commit could not be cherrypicked due to conflicts
8.x Commit could not be cherrypicked due to conflicts
9.0 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 124651

JVerwolf added a commit to JVerwolf/elasticsearch that referenced this pull request Mar 14, 2025
This PR adds a new MetadataDeleteDataStreamService that allows us to delete system data streams prior to a restore operation.  This fixes a bug where system data streams were previously un-restorable.

(cherry picked from commit cb3c357)

# Conflicts:
#	modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/DeleteDataStreamTransportAction.java
#	server/src/main/java/org/elasticsearch/snapshots/RestoreService.java
#	server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsServiceTests.java
@JVerwolf
Copy link
Contributor Author

💔 Some backports could not be created

Status Branch Result
8.x
9.0
8.18 An unhandled error occurred. Please see the logs for details

Manual backport

To create the backport manually run:

backport --pr 124651

Questions ?

Please refer to the Backport tool documentation

JVerwolf added a commit to JVerwolf/elasticsearch that referenced this pull request Mar 14, 2025
This PR adds a new MetadataDeleteDataStreamService that allows us to delete system data streams prior to a restore operation.  This fixes a bug where system data streams were previously un-restorable.

(cherry picked from commit cb3c357)

# Conflicts:
#	modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/DeleteDataStreamTransportAction.java
#	server/src/main/java/org/elasticsearch/snapshots/RestoreService.java
#	server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsServiceTests.java
@JVerwolf
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.18

Questions ?

Please refer to the Backport tool documentation

JVerwolf added a commit to JVerwolf/elasticsearch that referenced this pull request Mar 14, 2025
This PR adds a new MetadataDeleteDataStreamService that allows us to delete system data streams prior to a restore operation.  This fixes a bug where system data streams were previously un-restorable.

(cherry picked from commit cb3c357)

# Conflicts:
#	modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/DeleteDataStreamTransportAction.java
#	server/src/main/java/org/elasticsearch/snapshots/RestoreService.java
#	server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsServiceTests.java
@JVerwolf
Copy link
Contributor Author

JVerwolf commented Mar 14, 2025

Curiously, the v8 backports are all failing the SystemResourceSnapshotTests (previously SystemIndexSnapshotTests) when the whole test class is run, but they all succeed when run individually. In a debugger, I see missing features that should have been added by the plugins. Seems like a test framework bug. Does anyone here have intuition about what might have changed between the 8/9 versions?

elasticsearchmachine added a commit that referenced this pull request Mar 14, 2025
…24910)

* Bug Fix: System Data Streams Should Be Restorable (#124651)

This PR adds a new MetadataDeleteDataStreamService that allows us to delete system data streams prior to a restore operation.  This fixes a bug where system data streams were previously un-restorable.

(cherry picked from commit cb3c357)

# Conflicts:
#	modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/DeleteDataStreamTransportAction.java
#	server/src/main/java/org/elasticsearch/snapshots/RestoreService.java
#	server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsServiceTests.java

* Fix test bug, mute test

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <[email protected]>
elasticsearchmachine pushed a commit that referenced this pull request Mar 14, 2025
…124912)

* Bug Fix: System Data Streams Should Be Restorable (#124651)

This PR adds a new MetadataDeleteDataStreamService that allows us to delete system data streams prior to a restore operation.  This fixes a bug where system data streams were previously un-restorable.

(cherry picked from commit cb3c357)

# Conflicts:
#	modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/DeleteDataStreamTransportAction.java
#	server/src/main/java/org/elasticsearch/snapshots/RestoreService.java
#	server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsServiceTests.java

* Fix test bug, mute test
elasticsearchmachine pushed a commit that referenced this pull request Mar 14, 2025
…24900)

* Bug Fix: System Data Streams Should Be Restorable (#124651)

This PR adds a new MetadataDeleteDataStreamService that allows us to delete system data streams prior to a restore operation.  This fixes a bug where system data streams were previously un-restorable.

(cherry picked from commit cb3c357)

# Conflicts:
#	modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/DeleteDataStreamTransportAction.java
#	server/src/main/java/org/elasticsearch/snapshots/RestoreService.java
#	server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsServiceTests.java

* Fix test bug

* mute test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged backport pending >bug :Core/Infra/Core Core issues without another label :Data Management/Data streams Data streams and their lifecycles Team:Core/Infra Meta label for core/infra team Team:Data Management Meta label for data/management team v8.18.1 v8.19.0 v9.0.1 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.fleet-actions-results data stream cannot be restored via the fleet feature state
6 participants