Skip to content

Remove Snapshot INIT Step (#55918)#59374

Merged
original-brownbear merged 3 commits intoelastic:7.xfrom
original-brownbear:59918-7.x
Jul 13, 2020
Merged

Remove Snapshot INIT Step (#55918)#59374
original-brownbear merged 3 commits intoelastic:7.xfrom
original-brownbear:59918-7.x

Conversation

@original-brownbear
Copy link
Copy Markdown
Contributor

With #55773 the snapshot INIT state step has become obsolete. We can set up the snapshot directly in one single step to simplify the state machine.

This is a big help for building concurrent snapshots because it allows us to establish a deterministic order of operations between snapshot create and delete operations since all of their entries now contain a repository generation. With this change simple queuing up of snapshot operations can and will be added in a follow-up.

backport of #55918

With #55773 the snapshot INIT state step has become obsolete. We can set up the snapshot directly in one single step to simplify the state machine.

This is a big help for building concurrent snapshots because it allows us to establish a deterministic order of operations between snapshot create and delete operations since all of their entries now contain a repository generation. With this change simple queuing up of snapshot operations can and will be added in a follow-up.
@original-brownbear original-brownbear added :Distributed/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs backport labels Jul 12, 2020
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-distributed (:Distributed/Snapshot/Restore)

@elasticmachine elasticmachine added the Team:Distributed Meta label for distributed team. label Jul 12, 2020
@original-brownbear
Copy link
Copy Markdown
Contributor Author

Jenkins run elasticsearch-ci/packaging-sample-windows (dep download issue)

@original-brownbear
Copy link
Copy Markdown
Contributor Author

Jenkins run elasticsearch-ci/2 (known GCS ITs infra issue)

* @param listener snapshot completion listener
*/
public void executeSnapshot(final CreateSnapshotRequest request, final ActionListener<SnapshotInfo> listener) {
public void executeSnapshotLegacy(final CreateSnapshotRequest request, final ActionListener<SnapshotInfo> listener) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This and the other *Legacy method rename (and the way they're selectively called from the transport action) is the only real difference between this commit and the original one that went into master. I realize that it is a little dirty to just duplicate everything and keep the old path code unchanged but IMO this is the easiest way to bring in the remaining snapshot back-ports cleanly.

@original-brownbear
Copy link
Copy Markdown
Contributor Author

@ywelsch @tlrx mainly just looking for a review of how I handled BwC here (see the line I commented), no need to review anything else :)

Copy link
Copy Markdown
Contributor

@ywelsch ywelsch left a comment

Choose a reason for hiding this comment

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

I've left one important comment. Can we dry up some of the logic that's shared by both methods in a follow-up (and do the same on master branch)? I'm generally fine with the approach but worried a bit about testing coverage of that old code branch.

*/
public void executeSnapshot(final CreateSnapshotRequest request, final ActionListener<SnapshotInfo> listener) {
public void executeSnapshotLegacy(final CreateSnapshotRequest request, final ActionListener<SnapshotInfo> listener) {
createSnapshot(request,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be createSnapshotLegacy?
Is this covered by testing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is covered by mixed cluster tests yes. createSnapshotLegacy is already taken for the non-blocking path, I just figured I'd stick with the naming from the original methods for both here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm confused. Why is the executeSnapshotLegacy method not delegating to createSnapshotLegacy?

Copy link
Copy Markdown
Contributor Author

@original-brownbear original-brownbear Jul 13, 2020

Choose a reason for hiding this comment

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

🤦 ok now I get it. Sorry. Sadly we don't have a test that would've caught the issue from this mistake and I don't see an easy way to add one. What we'd need is a BwC disruption test where we fail over from new version to old version master while the snapshot is in progress. I'm starting to think we should have that but I don't see a quick way of setting this up since all the BwC tests are rest tests right now and we don't have any way of using the mock repository with those.

=> Just fixed it for now.

@original-brownbear
Copy link
Copy Markdown
Contributor Author

Can we dry up some of the logic that's shared by both methods in a follow-up (and do the same on master branch)

First off, this code isn't part of the master branch. The legacy paths only apply to clusters that contain nodes older than 7.5.0 which master never has to deal with now so it doesn't have that code.

As for drying up. I actually wanted to specifically avoid drying things up here precisely because master doesn't have these code paths. Some thing I did dry up in earlier PRs (like the shard to node assignment logic) to prepare for this, but what's left I think is hard to dry up. Note that upcoming backports like #58994 will make both paths diverge even further. => I'd rather not dry up anything here if that's ok.

Copy link
Copy Markdown
Contributor

@ywelsch ywelsch left a comment

Choose a reason for hiding this comment

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

LGTM

@original-brownbear
Copy link
Copy Markdown
Contributor Author

Thanks Yannick!

@original-brownbear original-brownbear merged commit 08b54fe into elastic:7.x Jul 13, 2020
@original-brownbear original-brownbear deleted the 59918-7.x branch July 13, 2020 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport :Distributed/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs Team:Distributed Meta label for distributed team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants