HDDS-11482. EC Checksum throws IllegalArgumentException because the buffer limit is negative #7230
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
The parity checksum bytes calculation for the EC stripe checksum should be based on each stripe's first chunk's length. But right now it is calculated only on the first stripe's chunk length which results in incorrect results and, in many cases causes the byte buffer limit to become negative. Further, the checksum calculation has been simplified in this patch.
The checksum calculation for the last stripe is a little tricky, We have two cases for it.
For EC, We store the stripe checksum for the entire stripe in replica index 1 and the parity blocks. We use this stripe checksum to calculate the checksum during reading. The chunks we get during checksum calculation will always be from replica index 1 or parity blocks. And the chunk length will always be the stripe's first chunk's length.
Hence, we don't get the length of the last chunk which may be partial in most of the cases. We calculate the last chunk's size from the block size.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-11482
How was this patch tested?
Updated the existing test.
Test fails without the fix:https://github.com/aswinshakil/ozone/actions/runs/11002573679/job/30550687378
Test passed with the fix: https://github.com/aswinshakil/ozone/actions/runs/11002650413/job/30551032116