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

Write translog opSize twice #7735

Closed
wants to merge 1 commit into from

Conversation

dakrone
Copy link
Member

@dakrone dakrone commented Sep 16, 2014

Adds a new greedyRead method that will read the operation sizes, then
consume that many bytes in the stream, validating the checksum without
transforming the bytes into a Translog.Operation. If the bytes are not
corrupt they are read into an operation and returned.

This new greedyRead method is used when reading translogs from disk,
where they may have corrupted sizes that can cause OOMEs

Adds a new test with a translog with a corrupted opSize and removes the
@AwaitsFix from the testTranslogCorruption in
AbstractSimpleTranslogTests.

Adds a new `greedyRead` method that will read the operation sizes, then
consume that many bytes in the stream, validating the checksum without
transforming the bytes into a `Translog.Operation`. If the bytes are not
corrupt they are read into an operation and returned.

This new `greedyRead` method is used when reading translogs from disk,
where they may have corrupted sizes that can cause OOMEs

Adds a new test with a translog with a corrupted opSize and removes the
`@AwaitsFix` from the testTranslogCorruption in
`AbstractSimpleTranslogTests`.
public Translog.Operation greedyRead(StreamInput in) throws IOException {
int opSize = readAndVerifyOpSize(in);

byte[] bytes = new byte[opSize];
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can use ByteUtils.readIntLE(bytes, opsize-4) here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh cool, didn't know about that method, I'll do that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, looking at it now, StreamOutput writes in big endian, so I'll add a .readIntBE(bytes, opsize-4) method

@dakrone
Copy link
Member Author

dakrone commented Sep 16, 2014

Closing this in favor of a bigger change for 1.5 to come.

@dakrone dakrone closed this Sep 16, 2014
@clintongormley clintongormley changed the title Write translog opSize twice Internal: Write translog opSize twice Sep 26, 2014
@jpountz jpountz removed the review label Oct 21, 2014
@dakrone dakrone deleted the translog-corrupted-sizes branch June 1, 2015 22:34
@clintongormley clintongormley changed the title Internal: Write translog opSize twice Write translog opSize twice Jun 7, 2015
@clintongormley clintongormley added :Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. :Distributed/Engine Anything around managing Lucene and the Translog in an open shard. and removed :Translog :Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. labels Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker :Distributed/Engine Anything around managing Lucene and the Translog in an open shard. >enhancement v1.4.0.Beta1 v1.5.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants