yandrey321 opened a new pull request, #12046:
URL: https://github.com/apache/ozone/pull/12046

   ## What changes were proposed in this pull request?
   
   ### Problem
   
   `BaseFileChecksumHelper` was ported from HDFS `FileChecksumHelper` and has 
the same flaw as HDFS-17992: `makeCompositeCrcResult` reads the CRC of block 
`i` at offset `i * 4` of the block checksum buffer, assuming every block of the 
key contributed exactly one CRC.
   
   - A key can have a block with length 0, e.g. after lease recovery of a key 
whose writer died after allocating the block. Before reaching 
`makeCompositeCrcResult`, Ozone already fails on such a block in both combine 
modes: `checksumBlock` asks the datanode for the chunk list of a block that 
holds no data and throws `PathIOException` (or the GetBlock error).
   - Once an empty block contributes no CRC, every following block CRC would be 
read at the wrong offset, giving a wrong COMPOSITE_CRC without an error.
   - When a checksum is requested for a length shorter than the key, 
`checksumBlocks` stops early, but `makeCompositeCrcResult` still reads one CRC 
for every block of the key. The missing CRCs come from the zero padding of the 
buffer (or read out of bounds), so the result is wrong.
   
   ### Idea
   
   Port the HDFS-17992 approach:
   
   - `checksumBlocks` skips blocks with length 0 without contacting a datanode, 
in both combine modes.
   - `makeCompositeCrcResult` reads block CRCs with a cursor, skips the same 
empty blocks, and stops once the CRCs actually written are used up.
   - If no block contributed a checksum, return the same checksum as a key 
without blocks (extracted into `makeEmptyFileChecksum`).
   
   ### Decisions
   
   - Empty blocks are skipped in MD5MD5CRC mode too: an empty block adds no 
bytes to the key, and today such keys fail in both modes. MD5MD5CRC results do 
not change for any key that succeeds today.
   - Skipping is done by the length OM committed for the block, so no datanode 
call is made for it.
   - The MD5 of the empty-key checksum is computed once into a constant. Each 
call still returns a new `FileChecksum`, because `MD5MD5CRC32GzipFileChecksum` 
and `MD5Hash` are mutable `Writable`s.
   
   Co-authored-by: Claude Opus 5.5 <[email protected]>
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-16834
   
   ## How was this patch tested?
   
   Unit + integration tests.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to