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 2021/08/02 06:15:03 UTC

[GitHub] [ozone] sadanand48 commented on a change in pull request #2463: HDDS-5483. Validate block file length during put block

sadanand48 commented on a change in pull request #2463:
URL: https://github.com/apache/ozone/pull/2463#discussion_r680680029



##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java
##########
@@ -427,6 +429,17 @@ ContainerCommandResponseProto handlePutBlock(
       ContainerProtos.BlockData data = request.getPutBlock().getBlockData();
       BlockData blockData = BlockData.getFromProtoBuf(data);
       Preconditions.checkNotNull(blockData);
+      ChunkLayOutVersion layoutVersion =
+          ChunkLayOutVersion.getConfiguredVersion(conf);
+      if (layoutVersion == FILE_PER_BLOCK) {
+        File blockFile = layoutVersion
+            .getChunkFile(kvContainer.getContainerData(),
+                blockData.getBlockID(), null);
+        // ensure that the putBlock length <= blockFile length
+        Preconditions.checkArgument(blockFile.length() >= blockData.getSize(),

Review comment:
       @smengcl This is just a safety check. The ozone streaming write path will not use the current ratisAsyncApi which ensures sequential transactions i.e putBlock would always  occur after writeChunk.  To be on a safer side, this check is added.  We may remove this after the complete streaming implementation if this check is redundant
   cc : @mukul1987 




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