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