You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "chihsuan (via GitHub)" <gi...@apache.org> on 2026/08/13 14:40:49 UTC

[PR] HDDS-16127. Fix quota repair usedBytes for versioned buckets [ozone]

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

   ## What changes were proposed in this pull request?
   
   `ozone admin om quota repair` undercounts `usedBytes` for versioning-enabled buckets.
   
   When a key is overwritten, OM retains the blocks for all versions but stores only the latest version's size in `OmKeyInfo.dataSize`. Live quota accounting charges every committed version. Quota repair, however, previously counted only `OmKeyInfo.getReplicatedSize()`, which represents the latest version. Repair could therefore replace the correct accumulated usage with a lower value.
   
   This patch updates quota repair to:
   
   - Detect whether each bucket has versioning enabled.
   - Sum the replicated size of all retained versions for versioned buckets.
   - Preserve the existing behavior for non-versioned buckets.
   - Calculate replicated size once per version, which is necessary for correct EC accounting.
   
   For example, if a key has retained versions of 300 and 600 bytes, live usage is 900 bytes. Before this patch, quota repair changed it to 600 bytes. With this patch, it remains 900 bytes.
   
   `usedNamespace` is intentionally unchanged because the existing accounting behavior is inconsistent: commits can charge one unit per version, while deletion and user-facing quota behavior treat namespace usage as a key count. This should be addressed separately.
   
   The fix relies on the bucket's current versioning flag. If versioning was toggled while a key was being written, the stored metadata does not contain enough information to reconstruct the exact historical charge. MPU overwrites and repeated `hsync` commits are also outside the scope of this patch because their previous charges cannot be recovered from the active key table.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-16127
   
   ## How was this patch tested?
   
   Added three cases to `TestQuotaRepairTask`:
   
   - `testQuotaRepairVersionedBucketUndercount` commits two versions of an OBS key through `OMKeyCommitRequest` and verifies that repair preserves the combined 900-byte usage.
   - `testQuotaRepairVersionedBucketWithECKey` verifies per-version EC size calculation. The expected usage is 9216 bytes; converting each block separately would incorrectly produce 11264.
   - `testQuotaRepairVersionedFsoBucket` verifies the version-aware recount through the FSO key-table path.
   
   All three tests fail without the patch, producing 600, 5120, and 600 bytes respectively.
   
   Test commands:
   
   ```
   mvn -pl :ozone-manager test -Dtest=TestQuotaRepairTask -DskipShade -DskipRecon -DskipDocs
   mvn -pl :ozone-manager test -Dtest='TestOMKeyCommitRequest*,TestOmMetadataManager' -DskipShade -DskipRecon -DskipDocs
   ./hadoop-ozone/dev-support/checks/checkstyle.sh
   ./hadoop-ozone/dev-support/checks/rat.sh
   ```
   
   Generated-by: Claude Code (Opus 5)
   


-- 
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-16127. Document OmKeyInfo key location version semantics [ozone]

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


-- 
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-16127. Document OmKeyInfo key location version semantics [ozone]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #11018:
URL: https://github.com/apache/ozone/pull/11018#issuecomment-5746300682

   This PR has been marked as stale due to 21 days of inactivity. Please comment or remove the stale label to keep it open. Otherwise, it will be automatically closed in 7 days.


-- 
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-16127. Document OmKeyInfo key location version semantics [ozone]

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

   Hi @smengcl ๐Ÿ‘‹ Just a gentle ping on this one. Let me know if you need anything else. Thanks! ๐Ÿ™‡โ€โ™‚๏ธ 


-- 
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-16127. Document that OmKeyInfo holds a single key version [ozone]

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


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java:
##########
@@ -74,6 +74,11 @@ public final class OmKeyInfo extends WithParentObjectId
   // name of key client specified
   private String keyName;
   private long dataSize;
+  /**
+   * Block locations of the key, one group per key version. No write path produces more than one group today, so a
+   * key holds a single version and {@code dataSize} covers all of its blocks. Object versioning (HDDS-15728) keeps
+   * each object version in its own OmKeyInfo rather than adding groups here.
+   */
   private List<OmKeyLocationInfoGroup> keyLocationVersions;

Review Comment:
   Thanks for the review! @smengcl 
   
   You're right, the wording rules out a case `testOverWriteKeyWithAndWithOutVersioning` actually reaches, so it does need to change. I'll reword it to describe the versioned-bucket case rather than deny it.
   
   On handling multiple groups, I'd like to check with you before going that way. Fixing the active-table recount on its own would still leave `snapshotUsedBytes` collapsing (HDDS-16184) and leave repair and delete disagreeing on the same key (HDDS-16178), and the EC formula question in HDDS-16176 may well change the conversion again, so it seems to grow into a set of four rather than a single fix. Since no write path exercises versioning today, I leaned toward documenting it accurately for now, but I'm happy to take on the whole set if you feel it's worth doing properly. What do you think?
   
   



-- 
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-16127. Document OmKeyInfo key location version semantics [ozone]

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

   Thanks @chihsuan for the patch.


-- 
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-16127. Document that OmKeyInfo holds a single key version [ozone]

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


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java:
##########
@@ -74,6 +74,11 @@ public final class OmKeyInfo extends WithParentObjectId
   // name of key client specified
   private String keyName;
   private long dataSize;
+  /**
+   * Block locations of the key, one group per key version. No write path produces more than one group today, so a
+   * key holds a single version and {@code dataSize} covers all of its blocks. Object versioning (HDDS-15728) keeps
+   * each object version in its own OmKeyInfo rather than adding groups here.
+   */
   private List<OmKeyLocationInfoGroup> keyLocationVersions;

Review Comment:
   It looks like the current write path can create more than one location group. 
   
   `testOverWriteKeyWithAndWithOutVersioning` enables versioning, overwrites a key through the client, and verifies that keyLocationVersions has two groups.
   
   `dataSize` contains only the latest versionโ€™s size. Therefore, quota repair can undercount used space.
   
   HDDS-15728 proposes a future layout, but it does not remove the current path. Pls remove this statement, or handle multiple groups.



-- 
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-16127. Document that OmKeyInfo holds a single key version [ozone]

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


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java:
##########
@@ -74,6 +74,11 @@ public final class OmKeyInfo extends WithParentObjectId
   // name of key client specified
   private String keyName;
   private long dataSize;
+  /**
+   * Block locations of the key, one group per key version. No write path produces more than one group today, so a
+   * key holds a single version and {@code dataSize} covers all of its blocks. Object versioning (HDDS-15728) keeps
+   * each object version in its own OmKeyInfo rather than adding groups here.
+   */
   private List<OmKeyLocationInfoGroup> keyLocationVersions;

Review Comment:
   Thanks @chihsuan . Let's just document it properly atm.



-- 
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-16127. Document OmKeyInfo key location version semantics [ozone]

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


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java:
##########
@@ -74,6 +74,11 @@ public final class OmKeyInfo extends WithParentObjectId
   // name of key client specified
   private String keyName;
   private long dataSize;
+  /**
+   * Block locations of the key, one group per key version. No write path produces more than one group today, so a
+   * key holds a single version and {@code dataSize} covers all of its blocks. Object versioning (HDDS-15728) keeps
+   * each object version in its own OmKeyInfo rather than adding groups here.
+   */
   private List<OmKeyLocationInfoGroup> keyLocationVersions;

Review Comment:
   Thanks @smengcl Iโ€™ve updated the Javadoc and PR description accordingly. ๐Ÿ™ 



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