Skip to content

Conversation

@aryangupta1998
Copy link
Contributor

What changes were proposed in this pull request?

DirectoryDeletingService should use rocksdb deleteRange instead of creating individual tombstones which can cause seek time issue. But in the presence of snapshots the deleteRange APi should stitch continuous key ranges together that are reclaimable and not issue a blind deleteRange which could lead to incorrect reclaimation of the entry and lead to unreference orphan blocks when the snapshots are deleted.

DeleteRange APIs on FileTable, DirectoryTable, KeyTable can be used by background garbage collection services and should never be used by user facing APIs like keyDelete as that can cause issues in snapshot correctness.

E.g.

Dir1/Key1(Reclaimable) Dir1/Key2(Reclaimable) Dir1/key3(Not Reclaimable) Dir1/Key4(Reclaimable) Dir1/Key5(Reclaimable)

Then DirectoryDeletingService should issue 2 delete range like
[Dir1/Key1..Dir1/Key2] (Both inclusive)
[Dir1/Key4..Dir1/Key5]
In terms of rocksdb deleteRange where the end key range is exclusive this would be equivalent to
[Dir1/Key1..Dir1/Key3) and [Dir1/Key4..lexicographicalHigherString(Dir1/)]

What is the link to the Apache JIRA

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

How was this patch tested?

Testes via UT.

@swamirishi swamirishi self-requested a review December 3, 2025 17:58
Copy link
Contributor

@swamirishi swamirishi left a comment

Choose a reason for hiding this comment

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

thanks for the patch @aryangupta1998 Change this one fix I am reviewing other parts in the meanwhile

@adoroszlai adoroszlai marked this pull request as draft December 3, 2025 19:19
@adoroszlai
Copy link
Contributor

Please wait for clean CI run in fork before opening PR.

@aryangupta1998 aryangupta1998 marked this pull request as ready for review December 3, 2025 23:14
Copy link
Contributor

@swamirishi swamirishi left a comment

Choose a reason for hiding this comment

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

@aryangupta1998 please add unit tests for KeyManagerImpl and DirectoryDeletingService changes

Comment on lines 2325 to 2328
if (startKey != null) {
keyRanges.add(new DeleteKeysResult.ExclusiveRange(startKey, lastLoopExclusiveKey));
}
return new DeleteKeysResult(keyInfos, keyRanges, processedAllKeys);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (startKey != null) {
keyRanges.add(new DeleteKeysResult.ExclusiveRange(startKey, lastLoopExclusiveKey));
}
return new DeleteKeysResult(keyInfos, keyRanges, processedAllKeys);
boolean processedAllKeys = iterator.hasNext();
if (startKey != null) {
keyRanges.add(new DeleteKeysResult.ExclusiveRange(startKey, processedAllKeys ? getLexicographicallyHigherString(seekFileInDB) : iterator.next().getKey()));
}
return new DeleteKeysResult(keyInfos, keyRanges, processedAllKeys);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be boolean processedAllKeys = !iterator.hasNext();

private PurgePathRequest wrapPurgeRequest(
final long volumeId, final long bucketId, final String purgeDeletedDir,
final List<OmKeyInfo> purgeDeletedFiles, final List<OmKeyInfo> markDirsAsDeleted) {
return wrapPurgeRequest(
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Two helper functions don't require ranges, and my added tests require a range parameter, which is why it's needed.

@swamirishi swamirishi marked this pull request as draft December 4, 2025 01:15
@swamirishi
Copy link
Contributor

swamirishi commented Dec 4, 2025

@aryangupta1998 Don't make it ready for review until you get a +1 from reviewers

@smengcl smengcl self-requested a review December 4, 2025 16:29
@jojochuang jojochuang requested a review from smengcl December 4, 2025 16:29
@jojochuang jojochuang added the snapshot https://issues.apache.org/jira/browse/HDDS-6517 label Dec 4, 2025
@adoroszlai adoroszlai changed the title HDDS-13311. Directory Deleting Service can use deleteRange to delete subDirectories and subFiles HDDS-13311. Directory Deleting Service can use deleteRange for subDirectories and subFiles Dec 7, 2025
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