You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "sumitagrawl (via GitHub)" <gi...@apache.org> on 2025/06/17 05:50:10 UTC

[PR] HDDS-12151. write fail on volume full case considering min free space [ozone]

sumitagrawl opened a new pull request, #8642:
URL: https://github.com/apache/ozone/pull/8642

   ## What changes were proposed in this pull request?
   
   When volume if full, means no space available for data write, need to make write failure as Disk out of space.
   
   Here, available includes: available - reserved part available - min.free.space configured
   
   This is to mandate that min.free.space is available for ozone work.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-12151
   
   ## How was this patch tested?
   
   - unit test updated
   


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


Re: [PR] HDDS-12151. Fail write when volume is full considering min free space [ozone]

Posted by "sumitagrawl (via GitHub)" <gi...@apache.org>.
sumitagrawl merged PR #8642:
URL: https://github.com/apache/ozone/pull/8642


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


Re: [PR] HDDS-12151. write fail on volume full case considering min free space [ozone]

Posted by "sumitagrawl (via GitHub)" <gi...@apache.org>.
sumitagrawl commented on code in PR #8642:
URL: https://github.com/apache/ozone/pull/8642#discussion_r2160805730


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java:
##########
@@ -612,6 +617,25 @@ private void sendCloseContainerActionIfNeeded(Container container) {
     }
   }
 
+  private void validateVolumeFullForWrite(
+      Container container, Type cmdType, boolean isVolumeFullForWrite) throws StorageContainerException {
+    if (!isVolumeFullForWrite) {
+      return;
+    }
+
+    HddsVolume volume = container.getContainerData().getVolume();
+    SpaceUsageSource currentUsage = volume.getCurrentUsage();
+    LOG.warn("Volume [{}] is full. containerID: {}. Volume usage: [{}]. Minimum required free space: {}", volume,
+        container.getContainerData().getContainerID(), currentUsage,
+        volume.getFreeSpaceToSpare(currentUsage.getCapacity()));
+    if (cmdType == Type.WriteChunk || cmdType == Type.PutBlock || cmdType == Type.PutSmallFile) {
+      // If the volume is full, we should not allow more writes.
+      throw new StorageContainerException("Container write failed due to volume " + volume.getStorageID()
+          + " out of space " + currentUsage + " with minimum free space required: "
+          + volume.getFreeSpaceToSpare(currentUsage.getCapacity()), DISK_OUT_OF_SPACE);

Review Comment:
   changes are updated and conflict is resolved. Please recheck



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


Re: [PR] HDDS-12151. write fail on volume full case considering min free space [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #8642:
URL: https://github.com/apache/ozone/pull/8642#discussion_r2155198091


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java:
##########
@@ -612,6 +617,25 @@ private void sendCloseContainerActionIfNeeded(Container container) {
     }
   }
 
+  private void validateVolumeFullForWrite(
+      Container container, Type cmdType, boolean isVolumeFullForWrite) throws StorageContainerException {
+    if (!isVolumeFullForWrite) {
+      return;
+    }
+
+    HddsVolume volume = container.getContainerData().getVolume();
+    SpaceUsageSource currentUsage = volume.getCurrentUsage();
+    LOG.warn("Volume [{}] is full. containerID: {}. Volume usage: [{}]. Minimum required free space: {}", volume,
+        container.getContainerData().getContainerID(), currentUsage,
+        volume.getFreeSpaceToSpare(currentUsage.getCapacity()));
+    if (cmdType == Type.WriteChunk || cmdType == Type.PutBlock || cmdType == Type.PutSmallFile) {
+      // If the volume is full, we should not allow more writes.
+      throw new StorageContainerException("Container write failed due to volume " + volume.getStorageID()
+          + " out of space " + currentUsage + " with minimum free space required: "
+          + volume.getFreeSpaceToSpare(currentUsage.getCapacity()), DISK_OUT_OF_SPACE);

Review Comment:
   Or we may need even more change.



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


Re: [PR] HDDS-12151. write fail on volume full case considering min free space [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #8642:
URL: https://github.com/apache/ozone/pull/8642#discussion_r2154333508


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java:
##########
@@ -612,6 +617,25 @@ private void sendCloseContainerActionIfNeeded(Container container) {
     }
   }
 
+  private void validateVolumeFullForWrite(
+      Container container, Type cmdType, boolean isVolumeFullForWrite) throws StorageContainerException {
+    if (!isVolumeFullForWrite) {
+      return;
+    }
+
+    HddsVolume volume = container.getContainerData().getVolume();
+    SpaceUsageSource currentUsage = volume.getCurrentUsage();
+    LOG.warn("Volume [{}] is full. containerID: {}. Volume usage: [{}]. Minimum required free space: {}", volume,
+        container.getContainerData().getContainerID(), currentUsage,
+        volume.getFreeSpaceToSpare(currentUsage.getCapacity()));
+    if (cmdType == Type.WriteChunk || cmdType == Type.PutBlock || cmdType == Type.PutSmallFile) {
+      // If the volume is full, we should not allow more writes.
+      throw new StorageContainerException("Container write failed due to volume " + volume.getStorageID()
+          + " out of space " + currentUsage + " with minimum free space required: "
+          + volume.getFreeSpaceToSpare(currentUsage.getCapacity()), DISK_OUT_OF_SPACE);

Review Comment:
   Please, for consistency (of "is full" check, log message and exception message) and to avoid duplication:
   
   - use the method being added in #8644
   - move the warning log inside that method
   - remove `isVolumeFullForWrite` as a parameter here, let the method check itself



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


Re: [PR] HDDS-12151. write fail on volume full case considering min free space [ozone]

Posted by "sumitagrawl (via GitHub)" <gi...@apache.org>.
sumitagrawl commented on code in PR #8642:
URL: https://github.com/apache/ozone/pull/8642#discussion_r2153662763


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java:
##########
@@ -609,6 +615,17 @@ private void sendCloseContainerActionIfNeeded(Container container) {
           LOG.warn("Triggered immediate heartbeat because of full volume.");
         }
       }
+      if (isVolumeFull) {
+        HddsVolume volume = containerData.getVolume();
+        LOG.warn("Volume [{}] is full. containerID: {}. Volume usage: [{}].", volume, containerData.getContainerID(),
+            volume.getCurrentUsage());
+        if (cmdType == Type.WriteChunk || cmdType == Type.PutBlock || cmdType == Type.PutSmallFile) {
+          // If the container is full, we should not allow any more writes.
+          // This will prevent the client from writing to a full container.
+          throw new StorageContainerException("Container creation failed, due to volume out of space",
+              DISK_OUT_OF_SPACE);

Review Comment:
   client will retry for StorageContainerException with another pipeline and container. This is similar to one of pipeline disk full condition.



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


Re: [PR] HDDS-12151. write fail on volume full case considering min free space [ozone]

Posted by "siddhantsangwan (via GitHub)" <gi...@apache.org>.
siddhantsangwan commented on code in PR #8642:
URL: https://github.com/apache/ozone/pull/8642#discussion_r2161808660


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java:
##########
@@ -335,8 +334,22 @@ && getMissingContainerSet().contains(containerID)) {
     }
     // Small performance optimization. We check if the operation is of type
     // write before trying to send CloseContainerAction.
+    boolean isVolumeFullForWrite = false;
     if (!HddsUtils.isReadOnly(msg)) {
-      sendCloseContainerActionIfNeeded(container);
+      try {
+        if (container != null && container.getContainerState() == State.OPEN) {
+          ContainerUtils.assertSpaceAvailability(containerID, container.getContainerData().getVolume(), 0);
+        }
+      } catch (StorageContainerException e) {
+        LOG.warn(e.getMessage());

Review Comment:
   We should add the actual path of the volume to the message being constructed in `assertSpaceAvailability` to help in figuring out which volume is full. Right now it just has the volume UUID.



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


Re: [PR] HDDS-12151. write fail on volume full case considering min free space [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on PR #8642:
URL: https://github.com/apache/ozone/pull/8642#issuecomment-2998737745

   Thanks @sumitagrawl , the last patch LGTM,  +1. 


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


Re: [PR] HDDS-12151. write fail on volume full case considering min free space [ozone]

Posted by "sumitagrawl (via GitHub)" <gi...@apache.org>.
sumitagrawl commented on code in PR #8642:
URL: https://github.com/apache/ozone/pull/8642#discussion_r2153969965


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java:
##########
@@ -577,9 +586,11 @@ public void validateContainerCommand(
   /**
    * If the container usage reaches the close threshold or the container is
    * marked unhealthy we send Close ContainerAction to SCM.
+   *
    * @param container current state of container
+   * @param cmdType request command type
    */
-  private void sendCloseContainerActionIfNeeded(Container container) {
+  private void sendCloseContainerActionIfNeeded(Container container, Type cmdType) throws StorageContainerException {

Review Comment:
   done



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


Re: [PR] HDDS-12151. write fail on volume full case considering min free space [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #8642:
URL: https://github.com/apache/ozone/pull/8642#discussion_r2151659889


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java:
##########
@@ -577,9 +586,11 @@ public void validateContainerCommand(
   /**
    * If the container usage reaches the close threshold or the container is
    * marked unhealthy we send Close ContainerAction to SCM.
+   *
    * @param container current state of container
+   * @param cmdType request command type
    */
-  private void sendCloseContainerActionIfNeeded(Container container) {
+  private void sendCloseContainerActionIfNeeded(Container container, Type cmdType) throws StorageContainerException {

Review Comment:
   Can we add new function to handle volume full case, and let this sendCloseContainerActionIfNeeded handle container related cases, so the code is more readable



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


Re: [PR] HDDS-12151. write fail on volume full case considering min free space [ozone]

Posted by "sumitagrawl (via GitHub)" <gi...@apache.org>.
sumitagrawl commented on code in PR #8642:
URL: https://github.com/apache/ozone/pull/8642#discussion_r2157047443


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java:
##########
@@ -612,6 +617,25 @@ private void sendCloseContainerActionIfNeeded(Container container) {
     }
   }
 
+  private void validateVolumeFullForWrite(
+      Container container, Type cmdType, boolean isVolumeFullForWrite) throws StorageContainerException {
+    if (!isVolumeFullForWrite) {
+      return;
+    }
+
+    HddsVolume volume = container.getContainerData().getVolume();
+    SpaceUsageSource currentUsage = volume.getCurrentUsage();
+    LOG.warn("Volume [{}] is full. containerID: {}. Volume usage: [{}]. Minimum required free space: {}", volume,
+        container.getContainerData().getContainerID(), currentUsage,
+        volume.getFreeSpaceToSpare(currentUsage.getCapacity()));
+    if (cmdType == Type.WriteChunk || cmdType == Type.PutBlock || cmdType == Type.PutSmallFile) {
+      // If the volume is full, we should not allow more writes.
+      throw new StorageContainerException("Container write failed due to volume " + volume.getStorageID()
+          + " out of space " + currentUsage + " with minimum free space required: "
+          + volume.getFreeSpaceToSpare(currentUsage.getCapacity()), DISK_OUT_OF_SPACE);

Review Comment:
   @adoroszlai refactored code, and both PR is having same method `ContainerUtils.assertSpaceAvailability`. will resolve conflict once one of PR is merged.



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


Re: [PR] HDDS-12151. write fail on volume full case considering min free space [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #8642:
URL: https://github.com/apache/ozone/pull/8642#discussion_r2151696563


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java:
##########
@@ -609,6 +615,17 @@ private void sendCloseContainerActionIfNeeded(Container container) {
           LOG.warn("Triggered immediate heartbeat because of full volume.");
         }
       }
+      if (isVolumeFull) {
+        HddsVolume volume = containerData.getVolume();
+        LOG.warn("Volume [{}] is full. containerID: {}. Volume usage: [{}].", volume, containerData.getContainerID(),
+            volume.getCurrentUsage());
+        if (cmdType == Type.WriteChunk || cmdType == Type.PutBlock || cmdType == Type.PutSmallFile) {
+          // If the container is full, we should not allow any more writes.
+          // This will prevent the client from writing to a full container.
+          throw new StorageContainerException("Container creation failed, due to volume out of space",
+              DISK_OUT_OF_SPACE);

Review Comment:
   When this exception happens, will client retry the write with another pipeline or client will just fail? 



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


Re: [PR] HDDS-12151. write fail on volume full case considering min free space [ozone]

Posted by "sumitagrawl (via GitHub)" <gi...@apache.org>.
sumitagrawl commented on code in PR #8642:
URL: https://github.com/apache/ozone/pull/8642#discussion_r2154965763


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java:
##########
@@ -612,6 +617,25 @@ private void sendCloseContainerActionIfNeeded(Container container) {
     }
   }
 
+  private void validateVolumeFullForWrite(
+      Container container, Type cmdType, boolean isVolumeFullForWrite) throws StorageContainerException {
+    if (!isVolumeFullForWrite) {
+      return;
+    }
+
+    HddsVolume volume = container.getContainerData().getVolume();
+    SpaceUsageSource currentUsage = volume.getCurrentUsage();
+    LOG.warn("Volume [{}] is full. containerID: {}. Volume usage: [{}]. Minimum required free space: {}", volume,
+        container.getContainerData().getContainerID(), currentUsage,
+        volume.getFreeSpaceToSpare(currentUsage.getCapacity()));
+    if (cmdType == Type.WriteChunk || cmdType == Type.PutBlock || cmdType == Type.PutSmallFile) {
+      // If the volume is full, we should not allow more writes.
+      throw new StorageContainerException("Container write failed due to volume " + volume.getStorageID()
+          + " out of space " + currentUsage + " with minimum free space required: "
+          + volume.getFreeSpaceToSpare(currentUsage.getCapacity()), DISK_OUT_OF_SPACE);

Review Comment:
   We need isFullVolume flag for sendCloseContainerActionIfNeeded(), so it will be checked twice if use that method. Additionally this is handled for few set of request for throw exception.
   
   Considering this, it may not be possible to use common method here. Since write path needs to be fast, so avoiding getting the spaceusages multiple time.
   
   @adoroszlai I think we may not need change considering above cases.



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