You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "smengcl (via GitHub)" <gi...@apache.org> on 2026/10/08 18:33:36 UTC
Re: [PR] HDDS-16327. Read the block file length once per WriteChunk instead of three fstat calls [ozone]
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org