Skip to content

Conversation

@sarvekshayr
Copy link
Contributor

What changes were proposed in this pull request?

Saw this warning when datanode disk was nearly full:

2025-12-15 10:37:20,903 WARN [166c5ca8-343e-46ed-b619-84ac193e0069-ChunkReader-215]-org.apache.hadoop.hdds.fs.CachingSpaceUsageSource: Attempted to decrement available space to a negative value. Current: 0, Decrement: 1048576, Source: /ipdr_ozone31/hadoop-ozone/datanode/data

Prior to this message, there were many failed writes. Perhaps it needs to increment the value when the write fails.

The fix adds rollback logic in KeyValueHandler.handleWriteChunk() that tracks when a chunk write succeeds and increments the usedSpace counter. If any subsequent operation fails, the exception handler calls volume.decrementUsedSpace() to restore the counter.

What is the link to the Apache JIRA

HDDS-14183

How was this patch tested?

CI: https://github.com/sarvekshayr/ozone/actions/runs/21200210393

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add test coverage to verify the restore of both usedspace and committedBytes

/**
* Commit space reserved for write to usedSpace when write operation succeeds.
*/
private void commitSpaceReservedForWrite(HddsVolume volume, boolean spaceReserved, long bytes) {

Choose a reason for hiding this comment

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

can commit happen when space is not reserved?

private void commitSpaceReservedForWrite(HddsVolume volume, boolean spaceReserved, long bytes) {
if (spaceReserved) {
volume.releaseReservedSpaceForWrite(bytes);
volume.incrementUsedSpace(bytes);
Copy link

@yandrey321 yandrey321 Jan 23, 2026

Choose a reason for hiding this comment

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

since release and increment are not inside critical section, its better to incrementUsedSpace first and then release reserved space, if its done as it currently implemented if other thread check free space between these 2 calls it could try to use free space that already used by this write.

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.

3 participants