Skip to content

Conversation

@aswinshakil
Copy link
Member

What changes were proposed in this pull request?

Currently, deleted directories are kept in snapshot's deletedDirTable. It doesn't have information on the total size of the keys it holds. So we won't be able to get the exclusiveSize of the snapshot unless we expand it. This PR expands the deledDirTable of all the snapshots.

What is the link to the Apache JIRA

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

How was this patch tested?

Added Integration Test.

@aswinshakil aswinshakil added the snapshot https://issues.apache.org/jira/browse/HDDS-6517 label Sep 20, 2023
@aswinshakil aswinshakil self-assigned this Sep 20, 2023
@aswinshakil
Copy link
Member Author

cc: @swamirishi

snapshotInfoActual.getExclusiveSize());
Assert.assertEquals(snapshotInfoExpected.getExclusiveReplicatedSize(),
snapshotInfoActual.getExclusiveReplicatedSize());
Assert.assertEquals(snapshotInfoExpected.getExpandedDeletedDir(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just assertEquals on snapshotInfoExpected and snapshotInfoActual?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes we can, but this is just to check each field individually.

Copy link
Contributor

Choose a reason for hiding this comment

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

assertEquals() will do the same thing as long as equals method is overridden.
https://github.com/junit-team/junit4/blob/main/src/main/java/org/junit/Assert.java#L145

}

Table.KeyValue<String, OmKeyInfo> deletedDirInfo;
List<Pair<String, OmKeyInfo>> allSubDirList
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Is there any specific reason it is list of Pair? If no, use map instead for simplification.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is also a copy-pasta from the DirectoryDeletingService. This was the structure used by the service all this time. So I kept it this way.

List<Pair<String, OmKeyInfo>> allSubDirList
= new ArrayList<>((int) remainNum);

try (TableIterator<String, ? extends Table.KeyValue<String,
Copy link
Contributor

Choose a reason for hiding this comment

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

Code inside this try block is mostly duplicate of above try block. Duplication can be removed, if you create a helper function and extract this out. It will also improve the readability.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't fully extract it because we use some snapshot-specific code in-between. So I kept it separately.

Copy link
Contributor

@hemantk-12 hemantk-12 Sep 27, 2023

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

One more point, we are not iterating over deletedIterator? Is it intentional? Also do we need to call deletedIterator.seekToFirst(); and deletedIterator.hasNext(); before calling deletedIterator.next(); ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct I missed that part with copy-pasting, I have updated the PR.

if (remainNum > 0) {
expandSnapshotDirectories(remainNum);
}
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can just catch this exception inside expandSnapshotDirectories and log there instead of logging it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

expandSnapshotDirectories already has its own separate logging for something similar.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then it is double logging. May be expandSnapshotDirectories doesn't need to throw an IOException.

Copy link
Member Author

Choose a reason for hiding this comment

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

It will throw because we still do get from RocksDB. But the exception on inside of expandSnapshotDirectories is specific for iterating through snapDeletedDirTable. The one outside is overall exeption. The main reason is expandSnapshotDirectories already las many try blocks, adding more will decrease the readability.

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.

@aswinshakil thanks for the patch. Have a few review comments from the first round of review. I will add more comments as and when I get more clarity on the whole thing.


// Expand deleted dirs only on active snapshot. Deleted Snapshots
// will be cleaned up by SnapshotDeletingService.
if (currSnapInfo.getSnapshotStatus() != SNAPSHOT_ACTIVE ||
Copy link
Contributor

Choose a reason for hiding this comment

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

We should take a lock on this snapshot to avoid race condition

"null for snapshotted bucket. The OM is in unexpected state.");
}

String dbBucketKeyForDir = getOzoneManager().getMetadataManager()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have some kind of a util function for this? or use one if it is already there. As in appending OM_KEY_PREFIX at the end.

currSnapInfo.getVolumeName(),
currSnapInfo.getBucketName(),
getSnapshotPrefix(currSnapInfo.getName()),
true)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this should be false here. skipActiveCheck has to be false.

subFileNum += request.getDeletedSubFilesCount();
}

optimizeDirDeletesAndSubmitRequest(
Copy link
Contributor

Choose a reason for hiding this comment

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

From what I understand this would put a request to expand the directory and manipulate the directory table and key table entries. I am not sure how this would impact snapshot diff. @hemantk-12 @prashantpogde .

Copy link
Contributor

Choose a reason for hiding this comment

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

Full diff and Dag based diff will start showing different outputs.

@aswinshakil
Copy link
Member Author

We have discussed a different approach to not modify keyTable and dirTable as it will change the snapDiff.

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.

3 participants