Skip to content

Add system data streams to feature state snapshots #75902

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

williamrandolph
Copy link
Contributor

This PR adds system data streams to the "snapshot feature state" code block, so that if we're snapshotting a feature by name we grab that feature's system data streams too.

Fixes #75860

@williamrandolph williamrandolph marked this pull request as ready for review August 3, 2021 21:16
@williamrandolph williamrandolph requested a review from gwbrown August 3, 2021 21:16
Copy link
Contributor

@gwbrown gwbrown left a comment

Choose a reason for hiding this comment

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

LGTM apart from a couple nitpicks, but I think it'd be a good idea to also get a +1 from the Distributed team - I'll add someone.

assertThat(createSnapshotResponse.getSnapshotInfo().dataStreams(), not(empty()));

// We have to delete the data stream directly, as the feature reset API doesn't clean up system data streams yet
// See https://github.com/elastic/elasticsearch/issues/75818
Copy link
Contributor

Choose a reason for hiding this comment

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

Added a comment to the linked issue so we remember to clean up the places we have to work around this in tests. No action required here, just noting.

Copy link
Contributor

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

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

Just a smaller question and test cleanup suggestions, looking good otherwise.

}
}

private void assertSnapshotSuccess(CreateSnapshotResponse createSnapshotResponse) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can just use org.elasticsearch.snapshots.AbstractSnapshotIntegTestCase#assertSuccessful(org.elasticsearch.action.ActionFuture<org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse>) here with minor adjustments.

Copy link
Contributor

Choose a reason for hiding this comment

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

This method seems unused now?

|| featureAssociatedIndices.size() > 0
|| featureDataStreamBackingIndices.size() > 0) {

featureStates.add(new SnapshotFeatureInfo(featureName, featureSystemIndices));
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we have duplicate index names/data-streams in these lists (like featureSystemIndices)? I'm mainly asking because on the snapshot side we're handling everything as List while when restoring we do create sets which only really add anything if there's duplicates so either we can go with just lists on the restore end or we should use sets here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We implicitly eliminate duplicate feature names at node startup by constructing a map keyed on feature names, and we check for overlapping system index/datastream names with SystemIndices#checkForOverLappingPatterns. So I don't believe we should run into issues with duplicates with any of the system resources.

I am trying to remember if we want the ordered property of lists for consistency.

What do you think would be a good way to scope this fix to the PR?

Copy link
Contributor Author

@williamrandolph williamrandolph Aug 11, 2021

Choose a reason for hiding this comment

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

I will take a look at turning a few of these Lists into Sets:

  • featureStates, systemDataStreamNames
  • Other collections used only within the for-loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@original-brownbear I think I've addressed all the issues you raised. Do you think we're good to merge this one?

Copy link
Contributor

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

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

Thanks @williamrandolph looks good for the most part :) Just a few small points that I found on re-reading this and one new question.

}
}

private void assertSnapshotSuccess(CreateSnapshotResponse createSnapshotResponse) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method seems unused now?

Copy link
Contributor

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

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

LGTM, if CI is happy I'm happy, though maybe fix the logging :)

return true;
}
logger.warn(
"Restoring snapshot ["
Copy link
Contributor

Choose a reason for hiding this comment

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

Use normal style logging with placeholders instead of concatenation?

@williamrandolph williamrandolph merged commit 81b6d10 into elastic:master Aug 16, 2021
williamrandolph added a commit to williamrandolph/elasticsearch that referenced this pull request Aug 16, 2021
Add system data streams to the "snapshot feature state" code block, so that if
we're snapshotting a feature by name we grab that feature's system data streams
too. Handle these data streams on the restore side as well.

* Add system data streams to feature state snapshots
* Don't pass system data streams through index name resolution
* Don't add no-op features to snapshots
* Hook in system data streams for snapshot restoration
williamrandolph added a commit that referenced this pull request Aug 16, 2021
* Add system data streams to feature state snapshots (#75902)

Add system data streams to the "snapshot feature state" code block, so that if
we're snapshotting a feature by name we grab that feature's system data streams
too. Handle these data streams on the restore side as well.

* Add system data streams to feature state snapshots
* Don't pass system data streams through index name resolution
* Don't add no-op features to snapshots
* Hook in system data streams for snapshot restoration
@williamrandolph williamrandolph deleted the system-data-streams-in-snapshots branch August 16, 2021 16:55
@williamrandolph
Copy link
Contributor Author

Backport PR: #76568

@williamrandolph williamrandolph added :Core/Infra/Core Core issues without another label >bug labels Aug 16, 2021
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Aug 16, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

wjp719 added a commit to wjp719/elasticsearch that referenced this pull request Aug 17, 2021
* master: (868 commits)
  Query API key - Rest spec and yaml tests (elastic#76238)
  Delay shard reassignment from nodes which are known to be restarting (elastic#75606)
  Reenable bwc tests for elastic#76475 (elastic#76576)
  Set version to 7.15 in BWC code (elastic#76577)
  Don't remove warning headers on all failure (elastic#76434)
  Disable bwc tests for elastic#76475 (elastic#76541)
  Re-enable bwc tests (elastic#76567)
  Keep track of data recovered from snapshots in RecoveryState (elastic#76499)
  [Transform] Align transform checkpoint range with date_histogram interval for better performance (elastic#74004)
  EQL: Remove "wildcard" function (elastic#76099)
  Fix 'accept' and 'content_type' fields for search_mvt API
  Add persistent licensed feature tracking (elastic#76476)
  Add system data streams to feature state snapshots (elastic#75902)
  fix the error message for instance methods that don't exist (elastic#76512)
  ILM: Add validation of the number_of_shards parameter in Shrink Action of ILM (elastic#74219)
  remove dashboard only reserved role (elastic#76507)
  Fix Stack Overflow in UnassignedInfo in Corner Case (elastic#76480)
  Add (Extended)KeyUsage KeyUsage, CipherSuite & Protocol to SSL diagnostics (elastic#65634)
  Add recovery from snapshot to tests (elastic#76535)
  Reenable BwC Tests after elastic#76532 (elastic#76534)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Core Core issues without another label Team:Core/Infra Meta label for core/infra team v7.15.0 v8.0.0-alpha2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include system data streams when snapshotting feature states
6 participants