danny0405 commented on code in PR #8610:
URL: https://github.com/apache/hudi/pull/8610#discussion_r1194799259
##########
hudi-common/src/main/java/org/apache/hudi/common/fs/HoodieWrapperFileSystem.java:
##########
@@ -1039,21 +1039,27 @@ public void createImmutableFileInPath(Path fullPath,
Option<byte[]> content)
fsout.write(content.get());
}
} catch (IOException e) {
- String errorMsg = "Failed to create file" + (tmpPath != null ? tmpPath :
fullPath);
+ String errorMsg = "Failed to create file " + (tmpPath != null ? tmpPath
: fullPath);
throw new HoodieIOException(errorMsg, e);
} finally {
try {
if (null != fsout) {
fsout.close();
}
} catch (IOException e) {
- String errorMsg = "Failed to close file" + (needTempFile ? tmpPath :
fullPath);
+ String errorMsg = "Failed to close file " + (needTempFile ? tmpPath :
fullPath);
throw new HoodieIOException(errorMsg, e);
}
try {
if (null != tmpPath) {
- fileSystem.rename(tmpPath, fullPath);
+ boolean renameSuccess = fileSystem.rename(tmpPath, fullPath);
+ if (!renameSuccess) {
+ fileSystem.delete(tmpPath, false);
+ LOG.error("Fail to rename " + tmpPath + " to " + fullPath);
+ throw new HoodieIOException("Failed to rename " + tmpPath + " to
the target " + fullPath
+ + ", target file exists: " + fileSystem.exists(fullPath));
+ }
Review Comment:
The exception `HoodieIOException` is catched up by the outer code, can we
avoid that?
--
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]