发现一个hdfs空文件导致任务失败问题
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 5.7k
- PR merge metrics
- No merged PRs in 30d
Description
问题所在方法:
> com.alibaba.datax.plugin.reader.hdfsreader.DFSUtil.getHDFSAllFilesNORegex(String path, FileSystem hdfs)
方法内容:
private HashSet getHDFSAllFilesNORegex(String path, FileSystem hdfs) throws IOException {
Path listFiles = new Path(path);
// If the network disconnected, this method will retry 45 times
// each time the retry interval for 20 seconds
FileStatus stats[] = hdfs.listStatus(listFiles);
for (FileStatus f : stats) {
if (f.isDirectory()) {
LOG.info(String.format("[%s] 是目录, 递归获取该目录下的文件", f.getPath().toString()));
getHDFSAllFilesNORegex(f.getPath().toString(), hdfs);
} else if (f.isFile()) {
//这里没有对空文件作判断,会导致后续校验ORCFile时报数组越界错误,导致整个任务失败
addSourceFileByType(f.getPath().toString());
} else {
String message = String.format("该路径[%s]文件类型既不是目录也不是文件,插件自动忽略。",
f.getPath().toString());
LOG.info(message);
}
}
return sourceHDFSAllFilesList;
}
建议在上面判断中加入如下代码:
> if (f.getLen() == 0){
> String message = String.format("文件[%s]长度为0,将会跳过不作处理!", path);
> LOG.warn(message);
> continue;
> }
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with com.alibaba.datax.plugin.reader.hdfsreader.DFSUtil.getHDFSAllFilesNORegex(String path, FileSystem hdfs) and trace how discovered files reach ORCFile validation. Verify the behavior for a zero-length HDFS file, then confirm that it is logged and skipped while non-empty files continue through normal processing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- data-engineering, distributed-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100