smengcl commented on code in PR #11150:
URL: https://github.com/apache/ozone/pull/11150#discussion_r4222748734
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/FilePerBlockStrategy.java:
##########
@@ -157,31 +156,32 @@ public void writeChunk(Container container, BlockID
blockID, ChunkInfo info,
HddsVolume volume = containerData.getVolume();
FileChannel channel = null;
- boolean overwrite;
try {
channel = files.getChannel(chunkFile, doSyncWrite);
- overwrite = validateChunkForOverwrite(channel, info);
} catch (IOException e) {
onFailure(volume);
throw e;
}
+ // Read the block file length once and reuse it for the overwrite check,
+ // the offset validation and the space accounting below.
+ long fileLengthBeforeWrite;
+ try {
+ fileLengthBeforeWrite = channel.size();
+ } catch (IOException e) {
+ throw new UncheckedIOException("Encountered an error while getting the
file size for " + chunkFile.getName(), e);
Review Comment:
It looks to me that this code keeps the response code for a failure in the
first file size read.
The original call in `isOverWriteRequested()` threw `UncheckedIOException`
if `channel.size()` failed. `KeyValueHandler.handle()` then returned
`CONTAINER_INTERNAL_ERROR`.
The later file size reads used `CHUNK_FILE_INCONSISTENCY` if they failed
after the first read succeeded. This patch removes those reads. The suggested
change would therefore change the response code for a failure in the first read.
--
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]