peterxcli commented on code in PR #11150:
URL: https://github.com/apache/ozone/pull/11150#discussion_r4111436913


##########
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:
   ```suggestion
         throw new StorageContainerException("Encountered an error while 
getting the file size for "
             + chunkFile.getName(), CHUNK_FILE_INCONSISTENCY);
   ```
   
   <img width="1205" height="171" alt="Image" 
src="https://github.com/user-attachments/assets/226047d6-f507-4d3f-83a1-ee35d9e626f9";
 />
   
   let's just keep original error handling



-- 
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]

Reply via email to