You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/04/20 13:11:12 UTC

[GitHub] [ozone] guihecheng commented on a diff in pull request #3323: HDDS-6614. EC: Fix Datanode block file INCONSISTENCY during heavy load.

guihecheng commented on code in PR #3323:
URL: https://github.com/apache/ozone/pull/3323#discussion_r854115145


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/ChunkUtils.java:
##########
@@ -383,14 +383,21 @@ private static ContainerProtos.Result translate(Exception cause) {
    * Checks if the block file length is equal to the chunk offset.
    *
    */
-  public static void validateChunkSize(File chunkFile, ChunkInfo chunkInfo)
+  public static void validateChunkSize(FileChannel fileChannel,
+      ChunkInfo chunkInfo, String fileName)
       throws StorageContainerException {
     long offset = chunkInfo.getOffset();
-    long len = chunkFile.length();
-    if (chunkFile.length() != offset) {
+    long fileLen;
+    try {
+      fileLen = fileChannel.size();
+    } catch (IOException e) {
+      throw new StorageContainerException("IO error encountered while " +
+          "getting the file size for " + fileName, CHUNK_FILE_INCONSISTENCY);
+    }
+    if (fileLen != offset) {
       throw new StorageContainerException(
-          "Chunk file offset " + offset + " does not match blockFile length " +
-          len, CHUNK_FILE_INCONSISTENCY);
+          "Chunk offset " + offset + " does not match length " +
+          fileLen + "of blockFile " + fileName, CHUNK_FILE_INCONSISTENCY);

Review Comment:
   Ah, thanks for the indent.



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