Skip to content
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

Switch to write once mode for snapshot metadata files #8782

Merged

Conversation

imotov
Copy link
Contributor

@imotov imotov commented Dec 4, 2014

This commit removes creation of in-progress snapshot file and makes creation of the final snapshot file atomic.

Fixes #8696

@imotov imotov added :Distributed/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs >bug v2.0.0-beta1 review labels Dec 4, 2014
@s1monw s1monw self-assigned this Dec 4, 2014
@s1monw
Copy link
Contributor

s1monw commented Dec 4, 2014

w00t! - I will review

public void move(String source, String target) throws IOException {
Path sourcePath = path.resolve(source);
Path targetPath = path.resolve(target);
Files.move(sourcePath, targetPath, new CopyOption[]{StandardCopyOption.ATOMIC_MOVE});
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 this can just be

Files.move(sourcePath, targetPath, StandardCopyOption.ATOMIC_MOVE);

@s1monw
Copy link
Contributor

s1monw commented Dec 4, 2014

I really like it. I think we should have a small unittest in BlobStoreTest but other than that LGTM

@@ -295,19 +304,19 @@ public ClusterState execute(ClusterState currentState) {
SnapshotMetaData snapshots = metaData.custom(SnapshotMetaData.TYPE);
ImmutableList.Builder<SnapshotMetaData.Entry> entries = ImmutableList.builder();
for (SnapshotMetaData.Entry entry : snapshots.entries()) {
if (entry.snapshotId().equals(snapshot.snapshotId())) {
if (entry.snapshotId().equals(entry.snapshotId())) {
Copy link
Member

Choose a reason for hiding this comment

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

Is that comparison really intended?

@tlrx
Copy link
Member

tlrx commented Dec 5, 2014

The more I dig into the snapshot/restore code, the more I like it :)

LGTM, left two comments.

This commit removes creation of in-progress snapshot file and makes creation of the final snapshot file atomic.

Fixes elastic#8696
@imotov imotov force-pushed the issue-8696-dont-overwrite-snapshot-files branch from 19338f5 to 0b024ad Compare December 5, 2014 17:59
@imotov imotov merged commit 0b024ad into elastic:master Dec 5, 2014
dadoonet added a commit to dadoonet/elasticsearch-cloud-azure that referenced this pull request Jan 30, 2015
This has been added in elasticsearch 2.0.0. See elastic/elasticsearch#8782

Wondering if this PR should be split in two parts:

* one that clean the code and which is portable to 1.4, 1.x and master
* one that simply add move() method for master branch

@imotov WDYT?

Closes elastic#49.
dadoonet added a commit to elastic/elasticsearch-cloud-azure that referenced this pull request Feb 12, 2015
This has been added in elasticsearch 2.0.0. See elastic/elasticsearch#8782

Wondering if this PR should be split in two parts:

* one that clean the code and which is portable to 1.4, 1.x and master
* one that simply add move() method for master branch

@imotov WDYT?

Closes #49.
imotov added a commit to imotov/elasticsearch that referenced this pull request Feb 25, 2015
Together with elastic#8782 it should help in the situations simliar to elastic#8887 by adding an ability to get information about currently running snapshot without accessing the repository itself.

Closes elastic#8887
@clintongormley clintongormley changed the title Snapshot/Restore: switch to write once mode for snapshot metadata files Switch to write once mode for snapshot metadata files Jun 8, 2015
@imotov imotov deleted the issue-8696-dont-overwrite-snapshot-files branch May 1, 2020 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CI Failure] [test-repo:test-snap] failed to get snapshots
4 participants