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

Add checksum to snapshot metadata files #12002

Merged

Conversation

imotov
Copy link
Contributor

@imotov imotov commented Jul 2, 2015

This commit adds checksum to snapshot files that store global and index based metadata as well as shard information.

Closes #11589

Streams.readFully(inputStream, buffer);
}
int location = randomIntBetween(0, buffer.length - 1);
buffer[location] = (byte)(buffer[location] ^ 42);
Copy link
Contributor

Choose a reason for hiding this comment

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

can we compute CRC on buffer before and after introducing this corrupted byte. We can assume() the checksum has actually changed, so the test does not fail rarely?

@imotov
Copy link
Contributor Author

imotov commented Jul 6, 2015

@rmuir I pushed the fix for the checksum issue. Could you or @s1monw review when you have a chance?

* A version of {@link BlobStoreFormat} that can automatically resolve blob names base on snapshot id
* and writes blobs in atomic manner
*/
public abstract class AtomicSnapshotBlobStoreFormat<T> extends SnapshotBlobStoreFormat<T> {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we just fold this into thr default and always make the move?

@imotov imotov force-pushed the issue-11589-add-checksum-to-snapshot-files branch from 9b24fd0 to 395126e Compare July 8, 2015 00:20
@imotov
Copy link
Contributor Author

imotov commented Jul 8, 2015

@s1monw I pushed the changes as we discussed and opened #12105 to track parsing exception changes.

* @param name blob name
* @throws IOException
*/
public void write(T obj, BlobContainer blobContainer, String name) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

I think we should use writeAtomic everywhere just to reduce the complexity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to do that but it creates a lot of inefficiency on slow repositories and problems while trying to create a snapshot with the same name as previously failed snapshot. We can do this switch, but I would prefer move it into another PR.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense

MetaData.Builder.toXContent(metaData, builder, snapshotOnlyFormatParams);
builder.endObject();
builder.flush();
private BlobStoreFormat<IndexMetaData> indexMetaDataFormat(Version version) {
Copy link
Member

Choose a reason for hiding this comment

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

And here, you removed all the Javadoc! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a different method. So I didn't remove javadoc, I just didn't add it :)

@dakrone
Copy link
Member

dakrone commented Jul 10, 2015

Left some comments

@imotov
Copy link
Contributor Author

imotov commented Jul 10, 2015

@dakrone thanks for the review. I pushed fixes.


protected final boolean compress;

public final String codec;
Copy link
Member

Choose a reason for hiding this comment

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

does this need to be public?

@dakrone
Copy link
Member

dakrone commented Jul 14, 2015

Left a couple more comments, other than that I have a question, I see you creating and passing around a ParseFieldMatcher in the classes, but not using it anywhere, am I missing where you are using it?

@imotov
Copy link
Contributor Author

imotov commented Jul 14, 2015

@dakrone I pushed the revision. Currently, ParseFieldMatcher is used in BlobStoreIndexShardSnapshot, BlobStoreIndexShardSnapshots. I could probably get rid of it in these classes but ParseFieldMatcher's usage will be probably expanded in the future. So, it's nice to keep it handy.

@dakrone
Copy link
Member

dakrone commented Jul 14, 2015

LGTM

This commit adds checksum to snapshot files that store global and index based metadata as well as shard information.

Closes elastic#11589
@imotov imotov force-pushed the issue-11589-add-checksum-to-snapshot-files branch from c1626fc to bfbee38 Compare July 15, 2015 23:17
@imotov imotov merged commit bfbee38 into elastic:master Jul 15, 2015
@imotov imotov deleted the issue-11589-add-checksum-to-snapshot-files branch May 1, 2020 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs >enhancement resiliency v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants