[ 
https://issues.apache.org/jira/browse/HADOOP-20060?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18144754#comment-18144754
 ] 

ASF GitHub Bot commented on HADOOP-20060:
-----------------------------------------

slfan1989 commented on code in PR #8923:
URL: https://github.com/apache/hadoop/pull/8923#discussion_r4572683317


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFileSystem.java:
##########
@@ -523,7 +523,7 @@ public void readVectored(final List<? extends FileRange> 
ranges,
      * the data stream.
      */
     private boolean dataStreamToHandleVectorIO() {
-      return sums == null;
+      return sums == null || !needChecksum();

Review Comment:
   Thanks for fixing the fallback for unreadable checksum headers! 
   
   Could we also forward the release callback by calling 
`datas.readVectored(ranges, allocate, release)` ? 
   
   I reproduced a case with an empty `.crc` file and a range extending past EOF 
where a buffer was allocated but the release callback was never called.





> ChecksumFileSystem: readVectored() fails when the .crc header is unreadable, 
> while read() falls back to unverified reads
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-20060
>                 URL: https://issues.apache.org/jira/browse/HADOOP-20060
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: fs
>            Reporter: Yang Jie
>            Priority: Minor
>              Labels: pull-request-available
>
> When a file's .crc exists but its header cannot be read (zero length, 
> truncated, or bad magic), ChecksumFSInputChecker logs "Problem opening 
> checksum file ... Ignoring exception" and reads the data without 
> verification. readVectored() does not do the same. It only hands the ranges 
> to the data stream when {{sums == null}}, and here {{sums}} is still open, so 
> it computes checksum ranges with the default {{bytesPerSum}} of 1 and reads 
> them from the broken .crc. That fails with "EOFException: Read past End of 
> File", or with a ChecksumException at meaningless offsets if the .crc is 
> large. hasCapability(VECTOREDIO_BUFFERS_SLICED) also returns true.
> A zero-length .crc is what a writer leaves behind when it dies before closing 
> the file, because the header stays in a buffer until roughly 511 KiB of data 
> has been written. Parquet 1.16 enables vectored reads by default, so Spark 
> reading such a Parquet file from file:// reads the footer and then fails on 
> the row groups. With Parquet 1.15 the same file can be read.
> The fix makes {{dataStreamToHandleVectorIO()}} also delegate when checksums 
> are not being verified ({{!needChecksum()}}), as its javadoc already says it 
> should.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

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

Reply via email to