Skip to content

HDDS-15110. Fix negative container size handling in replication#10126

Open
ptlrs wants to merge 5 commits intoapache:masterfrom
ptlrs:HDDS-15110-Improve-container-size-calculation
Open

HDDS-15110. Fix negative container size handling in replication#10126
ptlrs wants to merge 5 commits intoapache:masterfrom
ptlrs:HDDS-15110-Improve-container-size-calculation

Conversation

@ptlrs
Copy link
Copy Markdown
Contributor

@ptlrs ptlrs commented Apr 24, 2026

What changes were proposed in this pull request?

The container size is currently calculated by subtracting the deleted bytes from the existing bytes. We need to add safeguards to ensure that the calculation never results in a negative value.

What is the link to the Apache JIRA

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

How was this patch tested?

CI: https://github.com/ptlrs/ozone/actions/runs/24913951609

blockCount -= deletedBlockCount;
blockPendingDeletion -= processedBlockCount;
blockPendingDeletionBytes -= processedBytes;
blockBytes = Math.max(1L, blockBytes - deletedBytes);
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.

If blockBytes - deletedBytes == 0, we should not make blockBytes = 1L. If we do this then never blockBytes will become 0. Only when if there is negative value after calculation we can keep something like 1L.

@ptlrs ptlrs requested a review from ashishkumar50 April 27, 2026 17:19
@ptlrs
Copy link
Copy Markdown
Contributor Author

ptlrs commented Apr 27, 2026

Thanks for the review @ashishkumar50. I have update the changes.

@ashishkumar50 ashishkumar50 marked this pull request as ready for review April 28, 2026 06:01
@ashishkumar50
Copy link
Copy Markdown
Contributor

@ptlrs newly added test is failing

@ptlrs
Copy link
Copy Markdown
Contributor Author

ptlrs commented Apr 29, 2026

@ashishkumar50 the test was failing as it depended on another PR #10130.

I have updated the branch with master.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants