Skip to content

Conversation

@Cyrill
Copy link
Contributor

@Cyrill Cyrill commented Mar 19, 2024

What changes were proposed in this pull request?

HDDS-10547. Fix the buffer for the datanode checksum calculation

Datanode chunk checksum validation was broken.
computeChecksum code and chunkWrite code shared the same byte buffer, hence the first one to read from the buffer succeeds and the second attempt to read fails as the buffer position is at the end.

Apparently there are no tests to check that. I returned back the previous code to make it work.
There are three places where validateChunkChecksumData is called. I added a unit test to check all three. Also I had to change handlePutSmallFile method as it didn't work correctly even with the checksum buffer fix.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-10547

How was this patch tested?

Unit tests.

Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

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

Thanks @Cyrill for the patch.

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

@Cyrill , thanks for working on this, good catch on the bug! Please see the comment inlined.

if (validateChunkChecksumData) {
try {
Checksum.verifyChecksum(data, info.getChecksumData(), 0);
Checksum.verifyChecksum(data.toByteString(byteBufferToByteString), info.getChecksumData(), 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use as below. The toByteString may have buffer copying.

        data = data.duplicate(data.position(), data.limit());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

+1 the change looks good.

@adoroszlai adoroszlai merged commit 8eca5b7 into apache:master Mar 25, 2024
@adoroszlai
Copy link
Contributor

Thanks @Cyrill for the patch, @szetszwo for the review.

@Cyrill Cyrill deleted the HDDS-10547 branch March 26, 2024 07:55
smitajoshi12 pushed a commit to smitajoshi12/ozone that referenced this pull request Mar 27, 2024
myskov pushed a commit to myskov/ozone that referenced this pull request Apr 4, 2024
smengcl pushed a commit to smengcl/hadoop-ozone that referenced this pull request Apr 4, 2024
jojochuang pushed a commit to jojochuang/ozone that referenced this pull request May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants