Skip to content

HDDS-15650. Fix snapshotUsedNamespace underflow when FSO directory is deleted and purged#10545

Merged
jojochuang merged 1 commit into
apache:masterfrom
jojochuang:HDDS-14435
Jun 23, 2026
Merged

HDDS-15650. Fix snapshotUsedNamespace underflow when FSO directory is deleted and purged#10545
jojochuang merged 1 commit into
apache:masterfrom
jojochuang:HDDS-14435

Conversation

@jojochuang

@jojochuang jojochuang commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

HDDS-15650. Fix snapshotUsedNamespace underflow when FSO directory is deleted and purged

Please describe your PR in detail:
• The Problem: FSO directories have no blocks, so directory deletion incorrectly evaluated to isKeyNonEmpty = false . This decremented the active
bucket namespace usedNamespace but did not increment snapshotUsedNamespace , causing a mismatch when the directory was later purged (unconditionally
decrementing snapshotUsedNamespace by 1 and underflowing the count to -1 ).
• The Fix: Updated OMKeyDeleteRequestWithFSO.java to shift the namespace quota to the snapshot namespace on deletion if it is either a non-empty key or a
directory (
isKeyNonEmpty || keyStatus.isDirectory() ).
• Test Utils Alignment: Updated mock deleteDir helper in OMRequestTestUtils.java to align with actual deletion quota tracking.
• Regression Test: Added a test case testSnapshotUsedNamespaceAfterDirectoryDeleteAndPurge in TestOMKeyDeleteRequestWithFSO.java to verify that
directory deletion
followed by a purge does not cause negative snapshotUsedNamespace values.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-14435

How was this patch tested?

New unit test

… deleted and purged

Change-Id: I36ed18620c9aeecf53def5a8ad10bafa2ee567ad
@jojochuang jojochuang added the snapshot https://issues.apache.org/jira/browse/HDDS-6517 label Jun 18, 2026

@sadanand48 sadanand48 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jojochuang for the finding this , LGTM

@rnblough rnblough left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good fix. Adding the isDirectory check is the minimal effective change to switch it to the behavior the current design expects. I appreciate the additional sanity checks on the testing side, in particular the assertTrue >=0 test added to TestOMKeyDeleteRequestWithFSO.java‎ in lines 401-403. We should copy this practice for every counting value Ozone has.

Thanks @jojochuang!

@jojochuang jojochuang marked this pull request as ready for review June 22, 2026 18:49
@jojochuang jojochuang changed the title HDDS-14435. Fix snapshotUsedNamespace underflow when FSO directory is deleted and purged HDDS-15650. Fix snapshotUsedNamespace underflow when FSO directory is deleted and purged Jun 23, 2026
@jojochuang jojochuang merged commit d4c06b2 into apache:master Jun 23, 2026
62 of 63 checks passed
Comment on lines +402 to +403
assertTrue(bucketInfoAfterPurge.getSnapshotUsedNamespace() >= 0,
"SnapshotUsedNamespace went negative (" + bucketInfoAfterPurge.getSnapshotUsedNamespace() + ") due to bug.");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: please use assertThat(<number>).isNotNegative() instead of assertTrue(<number> >= 0), see HDDS-9951

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah good point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

snapshot https://issues.apache.org/jira/browse/HDDS-6517

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants